Skip to content

Commit

Permalink
fix CI failures due to race condition in recoverysigner unit tests (#…
Browse files Browse the repository at this point in the history
…5472)

* fix CI failures due to race condition in recoverysigner unit tests
* Update support/db/dbtest/db.go
Co-authored-by: tamirms <[email protected]>
  • Loading branch information
urvisavla authored Sep 24, 2024
1 parent f668d5b commit 6fbba33
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions support/db/dbtest/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ func checkReadOnly(t testing.TB, DSN string) {
if !rows.Next() {
_, err = tx.Exec("CREATE ROLE user_ro WITH LOGIN PASSWORD 'user_ro';")
if err != nil {
// Handle race condition by ignoring the error if it's a duplicate key violation
if pqErr, ok := err.(*pq.Error); ok && pqErr.Code == "23505" {
// Handle race condition by ignoring the error if it's a duplicate key violation or duplicate object error
if pqErr, ok := err.(*pq.Error); ok && (pqErr.Code == "23505" || pqErr.Code == "42710") {
return
} else if ok {
t.Logf("pq error code: %s", pqErr.Code)
}
}
require.NoError(t, err)
Expand Down

0 comments on commit 6fbba33

Please sign in to comment.