Commit b94e4bb
committed
[BugFix] Unschedule global RF timer in PipelineDriver destructor
A queued or blocked PipelineDriver that is abandoned when the driver executor
is closed during shutdown is destroyed without going through finalize(), which
was the only place the global runtime-filter timer (RFScanWaitTimeout) was
unscheduled. Because the bthread TimerThread keeps only a raw pointer to the
task, it can then fire on a task whose sole owning shared_ptr
(PipelineDriver::_global_rf_timer) is already gone. PipelineTimerTask::doRun()
calls shared_from_this() on that freed object and throws std::bad_weak_ptr,
aborting the process:
terminate called after throwing an instance of 'std::bad_weak_ptr'
RunTimerTask -> bthread::TimerThread::run
This is the abandoned-driver counterpart to the query-context-destruction race
fixed in #73082, which only unscheduled from finalize(); the throwing
shared_from_this() in doRun() was introduced in #72058.
Move the unschedule into a helper called from both finalize() and
~PipelineDriver(). The helper moves the shared_ptr into a local so the task
stays alive across unschedule_and_join(), closing the window where a
concurrently running doRun() could observe a zero use_count.
Add unit tests covering the destructor unscheduling a pending timer and the
destructor blocking until an in-flight timer task finishes.1 parent 202255e commit b94e4bb
3 files changed
Lines changed: 75 additions & 5 deletions
File tree
- be
- src/exec/runtime
- test/exec/pipeline/schedule
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
| |||
884 | 888 | | |
885 | 889 | | |
886 | 890 | | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
| 891 | + | |
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
| |||
939 | 939 | | |
940 | 940 | | |
941 | 941 | | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
942 | 952 | | |
943 | 953 | | |
944 | 954 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| 449 | + | |
449 | 450 | | |
450 | 451 | | |
451 | 452 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
76 | 89 | | |
77 | 90 | | |
78 | 91 | | |
| |||
303 | 316 | | |
304 | 317 | | |
305 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
306 | 365 | | |
307 | 366 | | |
308 | 367 | | |
| |||
0 commit comments