WIP: block/repair.rs: Initial implementation of scrub checkpointing #582

Closed
jpds wants to merge 1 commits from jpds/garage:scrub-last-hash-persister into main
Contributor

Fixes: #518.

Fixes: #518.
jpds added 1 commit 2023-06-08 13:26:03 +00:00
Author
Contributor

@lx I have tunnel-vision from looking at this code for too long - can you please take a look and tell me what would be the best way to hook the last_hash in next() to the last_path ?

@lx I have tunnel-vision from looking at this code for too long - can you please take a look and tell me what would be the best way to hook the `last_hash` in `next()` to the `last_path` ?
Owner

Here is my suggestion:

  • keep the next() function as before, with zero argument

  • add to the BlockStoreIterator a function skip_until(hash: Hash) that reads the root directory, skips until the first subdirectory relevant to the given hash, and then does the same for sub-subdirectories

    OR maybe there's a simpler way of doing it by adding a field start_at: Hash in the BlockStoreIterator itself, and then at each time a subdirectory is read, pos is initialized not to zero but to the first position that is relevant given the hash we want to start at (on the line *last_path = ReadingDir::Read { subpaths, pos: 0 };)

  • in ScrubWorker::new, put something like this:

let work = match persisted.last_hash_checked {
    None => ScrubWorkerState::Finished,
    Some(hash) => {
        let mut it = BlockStoreIterator::new(...);
        it.skip_until(hash).await?;
        ScrubWorkerState::Running(it)
    }
};
Self {
    work,
    ...
}

(this will require making the new function async and making it return a Result)

Here is my suggestion: - keep the `next()` function as before, with zero argument - add to the `BlockStoreIterator` a function `skip_until(hash: Hash)` that reads the root directory, skips until the first subdirectory relevant to the given hash, and then does the same for sub-subdirectories OR maybe there's a simpler way of doing it by adding a field `start_at: Hash` in the BlockStoreIterator itself, and then at each time a subdirectory is read, `pos` is initialized not to zero but to the first position that is relevant given the hash we want to start at (on the line `*last_path = ReadingDir::Read { subpaths, pos: 0 };`) - in `ScrubWorker::new`, put something like this: ```rust let work = match persisted.last_hash_checked { None => ScrubWorkerState::Finished, Some(hash) => { let mut it = BlockStoreIterator::new(...); it.skip_until(hash).await?; ScrubWorkerState::Running(it) } }; Self { work, ... } ``` (this will require making the `new` function async and making it return a Result)
lx reviewed 2023-06-09 09:13:28 +00:00
@ -205,3 +205,3 @@
}
pub use v082::*;
mod v083 {
Owner

BTW you do not need to add this whole module with a new migration. Since the value of last_hash_checked if it was not present before is its Default::default() value (None), you can just add it to the struct in v082 with the attribute #[serde(default)]

BTW you do not need to add this whole module with a new migration. Since the value of `last_hash_checked` if it was not present before is its `Default::default()` value (`None`), you can just add it to the struct in `v082` with the attribute `#[serde(default)]`
Owner

I will implement this as part of #625, as I am making some changes to the block store iterator for multi-hdd support which incidentally make it much easier to implement checkpointing.

I will implement this as part of #625, as I am making some changes to the block store iterator for multi-hdd support which incidentally make it much easier to implement checkpointing.
lx closed this pull request 2023-09-04 14:12:06 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
Required
Details

Pull request closed

Sign in to join this conversation.
No description provided.