CRITICAL FIX: Remove --single-transaction and --exit-on-error from pg_restore

- Disabled --single-transaction to prevent lock table exhaustion with large objects
- Removed --exit-on-error to allow PostgreSQL to skip ignorable errors
- Fixes 'could not open large object' errors (lock exhaustion with 35K+ BLOBs)
- Fixes 'already exists' errors causing complete restore failure
- Each object now restored in its own transaction (locks released incrementally)
- PostgreSQL default behavior (continue on ignorable errors) is correct

Per PostgreSQL docs: --single-transaction incompatible with large object restores
and causes ALL locks to be held until commit, exhausting lock table with 1000+ objects
This commit is contained in:
2025-11-18 10:16:59 +00:00
parent bfce57a0b6
commit 2548bfb6ae
3 changed files with 171 additions and 6 deletions

View File

@@ -371,9 +371,9 @@ func (p *PostgreSQL) BuildRestoreCommand(database, inputFile string, options Res
cmd = append(cmd, "--single-transaction")
}
// CRITICAL: Exit on first error (by default pg_restore continues on errors)
// This ensures we catch failures immediately instead of at the end
cmd = append(cmd, "--exit-on-error")
// NOTE: --exit-on-error removed because it causes entire restore to fail on
// "already exists" errors. PostgreSQL continues on ignorable errors by default
// and reports error count at the end, which is correct behavior for restores.
// Skip data restore if table creation fails (prevents duplicate data errors)
cmd = append(cmd, "--no-data-for-failed-tables")