Skip to content

Stop overcollecting values for set skip indexes - #104519

Merged
alexey-milovidov merged 14 commits into
masterfrom
fix-hung-check-deadlock
May 20, 2026
Merged

alexey-milovidov merged 14 commits into
masterfrom
fix-hung-check-deadlock

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 10, 2026 •

Copy link
Copy Markdown
Member

Fixes a master CI stress failure where a cancelled INSERT into a table with an overfull set(N) skip index kept collecting every distinct value in MergeTreeIndexAggregatorSet::update. set(N) granules with more than N values serialize as empty, so this bounds retained values to N + 1.

CI examples: https://play.clickhouse.com/play?user=play&run=1#U0VMRUNUIGNoZWNrX3N0YXJ0X3RpbWUsIGNoZWNrX25hbWUsIHRlc3RfbmFtZSwgcmVwb3J0X3VybApGUk9NIGNoZWNrcwpXSEVSRSAxCiAgICBBTkQgY2hlY2tfc3RhcnRfdGltZSA+PSBub3coKSAtIElOVEVSVkFMIDI0IEhPVVIKICAgIEFORCAoaGVhZF9yZWYgPSAnbWFzdGVyJyBBTkQgc3RhcnRzV2l0aChoZWFkX3JlcG8sICdDbGlja0hvdXNlLycpKQogICAgQU5EIHRlc3Rfc3RhdHVzICE9ICdTS0lQUEVEJwogICAgQU5EICh0ZXN0X3N0YXR1cyBMSUtFICdGJScgT1IgdGVzdF9zdGF0dXMgTElLRSAnRSUnKQogICAgQU5EIGNoZWNrX3N0YXR1cyAhPSAnc3VjY2VzcycKICAgIEFORCBjaGVja19uYW1lIE5PVCBMSUtFICdsaWJGdXp6ZXIlJwogICAgQU5EIGNoZWNrX25hbWUgIT0gJ0NsaWNrSG91c2UgS2VlcGVyIEplcHNlbicKICAgIEFORCBjaGVja19uYW1lIE5PVCBMSUtFICdJbnRlZ3JhdGlvbiB0ZXN0cyAoYW1kX2xsdm1fY292ZXJhZ2UlJwpPUkRFUiBCWSBjaGVja19zdGFydF90aW1lIERFU0M=

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=1b76e322cbdb89960eea5236f4eda5ad3f9e164d&name_0=MasterCI&name_1=Stress%20test%20%28experimental%2C%20serverfuzz%2C%20azure%2C%20amd_tsan%29&name_1=Stress%20test%20%28experimental%2C%20serverfuzz%2C%20azure%2C%20amd_tsan%29

Open issue search: no matching open issue found for Hung check failed, possible deadlock found.

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 applicable.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.870

The latest `Hung check failed, possible deadlock found` report shows a
cancelled `INSERT` spending most of its time in
`MergeTreeIndexAggregatorSet::update`, with
`MergeTreeDataWriterSkipIndicesCalculationMicroseconds` at about 26 minutes.

`set(N)` skip-index granules with more than `N` distinct values are serialized
as empty, so retaining every subsequent distinct value cannot improve pruning.
Stop after retaining the `N + 1`st value; that is enough to preserve the
overfull state while bounding CPU and memory for the granule.

Add a unit test for the retention bound.

CI examples: https://play.clickhouse.com/play?user=play&run=1#U0VMRUNUIGNoZWNrX3N0YXJ0X3RpbWUsIGNoZWNrX25hbWUsIHRlc3RfbmFtZSwgcmVwb3J0X3VybApGUk9NIGNoZWNrcwpXSEVSRSAxCiAgICBBTkQgY2hlY2tfc3RhcnRfdGltZSA+PSBub3coKSAtIElOVEVSVkFMIDI0IEhPVVIKICAgIEFORCAoaGVhZF9yZWYgPSAnbWFzdGVyJyBBTkQgc3RhcnRzV2l0aChoZWFkX3JlcG8sICdDbGlja0hvdXNlLycpKQogICAgQU5EIHRlc3Rfc3RhdHVzICE9ICdTS0lQUEVEJwogICAgQU5EICh0ZXN0X3N0YXR1cyBMSUtFICdGJScgT1IgdGVzdF9zdGF0dXMgTElLRSAnRSUnKQogICAgQU5EIGNoZWNrX3N0YXR1cyAhPSAnc3VjY2VzcycKICAgIEFORCBjaGVja19uYW1lIE5PVCBMSUtFICdsaWJGdXp6ZXIlJwogICAgQU5EIGNoZWNrX25hbWUgIT0gJ0NsaWNrSG91c2UgS2VlcGVyIEplcHNlbicKICAgIEFORCBjaGVja19uYW1lIE5PVCBMSUtFICdJbnRlZ3JhdGlvbiB0ZXN0cyAoYW1kX2xsdm1fY292ZXJhZ2UlJwpPUkRFUiBCWSBjaGVja19zdGFydF90aW1lIERFU0M=
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=1b76e322cbdb89960eea5236f4eda5ad3f9e164d&name_0=MasterCI&name_1=Stress%20test%20%28experimental%2C%20serverfuzz%2C%20azure%2C%20amd_tsan%29&name_1=Stress%20test%20%28experimental%2C%20serverfuzz%2C%20azure%2C%20amd_tsan%29
@clickhouse-gh

clickhouse-gh Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9a902609]

Summary: ✅


AI Review

Summary

This PR bounds set(N) skip-index aggregation work once the granule becomes overfull by stopping collection after N + 1 distinct values, which preserves existing semantics (size() > max_rows serializes as empty) while preventing unbounded memory/CPU growth in MergeTreeIndexAggregatorSet::update. The added unit test directly verifies the new bound (max_rows = 3 results in collected size 4). I found no remaining correctness, safety, performance, or metadata issues in the current diff.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 10, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, please investigate the following CI failures — none of them appear related to this PR (which only touches MergeTreeIndexAggregatorSet::buildFilter):

  1. Stateless tests (amd_msan, WasmEdge, parallel, 2/2) — four tests (03634_autopr_input_bytes_estimation_compact, 03928_full_join_swap_tables, 03777_join_runtime_filter_unsupported_type, 03231_hive_partitioning_filtering) all timed out on SYSTEM FLUSH LOGS query_log (180s). This is a widespread amd_msan flakiness affecting master and many PRs on 2026-05-14/2026-05-15 — different tests hit it each run. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104519&sha=23e16f0a2c096868b2c65af0624a3da704ff8a08&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%202%2F2%29

  2. Stateless tests (amd_tsan, s3 storage, parallel, 1/2) — 01825_json_type_missed_values timed out, but the auto-rerun confirmed it was transient ("All reruns passed. The failure is not reproducible"). Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104519&sha=23e16f0a2c096868b2c65af0624a3da704ff8a08&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20parallel%2C%201%2F2%29

  3. CH Inc sync — two private-sync failures: 03053_shared_merge_tree_drop_disk_metadata_cache and a Hung check failed in Stress test (arm_asan_ubsan, SharedCatalog, meta in keeper). The hung-check diagnostic itself failed with Code: 60. Both table name and UUID are empty. (UNKNOWN_TABLE) before it could capture stack traces. Hung-check failures on arm_asan_ubsan are widespread (5–20 failures/day across many PRs on 2026-05-13/2026-05-14/2026-05-15). Sync PR: https://github.com/ClickHouse/clickhouse-private/pull/57618

If fixes for any of these are already in progress, please link them here.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov — attribution for the three clusters, all confirmed unrelated to this PR (which only modifies MergeTreeIndexAggregatorSet::buildFilter):

1. Stateless tests (amd_msan, WasmEdge, parallel, 2/2) — 4 tests timing out on SYSTEM FLUSH LOGS query_log (180 s)

This is the WasmEdge MSan SystemLog-flush family (umbrella #104866 — 14 tracked test patterns, all failing with the same Timeout exceeded (180 s) while flushing system log 'DB::SystemLogQueue<DB::QueryLogElement>' signature). Root cause: x86-64-v3 ISA baseline flip combined with MSan's -fsanitize-memory-track-origins=2 adding vzeroupper + __msan_chain_origin overhead.

Your revert PR #104971 ("Revert x86 default from x86-64-v3 back to x86-64-v2") merged 2026-05-15 08:57 UTC — i.e. after PR #104519's failing CI runs (2026-05-14/15 morning). CIDB confirms the family was still bleeding right up to the revert merge:

day master hits distinct PRs distinct tests
2026-05-15 5 13 30
2026-05-14 6 32 63
2026-05-13 4 24 38

Re-running PR #104519's CI on a post-revert master should clear these four tests. Follow-up tracker is PR #105019 (re-enable v3 after proper fix). No action needed on #104519.

2. Stateless tests (amd_tsan, s3 storage, parallel, 1/2) — 01825_json_type_missed_values 180 s timeout

Confirmed transient by the auto-rerun (you noted "All reruns passed"). No tracking needed.

3a. CH Inc sync — 03053_shared_merge_tree_drop_disk_metadata_cache

This test is CH Inc–private only — it does not exist in the public tests/queries/0_stateless/ tree (the public 03053 slot is 03053_analyzer_join_alias) and has 0 hits across 30 days in the public CIDB. The failure cannot be triaged or fixed from public-repo data; it belongs to private CH Inc CI ownership.

3b. CH Inc sync — Hung check failed in Stress test (arm_asan_ubsan, SharedCatalog, meta in keeper)

The hung-check itself failed to capture traces (the Code: 60. Both table name and UUID are empty. (UNKNOWN_TABLE) diagnostic abort you noted is the symptom, not the cause). Hung-check chronic on arm_asan_ubsan is confirmed by CIDB across the past 14 days on public master too:

day master hits distinct PRs
2026-05-15 6 9
2026-05-14 17 16
2026-05-13 13 6
2026-05-11 14 2

Totals: ~58 master hits, 1–16 distinct PRs/day. Tracked under chronic umbrella (hung-check-deadlock-chronic-trunk family). The private-CI manifestation on PR #104519 is the same pattern.

Summary: PR #104519's own diff is fine. Clusters 1 + 3b are chronic family hits; cluster 2 is transient; cluster 3a is private-only. Recommend rerunning post-#104971-merge to clear cluster 1 and merging once cluster 3b clears via retry.

Session: cron:clickhouse-ci-task-worker:20260516-014500

@clickhouse-gh

clickhouse-gh Bot commented May 19, 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: 100.00% (24/24) · Uncovered code

Full report · Diff report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change.

@alexey-milovidov alexey-milovidov self-assigned this May 20, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 20, 2026
Merged via the queue into master with commit 4390e7a May 20, 2026
165 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-hung-check-deadlock branch May 20, 2026 05:57
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 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
…eadlock

Stop overcollecting values for set skip indexes
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