diff options
| author | Hana Kim <hyangah@gmail.com> | 2026-03-11 17:35:38 -0400 |
|---|---|---|
| committer | Hyang-Ah Hana Kim <hyangah@gmail.com> | 2026-03-12 08:21:08 -0700 |
| commit | e1e0df70af37f136110777d7b7af409f4201b925 (patch) | |
| tree | d830f13d50dcd4e96caca7090276661f02559667 | |
| parent | 194e570e21c1dedb0321266981abb82e27cb00dd (diff) | |
| download | go-x-pkgsite-e1e0df70af37f136110777d7b7af409f4201b925.tar.xz | |
devtools/cmd/seeddb, internal/database: reduce contention and increase retries
Lower the concurrency limit of seeddb from 10 to 5 to reduce
database contention.
Increase the maximum number of transaction retries on serialization
failure from 10 to 20 to improve reliability for large module
insertions.
Change-Id: Id57eea3bf7b7cf5554d4e99fbe68ac89bb355904
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/754540
kokoro-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ethan Lee <ethanalee@google.com>
| -rw-r--r-- | devtools/cmd/seeddb/main.go | 2 | ||||
| -rw-r--r-- | internal/database/database.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/devtools/cmd/seeddb/main.go b/devtools/cmd/seeddb/main.go index 3c2c96b8..623b37b4 100644 --- a/devtools/cmd/seeddb/main.go +++ b/devtools/cmd/seeddb/main.go @@ -112,7 +112,7 @@ func run(ctx context.Context, db *database.DB, proxyURL string) error { } g, gctx := errgroup.WithContext(ctx) - g.SetLimit(10) + g.SetLimit(5) f := &worker.Fetcher{ ProxyClient: proxyClient, SourceClient: sourceClient, diff --git a/internal/database/database.go b/internal/database/database.go index bcb7c09a..5fd3af9e 100644 --- a/internal/database/database.go +++ b/internal/database/database.go @@ -246,7 +246,7 @@ func (db *DB) transactWithRetry(ctx context.Context, opts *sql.TxOptions, txFunc defer derrors.Wrap(&err, "transactWithRetry(%v)", opts) // Retry on serialization failure, up to some max. // See https://www.postgresql.org/docs/11/transaction-iso.html. - const maxRetries = 10 + const maxRetries = 20 sleepDur := 125 * time.Millisecond for i := 0; i <= maxRetries; i++ { err = db.transact(ctx, opts, txFunc) |
