Add debug spans to DB write paths (#8895)

Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
Jimmy Chen
2026-02-25 07:53:33 +11:00
committed by GitHub
parent 886d31fe7e
commit e59f1f03ef
2 changed files with 29 additions and 10 deletions

View File

@@ -12,7 +12,7 @@ use std::time::Duration;
use store::metadata::DataColumnInfo; use store::metadata::DataColumnInfo;
use store::{AnchorInfo, BlobInfo, DBColumn, Error as StoreError, KeyValueStore, KeyValueStoreOp}; use store::{AnchorInfo, BlobInfo, DBColumn, Error as StoreError, KeyValueStore, KeyValueStoreOp};
use strum::IntoStaticStr; use strum::IntoStaticStr;
use tracing::{debug, instrument}; use tracing::{debug, debug_span, instrument};
use types::{Hash256, Slot}; use types::{Hash256, Slot};
/// Use a longer timeout on the pubkey cache. /// Use a longer timeout on the pubkey cache.
@@ -256,9 +256,18 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// Write the I/O batches to disk, writing the blocks themselves first, as it's better // Write the I/O batches to disk, writing the blocks themselves first, as it's better
// for the hot DB to contain extra blocks than for the cold DB to point to blocks that // for the hot DB to contain extra blocks than for the cold DB to point to blocks that
// do not exist. // do not exist.
self.store.blobs_db.do_atomically(blob_batch)?; {
self.store.hot_db.do_atomically(hot_batch)?; let _span = debug_span!("backfill_write_blobs_db").entered();
self.store.cold_db.do_atomically(cold_batch)?; self.store.blobs_db.do_atomically(blob_batch)?;
}
{
let _span = debug_span!("backfill_write_hot_db").entered();
self.store.hot_db.do_atomically(hot_batch)?;
}
{
let _span = debug_span!("backfill_write_cold_db").entered();
self.store.cold_db.do_atomically(cold_batch)?;
}
let mut anchor_and_blob_batch = Vec::with_capacity(3); let mut anchor_and_blob_batch = Vec::with_capacity(3);

View File

@@ -38,7 +38,7 @@ use std::num::NonZeroUsize;
use std::path::Path; use std::path::Path;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use tracing::{debug, error, info, instrument, warn}; use tracing::{debug, debug_span, error, info, instrument, warn};
use typenum::Unsigned; use typenum::Unsigned;
use types::data::{ColumnIndex, DataColumnSidecar, DataColumnSidecarList}; use types::data::{ColumnIndex, DataColumnSidecar, DataColumnSidecarList};
use types::*; use types::*;
@@ -1510,14 +1510,24 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
let blob_cache_ops = blobs_ops.clone(); let blob_cache_ops = blobs_ops.clone();
// Try to execute blobs store ops. // Try to execute blobs store ops.
self.blobs_db let kv_blob_ops = self.convert_to_kv_batch(blobs_ops)?;
.do_atomically(self.convert_to_kv_batch(blobs_ops)?)?; {
let _span = debug_span!("write_blobs_db").entered();
self.blobs_db.do_atomically(kv_blob_ops)?;
}
let hot_db_cache_ops = hot_db_ops.clone(); let hot_db_cache_ops = hot_db_ops.clone();
// Try to execute hot db store ops. // Try to execute hot db store ops.
let tx_res = match self.convert_to_kv_batch(hot_db_ops) { let tx_res = {
Ok(kv_store_ops) => self.hot_db.do_atomically(kv_store_ops), let _convert_span = debug_span!("convert_hot_db_ops").entered();
Err(e) => Err(e), match self.convert_to_kv_batch(hot_db_ops) {
Ok(kv_store_ops) => {
drop(_convert_span);
let _span = debug_span!("write_hot_db").entered();
self.hot_db.do_atomically(kv_store_ops)
}
Err(e) => Err(e),
}
}; };
// Rollback on failure // Rollback on failure
if let Err(e) = tx_res { if let Err(e) = tx_res {