forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8f98352
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 parentabc510f commit8f98352
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 |
| |
| |||
69 | 70 |
| |
70 | 71 |
| |
71 | 72 |
| |
72 |
| - | |
73 | 73 |
| |
74 | 74 |
| |
75 | 75 |
| |
| 76 | + | |
76 | 77 |
| |
77 | 78 |
| |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
78 | 88 |
| |
79 | 89 |
| |
80 | 90 |
| |
| |||
135 | 145 |
| |
136 | 146 |
| |
137 | 147 |
| |
138 |
| - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
139 | 167 |
| |
140 | 168 |
| |
141 | 169 |
| |
| |||
183 | 211 |
| |
184 | 212 |
| |
185 | 213 |
| |
186 |
| - | |
| 214 | + | |
187 | 215 |
| |
188 | 216 |
| |
189 | 217 |
| |
190 |
| - | |
191 |
| - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
192 | 222 |
| |
193 |
| - | |
| 223 | + | |
194 | 224 |
| |
195 | 225 |
| |
196 |
| - | |
197 |
| - | |
| 226 | + | |
| 227 | + | |
198 | 228 |
| |
| 229 | + | |
199 | 230 |
| |
200 |
| - | |
| 231 | + | |
201 | 232 |
| |
202 | 233 |
| |
203 | 234 |
| |
| |||
219 | 250 |
| |
220 | 251 |
| |
221 | 252 |
| |
222 |
| - | |
| 253 | + | |
223 | 254 |
| |
224 | 255 |
| |
225 | 256 |
| |
| |||
229 | 260 |
| |
230 | 261 |
| |
231 | 262 |
| |
| 263 | + | |
232 | 264 |
| |
233 | 265 |
| |
234 | 266 |
| |
235 | 267 |
| |
236 | 268 |
| |
237 |
| - | |
| 269 | + | |
238 | 270 |
| |
239 | 271 |
| |
240 | 272 |
| |
241 | 273 |
| |
242 |
| - | |
| 274 | + | |
243 | 275 |
| |
244 | 276 |
| |
245 | 277 |
| |
|
0 commit comments
Comments
(0)