mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
fix(rocksdb): flush memtables before dropping (#21234)
This commit is contained in:
@@ -427,7 +427,17 @@ impl fmt::Debug for RocksDBProviderInner {
|
||||
impl Drop for RocksDBProviderInner {
|
||||
fn drop(&mut self) {
|
||||
match self {
|
||||
Self::ReadWrite { db, .. } => db.cancel_all_background_work(true),
|
||||
Self::ReadWrite { db, .. } => {
|
||||
// Flush all memtables if possible. If not, they will be rebuilt from the WAL on
|
||||
// restart
|
||||
if let Err(e) = db.flush_wal(true) {
|
||||
tracing::warn!(target: "storage::rocksdb", ?e, "Failed to flush WAL on drop");
|
||||
}
|
||||
if let Err(e) = db.flush() {
|
||||
tracing::warn!(target: "storage::rocksdb", ?e, "Failed to flush memtables on drop");
|
||||
}
|
||||
db.cancel_all_background_work(true);
|
||||
}
|
||||
Self::ReadOnly { db, .. } => db.cancel_all_background_work(true),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user