Skip to content

Commit

Permalink
fix race condition of TestConcurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Oct 8, 2023
1 parent 3798012 commit 685bded
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,6 @@ func TestConcurrent(t *testing.T) {
defer wg.Done()

tx, err := dbt.db.Begin()
atomic.AddInt32(&remaining, -1)

if err != nil {
if err.Error() != "Error 1040: Too many connections" {
Expand All @@ -1882,7 +1881,7 @@ func TestConcurrent(t *testing.T) {
}

// keep the connection busy until all connections are open
for remaining > 0 {
for atomic.AddInt32(&remaining, -1) > 0 {
if _, err = tx.Exec("DO 1"); err != nil {
fatalf("error on conn %d: %s", id, err.Error())
return
Expand Down

0 comments on commit 685bded

Please sign in to comment.