aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-09-21 15:37:28 +0200
committerAlex Auvolat <alex@adnab.me>2023-09-21 15:37:28 +0200
commit0635250b2bdcce4156704128de154f9052d34e9e (patch)
tree5b5f8d66637c4a10866b00e07a45081c93cf75cf
parentf97168f80567f43e15cf236092703e6ae5d8dc2e (diff)
downloadgarage-k2v-indices-lmdb.tar.gz
garage-k2v-indices-lmdb.zip
garage_table/queue_insert: delay worker notification to after transaction commit (fix #583)k2v-indices-lmdb
-rw-r--r--src/table/data.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/table/data.rs b/src/table/data.rs
index 665f4142..bbfdf58b 100644
--- a/src/table/data.rs
+++ b/src/table/data.rs
@@ -34,7 +34,7 @@ pub struct TableData<F: TableSchema, R: TableReplication> {
pub(crate) merkle_todo_notify: Notify,
pub(crate) insert_queue: db::Tree,
- pub(crate) insert_queue_notify: Notify,
+ pub(crate) insert_queue_notify: Arc<Notify>,
pub(crate) gc_todo: CountedTree,
@@ -80,7 +80,7 @@ impl<F: TableSchema, R: TableReplication> TableData<F, R> {
merkle_todo,
merkle_todo_notify: Notify::new(),
insert_queue,
- insert_queue_notify: Notify::new(),
+ insert_queue_notify: Arc::new(Notify::new()),
gc_todo,
metrics,
})
@@ -339,7 +339,9 @@ impl<F: TableSchema, R: TableReplication> TableData<F, R> {
.map_err(Error::RmpEncode)
.map_err(db::TxError::Abort)?;
tx.insert(&self.insert_queue, &tree_key, new_entry)?;
- self.insert_queue_notify.notify_one();
+
+ let notif = self.insert_queue_notify.clone();
+ tx.on_commit(move || notif.notify_one());
Ok(())
}