Skip to content

Commit

Permalink
Fix test case to properly wait for all queries to be pending.
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schreiber <[email protected]>
  • Loading branch information
arthurschreiber committed Mar 4, 2024
1 parent 0f30e84 commit c1ca7b6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions go/vt/vttablet/tabletserver/tabletserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,20 @@ func TestSerializeTransactionsSameRow_ConcurrentTransactions(t *testing.T) {
db.SetBeforeFunc("update test_table set name_string = 'tx1' where pk = 1 and `name` = 1 limit 10001",
func() {
close(tx1Started)

// Wait for other queries to be pending.
<-allQueriesPending
})

db.SetBeforeFunc("update test_table set name_string = 'tx2' where pk = 1 and `name` = 1 limit 10001",
func() {
// Wait for other queries to be pending.
<-allQueriesPending
})

db.SetBeforeFunc("update test_table set name_string = 'tx3' where pk = 1 and `name` = 1 limit 10001",
func() {
// Wait for other queries to be pending.
<-allQueriesPending
})

Expand Down Expand Up @@ -1190,6 +1204,8 @@ func TestSerializeTransactionsSameRow_ConcurrentTransactions(t *testing.T) {
// to allow more than connection attempt at a time.
err := waitForTxSerializationPendingQueries(tsv, "test_table where pk = 1 and `name` = 1", 3)
require.NoError(t, err)

// Signal that all queries are pending now.
close(allQueriesPending)

wg.Wait()
Expand Down

0 comments on commit c1ca7b6

Please sign in to comment.