Skip to content

Commit

Permalink
remove disable_lock feature
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo committed Jun 11, 2024
1 parent 6862d70 commit 748a45e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
1 change: 0 additions & 1 deletion crates/storage/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ mdbx = ["reth-libmdbx"]
bench = []
arbitrary = ["reth-primitives/arbitrary", "reth-db-api/arbitrary"]
optimism = []
disable_lock = []

[[bench]]
name = "hash_keys"
Expand Down
22 changes: 5 additions & 17 deletions crates/storage/db/src/lockfile.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Storage lock utils.

#![cfg_attr(feature = "disable_lock", allow(dead_code))]

use reth_storage_errors::lockfile::StorageLockError;
use reth_tracing::tracing::error;
use std::{
Expand Down Expand Up @@ -31,23 +29,13 @@ impl StorageLock {
/// with the same PID), it will succeed.
pub fn try_acquire(path: &Path) -> Result<Self, StorageLockError> {
let file_path = path.join(LOCKFILE_NAME);

#[cfg(feature = "disable_lock")]
{
// Too expensive for ef-tests to write/read lock to/from disk.
Ok(Self(Arc::new(StorageLockInner { file_path })))
}

#[cfg(not(feature = "disable_lock"))]
{
if let Some(process_lock) = ProcessUID::parse(&file_path)? {
if process_lock.pid != (process::id() as usize) && process_lock.is_active() {
return Err(StorageLockError::Taken(process_lock.pid))
}
if let Some(process_lock) = ProcessUID::parse(&file_path)? {
if process_lock.pid != (process::id() as usize) && process_lock.is_active() {
return Err(StorageLockError::Taken(process_lock.pid))
}

Ok(Self(Arc::new(StorageLockInner::new(file_path)?)))
}

Ok(Self(Arc::new(StorageLockInner::new(file_path)?)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion testing/ef-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ asm-keccak = ["reth-primitives/asm-keccak"]

[dependencies]
reth-primitives.workspace = true
reth-db = { workspace = true, features = ["mdbx", "test-utils", "disable_lock"] }
reth-db = { workspace = true, features = ["mdbx", "test-utils"] }
reth-db-api.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] }
reth-stages.workspace = true
Expand Down

0 comments on commit 748a45e

Please sign in to comment.