Skip to content

Commit 044bc56

Browse files
suntzu93lutter
authored andcommitted
fix: add statement_timeout and lock_timeout to mirror_primary_tables to prevent FDW zombie locks
Add SET LOCAL timeouts to refresh_tables() to prevent FDW zombie connections from holding ACCESS EXCLUSIVE locks on mirrored tables indefinitely. This fixes a v0.42.0 regression where stuck FDW queries during mirror_primary_tables() cascade into full system lock. - statement_timeout=60s: kills stuck FDW queries (normally <5s) - lock_timeout=10s: prevents TRUNCATE stampede from multiple nodes Both are SET LOCAL (transaction-scoped), zero impact on other queries.
1 parent 37acb91 commit 044bc56

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

store/postgres/src/primary.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,6 +2218,14 @@ impl Mirror {
22182218
.await
22192219
}
22202220

2221+
// Prevent FDW zombie connections from holding ACCESS EXCLUSIVE locks
2222+
// indefinitely. lock_timeout prevents TRUNCATE stampede when multiple
2223+
// nodes mirror simultaneously. statement_timeout kills stuck FDW
2224+
// queries. SET LOCAL scopes these to this transaction only.
2225+
conn.batch_execute("SET LOCAL statement_timeout = '60s'; SET LOCAL lock_timeout = '10s';")
2226+
.await
2227+
.map_err(StoreError::from)?;
2228+
22212229
// Truncate all tables at once, otherwise truncation can fail
22222230
// because of foreign key constraints
22232231
let tables = Self::PUBLIC_TABLES

0 commit comments

Comments
 (0)