Skip to content

Fix ThreadStatus destructor chassert in functions stress test - #105410

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-functions-stress-thread-status-detach
May 20, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-functions-stress-thread-status-detach

Conversation

@Algunenano

@Algunenano Algunenano commented May 20, 2026 •

Copy link
Copy Markdown
Member

The FunctionsStress unit test trips ~ThreadStatus's assertion because each iteration calls context->setCurrentQueryId("") without refreshing ThreadStatus::query_id. Detaching the thread group before destroying the ThreadStatus clears both query_id and query_context, so the destructor's id-vs-context invariant holds.

Surfaced by #105256 (converting assert to chassert).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105256&sha=a24f314f927ad5c12e928028e20be8d32d10b302&name_0=PR&name_1=Unit%20tests%20%28tsan%2C%20function_prop_fuzzer%29

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):

Fix assertion failure in FunctionsStress unit test.

Version info

  • Merged into: 26.5.1.900

…s test

`FunctionsStressTestThread::run` calls `context->setCurrentQueryId("")`
on every iteration but never refreshes `ThreadStatus::query_id`. When
the destructor's `(no ctx && empty id) || (ctx && id matches)` check
became a `chassert` (PR ClickHouse#105256), every worker tripped it.

Detach from the thread group right before `thread_status.reset()` so
the destructor sees the cleared state.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105256&sha=a24f314f927ad5c12e928028e20be8d32d10b302&name_0=PR&name_1=Unit%20tests%20%28tsan%2C%20function_prop_fuzzer%29

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [04db661]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) FAIL
01710_projection_additional_filters FAIL cidb IGNORED
Integration tests (amd_tsan, 6/6) FAIL
test_grpc_protocol/test.py::test_cancel_while_generating_output FAIL cidb, issue ISSUE EXISTS
Integration tests (amd_msan, 2/6) FAIL
test_storage_kafka/test_batch_slow_6.py::test_kafka_rebalance[generate_new_create_table_query-{}.*Saved offset] FAIL cidb IGNORED
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/check_report_messages.py FAIL IGNORED

AI Review

Summary

This PR fixes a FunctionsStress test-only assertion by detaching the current thread from its ThreadGroup before destroying ThreadStatus, which restores the destructor invariant between query_id and query_context. I reviewed the changed code path and related ThreadStatus/CurrentThread internals and did not find correctness, safety, or performance regressions.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh

clickhouse-gh Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 0.00% (0/2) · Uncovered code

Full report · Diff report

@antaljanosbenjamin antaljanosbenjamin self-assigned this May 20, 2026
@Algunenano
Algunenano added this pull request to the merge queue May 20, 2026
Merged via the queue into ClickHouse:master with commit 9cb683d May 20, 2026
161 of 166 checks passed
@Algunenano
Algunenano deleted the fix-functions-stress-thread-status-detach branch May 20, 2026 15:54
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label May 20, 2026
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
…ress-thread-status-detach

Fix ThreadStatus destructor chassert in functions stress test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants