channeldb+lnd: set invoice bucket tombstone after migration

This commit introduces the functionality to set a tombstone key
in the invoice bucket after the migration to the native SQL
database. The tombstone prevents the user from switching back
to the KV invoice database, ensuring data consistency and
avoiding potential issues like lingering invoices or partial
state in KV tables. The tombstone is checked on startup to
block any manual overrides that attempt to revert the migration.
This commit is contained in:
Andras Banki-Horvath
2025-01-23 14:32:18 +01:00
parent 6cabc74c20
commit 444524a762
4 changed files with 122 additions and 1 deletions

View File

@@ -298,6 +298,16 @@ func testInvoiceMigration(ht *lntest.HarnessTest) {
}
}
// Now restart Bob without the --db.use-native-sql flag so we can check
// that the KV tombstone was set and that Bob will fail to start.
require.NoError(ht, bob.Stop())
bob.SetExtraArgs(nil)
// Bob should now fail to start due to the tombstone being set.
require.NoError(ht, bob.StartLndCmd(ht.Context()))
require.Error(ht, bob.WaitForProcessExit())
// Start Bob again so the test can complete.
bob.SetExtraArgs([]string{"--db.use-native-sql"})
require.NoError(ht, bob.Start(ht.Context()))
}