Skip to content

Commit

Permalink
sql: deflake TestIndexBackfillFractionTracking
Browse files Browse the repository at this point in the history
Recent changes added some concurrency to index backfills, so the testing
hook needs a mutex to prevent concurrent access.

Release note: None
  • Loading branch information
rafiss committed Jan 16, 2025
1 parent 0e13eaa commit adb81db
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/sql/mvcc_backfiller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ func TestIndexBackfillFractionTracking(t *testing.T) {
require.NoError(t, splitIndex(tc, tableDesc, idx, sps))
}

// Chunks are processed concurrently, so we need to synchronize access to
// lastPercentage.
var mu syncutil.Mutex
var lastPercentage float32
assertFractionBetween := func(op string, min float32, max float32) {
mu.Lock()
defer mu.Unlock()
var fraction float32
sqlRunner.QueryRow(t, "SELECT fraction_completed FROM [SHOW JOBS] WHERE job_id = $1", jobID).Scan(&fraction)
t.Logf("fraction during %s: %f", op, fraction)
Expand Down

0 comments on commit adb81db

Please sign in to comment.