Unverified Commit 193f350e authored by Felix Lange's avatar Felix Lange Committed by GitHub

core/rawdb: improve freezerTable.Sync (#26245)

While investigating #22374, I noticed that the Sync operation of the
freezer does not take the table lock. It also doesn't call sync for all files
if there is an error with one of them. I doubt this will fix anything, but
didn't want to drop the fix on the floor either.
parent ec2ec2d0
......@@ -867,13 +867,20 @@ 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
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
}
func (t *freezerTable) dumpIndexStdout(start, stop int64) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment