Merge pull request 'block manager: avoid deadlock in fix_block_location (fix #845)' (#957) from fix-845 into main
All checks were successful
ci/woodpecker/push/debug Pipeline was successful
All checks were successful
ci/woodpecker/push/debug Pipeline was successful
Reviewed-on: #957
This commit is contained in:
commit
a94adf804f
1 changed files with 4 additions and 14 deletions
|
@ -668,10 +668,12 @@ impl BlockManager {
|
||||||
hash: &Hash,
|
hash: &Hash,
|
||||||
wrong_path: DataBlockPath,
|
wrong_path: DataBlockPath,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
|
let data = self.read_block_from(hash, &wrong_path).await?;
|
||||||
self.lock_mutate(hash)
|
self.lock_mutate(hash)
|
||||||
.await
|
.await
|
||||||
.fix_block_location(hash, wrong_path, self)
|
.write_block_inner(hash, &data, self, Some(wrong_path))
|
||||||
.await
|
.await?;
|
||||||
|
Ok(data.as_parts_ref().1.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn lock_mutate(&self, hash: &Hash) -> MutexGuard<'_, BlockManagerLocked> {
|
async fn lock_mutate(&self, hash: &Hash) -> MutexGuard<'_, BlockManagerLocked> {
|
||||||
|
@ -827,18 +829,6 @@ impl BlockManagerLocked {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fix_block_location(
|
|
||||||
&self,
|
|
||||||
hash: &Hash,
|
|
||||||
wrong_path: DataBlockPath,
|
|
||||||
mgr: &BlockManager,
|
|
||||||
) -> Result<usize, Error> {
|
|
||||||
let data = mgr.read_block_from(hash, &wrong_path).await?;
|
|
||||||
self.write_block_inner(hash, &data, mgr, Some(wrong_path))
|
|
||||||
.await?;
|
|
||||||
Ok(data.as_parts_ref().1.len())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DeleteOnDrop(Option<PathBuf>);
|
struct DeleteOnDrop(Option<PathBuf>);
|
||||||
|
|
Loading…
Add table
Reference in a new issue