forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd37776e
committed
Make timeout.c more robust against missed timer interrupts.
Commit09cf1d5 taught schedule_alarm() to not do anything ifthe next requested event is after when we expect the next interruptto fire. However, if somehow an interrupt gets lost, we'll continueto not do anything indefinitely, even after the "next interrupt" timeis obviously in the past. Thus, one missed interrupt can breaktimeout scheduling for the life of the session. Michael Harrisreported a scenario where a bug in a user-defined function caused thisto happen, so you don't even need to assume kernel bugs exist to thinkthis is worth fixing. We can make things more robust at little costby detecting the case where signal_due_at is before "now" and forcinga new setitimer call to occur. This isn't a completely bulletprooffix of course; but in our typical usage pattern where we frequently settimeouts and clear them before they are reached, the interrupt willget re-enabled after at most one timeout interval, which with a littleluck will be before we really need it.While here, let's mark signal_due_at as volatile, since the signalhandler can both examine and set it. I'm not sure there's anyactual risk given that signal_pending is already volatile, butit's surely questionable.Backpatch to v14 where this logic came in.Michael Harris and Tom LaneDiscussion:https://postgr.es/m/CADofcAWbMrvgwSMqO4iG_iD3E2v8ZUrC-_crB41my=VMM02-CA@mail.gmail.com1 parent9cd28c2 commitd37776e
1 file changed
+16
-3
lines changedLines changed: 16 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
71 | 71 |
| |
72 | 72 |
| |
73 | 73 |
| |
| 74 | + | |
74 | 75 |
| |
75 | 76 |
| |
76 | 77 |
| |
77 | 78 |
| |
78 |
| - | |
| 79 | + | |
79 | 80 |
| |
80 | 81 |
| |
81 | 82 |
| |
| |||
217 | 218 |
| |
218 | 219 |
| |
219 | 220 |
| |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
220 | 233 |
| |
221 | 234 |
| |
222 |
| - | |
223 |
| - | |
| 235 | + | |
| 236 | + | |
224 | 237 |
| |
225 | 238 |
| |
226 | 239 |
| |
|
0 commit comments
Comments
(0)