Txn conflict: allows the OS to do something else before retrying

pull/186/head
Tpt 3 years ago
parent e95bf721dc
commit bada850284
  1. 6
      lib/src/storage/backend/rocksdb.rs

@ -20,6 +20,7 @@ use std::ops::Deref;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
use std::sync::Arc; use std::sync::Arc;
use std::thread::yield_now;
use std::{ptr, slice}; use std::{ptr, slice};
macro_rules! ffi_result { macro_rules! ffi_result {
@ -393,7 +394,10 @@ impl Db {
msg == "Resource busy: " msg == "Resource busy: "
|| msg == "Operation timed out: Timeout waiting to lock key" || msg == "Operation timed out: Timeout waiting to lock key"
}); });
if !is_conflict_error { if is_conflict_error {
// We give a chance to the OS to do something else before retrying in order to help avoiding an other conflict
yield_now();
} else {
// We raise the error // We raise the error
return Err(e); return Err(e);
} }

Loading…
Cancel
Save