Skip to content

Commit

Permalink
replay: Deflake TestCompactionsQuiesce by waiting for sstable copy
Browse files Browse the repository at this point in the history
All the replay datadriven tests wait for all enqueued sstables
to finish copying to the collection directory before we terminate
the workload collector. The one exception is TestCompactionsQuiesce
which currently calls the Stop() method even if there are
sstables waiting to be copied. This change delays the call to Stop()
until all enqueued sstables have been copied over.

Fixes #2833.
  • Loading branch information
itsbilal committed Aug 18, 2023
1 parent 564b068 commit 40c977c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion replay/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ func buildHeavyWorkload(t *testing.T) vfs.FS {
require.NoError(t, b.Commit(pebble.NoSync))
require.NoError(t, d.Flush())
}
wc.Stop()
wc.WaitAndStop()

defer d.Close()
return destFS
Expand Down
12 changes: 12 additions & 0 deletions replay/workload_capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,18 @@ func (w *WorkloadCollector) Start(destFS vfs.FS, destPath string) {
go w.copyFiles()
}

// WaitAndStop waits for all enqueued sstables to be copied over, and then
// calls Stop. Gracefully ensures that all sstables referenced in the collected
// manifest's latest version edit will exist in the copy directory.
func (w *WorkloadCollector) WaitAndStop() {
w.mu.Lock()
for w.mu.tablesEnqueued != w.mu.tablesCopied {
w.mu.copyCond.Wait()
}
w.mu.Unlock()
w.Stop()
}

// Stop stops collection of the workload.
func (w *WorkloadCollector) Stop() {
w.mu.Lock()
Expand Down

0 comments on commit 40c977c

Please sign in to comment.