datastore: use new ProcessLocker

To make sure only one process runs garbage collection while having active writers.
This commit is contained in:
Dietmar Maurer
2019-03-22 09:42:15 +01:00
parent abfc001f25
commit 43b1303398
4 changed files with 25 additions and 10 deletions

View File

@ -175,6 +175,7 @@ impl IndexFile for FixedIndexReader {
pub struct FixedIndexWriter {
store: Arc<ChunkStore>,
_lock: tools::ProcessLockSharedGuard,
filename: PathBuf,
tmp_filename: PathBuf,
chunk_size: usize,
@ -204,6 +205,8 @@ impl FixedIndexWriter {
pub fn create(store: Arc<ChunkStore>, path: &Path, size: usize, chunk_size: usize) -> Result<Self, Error> {
let shared_lock = store.try_shared_lock()?;
let full_path = store.relative_path(path);
let mut tmp_path = full_path.clone();
tmp_path.set_extension("tmp_fidx");
@ -250,6 +253,7 @@ impl FixedIndexWriter {
Ok(Self {
store,
_lock: shared_lock,
filename: full_path,
tmp_filename: tmp_path,
chunk_size,