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

improve abortGeneration locks #559

Merged
merged 2 commits into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/state/snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,6 @@ func (t *Tree) AbortGeneration() {
// for it to shutdown before returning (if it is running). This call should not
// be made concurrently.
func (dl *diskLayer) abortGeneration() bool {
dl.lock.Lock()
defer dl.lock.Unlock()

// Store ideal time for abort to get better estimate of load
//
// Note that we set this time regardless if abortion was skipped otherwise we
Expand All @@ -580,7 +577,10 @@ func (dl *diskLayer) abortGeneration() bool {
}

// If the disk layer is running a snapshot generator, abort it
if dl.genAbort != nil && dl.genStats == nil {
dl.lock.RLock()
shouldAbort := dl.genAbort != nil && dl.genStats == nil
dl.lock.RUnlock()
if shouldAbort {
abort := make(chan struct{})
dl.genAbort <- abort
<-abort
Expand Down
Loading