Fix block repair to not deadlock with sqlite
This commit is contained in:
parent
295bc2741f
commit
9bb58638f0
1 changed files with 8 additions and 0 deletions
|
@ -218,9 +218,17 @@ impl BlockManager {
|
||||||
/// to fix any mismatch between the two.
|
/// to fix any mismatch between the two.
|
||||||
pub async fn repair_data_store(&self, must_exit: &watch::Receiver<bool>) -> Result<(), Error> {
|
pub async fn repair_data_store(&self, must_exit: &watch::Receiver<bool>) -> Result<(), Error> {
|
||||||
// 1. Repair blocks from RC table.
|
// 1. Repair blocks from RC table.
|
||||||
|
// TODO don't do this like this
|
||||||
|
let mut hashes = vec![];
|
||||||
for (i, entry) in self.rc.rc.iter()?.enumerate() {
|
for (i, entry) in self.rc.rc.iter()?.enumerate() {
|
||||||
let (hash, _) = entry?;
|
let (hash, _) = entry?;
|
||||||
let hash = Hash::try_from(&hash[..]).unwrap();
|
let hash = Hash::try_from(&hash[..]).unwrap();
|
||||||
|
hashes.push(hash);
|
||||||
|
if i & 0xFF == 0 && *must_exit.borrow() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i, hash) in hashes.into_iter().enumerate() {
|
||||||
self.put_to_resync(&hash, Duration::from_secs(0))?;
|
self.put_to_resync(&hash, Duration::from_secs(0))?;
|
||||||
if i & 0xFF == 0 && *must_exit.borrow() {
|
if i & 0xFF == 0 && *must_exit.borrow() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
Loading…
Reference in a new issue