-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add migration to remove bad blocks #6803
feat: add migration to remove bad blocks #6803
Conversation
WalkthroughThe changes update the migration process in the LMDB database by modifying the migration version constant from 1 to 2. A new conditional block checks if the current migration version is less than 2 and, if so, clears the bad blocks list in a write transaction and logs the operation. Finally, the migration version is updated in the metadata database along with additional log statements to provide more clarity during the migration. Changes
Sequence Diagram(s)sequenceDiagram
participant RM as run_migrations
participant WT as Write Transaction
participant MD as Metadata DB
participant LOG as Logger
RM->>RM: Check current migration version
alt Migration version < 2
RM->>WT: Begin transaction to clear bad blocks list
WT->>LOG: Log number of rows cleared
RM->>MD: Update migration version to 2
else
RM->>LOG: Log that no migration is needed
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs (1)
2893-2900
: LGTM! Well-structured migration with proper transaction handling.The migration logic is well-implemented with:
- Atomic transaction for clearing bad blocks
- Proper version check and update
- Informative logging of the operation
Consider adding error logging to help with debugging if the migration fails.
Add error logging before returning errors:
let txn = db.write_transaction()?; info!(target: LOG_TARGET, "Clearing bad blocks list due to median timestamp bug in nextnet"); -let rows_affected = lmdb_clear(&txn, &db.bad_blocks)?; +let rows_affected = match lmdb_clear(&txn, &db.bad_blocks) { + Ok(count) => count, + Err(e) => { + error!(target: LOG_TARGET, "Failed to clear bad blocks: {}", e); + return Err(e); + } +}; txn.commit()?;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: test (mainnet, stagenet)
- GitHub Check: machete
- GitHub Check: Cucumber tests / FFI
- GitHub Check: clippy
- GitHub Check: Cucumber tests / Base Layer
- GitHub Check: cargo check with stable
🔇 Additional comments (1)
base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs (1)
2876-2876
: LGTM! Migration version increment.The increment of
MIGRATION_VERSION
from 1 to 2 is appropriate for introducing a new migration.
Test Results (CI)1 039 tests 1 038 ✅ 10m 4s ⏱️ For more details on these failures, see this check. Results for commit aaada12. |
Adds a migration to clear the bad blocks table. This should be done in future for any bug fixes that cause bad blocks
Summary by CodeRabbit