From 685bdedffc5b8823e8c3d874018cb68250b62c2e Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sun, 8 Oct 2023 20:09:20 +0900 Subject: [PATCH 1/2] fix race condition of TestConcurrent --- driver_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/driver_test.go b/driver_test.go index dd3d73141..74f15c2d2 100644 --- a/driver_test.go +++ b/driver_test.go @@ -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" { @@ -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 From 1b43e640e4c7b04ee78a573607ebe9ff52485238 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sun, 8 Oct 2023 20:12:26 +0900 Subject: [PATCH 2/2] run tests with the '-race' option --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b25c9e389..8e1cb9bc3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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