Fix contention in CancellationChecker thread#95563
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the CancellationChecker thread by reducing unnecessary wake-ups and mutex contention. The key insight is that the worker thread doesn't need to be notified on every query removal since it will naturally wake up and recalibrate its timeout.
Changes:
- Removed unused
removeQueryFromSetmethod declaration and implementation - Modified
appendTaskto only notify the worker thread when a newly added task becomes the earliest one - Inlined query removal logic in
appendDoneTasksand removed the notification call with a comment explaining why it's safe
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Interpreters/CancellationChecker.h | Removed unused removeQueryFromSet method declaration |
| src/Interpreters/CancellationChecker.cpp | Inlined query removal logic, removed unnecessary notifications, and added conditional notification for new earliest tasks |
Contributor
|
Workflow [PR], commit [f43a395] Summary: ❌
|
antonio2368
approved these changes
Jan 30, 2026
Member
Author
|
There is crash and test failures, but I dont think it is related to the PR. Lets recheck |
This was referenced Feb 2, 2026
robot-clickhouse
added a commit
that referenced
this pull request
Feb 2, 2026
robot-clickhouse
added a commit
that referenced
this pull request
Feb 2, 2026
robot-clickhouse
added a commit
that referenced
this pull request
Feb 2, 2026
robot-clickhouse
added a commit
that referenced
this pull request
Feb 2, 2026
clickhouse-gh bot
added a commit
that referenced
this pull request
Feb 3, 2026
Backport #95563 to 26.1: Fix contention in CancellationChecker thread
clickhouse-gh bot
added a commit
that referenced
this pull request
Feb 3, 2026
Backport #95563 to 25.11: Fix contention in CancellationChecker thread
serxa
added a commit
that referenced
this pull request
Feb 3, 2026
Backport #95563 to 25.8: Fix contention in CancellationChecker thread
serxa
added a commit
that referenced
this pull request
Feb 3, 2026
Backport #95563 to 25.12: Fix contention in CancellationChecker thread
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.
Changelog category (leave one):
There is no need to wake-up cancelling worker thread on most of the changes to the set of queries with timeouts