Skip to content

Commit

Permalink
sql: deflake TestStatementTimeoutForSchemaChangeCommit
Browse files Browse the repository at this point in the history
Now we release the lock in a defer so that the test can't hang during
shutdown.

Release note: None
  • Loading branch information
rafiss committed Oct 31, 2024
1 parent ab2f9cf commit 14361b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/sql/run_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,10 @@ func TestStatementTimeoutForSchemaChangeCommit(t *testing.T) {
require.NoError(t, err)
// Test implicit transactions first.
blockSchemaChange.Swap(true)
defer func() {
close(waitForTimeout)
blockSchemaChange.Swap(false)
}()
if implicitTxn {
_, err := conn.DB.ExecContext(ctx, "ALTER TABLE t1 ADD COLUMN j INT DEFAULT 32")
require.ErrorContains(t, err, sqlerrors.QueryTimeoutError.Error())
Expand All @@ -1030,8 +1034,6 @@ func TestStatementTimeoutForSchemaChangeCommit(t *testing.T) {
err = txn.Commit()
require.NoError(t, err)
}
close(waitForTimeout)
blockSchemaChange.Swap(false)
})
}
}

0 comments on commit 14361b0

Please sign in to comment.