Skip to content

Fix false-positive assertion in paranoid check for covered parts on startup - #100652

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-paranoid-check-missing-parts-to-fetch
Mar 27, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-paranoid-check-missing-parts-to-fetch

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Mar 24, 2026 •

Copy link
Copy Markdown
Member

createLogEntriesToFetchBrokenParts was calling paranoidCheckForCoveredPartsInZooKeeperOnStart with an empty parts_to_fetch list. This caused a false-positive chassert(false) when a covered part existed in ZooKeeper but was missing from disk and was expected to be fetched from another replica.

The fix computes parts_to_fetch by finding ZooKeeper parts that don't have an active containing part locally, matching the logic already used in checkPartsImpl.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100364&sha=4020500293a0a0039b8c4d9e679dfabb8908e9f7&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29
#100364

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.337

…perOnStart`

`createLogEntriesToFetchBrokenParts` was calling
`paranoidCheckForCoveredPartsInZooKeeperOnStart` with an empty
`parts_to_fetch` list. This caused a false-positive `chassert(false)`
when a covered part existed in ZooKeeper but was missing from disk
and was expected to be fetched from another replica.

The fix computes `parts_to_fetch` by finding ZooKeeper parts that don't
have an active containing part locally, matching the logic already used
in `checkPartsImpl`.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100364&sha=4020500293a0a0039b8c4d9e679dfabb8908e9f7&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29

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

clickhouse-gh Bot commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fc7c14c]

Summary: ✅


AI Review

Summary

This PR fixes a real startup correctness issue in ReplicatedMergeTree: createLogEntriesToFetchBrokenParts previously called paranoidCheckForCoveredPartsInZooKeeperOnStart with empty parts_to_fetch, which can trigger a false-positive chassert(false) in debug/ASan builds. The code fix is targeted and consistent with existing checkPartsImpl logic. Main remaining concerns are PR metadata mismatch and missing regression coverage for this path.

PR Metadata

⚠️ Changelog category is currently CI Fix or Improvement, but the change is a storage startup correctness fix, not CI infrastructure.

Exact replacement:

  • Changelog category: Bug Fix (or Not for changelog if intentionally excluded)

⚠️ Changelog entry quality is insufficient (...). For Bug Fix, it should be a concrete user-facing sentence.

Suggested replacement:

  • Changelog entry: Fixed a false-positive assertion during ReplicatedMergeTree startup when a covered part exists in Keeper but is missing locally and scheduled for fetch.
Findings

⚠️ Majors

  • [src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp:247] PR metadata does not match the actual change type (CI Fix or Improvement vs storage bug fix), and Changelog entry is placeholder text. This weakens release-note quality and triage.
    • Suggested fix: update category to Bug Fix (or Not for changelog) and replace ... with a concrete entry.
Tests

⚠️ No regression test was added for the startup path fixed here (createLogEntriesToFetchBrokenParts + paranoidCheckForCoveredPartsInZooKeeperOnStart). Please add a test that reproduces: covered part in Keeper, missing on disk, expected to be fetched, and verify no false-positive assertion path.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ⚠️ Changelog category mismatch and placeholder Changelog entry.
Safe rollout ✅
Compilation time ✅
Final Verdict

Status: ⚠️ Request changes

Minimum required actions:

  1. Fix PR template metadata (Changelog category and concrete Changelog entry).
  2. Add a regression test for the covered-part startup scenario fixed by this PR.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Mar 24, 2026
if (!storage.getActiveContainingPart(part_name))
parts_to_fetch.push_back(part_name);

storage.paranoidCheckForCoveredPartsInZooKeeperOnStart(parts_in_zk, parts_to_fetch);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Please add a regression test for this startup path.

This change fixes a subtle assertion path in createLogEntriesToFetchBrokenParts, but the PR has no test changes. A test that reproduces: part exists in Keeper, is covered by another Keeper part, is missing on disk, and is expected to be fetched would prevent future regressions.

if (!storage.getActiveContainingPart(part_name))
parts_to_fetch.push_back(part_name);

storage.paranoidCheckForCoveredPartsInZooKeeperOnStart(parts_in_zk, parts_to_fetch);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changelog category currently says CI Fix or Improvement, but this PR changes ReplicatedMergeTree startup correctness (createLogEntriesToFetchBrokenParts / paranoidCheckForCoveredPartsInZooKeeperOnStart) rather than CI infrastructure.

Please switch category to Bug Fix (or Not for changelog if you intentionally keep this out of the changelog).

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.

It's okay.

@clickhouse-gh

clickhouse-gh Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.20% 84.20% +0.00%
Functions 24.40% 24.70% +0.30%
Branches 76.70% 76.70% +0.00%

Changed lines: 87.50% (7/8) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov merged commit 5a72417 into master Mar 27, 2026
149 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-paranoid-check-missing-parts-to-fetch branch March 27, 2026 21:24
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 27, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Apr 16, 2026
…rOnStart

The paranoid check on startup verifies that all ZK parts covered by another
ZK part either exist on disk or are in the parts_to_fetch list. However, it
does not check whether a local active part already covers the ZK part.

This legitimately happens after a merge or mutation: the covering part is
active locally, the covered part was cleaned from disk by
clearOldPartsAndRemoveFromZK, but the covered part's ZK entry has not been
cleaned up yet (ZK cleanup can lag behind disk cleanup, or the server was
restarted between the two). The data is preserved in the local covering
part, and the stale ZK entry will be removed by the cleanup thread after
startup.

Without this fix, the chassert(false) fires as a false positive in
debug/sanitizer builds during stress tests, particularly in the
createLogEntriesToFetchBrokenParts() call path (STID: 2508-5dc3,
2508-6644). Prior fixes PR ClickHouse#96164, ClickHouse#96705, and ClickHouse#100652 addressed other
false-positive scenarios in this function but missed the case where a local
active part covers the ZK part.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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