migrate-db: warn loudly before writing irreversible tombstones#86
Open
0xfandom wants to merge 1 commit intolightninglabs:mainfrom
Open
migrate-db: warn loudly before writing irreversible tombstones#860xfandom wants to merge 1 commit intolightninglabs:mainfrom
0xfandom wants to merge 1 commit intolightninglabs:mainfrom
Conversation
After a successful migration lndinit writes a tombstone marker into every source bbolt file. From that point lnd refuses to open those files, which is fine when the destination backend works but turns into unrecoverable data loss when the lnd binary that will run against the new backend was not compiled with the matching build tag (e.g. kvdb_sqlite). The user is left with tombstoned bbolt files and a destination backend that lnd cannot read. This is the "at minimum" mitigation requested in the issue: print a loud, multi-line WARN banner at the start of migrate-db that names the destination backend and tells the operator to confirm both that they have a backup of the bbolt files and that the target lnd binary supports the destination backend. A second per-DB WARN line is also printed immediately before each tombstone write so it shows up next to the affected prefix in the log. This is intentionally a logging-only change: no new flags, no behavioral or interface differences for existing callers. Pre-flight build-tag detection (option 1) and a deferred --finalize step (option 3) are real fixes worth their own design discussion and are not part of this PR. Refs lightninglabs#81
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements option 4 from #81 — the "at minimum" mitigation. After a successful migration
lndinit migrate-dbwrites a tombstone marker into every source bbolt file, after whichlndrefuses to open them. When thelndbinary that runs against the destination backend was not compiled with the matching build tag (e.g.kvdb_sqlite), the operator is left with tombstoned bbolt files AND a destination backendlndcannot read — only a pre-migration backup recovers the node.This PR adds:
migrate-dbthat names the destination backend and asks the operator to confirm both (1) they have a backup of every bbolt source file and (2) theirlndbinary supports the destination backend.Logging-only change. No new flags, no behavioral change for existing callers. Pre-flight build-tag detection (option 1) and a deferred
--finalizeflow (option 3) are real fixes too, but each deserves its own design discussion — happy to follow up on either if you want this PR to land first as the floor.Sample output (running with
--dest.backend sqlite):Testing
go test -tags="kvdb_etcd kvdb_postgres kvdb_sqlite" ./...clean (lndinit 14.9s, migratekvdb cached).golangci-lint run --timeout 10m --build-tags="kvdb_etcd kvdb_postgres kvdb_sqlite" ./...clean (v1.64.8 fromtools/go.mod).go buildclean.migrate-dbagainst an empty dir to confirm the banner prints with the destination backend name interpolated correctly.Related
Refs #81