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

Fix potential deadlock in rawdb.(*freezer).Ancient #22403

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions core/rawdb/freezer.go
Expand Up @@ -75,6 +75,7 @@ type freezer struct {

tables map[string]*freezerTable // Data tables for storing everything
instanceLock fileutil.Releaser // File-system lock to prevent double opens
ancientLock sync.Mutex // ancient lookup lock

trigger chan chan struct{} // Manual blocking freeze trigger, test determinism

Expand Down Expand Up @@ -165,6 +166,9 @@ func (f *freezer) HasAncient(kind string, number uint64) (bool, error) {

// Ancient retrieves an ancient binary blob from the append-only immutable files.
func (f *freezer) Ancient(kind string, number uint64) ([]byte, error) {
f.ancientLock.Lock()
defer f.ancientLock.Unlock()

if table := f.tables[kind]; table != nil {
return table.Retrieve(number)
}
Expand Down