Skip to content

Commit

Permalink
replay: fix race in WorkloadCollector
Browse files Browse the repository at this point in the history
WorkloadCollector.clean can be called before WorkloadCollector.Start
is called. Therefore, WorkloadCollector.Start must acquire
WorkloadCollector.mu.
  • Loading branch information
bananabrick committed Jan 19, 2023
1 parent f05f4ef commit 19fce0e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion replay/workload_capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,11 @@ func (w *WorkloadCollector) copySSTables(pending []string) {
// corresponding manifests are copied to the provided destination path on the
// provided FS.
func (w *WorkloadCollector) Start(destFS vfs.FS, destPath string) {
w.mu.Lock()
defer w.mu.Unlock()

// If the collector not is running then that means w.enabled == 0 so swap it
// to 1 and continue else return since it is not running.
// to 1 and continue else return since it is already running.
if !atomic.CompareAndSwapUint32(&w.atomic.enabled, 0, 1) {
return
}
Expand Down

0 comments on commit 19fce0e

Please sign in to comment.