Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into spanner-row-delet…
Browse files Browse the repository at this point in the history
…ion-policy-drop-support
  • Loading branch information
toga4 committed Dec 14, 2022
2 parents ac32ef3 + c9ff76f commit a644f07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions database/yugabytedb/yugabytedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database"
"github.com/hashicorp/go-multierror"
"github.com/jackc/pgconn"
"github.com/jackc/pgerrcode"
"github.com/lib/pq"
"go.uber.org/atomic"
)
Expand Down Expand Up @@ -462,18 +464,16 @@ func (c *YugabyteDB) newBackoff(ctx context.Context) backoff.BackOff {
}

func errIsRetryable(err error) bool {
pqErr := pq.Error{}
if !errors.As(err, &pqErr) {
var pgErr *pgconn.PgError
if !errors.As(err, &pgErr) {
return false
}

code := string(pqErr.Code)

// Assume that it's safe to retry 08006 and XX000 because we check for lock existence
// before creating and lock ID is primary key. Version field in migrations table is primary key too
// and delete all versions is an idempotend operation.
return code == "40001" || // Serialization error (optimistic locking conflict)
code == "40P01" || // Deadlock
code == "08006" || // Connection failure (node down, need to reconnect)
code == "XX000" // Internal error (may happen during HA)
// and delete all versions is an idempotent operation.
return pgErr.Code == pgerrcode.SerializationFailure || // optimistic locking conflict
pgErr.Code == pgerrcode.DeadlockDetected ||
pgErr.Code == pgerrcode.ConnectionFailure || // node down, need to reconnect
pgErr.Code == pgerrcode.InternalError // may happen during HA
}
4 changes: 3 additions & 1 deletion testing/testing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"testing"
)

func ExampleParallelTest(t *testing.T) { // nolint:govet
func ExampleParallelTest() {
t := &testing.T{} // Should actually be used in a Test

var isReady = func(i Instance) bool {
// Return true if Instance is ready to run tests.
// Don't block here though.
Expand Down

0 comments on commit a644f07

Please sign in to comment.