From 120702ce0e3c08fd7fe7799a50c2f333da5a23f6 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sun, 20 Mar 2022 22:01:57 +0000 Subject: [PATCH] Don't forget to commit after R/W operations --- quickpeep_raker/src/bin/qp-seedrake.rs | 1 + quickpeep_raker/src/raking/task.rs | 15 ++++++++++++--- quickpeep_raker/src/storage.rs | 5 +++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/quickpeep_raker/src/bin/qp-seedrake.rs b/quickpeep_raker/src/bin/qp-seedrake.rs index 31ebe8f..e4e4a49 100644 --- a/quickpeep_raker/src/bin/qp-seedrake.rs +++ b/quickpeep_raker/src/bin/qp-seedrake.rs @@ -283,5 +283,6 @@ async fn import_and_flush_batch( } } } + txn.commit()?; Ok(()) } diff --git a/quickpeep_raker/src/raking/task.rs b/quickpeep_raker/src/raking/task.rs index 1ee256e..c54f5dc 100644 --- a/quickpeep_raker/src/raking/task.rs +++ b/quickpeep_raker/src/raking/task.rs @@ -144,7 +144,9 @@ impl TaskContext { } // TODO delete the domain from the store + todo!(); + txn.commit()?; Ok(true) }) .await?; @@ -227,6 +229,7 @@ impl TaskContext { self.store .async_rw_txn(move |txn| { txn.mark_url_as_visited(&domain, &url_str, record)?; + txn.commit()?; Ok(()) }) .await?; @@ -266,6 +269,7 @@ impl TaskContext { backoff_sec: 0, }, )?; + txn.commit()?; Ok(()) }) .await?; @@ -374,7 +378,7 @@ impl TaskContext { self.store .async_rw_txn(move |txn| { txn.start_backing_off(&domain, new_backoff, url.to_string(), failure)?; - + txn.commit()?; Ok(()) }) .await?; @@ -425,7 +429,9 @@ impl EventProcessor<'_> { UrlVisitedRecord { last_visited_days: datestamp, }, - ) + )?; + txn.commit()?; + Ok(()) }) .await } @@ -453,6 +459,7 @@ impl EventProcessor<'_> { txn.enqueue_url(&reference.target, reference.last_mod, reference.kind.into())?; } + txn.commit()?; Ok(()) }) .await @@ -469,7 +476,9 @@ impl EventProcessor<'_> { UrlVisitedRecord { last_visited_days: datestamp, }, - ) + )?; + txn.commit()?; + Ok(()) }) .await } diff --git a/quickpeep_raker/src/storage.rs b/quickpeep_raker/src/storage.rs index 0b0519d..59a0a79 100644 --- a/quickpeep_raker/src/storage.rs +++ b/quickpeep_raker/src/storage.rs @@ -220,6 +220,11 @@ pub struct RakerTxn<'a, K: TransactionKind> { } impl<'a> RakerTxn<'a, RW> { + pub fn commit(self) -> anyhow::Result<()> { + self.mdbx_txn.commit()?; + Ok(()) + } + /// Inserts a domain into the active domain table, /// generating a raffle ticket (and inserting it too). ///