Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/freezer - retry sync write to disk #1439

Merged
merged 5 commits into from
Jun 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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