Skip to content

Commit

Permalink
core/rawdb: improve freezerTable.Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepatta committed Jun 29, 2024
1 parent 285b59d commit e82ff02
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions core/rawdb/freezer_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -875,13 +875,21 @@ func (t *freezerTable) advanceHead() error {
// Sync pushes any pending data from memory out to disk. This is an expensive
// operation, so use it with care.
func (t *freezerTable) Sync() error {
if err := t.index.Sync(); err != nil {
return err
}
if err := t.meta.Sync(); err != nil {
return err
// Fix: https://github.com/ethereum/go-ethereum/pull/26245
t.lock.Lock()
defer t.lock.Unlock()

var err error
trackError := func(e error) {
if e != nil && err == nil {
err = e
}
}
return t.head.Sync()

trackError(t.index.Sync())
trackError(t.meta.Sync())
trackError(t.head.Sync())
return err
}

// DumpIndex is a debug print utility function, mainly for testing. It can also
Expand Down

0 comments on commit e82ff02

Please sign in to comment.