Skip to content

Commit

Permalink
fix race condition of TestConcurrent (#1490)
Browse files Browse the repository at this point in the history
* fix race condition of TestConcurrent

* run tests with the '-race' option
  • Loading branch information
shogo82148 committed Oct 10, 2023
1 parent 5f74bcb commit 9c633df
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
- name: test
run: |
go test -v '-covermode=count' '-coverprofile=coverage.out'
go test -v '-race' '-covermode=atomic' '-coverprofile=coverage.out'
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
Expand Down
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 9c633df

Please sign in to comment.