Repository navigation
fix(toolkit): keep db mv placement when lite merge replaces archive dbs - #155
Open
halibobo1205 wants to merge 1 commit into
Open
halibobo1205 wants to merge 1 commit into
halibobo1205 wants to merge 1 commit into
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
CodeAnt Nitpicks1 code suggestion1.
|
CodeAnt PR Risk: Low Risk
Assessed commit: |
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.
Follow-up to tronprotocol/java-tron#6946 (comment).
The linked review reported that
db lite mergefollows the database symlinks created bydb mvand clears the relocated directories. This PR addresses that combined workflow by preserving the relocated storage locations during merge and adding regression coverage for the command sequence.What does this PR do?
Preserve the database placement established by
db mvwhendb lite mergerestores archive data.For relocated archive databases, merge replaces the contents of their actual storage directories while preserving the original symlinks and destination directories. The merged databases remain at the locations configured in
storage.properties.Failures from the new relocation helpers propagate to the CLI as a nonzero exit code. Archive databases that were not relocated retain their existing handling.
Why are these changes required?
A valid operational sequence is to relocate a LiteNode’s archive databases to a larger disk before restoring full history. Currently,
db lite mergecan undo that relocation while leaving the node configuration unchanged.Reproduction scenario
Consider a LiteNode whose database is initially stored at
/ssd/tron/output-directory/database. The operator wants to restore its block and transaction history while keeping the growing archive databases on HDD.The example assumes:
storage.db.directoryisdatabase.blockandtransdatabases./data/historycontains a compatible history dataset generated from FullNode data, with matching genesis and sufficient overlap with the LiteNode’s recent block range.Stop the node and configure the storage locations in
node.conf:Relocate the existing databases:
This moves their contents to HDD and creates links at the original paths:
Merge the history dataset into the LiteNode using its original database path:
Inspect the database locations after merge completes, then restart the node with the same configuration.
Behavior before this fix
Merge first backs up the existing archive databases. Its subsequent deletion follows the database symlinks, clears the HDD targets, and removes the original SSD links. History is then copied into newly created ordinary directories on SSD, and the required recent data is merged from the backup.
block-beta columns 5 A["1. db mv<br/>Move to HDD"] space B["2. SSD links<br/>Config: HDD"] space C["3. Start merge<br/>Back up data"] space:5 F["6. Restart<br/>Read empty HDD"] space E["5. Merge on SSD<br/>Delete backup"] space D["4. Clear HDD<br/>Delete SSD links"] A --> B B --> C C --> D D --> E E --> F style D fill:#fee2e2,stroke:#dc2626,color:#7f1d1d style E fill:#fee2e2,stroke:#dc2626,color:#7f1d1d style F fill:#fee2e2,stroke:#dc2626,color:#7f1d1dConsequences
The storage placement established by
db mvis effectively undone for the affected archive databases:After a successful merge, the merged archive data still exists on SSD. This is a recoverable storage placement and configuration mismatch: the node reads a location that no longer contains the expected block or transaction data.
Correcting the affected configuration paths can restore access to the SSD databases. Restoring the intended HDD placement requires another migration. Merge should preserve that placement without requiring these recovery steps.
Behavior with this fix
Merge identifies relocated archive databases before modifying them and resolves their actual storage directories. After backing up the existing data, it clears only the destination contents, preserving both the original symlinks and the destination root directories.
History is copied into those destinations. The existing history trimming and backup merge steps then operate through the preserved links.
block-beta columns 5 A["1. db mv<br/>Move to HDD"] space B["2. SSD links<br/>Config: HDD"] space C["3. Start merge<br/>Resolve links<br/>Back up data"] space:5 F["6. Restart<br/>Read HDD DBs"] space E["5. Merge on HDD<br/>Delete backup"] space D["4. Clear HDD<br/>Keep SSD links<br/>and HDD roots"] A --> B B --> C C --> D D --> E E --> F style D fill:#dcfce7,stroke:#16a34a,color:#14532d style E fill:#dcfce7,stroke:#16a34a,color:#14532d style F fill:#dcfce7,stroke:#16a34a,color:#14532dThis PR has been tested by:
DbMove → DbLitecommand tests covering all five archive databases, with history heights below, equal to, and above the snapshot height. These verify preserved links and merged data in the relocated directories.1, retained links and snapshot metadata, intact original data after backup failure, and readable backups after cleanup or copy failure.blockandtransdatabases, covering checkpoint versions 1 and 2.