From fdcdebb39231df34af7be099e5f1213df784bbe5 Mon Sep 17 00:00:00 2001 From: Michael Lopez Date: Wed, 23 Sep 2026 15:24:22 +0200 Subject: [PATCH] db: delete pre-auth key on its own savepoint --- hscontrol/db/preauth_keys.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hscontrol/db/preauth_keys.go b/hscontrol/db/preauth_keys.go index e839ff50..f913314a 100644 --- a/hscontrol/db/preauth_keys.go +++ b/hscontrol/db/preauth_keys.go @@ -341,8 +341,9 @@ func DestroyPreAuthKey(tx *gorm.DB, id uint64) error { return fmt.Errorf("clearing auth_key_id on nodes: %w", err) } - // Then delete the pre-auth key - res := tx.Unscoped().Delete(&types.PreAuthKey{}, id) + // Then delete the pre-auth key, on the same savepoint as the + // node update so both roll back together. + res := db.Unscoped().Delete(&types.PreAuthKey{}, id) if res.Error != nil { return res.Error }