Commit fd2ea21
[fix](be) Fix cross-thread CLOCK_THREAD_CPUTIME_ID read in scanner CPU timer
### What problem does this PR solve?
Problem Summary: Scanner::_cpu_watch (ThreadCpuStopWatch using CLOCK_THREAD_CPUTIME_ID)
was started via resume() on a scanner worker thread but read via pause() on the pipeline
task thread. Since CLOCK_THREAD_CPUTIME_ID is a per-thread CPU clock, reading it on a
different thread produces garbage/negative values, triggering the DCHECK:
Check failed: _value.load() > -1L (-39943795 vs. -1) delta: -252570258
In the non-EOS path of _scanner_scan(), update_scanner_profile() (which calls pause())
was only called for the EOS path. The non-EOS path left _cpu_watch running and later
ScannerScheduler::submit() called pause() from the pipeline task thread.
Fix:
1. Always call update_scanner_profile() before push_back_scan_task() in _scanner_scan(),
ensuring pause() runs on the scanner worker thread for both EOS and non-EOS paths.
2. Reinitialize _cpu_watch after reading in _update_scan_cpu_timer() so that any
subsequent cross-thread pause() call in submit() safely reads 0.
### Release note
None
### Check List (For Author)
- Test: Manual test - verified the logic by code analysis
- Behavior changed: No
- Does this need documentation: No
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent edc0524 commit fd2ea21
2 files changed
+10
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
304 | 309 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
| |||
0 commit comments