mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
triedb/pathdb: sync ancient store before journal
This commit is contained in:
parent
2a3f4cea13
commit
2f21f7279a
1 changed files with 10 additions and 1 deletions
|
|
@ -333,7 +333,16 @@ func (db *Database) Journal(root common.Hash) error {
|
||||||
if db.readOnly {
|
if db.readOnly {
|
||||||
return errDatabaseReadOnly
|
return errDatabaseReadOnly
|
||||||
}
|
}
|
||||||
|
// Forcibly sync the ancient store before persisting the in-memory layers.
|
||||||
|
// This prevents an edge case where the in-memory layers are persisted
|
||||||
|
// but the ancient store is not properly closed, resulting in recent writes
|
||||||
|
// being lost. After a restart, the ancient store would then be misaligned
|
||||||
|
// with the disk layer, causing data corruption.
|
||||||
|
if db.stateFreezer != nil {
|
||||||
|
if err := db.stateFreezer.SyncAncient(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
// Store the journal into the database and return
|
// Store the journal into the database and return
|
||||||
var (
|
var (
|
||||||
file *os.File
|
file *os.File
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue