aboutsummaryrefslogtreecommitdiff
path: root/internal/database/database.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2021-02-12 15:15:58 -0500
committerJonathan Amsterdam <jba@google.com>2021-02-12 21:22:07 +0000
commit443deaea06ee256d48681a37ece9c621b08313f7 (patch)
treec0a4693b3885c5db3ee03e36301258c2d8b34cec /internal/database/database.go
parent84574e5b8d2668d5f07f7bb7ee8ae19b7dfd22c3 (diff)
downloadgo-x-pkgsite-443deaea06ee256d48681a37ece9c621b08313f7.tar.xz
internal/database: catch missing retriable errors
We've noticed that we aren't retrying errors that have the right serialization code. The likely reason is that the error type is not what we expect. Get information about the type so we can recognize it in the code. For golang/go#43899 Change-Id: I72aceb12002eecbf580654b77c68d845759e8182 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/291609 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/database/database.go')
-rw-r--r--internal/database/database.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/internal/database/database.go b/internal/database/database.go
index be025553..e03ae5fe 100644
--- a/internal/database/database.go
+++ b/internal/database/database.go
@@ -195,6 +195,10 @@ func (db *DB) transactWithRetry(ctx context.Context, opts *sql.TxOptions, txFunc
db.mu.Unlock()
continue
}
+ if err != nil && strings.Contains(err.Error(), serializationFailureCode) {
+ return fmt.Errorf("error text has %q but not recognized as serialization failure: type %T, err %v",
+ serializationFailureCode, err, err)
+ }
if i > 0 {
log.Debugf(ctx, "retried serializable transaction %d time(s)", i)
}