Skip to content

Commit

Permalink
sql: fix TestAtMostOneRunningCreateStats txn retry hang
Browse files Browse the repository at this point in the history
Previously, this test could hang if there txn retry,
since we would end up waiting on a channel. To address
this patch will disable the testing knob once the channel
has been hit.

Fixes: #109007

Release note: None
  • Loading branch information
fqazi committed Aug 18, 2023
1 parent 104ed81 commit ccfad8a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/sql/stats/create_stats_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ func TestCreateStatisticsCanBeCancelled(t *testing.T) {
errCh <- err
}()
allowRequest <- struct{}{}
// If we end up ever retrying the txn, we should not block on
// the allow request channel again.
setTableID(descpb.InvalidID)
testutils.SucceedsSoon(t, func() error {
row := conn.QueryRow("SELECT query_id FROM [SHOW CLUSTER STATEMENTS] WHERE query LIKE 'CREATE STATISTICS%';")
var queryID string
Expand Down Expand Up @@ -214,7 +217,6 @@ func TestAtMostOneRunningCreateStats(t *testing.T) {
case err := <-errCh:
t.Fatal(err)
}

autoStatsRunShouldFail := func() {
_, err := conn.Exec(`CREATE STATISTICS __auto__ FROM d.t`)
expected := "another CREATE STATISTICS job is already running"
Expand Down

0 comments on commit ccfad8a

Please sign in to comment.