Skip to content

Commit b751e87

Browse files
committed
db: deflake TestMetrics
Fix #4624.
1 parent 73c2755 commit b751e87

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

data_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,10 @@ func runPopulateCmd(t *testing.T, td *datadriven.TestData, b *Batch) {
13791379
// waitTableStatsInitialLoad waits until the statistics for all files that
13801380
// existed during Open have been loaded; used in tests.
13811381
// The d.mu mutex must be locked while calling this method.
1382+
//
1383+
// TODO(jackson): Consolidate waitTableStatsInitialLoad and waitTableStats. It
1384+
// seems to be possible for loadedInitial to remain indefinitely false in some
1385+
// tests that use waitTableStats today.
13821386
func (d *DB) waitTableStatsInitialLoad() {
13831387
for !d.mu.tableStats.loadedInitial {
13841388
d.mu.tableStats.cond.Wait()

metrics_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ func TestMetrics(t *testing.T) {
341341
// The asynchronous loading of table stats can change metrics, so
342342
// wait for all the tables' stats to be loaded.
343343
d.mu.Lock()
344+
d.waitTableStatsInitialLoad()
344345
d.waitTableStats()
345346
d.mu.Unlock()
346347

0 commit comments

Comments
 (0)