- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitab35b9d
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 parent23e2a06 commitab35b9d
1 file changed
+43
-12
lines changedLines changed: 43 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
| 25 | + | |
25 | 26 |
| |
26 | 27 |
| |
27 | 28 |
| |
| |||
65 | 66 |
| |
66 | 67 |
| |
67 | 68 |
| |
68 |
| - | |
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
| 72 | + | |
72 | 73 |
| |
73 | 74 |
| |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
74 | 83 |
| |
75 | 84 |
| |
76 | 85 |
| |
| |||
102 | 111 |
| |
103 | 112 |
| |
104 | 113 |
| |
105 |
| - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
106 | 133 |
| |
107 | 134 |
| |
108 | 135 |
| |
| |||
150 | 177 |
| |
151 | 178 |
| |
152 | 179 |
| |
153 |
| - | |
| 180 | + | |
154 | 181 |
| |
155 | 182 |
| |
156 | 183 |
| |
157 |
| - | |
158 |
| - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
159 | 188 |
| |
160 |
| - | |
| 189 | + | |
161 | 190 |
| |
162 | 191 |
| |
163 |
| - | |
164 |
| - | |
| 192 | + | |
| 193 | + | |
165 | 194 |
| |
| 195 | + | |
166 | 196 |
| |
167 |
| - | |
| 197 | + | |
168 | 198 |
| |
169 | 199 |
| |
170 | 200 |
| |
| |||
186 | 216 |
| |
187 | 217 |
| |
188 | 218 |
| |
189 |
| - | |
| 219 | + | |
190 | 220 |
| |
191 | 221 |
| |
192 | 222 |
| |
| |||
196 | 226 |
| |
197 | 227 |
| |
198 | 228 |
| |
| 229 | + | |
199 | 230 |
| |
200 | 231 |
| |
201 | 232 |
| |
202 | 233 |
| |
203 | 234 |
| |
204 |
| - | |
| 235 | + | |
205 | 236 |
| |
206 | 237 |
| |
207 | 238 |
| |
208 | 239 |
| |
209 |
| - | |
| 240 | + | |
210 | 241 |
| |
211 | 242 |
| |
212 | 243 |
| |
|
0 commit comments
Comments
(0)