From 18bbdb5363682fcf122a77745796c675cdeb5f26 Mon Sep 17 00:00:00 2001 From: ziggie Date: Fri, 17 Jul 2026 21:57:20 -0300 Subject: [PATCH] kvdb/sqlbase: relax bulk migration isolation --- kvdb/sqlbase/migration_bulk_postgres.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kvdb/sqlbase/migration_bulk_postgres.go b/kvdb/sqlbase/migration_bulk_postgres.go index a64373e34..c3c8b5c86 100644 --- a/kvdb/sqlbase/migration_bulk_postgres.go +++ b/kvdb/sqlbase/migration_bulk_postgres.go @@ -88,8 +88,13 @@ func (p *postgresDB) BeginBulk(ctx context.Context) (MigrationBulkKVTx, error) { return nil, err } + // A bulk migration can touch millions of rows in a single transaction. + // PostgreSQL retains predicate locks until a serializable transaction + // ends, which can make its predicate lock table consume excessive memory. + // Read committed is sufficient because the migration owns the empty + // destination database while loading it. tx, err := conn.BeginTx(ctx, &sql.TxOptions{ - Isolation: sql.LevelSerializable, + Isolation: sql.LevelReadCommitted, }) if err != nil { locker.Unlock()