- Notifications
You must be signed in to change notification settings - Fork5
Commit89fd72c
committed
Introduce a pipe between postmaster and each backend, which can be used to
detect postmaster death. Postmaster keeps the write-end of the pipe open,so when it dies, children get EOF in the read-end. That can convenientlybe waited for in select(), which allows eliminating some of the pollingloops that check for postmaster death. This patch doesn't yet change allthe loops to use the new mechanism, expect a follow-on patch to do that.This changes the interface to WaitLatch, so that it takes as argument abitmask of events that it waits for. Possible events are latch set, timeout,postmaster death, and socket becoming readable or writeable.The pipe method behaves slightly differently from the kill() methodpreviously used in PostmasterIsAlive() in the case that postmaster has died,but its parent has not yet read its exit code with waitpid(). The pipereturns EOF as soon as the process dies, but kill() continues to returntrue until waitpid() has been called (IOW while the process is a zombie).Because of that, change PostmasterIsAlive() to use the pipe too, otherwiseWaitLatch() would return immediately with WL_POSTMASTER_DEATH, whilePostmasterIsAlive() would claim it's still alive. That could easily lead tobusy-waiting while postmaster is in zombie state.Peter Geoghegan with further changes by me, reviewed by Fujii Masao andFlorian Pflug.1 parent9598afa commit89fd72c
File tree
16 files changed
+322
-141
lines changed- src
- backend
- access/transam
- port
- postmaster
- replication
- storage/ipc
- include
- postmaster
- storage
16 files changed
+322
-141
lines changedLines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9938 | 9938 |
| |
9939 | 9939 |
| |
9940 | 9940 |
| |
9941 |
| - | |
| 9941 | + | |
9942 | 9942 |
| |
9943 | 9943 |
| |
9944 | 9944 |
| |
| |||
10165 | 10165 |
| |
10166 | 10166 |
| |
10167 | 10167 |
| |
10168 |
| - | |
| 10168 | + | |
10169 | 10169 |
| |
10170 | 10170 |
| |
10171 | 10171 |
| |
|
Lines changed: 70 additions & 31 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
93 | 93 |
| |
94 | 94 |
| |
95 | 95 |
| |
| 96 | + | |
96 | 97 |
| |
97 | 98 |
| |
98 | 99 |
| |
| |||
176 | 177 |
| |
177 | 178 |
| |
178 | 179 |
| |
179 |
| - | |
180 |
| - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
181 | 184 |
| |
182 |
| - | |
183 |
| - | |
184 |
| - | |
185 |
| - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
186 | 189 |
| |
187 | 190 |
| |
188 | 191 |
| |
189 | 192 |
| |
190 | 193 |
| |
191 |
| - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
192 | 204 |
| |
193 |
| - | |
194 |
| - | |
| 205 | + | |
| 206 | + | |
195 | 207 |
| |
196 |
| - | |
| 208 | + | |
197 | 209 |
| |
198 | 210 |
| |
199 | 211 |
| |
200 |
| - | |
201 |
| - | |
202 |
| - | |
| 212 | + | |
| 213 | + | |
203 | 214 |
| |
204 | 215 |
| |
205 |
| - | |
206 |
| - | |
| 216 | + | |
| 217 | + | |
207 | 218 |
| |
208 | 219 |
| |
209 | 220 |
| |
| |||
212 | 223 |
| |
213 | 224 |
| |
214 | 225 |
| |
215 |
| - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
216 | 233 |
| |
217 | 234 |
| |
218 | 235 |
| |
219 |
| - | |
| 236 | + | |
220 | 237 |
| |
| 238 | + | |
221 | 239 |
| |
222 | 240 |
| |
223 | 241 |
| |
224 | 242 |
| |
225 | 243 |
| |
226 | 244 |
| |
227 |
| - | |
| 245 | + | |
228 | 246 |
| |
229 | 247 |
| |
230 | 248 |
| |
| |||
235 | 253 |
| |
236 | 254 |
| |
237 | 255 |
| |
238 |
| - | |
| 256 | + | |
239 | 257 |
| |
240 |
| - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
241 | 263 |
| |
242 | 264 |
| |
243 | 265 |
| |
244 | 266 |
| |
245 | 267 |
| |
246 | 268 |
| |
247 |
| - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
248 | 278 |
| |
249 | 279 |
| |
250 | 280 |
| |
251 | 281 |
| |
252 | 282 |
| |
253 | 283 |
| |
254 | 284 |
| |
255 |
| - | |
| 285 | + | |
256 | 286 |
| |
257 | 287 |
| |
258 | 288 |
| |
259 | 289 |
| |
260 | 290 |
| |
261 | 291 |
| |
| 292 | + | |
262 | 293 |
| |
| 294 | + | |
| 295 | + | |
263 | 296 |
| |
264 | 297 |
| |
265 | 298 |
| |
| |||
268 | 301 |
| |
269 | 302 |
| |
270 | 303 |
| |
271 |
| - | |
| 304 | + | |
272 | 305 |
| |
273 | 306 |
| |
274 |
| - | |
275 |
| - | |
| 307 | + | |
276 | 308 |
| |
277 |
| - | |
278 |
| - | |
279 |
| - | |
| 309 | + | |
280 | 310 |
| |
281 |
| - | |
282 |
| - | |
| 311 | + | |
| 312 | + | |
283 | 313 |
| |
284 |
| - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
285 | 324 |
| |
286 | 325 |
| |
287 | 326 |
| |
|
Lines changed: 71 additions & 27 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
| 26 | + | |
26 | 27 |
| |
27 | 28 |
| |
28 | 29 |
| |
| |||
81 | 82 |
| |
82 | 83 |
| |
83 | 84 |
| |
84 |
| - | |
85 |
| - | |
| 85 | + | |
| 86 | + | |
86 | 87 |
| |
87 |
| - | |
| 88 | + | |
88 | 89 |
| |
89 | 90 |
| |
90 | 91 |
| |
91 |
| - | |
92 |
| - | |
| 92 | + | |
| 93 | + | |
93 | 94 |
| |
94 | 95 |
| |
95 |
| - | |
| 96 | + | |
96 | 97 |
| |
97 |
| - | |
| 98 | + | |
98 | 99 |
| |
99 | 100 |
| |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
100 | 118 |
| |
| 119 | + | |
101 | 120 |
| |
102 | 121 |
| |
103 | 122 |
| |
104 | 123 |
| |
105 | 124 |
| |
106 |
| - | |
| 125 | + | |
| 126 | + | |
107 | 127 |
| |
108 | 128 |
| |
109 | 129 |
| |
110 |
| - | |
| 130 | + | |
111 | 131 |
| |
112 |
| - | |
| 132 | + | |
113 | 133 |
| |
114 | 134 |
| |
115 | 135 |
| |
116 | 136 |
| |
117 | 137 |
| |
118 | 138 |
| |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
119 | 144 |
| |
120 |
| - | |
| 145 | + | |
121 | 146 |
| |
122 | 147 |
| |
123 | 148 |
| |
| |||
127 | 152 |
| |
128 | 153 |
| |
129 | 154 |
| |
130 |
| - | |
| 155 | + | |
131 | 156 |
| |
132 |
| - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
133 | 162 |
| |
134 | 163 |
| |
135 | 164 |
| |
136 |
| - | |
137 |
| - | |
| 165 | + | |
| 166 | + | |
138 | 167 |
| |
139 | 168 |
| |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
140 | 180 |
| |
141 | 181 |
| |
142 |
| - | |
143 |
| - | |
| 182 | + | |
144 | 183 |
| |
145 |
| - | |
146 |
| - | |
147 |
| - | |
| 184 | + | |
| 185 | + | |
148 | 186 |
| |
149 | 187 |
| |
150 | 188 |
| |
151 |
| - | |
152 |
| - | |
153 | 189 |
| |
154 | 190 |
| |
155 | 191 |
| |
156 | 192 |
| |
157 | 193 |
| |
158 |
| - | |
159 |
| - | |
160 |
| - | |
161 |
| - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
162 | 204 |
| |
| 205 | + | |
163 | 206 |
| |
164 | 207 |
| |
165 | 208 |
| |
| 209 | + | |
166 | 210 |
| |
167 | 211 |
| |
168 |
| - | |
| 212 | + | |
169 | 213 |
| |
170 | 214 |
| |
171 | 215 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
556 | 556 |
| |
557 | 557 |
| |
558 | 558 |
| |
559 |
| - | |
| 559 | + | |
560 | 560 |
| |
561 | 561 |
| |
562 | 562 |
| |
| |||
593 | 593 |
| |
594 | 594 |
| |
595 | 595 |
| |
596 |
| - | |
| 596 | + | |
597 | 597 |
| |
598 | 598 |
| |
599 | 599 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
381 | 381 |
| |
382 | 382 |
| |
383 | 383 |
| |
384 |
| - | |
| 384 | + | |
385 | 385 |
| |
386 | 386 |
| |
387 | 387 |
| |
|
0 commit comments
Comments
(0)