Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion triedb/pathdb/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,16 @@ func (db *Database) Journal(root common.Hash) error {
if db.readOnly {
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
var (
file *os.File
Expand Down