Skip to content

Commit

Permalink
test(storage): fix flaky read transaction safety (#6995)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Mar 6, 2024
1 parent 588c2f2 commit 0633fa5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/storage/db/src/implementation/mdbx/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<K: TransactionKind> MetricsHandler<K> {
self.transaction_mode().is_read_only()
{
let open_duration = self.start.elapsed();
if open_duration > self.long_transaction_duration {
if open_duration >= self.long_transaction_duration {
self.backtrace_recorded.store(true, Ordering::Relaxed);
warn!(
target: "storage::db::mdbx",
Expand Down Expand Up @@ -412,7 +412,8 @@ mod tests {
let mut tx = db.tx().unwrap();
tx.metrics_handler.as_mut().unwrap().long_transaction_duration = MAX_DURATION;
tx.disable_long_read_transaction_safety();
sleep(MAX_DURATION);
// Give the `TxnManager` some time to time out the transaction.
sleep(MAX_DURATION + Duration::from_millis(100));

assert_eq!(
tx.get::<tables::Transactions>(0).err(),
Expand All @@ -433,7 +434,8 @@ mod tests {

let mut tx = db.tx().unwrap();
tx.metrics_handler.as_mut().unwrap().long_transaction_duration = MAX_DURATION;
sleep(MAX_DURATION);
// Give the `TxnManager` some time to time out the transaction.
sleep(MAX_DURATION + Duration::from_millis(100));

assert_eq!(
tx.get::<tables::Transactions>(0).err(),
Expand Down

0 comments on commit 0633fa5

Please sign in to comment.