From e1e0df70af37f136110777d7b7af409f4201b925 Mon Sep 17 00:00:00 2001 From: Hana Kim Date: Wed, 11 Mar 2026 17:35:38 -0400 Subject: 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ethan Lee --- devtools/cmd/seeddb/main.go | 2 +- 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) -- cgit v1.3