Skip to content

Commit

Permalink
lock journal writer during memtable insert
Browse files Browse the repository at this point in the history
for good measure
  • Loading branch information
marvin-j97 committed Dec 18, 2024
1 parent a45a1fa commit 4f042af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/batch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ impl Batch {
}
}

drop(journal_writer);

// NOTE: Fully (write) lock, so the batch can be committed atomically
log::trace!("batch: Acquiring partitions lock");
let partitions = self.keyspace.partitions.write().expect("lock is poisoned");
Expand Down Expand Up @@ -174,6 +172,8 @@ impl Batch {
partitions_with_possible_stall.insert(partition.clone());
}

drop(journal_writer);

drop(locked_memtables);
drop(partitions);

Expand Down
8 changes: 4 additions & 4 deletions src/partition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,10 @@ impl PartitionHandle {
})?;
}

drop(journal_writer);

let (item_size, memtable_size) = self.tree.insert(key, value, seqno);

drop(journal_writer);

let write_buffer_size = self.write_buffer_manager.allocate(u64::from(item_size));

self.check_memtable_overflow(memtable_size)?;
Expand Down Expand Up @@ -967,10 +967,10 @@ impl PartitionHandle {
})?;
}

drop(journal_writer);

let (item_size, memtable_size) = self.tree.remove(key, seqno);

drop(journal_writer);

let write_buffer_size = self.write_buffer_manager.allocate(u64::from(item_size));

self.check_memtable_overflow(memtable_size)?;
Expand Down

0 comments on commit 4f042af

Please sign in to comment.