Commit 9e011f7
committed
fix(operator): terminate other client backends before drop_schemas_on
Before each DROP SCHEMA ... CASCADE run during schema-migration prep,
ask postgres to terminate every other client backend connected to
the target database. The operator owns the restore database fully
until handover, so any other session is necessarily a stray client
whose lock-holding would queue our DDL indefinitely.
Real scenario that triggered this: a long-running external psql
session got stuck mid-CREATE TABLE in the target restore while it
was still in the operator's Switching phase, holding namespace
locks that all subsequent DROP SCHEMA attempts queued behind for
20+ hours. With this change, the operator clears the deck before
attempting the DROP.
Best-effort by design: backends stuck in uninterruptible kernel
waits won't exit on SIGTERM (the case above eventually needed a
pod restart). But those are rare; the 99% case is a normal live
client and pg_terminate_backend takes care of it.1 parent 29f3933 commit 9e011f7
1 file changed
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
312 | 340 | | |
| 341 | + | |
| 342 | + | |
313 | 343 | | |
314 | 344 | | |
| 345 | + | |
315 | 346 | | |
316 | 347 | | |
317 | 348 | | |
| |||
0 commit comments