Enable redb database logging & close DB cleanly - #60
Closed
flyq wants to merge 4 commits into
Closed
Conversation
flyq
commented
Dec 26, 2025
yilongli
reviewed
Dec 26, 2025
| ); | ||
|
|
||
| let validator_logic = chain_sync(client.clone(), validator_db.clone(), config, chain_spec); | ||
| let (validator_logic, handles) = chain_sync(client, &validator_db, config, chain_spec)?; |
| info!("[Main] Total execution time: {:?}", start.elapsed()); | ||
|
|
||
| // Abort all background tasks and wait for them to finish (with timeout) | ||
| for handle in &handles { |
| if let Err(e) = tokio::time::timeout(timeout, future::join_all(handles)).await { | ||
| warn!( | ||
| "[Main] Tokio runtime shutdown reached the {:?} timeout, error: {e}.", | ||
| timeout |
| info!("[Chain Sync] Task recovery completed"); | ||
|
|
||
| // Spawn all background tasks | ||
| let mut handles = Vec::new(); |
| .await | ||
| .unwrap(); | ||
| // Spawn background tasks and run chain sync | ||
| let (main_loop, handles) = chain_sync(client, &validator_db, config, chain_spec).unwrap(); |
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
Enable redb database logging and refactor shutdown to ensure the database closes cleanly.
Problem
When the validator was restarted after exit, it displayed a warning:
This occurred because background tasks holding Arc references could prevent the database from being dropped before the process exited.
Changes
Enable redb Logging
Clean Shutdown Refactoring
a. Abort all background tasks via their handles
b. Wait up to 1 second for tasks to complete
c. Explicitly drop ValidatorDB to ensure clean database closure
Files Changed