aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-06 16:31:43 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-06 16:31:43 +0200
commit72e6419b1b43fed5381b94c6ec01c53de34e5b17 (patch)
tree736b305861d7f0e35214f59c1e3b443ef5d70dbb
parent1dabd98330cedd108c42b7613a1f29fc4e4123ad (diff)
downloadgarage-72e6419b1b43fed5381b94c6ec01c53de34e5b17.tar.gz
garage-72e6419b1b43fed5381b94c6ec01c53de34e5b17.zip
add comment
-rw-r--r--src/block/manager.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs
index ea984646..17b45935 100644
--- a/src/block/manager.rs
+++ b/src/block/manager.rs
@@ -222,6 +222,15 @@ impl BlockManager {
// 1. Repair blocks from RC table.
let mut next_start: Option<Hash> = None;
loop {
+ // We have to do this complicated two-step process where we first read a bunch
+ // of hashes from the RC table, and then insert them in the to-resync queue,
+ // because of SQLite. Basically, as long as we have an iterator on a DB table,
+ // we can't do anything else on the DB. The naive approach (which we had previously)
+ // of just iterating on the RC table and inserting items one to one in the resync
+ // queue can't work here, it would just provoke a deadlock in the SQLite adapter code.
+ // This is mostly because the Rust bindings for SQLite assume a worst-case scenario
+ // where SQLite is not compiled in thread-safe mode, so we have to wrap everything
+ // in a mutex (see db/sqlite_adapter.rs).
let mut batch_of_hashes = vec![];
let start_bound = match next_start.as_ref() {
None => Bound::Unbounded,