Repository navigation
Fix a lost wakeup in the Delta Lake data file iterator - #129547
Conversation
`TableSnapshot::Iterator::setScanException` set `scan_exception` and `shutdown` without holding `next_mutex` and then notified `data_files_cv`. If the notification came after `next` checked the condition of the wait but before it started waiting, `next` waited forever, and the query hung. This happens when the scanning thread fails, e.g. with `PATH_ACCESS_DENIED` for a data file outside of the table directory, and it was seen with TSan. The destructor set `shutdown` in the same way before notifying the scanning thread, which waits on `schedule_next_batch_cv` with the same condition, so it could hang in `join` as well. Set them under the mutex. This also makes `next` read `scan_exception` after it is written. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=129093&sha=23927a29eeb17c626ca415713a6eae693f2d74c9&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20targeted%29 Related: #129093 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [ae7bb14] Summary: ✅
AI ReviewSummaryThe PR protects iterator shutdown and scan-exception publication with Findings
Tests
Final VerdictStatus: |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 13 s compile time in total, 7 of them have a recent master baseline. |
| /// checking the condition and starting to wait, and reads `scan_exception` after it is set. | ||
| void setScanException() | ||
| { | ||
| std::lock_guard lock(next_mutex); |
There was a problem hiding this comment.
[Major] Please validate the known lost-wakeup reproducer with the patched iterator under TSan. 05526_delta_lake_kernel_golden_errors times out on master, but it is absent from the completed targeted TSan run at 85b72dfd, despite that job reporting 880 passes. The current head's targeted TSan job is still pending. The described release runs cannot establish that the observed TSan-only hang is fixed, since they also passed without the fix. No additional test is needed: select the existing reproducer for repeated TSan runs and attach the result showing that the scan errors propagate without a timeout.
A query reading a Delta Lake table could hang forever when the data file scanning thread failed, e.g. with
PATH_ACCESS_DENIEDfor a data file referred to by a path outside of the table directory.TableSnapshot::Iterator::setScanExceptionsetscan_exceptionandshutdownwithout holdingnext_mutexand then notifieddata_files_cv. If the notification came afternexthad checked the condition of its wait but before it started waiting, the wakeup was lost. The destructor setshutdownthe same way before notifying the scanning thread, which waits onschedule_next_batch_cvwith the same kind of condition, so it could hang injoin. Both are set under the mutex now, which also makesnextreadscan_exceptionafter it is written.It was found by
05526_delta_lake_kernel_golden_errorsof #129093, which reads thecanonicalized-paths-*golden tables of delta-kernel-rs: it hung with TSan in two jobs, with the main thread waiting on a condition variable (report). The race does not reproduce in a release build (200 parallel runs with and without the fix), so there is no separate test. #129093 has been merged first, and05526_delta_lake_kernel_golden_errorsnow times out on master the same way (report); this PR fixes it.Related: #129093
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a rare hang of a query reading a Delta Lake table when listing its data files fails.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/129547]
Version info
26.11.1.1596-master(included in26.11and later)