Skip to content

Commit

Permalink
core/freezer - retry sync write to disk (#1439)
Browse files Browse the repository at this point in the history
* core/freezer - retry sync write to disk
* Add backoff to retry

Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com>
  • Loading branch information
antonydenyer and baptiste-b-pegasys authored Jun 23, 2022
1 parent 58a13fc commit 12fe341
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion core/rawdb/freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,32 @@ func (f *freezer) TruncateAncients(items uint64) error {

// Sync flushes all data tables to disk.
func (f *freezer) Sync() error {
return f.SyncRetry(1, 1*time.Second)
}

// SyncRetry
// Quorum
// add retry to sync
func (f *freezer) SyncRetry(retry uint8, delay time.Duration) error {
var errs []error
for _, table := range f.tables {
if err := table.Sync(); err != nil {
errs = append(errs, err)
}
}
if errs != nil {
hasError := len(errs) > 0
if hasError && retry < 5 {
log.Info("sync", "retry", retry, "errors", errs)
time.Sleep(delay)
return f.SyncRetry(retry+1, delay*2)
} else if hasError {
return fmt.Errorf("%v", errs)
}
return nil
}

// End Quorum

// freeze is a background thread that periodically checks the blockchain for any
// import progress and moves ancient data from the fast database into the freezer.
//
Expand Down

0 comments on commit 12fe341

Please sign in to comment.