forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit16e1b7a
committed
Fix assorted race conditions in the new timeout infrastructure.
Prevent handle_sig_alarm from losing control partway through due to a querycancel (either an asynchronous SIGINT, or a cancel triggered by one of thetimeout handler functions). That would at least result in failure toschedule any required future interrupt, and might result in actualcorruption of timeout.c's data structures, if the interrupt happened whilewe were updating those.We could still lose control if an asynchronous SIGINT arrives just as thefunction is entered. This wouldn't break any data structures, but it wouldhave the same effect as if the SIGALRM interrupt had been silently lost:we'd not fire any currently-due handlers, nor schedule any new interrupt.To forestall that scenario, forcibly reschedule any pending timer interruptduring AbortTransaction and AbortSubTransaction. We can avoid any extrakernel call in most cases by not doing that until we've allowedLockErrorCleanup to kill the DEADLOCK_TIMEOUT and LOCK_TIMEOUT events.Another hazard is that some platforms (at least Linux and *BSD) block asignal before calling its handler and then unblock it on return. When welongjmp out of the handler, the unblock doesn't happen, and the signal isleft blocked indefinitely. Again, we can fix that by forcibly unblockingsignals during AbortTransaction and AbortSubTransaction.These latter two problems do not manifest when the longjmp reachespostgres.c, because the error recovery code there kills all pending timeoutevents anyway, and it uses sigsetjmp(..., 1) so that the appropriate signalmask is restored. So errors thrown outside any transaction should be OKalready, and cleaning up in AbortTransaction and AbortSubTransaction shouldbe enough to fix these issues. (We're assuming that any code that catchesa query cancel error and doesn't re-throw it will do at least asubtransaction abort to clean up; but that was pretty much required alreadyby other subsystems.)Lastly, ProcSleep should not clear the LOCK_TIMEOUT indicator flag whendisabling that event: if a lock timeout interrupt happened after the lockwas granted, the ensuing query cancel is still going to happen at the nextCHECK_FOR_INTERRUPTS, and we want to report it as a lock timeout not a usercancel.Per reports from Dan Wood.Back-patch to 9.3 where the new timeout handling infrastructure wasintroduced. We may at some point decide to back-patch the signalunblocking changes further, but I'll desist from that until we hearactual field complaints about it.1 parent50107ee commit16e1b7a
File tree
6 files changed
+117
-7
lines changed- src
- backend
- access/transam
- postmaster
- storage/lmgr
- tcop
- utils/misc
- include/utils
6 files changed
+117
-7
lines changedLines changed: 38 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
| 37 | + | |
37 | 38 |
| |
38 | 39 |
| |
39 | 40 |
| |
| |||
52 | 53 |
| |
53 | 54 |
| |
54 | 55 |
| |
| 56 | + | |
55 | 57 |
| |
56 | 58 |
| |
57 | 59 |
| |
| |||
2296 | 2298 |
| |
2297 | 2299 |
| |
2298 | 2300 |
| |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
2299 | 2317 |
| |
2300 | 2318 |
| |
2301 | 2319 |
| |
| |||
4222 | 4240 |
| |
4223 | 4241 |
| |
4224 | 4242 |
| |
| 4243 | + | |
| 4244 | + | |
| 4245 | + | |
| 4246 | + | |
4225 | 4247 |
| |
4226 | 4248 |
| |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
| 4254 | + | |
| 4255 | + | |
| 4256 | + | |
| 4257 | + | |
| 4258 | + | |
| 4259 | + | |
| 4260 | + | |
| 4261 | + | |
| 4262 | + | |
| 4263 | + | |
| 4264 | + | |
4227 | 4265 |
| |
4228 | 4266 |
| |
4229 | 4267 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
493 | 493 |
| |
494 | 494 |
| |
495 | 495 |
| |
496 |
| - | |
497 | 496 |
| |
498 |
| - | |
| 497 | + | |
499 | 498 |
| |
500 | 499 |
| |
501 | 500 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1266 | 1266 |
| |
1267 | 1267 |
| |
1268 | 1268 |
| |
1269 |
| - | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
1270 | 1273 |
| |
1271 | 1274 |
| |
1272 | 1275 |
| |
| |||
1275 | 1278 |
| |
1276 | 1279 |
| |
1277 | 1280 |
| |
1278 |
| - | |
| 1281 | + | |
1279 | 1282 |
| |
1280 | 1283 |
| |
1281 | 1284 |
| |
|
Lines changed: 16 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3803 | 3803 |
| |
3804 | 3804 |
| |
3805 | 3805 |
| |
| 3806 | + | |
| 3807 | + | |
| 3808 | + | |
| 3809 | + | |
| 3810 | + | |
| 3811 | + | |
| 3812 | + | |
3806 | 3813 |
| |
3807 | 3814 |
| |
3808 | 3815 |
| |
| |||
3823 | 3830 |
| |
3824 | 3831 |
| |
3825 | 3832 |
| |
3826 |
| - | |
| 3833 | + | |
| 3834 | + | |
| 3835 | + | |
| 3836 | + | |
| 3837 | + | |
| 3838 | + | |
| 3839 | + | |
| 3840 | + | |
3827 | 3841 |
| |
3828 |
| - | |
3829 | 3842 |
| |
3830 |
| - | |
| 3843 | + | |
3831 | 3844 |
| |
3832 | 3845 |
| |
3833 | 3846 |
| |
|
Lines changed: 56 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
| 19 | + | |
19 | 20 |
| |
20 | 21 |
| |
21 | 22 |
| |
| |||
259 | 260 |
| |
260 | 261 |
| |
261 | 262 |
| |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
262 | 280 |
| |
263 | 281 |
| |
264 | 282 |
| |
| |||
311 | 329 |
| |
312 | 330 |
| |
313 | 331 |
| |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
314 | 346 |
| |
315 | 347 |
| |
316 | 348 |
| |
| |||
387 | 419 |
| |
388 | 420 |
| |
389 | 421 |
| |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
390 | 446 |
| |
391 | 447 |
| |
392 | 448 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
67 | 67 |
| |
68 | 68 |
| |
69 | 69 |
| |
| 70 | + | |
70 | 71 |
| |
71 | 72 |
| |
72 | 73 |
| |
|
0 commit comments
Comments
(0)