Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(storage): fix flaky read transaction safety #6995

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading