Repository navigation
Fix data race in scheduler node destruction during DROP WORKLOAD - #97372
Merged
Merged
Conversation
…LOAD` In `WorkloadResourceManager::Resource::deleteNode`, the lambda passed to `executeInSchedulerThread` captures the `UnifiedSchedulerNode` shared_ptr as `n`. Despite the comment claiming `n` is destroyed in the scheduler thread, it was actually destroyed in the caller's (TCPHandler) thread: `executeInSchedulerThread` captures the task by reference, so the lambda (with `n`) lives on the caller's stack and is destroyed when `executeInSchedulerThread` returns, not when `task()` finishes. This caused `~UnifiedSchedulerNode` → `removeChild` → `setParent(nullptr)` to write `FifoQueue->parent` from the TCPHandler thread, racing with the scheduler thread reading `FifoQueue->parent` in `processActivation`. Fix by explicitly calling `n.reset()` inside the lambda body (making it `mutable`), so the node is actually destroyed in the scheduler thread as intended. When the lambda is later destroyed in the caller's thread, `n` is already null. https://s3.amazonaws.com/clickhouse-test-reports/REFs/master/30cbcec0ee3a8caa809dc7e94fe48f448590322d/stateless_tests_amd_tsan_s3_storage_sequential_2_2/stderr.log Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
|
Workflow [PR], commit [b8a72ed] Summary: ❌
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DROP WORKLOAD) and the scheduler thread (processing activations) onISchedulerNode::parentWorkloadResourceManager::Resource::deleteNode, the lambda passed toexecuteInSchedulerThreadcapturesn(ashared_ptr<UnifiedSchedulerNode>) by value. Despite the existing comment,nwas destroyed in the caller's thread (not the scheduler thread), becauseexecuteInSchedulerThreadcaptures the task by reference — the lambda lives on the caller's stack and is destroyed whenexecuteInSchedulerThreadreturnsn.reset()inside the lambda body (withmutable) so the node is actually destroyed in the scheduler thread as intendedDetails
The write (
parent = nullptrinsetParent) happened via~UnifiedSchedulerNode→removeChild→setParentfrom the TCPHandler thread, racing with the scheduler thread readingparentinprocessActivation.CI report: https://s3.amazonaws.com/clickhouse-test-reports/REFs/master/30cbcec0ee3a8caa809dc7e94fe48f448590322d/stateless_tests_amd_tsan_s3_storage_sequential_2_2/stderr.log
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
🤖 Generated with Claude Code
Version info
26.2.1.947