- Notifications
You must be signed in to change notification settings - Fork5
Commit1bf4a84
committed
Skip dead backends in MinimumActiveBackends
Back ined0b409, PGPROC was split and moved to static variables inprocarray.c, with procs in ProcArrayStruct replaced by an array ofintegers representing process numbers (pgprocnos), with -1 indicating adead process which has yet to be removed. Access to procArray isgenerally done under ProcArrayLock and therefore most code does not haveto concern itself with -1 entries.However, MinimumActiveBackends intentionally does not takeProcArrayLock, which means it has to be extra careful when accessingprocArray. Prior toed0b409, this was handled by checking for a NULLin the pointer array, but that check was no longer valid after thesplit. Coverity pointed out that the check could never happen and soit was removed in5592eba. That didn't make anything worse, but itdidn't fix the issue either.The correct fix is to check for pgprocno == -1 and skip over that entryif it is encountered.Back-patch to 9.2, since there can be attempts to access the arraysprior to their start otherwise. Note that the changes prior to 9.4 willlook a bit different due to the change in5592eba.Note that MinimumActiveBackends only returns a bool for heuristicpurposes and any pre-array accesses are strictly read-only and so thereis no security implication and the lack of fields complaints indicatesit's very unlikely to run into issues due to this.Pointed out by Noah.1 parent44096f1 commit1bf4a84
1 file changed
+2
-0
lines changedLines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2466 | 2466 |
| |
2467 | 2467 |
| |
2468 | 2468 |
| |
| 2469 | + | |
| 2470 | + | |
2469 | 2471 |
| |
2470 | 2472 |
| |
2471 | 2473 |
| |
|
0 commit comments
Comments
(0)