fix: disable long read transaction safety in db diff (#7575)

This commit is contained in:
Dan Cline
2024-04-11 16:37:20 -04:00
committed by GitHub
parent 39dea65b63
commit 8304780558

View File

@@ -21,7 +21,7 @@ use std::{
io::Write,
path::{Path, PathBuf},
};
use tracing::info;
use tracing::{info, warn};
#[derive(Parser, Debug)]
/// The arguments for the `reth db diff` command
@@ -58,6 +58,7 @@ impl Command {
/// The discrepancies and extra elements, along with a brief summary of the diff results are
/// then written to a file in the output directory.
pub fn execute(self, tool: &DbTool<DatabaseEnv>) -> eyre::Result<()> {
warn!("Make sure the node is not running when running `reth db diff`!");
// open second db
let second_db_path: PathBuf = self.secondary_datadir.join("db").into();
let second_db = open_db_read_only(&second_db_path, self.second_db.database_args())?;
@@ -68,8 +69,13 @@ impl Command {
};
for table in tables {
let primary_tx = tool.provider_factory.db_ref().tx()?;
let secondary_tx = second_db.tx()?;
let mut primary_tx = tool.provider_factory.db_ref().tx()?;
let mut secondary_tx = second_db.tx()?;
// disable long read transaction safety, since this will run for a while and it's
// expected that the node is not running
primary_tx.disable_long_read_transaction_safety();
secondary_tx.disable_long_read_transaction_safety();
let output_dir = self.output.clone();
match table {