Repository navigation
Fix crash when lowering a workload concurrency limit below in-flight - #118836
Conversation
SemaphoreConstraint::updateConstraints takes a deactivation trick when a workload update lowers a semaphore limit (max_concurrent_queries / max_bytes_inflight) below the currently in-flight amount while the node is active: it calls parent->removeChild(this) followed by parent->attachChild(self). removeChild resets this node's own `parent` member to nullptr (via setParentNode()), so the subsequent re-read of `parent` dereferenced a null pointer and crashed the server (SIGSEGV). Capture the parent pointer in a local before detaching and reuse it for the re-attach. Add a regression test that lowers a semaphore limit below the in-flight amount while the node is active.
|
Workflow [PR], commit [507652b] Summary: ✅
AI ReviewSummaryThis PR fixes Final Verdict✅ No blocking issues found in the current diff. LLVM Coverage ReportMeasured on commit 507652b.
Changed lines: Changed C/C++ lines covered: 29/29 (100.00%) · Uncovered code |
|
Backport labels have been automatically added based on https://github.com/clickhouse/clickhouse-core-incidents/issues/2067 Labels added:
These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 14 s compile time in total, 8 of them have a recent master baseline. |
…phore When updateConstraints lowers a semaphore limit below the in-flight amount it force-deactivates the node via removeChild/attachChild. A concurrent finishRequest may have queued an activation for the node under the old limit; left in the EventQueue it would re-activate the semaphore under the new lower limit and admit one request over the bound (dequeueRequest has no satisfied() gate). Cancel the pending activation in the deactivation branch, mirroring FifoQueue when its queue empties. Add a regression test that leaves an activation pending across the update.
…t-update-null-parent
…ncy limit below in-flight
Backport #118836 to 26.8: Fix crash when lowering a workload concurrency limit below in-flight
Backport #118836 to 26.6: Fix crash when lowering a workload concurrency limit below in-flight
…ncy limit below in-flight
Backport #118836 to 26.7: Fix crash when lowering a workload concurrency limit below in-flight
Backport #118836 to 26.3: Fix crash when lowering a workload concurrency limit below in-flight
…d concurrency limit below in-flight
…d concurrency limit below in-flight
Linked issues
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a server crash that could happen when a
WORKLOADsetting limiting concurrency (e.g.max_concurrent_queriesormax_bytes_inflight) was lowered below the number of currently in-flight resource requests while the workload was active.Description
When a workload update lowers a semaphore limit below the amount currently in flight while the node is active,
SemaphoreConstraint::updateConstraintstransitionsactive()fromtruetofalseand deactivates the node with a detach/re-attach trick:removeChild(this)resets this node's ownparentmember tonullptr(viasetParentNode(nullptr)), so the second statement re-read the now-nullparentand performed a virtual call on it, crashing the server with aSIGSEGV. OnlySemaphoreConstraintis affected —ThrottlerConstraint::updateConstraintshas no deactivation branch.The fix captures the parent pointer in a local before detaching and reuses it for the re-attach.
updateConstraintsruns on the scheduler thread, where tree mutations are serialized, so the saved pointer stays valid and the re-attach semantics are unchanged.A regression test (
SchedulerTimeSharedWorkloadNode.UpdateSemaphoreDeactivateBelowInflight) lowers a semaphore limit below the in-flight amount while the node is active; it crashes without the fix and passes with it.Workflow [PR]
Sync PR [sync-upstream/pr/118836]
Version info
26.9.1.1307(included in26.9and later)26.8.3.101,26.7.7.92,26.6.5.119,26.3.33.68