mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
fix: check disklayer hash consistency
This commit is contained in:
parent
b97b0b65e1
commit
d5e4c6c7f8
1 changed files with 5 additions and 4 deletions
|
|
@ -233,17 +233,18 @@ func (dl *diffLayer) node(owner common.Hash, path []byte, hash common.Hash, dept
|
|||
diffHashCacheMissMeter.Mark(1)
|
||||
persistLayer := dl.originDiskLayer()
|
||||
if persistLayer != nil {
|
||||
blob, bhash, nloc, err := persistLayer.node(owner, path, hash, depth+1)
|
||||
if err != nil {
|
||||
blob, rhash, nloc, err := persistLayer.node(owner, path, hash, depth+1)
|
||||
if err != nil || rhash != hash {
|
||||
// This is a bad case with a very low probability.
|
||||
// r/w the difflayer cache and r/w the disklayer are not in the same lock,
|
||||
// so in extreme cases, both reading the difflayer cache and reading the disklayer may fail, eg, disklayer is stale.
|
||||
// In this case, fallback to the original 128-layer recursive difflayer query path.
|
||||
diffHashCacheSlowPathMeter.Mark(1)
|
||||
log.Debug("Retry difflayer due to query origin failed", "owner", owner, "path", path, "hash", hash.String(), "error", err)
|
||||
log.Debug("Retry difflayer due to query origin failed",
|
||||
"owner", owner, "path", path, "query_hash", hash.String(), "return_hash", rhash.String(), "error", err)
|
||||
return dl.intervalNode(owner, path, hash, 0)
|
||||
} else { // This is the fastpath.
|
||||
return blob, bhash, nloc, nil
|
||||
return blob, rhash, nloc, nil
|
||||
}
|
||||
}
|
||||
diffHashCacheSlowPathMeter.Mark(1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue