forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb10546e
committed
Harden pmsignal.c against clobbered shared memory.
The postmaster is not supposed to do anything that dependsfundamentally on shared memory contents, because that createsthe risk that a backend crash that trashes shared memory willtake the postmaster down with it, preventing automatic recovery.In commit969d7cd I lost sight of this principle and codedAssignPostmasterChildSlot() in such a way that it could failor even crash if the shared PMSignalState structure becamecorrupted. Remarkably, we've not seen field reports of suchcrashes; but I managed to induce one while testing the recentchanges around palloc chunk headers.To fix, make a semi-duplicative state array inside the postmasterso that we need consult only local state while choosing a "childslot" for a new backend. Ensure that other postmaster-executedroutines in pmsignal.c don't have critical dependencies on theshared state, either. Corruption of PMSignalState might nowlead ReleasePostmasterChildSlot() to conclude that backend Xfailed, when actually backend Y was the one that trashed things.But that doesn't matter, because we'll force a cluster-wide resetregardless.Back-patch to all supported branches, since this is an old bug.Discussion:https://postgr.es/m/3436789.1665187055@sss.pgh.pa.us1 parent3162bd9 commitb10546e
1 file changed
+44
-12
lines changedLines changed: 44 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
| 29 | + | |
29 | 30 |
| |
30 | 31 |
| |
31 | 32 |
| |
| |||
75 | 76 |
| |
76 | 77 |
| |
77 | 78 |
| |
78 |
| - | |
79 | 79 |
| |
80 | 80 |
| |
81 | 81 |
| |
| 82 | + | |
82 | 83 |
| |
83 | 84 |
| |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
84 | 94 |
| |
85 | 95 |
| |
86 | 96 |
| |
| |||
142 | 152 |
| |
143 | 153 |
| |
144 | 154 |
| |
145 |
| - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
146 | 174 |
| |
147 | 175 |
| |
148 | 176 |
| |
| |||
218 | 246 |
| |
219 | 247 |
| |
220 | 248 |
| |
221 |
| - | |
| 249 | + | |
222 | 250 |
| |
223 | 251 |
| |
224 | 252 |
| |
225 |
| - | |
226 |
| - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
227 | 257 |
| |
228 |
| - | |
| 258 | + | |
229 | 259 |
| |
230 | 260 |
| |
231 |
| - | |
232 |
| - | |
| 261 | + | |
| 262 | + | |
233 | 263 |
| |
| 264 | + | |
234 | 265 |
| |
235 |
| - | |
| 266 | + | |
236 | 267 |
| |
237 | 268 |
| |
238 | 269 |
| |
| |||
254 | 285 |
| |
255 | 286 |
| |
256 | 287 |
| |
257 |
| - | |
| 288 | + | |
258 | 289 |
| |
259 | 290 |
| |
260 | 291 |
| |
| |||
264 | 295 |
| |
265 | 296 |
| |
266 | 297 |
| |
| 298 | + | |
267 | 299 |
| |
268 | 300 |
| |
269 | 301 |
| |
270 | 302 |
| |
271 | 303 |
| |
272 |
| - | |
| 304 | + | |
273 | 305 |
| |
274 | 306 |
| |
275 | 307 |
| |
276 | 308 |
| |
277 |
| - | |
| 309 | + | |
278 | 310 |
| |
279 | 311 |
| |
280 | 312 |
| |
|
0 commit comments
Comments
(0)