forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit25576be
committed
Guard against spurious signals in LockBufferForCleanup.
When LockBufferForCleanup() has to wait for getting a cleanup lock on abuffer it does so by setting a flag in the buffer header and then waitfor other backends to signal it using ProcWaitForSignal().Unfortunately LockBufferForCleanup() missed that ProcWaitForSignal() canreturn for other reasons than the signal it is hoping for. If such aspurious signal arrives the wait flags on the buffer header will stillbe set. That then triggers "ERROR: multiple backends attempting to waitfor pincount 1".The fix is simple, unset the flag if still set when retrying. Thatimplies an additional spinlock acquisition/release, but that's unlikelyto matter given the cost of waiting for a cleanup lock. Alternativelyit'd have been possible to move responsibility for maintaining therelevant flag to the waiter all together, but that might have hadnegative consequences due to possible floods of signals. Besides beingmore invasive.This looks to be a very longstanding bug. The relevant code inLockBufferForCleanup() hasn't changed materially since its introductionand ProcWaitForSignal() was documented to return for unrelated reasonssince 8.2. The master only patch series removing ImmediateInterruptOKmade it much easier to hit though, as ProcSendSignal/ProcWaitForSignalnow uses a latch shared with other tasks.Per discussion with Kevin Grittner, Tom Lane and me.Backpatch to all supported branches.Discussion: 11553.1423805224@sss.pgh.pa.us1 parent7052abb commit25576be
1 file changed
+14
-0
lines changedLines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2506 | 2506 |
| |
2507 | 2507 |
| |
2508 | 2508 |
| |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
2509 | 2523 |
| |
2510 | 2524 |
| |
2511 | 2525 |
| |
|
0 commit comments
Comments
(0)