handle error about rocksdb lock already taken. concurrent start of ngd in same working directory

pull/31/head
Niko PLP 4 months ago
parent 3c0a1f8971
commit e2c2596e1e
  1. 1
      ng-repo/src/errors.rs
  2. 9
      ng-storage-rocksdb/src/block_storage.rs
  3. 9
      ng-storage-rocksdb/src/kcv_storage.rs

@ -218,6 +218,7 @@ pub enum StorageError {
OverlayBranchNotFound,
Abort,
NotEmpty,
ServerAlreadyRunningInOtherProcess,
}
impl core::fmt::Display for StorageError {

@ -79,7 +79,14 @@ impl RocksDbBlockStorage {
let env = Env::enc_env(key).unwrap();
opts.set_env(&env);
let tx_options = TransactionDBOptions::new();
let db: TransactionDB = TransactionDB::open(&opts, &tx_options, &path).unwrap();
let db: TransactionDB = TransactionDB::open(&opts, &tx_options, &path).map_err(|e| {
log_err!("{e}");
if e.into_string().starts_with("IO error: While lock file") {
StorageError::ServerAlreadyRunningInOtherProcess
} else {
StorageError::BackendError
}
})?;
log_info!(
"created blockstorage with Rocksdb Version: {}",

@ -702,7 +702,14 @@ impl RocksDbKCVStorage {
// TODO: use open_cf and choose which column family to create/ versus using set_prefix_extractor and doing prefix seek
let tx_options = TransactionDBOptions::new();
let db: TransactionDB = TransactionDB::open(&opts, &tx_options, &path).unwrap();
let db: TransactionDB = TransactionDB::open(&opts, &tx_options, &path).map_err(|e| {
log_err!("{e}");
if e.into_string().starts_with("IO error: While lock file") {
StorageError::ServerAlreadyRunningInOtherProcess
} else {
StorageError::BackendError
}
})?;
log_info!(
"created kcv storage with Rocksdb Version: {}",

Loading…
Cancel
Save