Abstract database behind generic interface and implement alternative drivers #322

Merged
lx merged 64 commits from db-abstraction into main 2022-06-08 08:01:56 +00:00
2 changed files with 17 additions and 2 deletions
Showing only changes of commit 3d18c9e183 - Show all commits

View file

@ -363,6 +363,7 @@ impl<'a> DbValueIterator<'a> {
_pin: PhantomPinned, _pin: PhantomPinned,
}; };
let mut boxed = Box::pin(res); let mut boxed = Box::pin(res);
trace!("make iterator with sql: {}", sql);
unsafe { unsafe {
let db = NonNull::from(&boxed.db); let db = NonNull::from(&boxed.db);

View file

@ -64,8 +64,9 @@ impl Repair {
async fn repair_versions(&self, must_exit: &watch::Receiver<bool>) -> Result<(), Error> { async fn repair_versions(&self, must_exit: &watch::Receiver<bool>) -> Result<(), Error> {
let mut pos = vec![]; let mut pos = vec![];
let mut i = 0;
while *must_exit.borrow() { while !*must_exit.borrow() {
let item_bytes = { let item_bytes = {
let (k, v) = match self.garage.version_table.data.store.get_gt(pos)? { let (k, v) = match self.garage.version_table.data.store.get_gt(pos)? {
Some(pair) => pair, Some(pair) => pair,
@ -75,6 +76,11 @@ impl Repair {
v.into_vec() v.into_vec()
}; };
i += 1;
if i % 1000 == 0 {
info!("repair_versions: {}", i);
}
let version = rmp_serde::decode::from_read_ref::<_, Version>(&item_bytes)?; let version = rmp_serde::decode::from_read_ref::<_, Version>(&item_bytes)?;
if version.deleted.get() { if version.deleted.get() {
continue; continue;
@ -104,13 +110,15 @@ impl Repair {
.await?; .await?;
} }
} }
info!("repair_versions: finished, done {}", i);
Ok(()) Ok(())
} }
async fn repair_block_ref(&self, must_exit: &watch::Receiver<bool>) -> Result<(), Error> { async fn repair_block_ref(&self, must_exit: &watch::Receiver<bool>) -> Result<(), Error> {
let mut pos = vec![]; let mut pos = vec![];
let mut i = 0;
while *must_exit.borrow() { while !*must_exit.borrow() {
let item_bytes = { let item_bytes = {
let (k, v) = match self.garage.block_ref_table.data.store.get_gt(pos)? { let (k, v) = match self.garage.block_ref_table.data.store.get_gt(pos)? {
Some(pair) => pair, Some(pair) => pair,
@ -120,6 +128,11 @@ impl Repair {
v.into_vec() v.into_vec()
}; };
i += 1;
if i % 1000 == 0 {
info!("repair_block_ref: {}", i);
}
let block_ref = rmp_serde::decode::from_read_ref::<_, BlockRef>(&item_bytes)?; let block_ref = rmp_serde::decode::from_read_ref::<_, BlockRef>(&item_bytes)?;
if block_ref.deleted.get() { if block_ref.deleted.get() {
continue; continue;
@ -146,6 +159,7 @@ impl Repair {
.await?; .await?;
} }
} }
info!("repair_block_ref: finished, done {}", i);
Ok(()) Ok(())
} }
} }