Skip to content

Fix flaky test 05239_workload_drop_memory_reservation_in_use - #127158

Merged
serxa merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05239-workload-drop-kill-noop
Oct 22, 2026
Merged

serxa merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05239-workload-drop-kill-noop

Conversation

@groeneai

@groeneai groeneai commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #123341
Related: #125968

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not required.

Description

Stateless tests (amd_asan_ubsan, db disk, distributed plan, sequential, 3/3) on master 3eecd139 failed with having stderror: KILL QUERY ... SYNC got Code: 785 ... No query to kill. (NOTHING_TO_KILL). No related open issue found.

Two merged changes interact. Since #123341, DROP WORKLOAD purges the dropped workload's queue, so the running query's memory reservation fails with MEMORY_RESERVATION_FAILED (Allocation queue is about to be destructed) at its next sync after the drop. That is intended: MemoryReservationDropWorkloadFailsRunningAllocation in #123341 asserts it. When the query's 1-second step ends between DROP WORKLOAD and KILL, the query is already gone when KILL runs. That used to be a silent no-op, but #125968 made kill_throw_if_noop default to true, so the KILL now throws. In the failing job's server log the query fails 95 ms after the drop and the KILL runs about 370 ms later.

The KILL now passes kill_throw_if_noop = false, as 03824 and 04726 already do, and the comment states the current behavior. Any other KILL error still reaches stderr, a query that cannot be killed still hangs the test, and the reservation is still destroyed after the purge in both branches.

Validation, on the CI binaries of 3eecd139 with randomized settings:

  • amd_asan_ubsan: unmodified test 7/30 FAIL, all NOTHING_TO_KILL; new test 50/50 OK, with 17 of the 50 runs taking the drop-failed branch.
  • amd_debug with sleep 1.5 injected between DROP WORKLOAD and KILL: unmodified KILL 10/10 FAIL, new KILL 10/10 OK, each run's query failing with MEMORY_RESERVATION_FAILED first. Plain new test 50/50 OK.

Workflow [PR]
Sync PR [sync-upstream/pr/127158]

Version info

  • Merged into: 26.11.1.561-master (included in 26.11 and later)
  • Backported to: 26.10.2.83

Since ClickHouse#123341, DROP WORKLOAD purges the dropped workload's queue: the
running query's memory reservation fails with MEMORY_RESERVATION_FAILED
("Allocation queue is about to be destructed") at its next sync, which
for sleepEachRow(1) with max_block_size 1 is the end of the current
1-second step. When that step ends between DROP WORKLOAD and KILL QUERY,
the query is already gone and KILL matches nothing. That was a silent
no-op until ClickHouse#125968 made kill_throw_if_noop default to true; now KILL
writes NOTHING_TO_KILL to stderr and the test fails with
"having stderror" (master 3eecd13, amd_asan_ubsan).

The failing purge is the intended behavior (covered by the
MemoryReservationDropWorkloadFailsRunningAllocation gtest), so the test
now tolerates a no-op KILL with kill_throw_if_noop = false, the idiom of
03824 and 04726, and its comment states the current semantics. Other
KILL errors still reach stderr, and the reservation is destroyed after
the purge in both branches.

Validated on the CI binaries of 3eecd13: amd_asan_ubsan unmodified
7/30 FAIL (all NOTHING_TO_KILL), fixed 50/50 OK with 17 runs in the
drop-failed branch; amd_debug with sleep 1.5 injected between DROP and
KILL: unmodified 10/10 FAIL, fixed 10/10 OK; plain fixed 50/50 OK.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding), plus my own cold review of the diff (0 findings).

# Sev Finding Verdict Evidence / action
1 💡 SQL names in the rewritten test comment are not in inline code (05239_workload_drop_memory_reservation_in_use.sh:23-24) AGREE, not blocking Comment-only nit (.claude/CLAUDE.md); not applied, the final comment pass does not edit test files.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261021-110300

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. With sleep 1.5 injected between DROP WORKLOAD and KILL, the test fails 10/10 with NOTHING_TO_KILL (amd_debug CI binary of 3eecd139); unmodified, 7/30 on amd_asan_ubsan.
b Root cause explained? Yes. DROP WORKLOAD purges the queue (#123341), so the query fails with MEMORY_RESERVATION_FAILED before KILL, and since #125968 a no-op KILL throws NOTHING_TO_KILL.
c Fix matches root cause? Yes. The engine behavior is intended (gtest in #123341); only the no-op is tolerated, other KILL errors still fail the test.
d Test intent preserved / new tests added? Yes. The workload is still dropped under a live memory reservation and the server is still checked. Test-only change.
e Both directions demonstrated? Yes. Injected: 10/10 FAIL vs 10/10 OK. amd_asan_ubsan: 7/30 FAIL vs 0/50 FAIL (17 in the drop-failed branch). amd_debug: 50/50 OK.
f Fix is general across code paths? N/A for source. The other workload tests that KILL (05332, 05394) already ignore KILL errors.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (flaky test fix).
h Backward compatible? (maintainer-approved exception only) Yes, test-only.
i Invariants and contracts preserved? N/A, no source change; the test's output (1) is unchanged.

Session id: cron:clickhouse-impl-slot-40:20261021-102300

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @serxa, could you review this and add the can be tested label so CI runs? Since #123341 DROP WORKLOAD fails the running query's memory reservation, so the query can end before KILL, and since #125968 made kill_throw_if_noop default to true that KILL throws NOTHING_TO_KILL; the test now passes kill_throw_if_noop = false to it.

@clickhouse-gh

clickhouse-gh Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [867b588]

Summary: ✅


AI Review

Summary

The PR fixes a race in 05239_workload_drop_memory_reservation_in_use by setting kill_throw_if_noop = false for its cleanup KILL QUERY: DROP WORKLOAD can already have terminated the query through a failed memory reservation. The change preserves synchronous cancellation and reporting of other exceptions. No actionable findings in head 867b588324fdbc5115f6245faf5c8f657b7bfd5f.

Missing context / blind spots
  • ⚠️ Current PR stateless reports have no completed test results yet. Runtime evidence comes from the author's documented ASan and debug repetitions, including deterministic reproduction; I did not independently rerun them.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Oct 21, 2026
@serxa

serxa commented Oct 21, 2026

Copy link
Copy Markdown
Member

Make sure it is green and ping me

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI has not started yet: the PR has no can be tested label, so Config Workflow stops at the can_be_tested check, and I don't have permission to add labels on this repo. Could you add it? I will ping you once CI is green.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 21, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

robot-clickhouse-ci-2 added a commit that referenced this pull request Oct 22, 2026
Cherry pick #127158 to 26.10: Fix flaky test `05239_workload_drop_memory_reservation_in_use`
robot-clickhouse added a commit that referenced this pull request Oct 22, 2026
robot-clickhouse added a commit that referenced this pull request Oct 22, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 22, 2026
Backport #127158 to 26.10: Fix flaky test `05239_workload_drop_memory_reservation_in_use`
PedroTadim added a commit that referenced this pull request Oct 29, 2026
…6.8-123341

Resolve the conflicts of #123341:
- This branch still has `TimeShared/FifoQueue.h` instead of `TimeShared/RequestQueue.h`, so the change to
  `RequestQueue::purgeQueue` goes to `FifoQueue::purgeQueue`.
- `WorkloadNode.h`: keep the branch's `FifoQueue` comment and add `queue_dropped`.
- Take master's `05239_workload_drop_memory_reservation_in_use.sh`, which includes the follow-up fix
  #127158 (`kill_throw_if_noop = false`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim added a commit that referenced this pull request Oct 29, 2026
…6.9-123341

Resolve the conflicts of #123341:
- This branch still has `TimeShared/FifoQueue.h` instead of `TimeShared/RequestQueue.h`, so the change to
  `RequestQueue::purgeQueue` goes to `FifoQueue::purgeQueue`.
- `WorkloadNode.h`: keep the branch's `FifoQueue` comment and add `queue_dropped`.
- Take master's `05239_workload_drop_memory_reservation_in_use.sh`, which includes the follow-up fix
  #127158 (`kill_throw_if_noop = false`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 29, 2026
@clickhouse-gh clickhouse-gh Bot added comp-scheduler Workload scheduler and resource management: CPU/IO/memory scheduling, concurrency control, worklo... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-scheduler Workload scheduler and resource management: CPU/IO/memory scheduling, concurrency control, worklo... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.6-must-backport v26.7-must-backport v26.8-must-backport v26.9-must-backport v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants