Skip to content

Cherry pick #106867 to 26.5: Fix "Too many marks" for text index on an empty merged part - #108262

Merged
robot-clickhouse merged 4 commits into
backport/26.5/106867from
cherrypick/26.5/106867
Jun 23, 2026
Merged

robot-clickhouse merged 4 commits into
backport/26.5/106867from
cherrypick/26.5/106867

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

Original pull-request #106867

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

azat and others added 4 commits June 16, 2026 17:21
When a merge produces a part with zero rows (for example when a lightweight
delete removes everything), `MergeTextIndexesTask::executeStep` still wrote a
single mark into the text index marks file "for compatibility with other skip
indexes". But an empty part reports zero marks, so
`getMarksCountForSkipIndex` returns 0, and reading the marks back (e.g. while
prewarming the mark cache on attach with `prewarm_mark_cache`) failed with
`Too many marks in file ... skp_idx_idx.cmrk2`.

Regular skip indexes gate every mark/granule write on actually having data
(`calculateAndSerializeSkipIndices` only writes inside the per-granule loop,
`fillSkipIndicesChecksums` only serializes a granule when the aggregator is
non-empty), so they naturally emit zero marks for an empty part. Make the text
index merge task follow the same invariant: skip the mark when the resulting
part has no marks, keeping the marks file consistent with
`getMarksCountForSkipIndex`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The previous commit gated the text index mark on
`new_data_part->index_granularity->getMarksCountWithoutFinal()`, but the
`MergeTextIndexStage` runs before `MergeProjectionsStage` finalizes the part,
so at that point `index_granularity` is still empty and the check returned
zero for every part - the compatibility mark was skipped always, not only for
empty parts.

Pass the number of merged rows into `MergeTextIndexesTask` instead
(`rows_written` from the merge / mutation context, which is final by this
stage) and write the mark only when the resulting part is non-empty.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Fix "Too many marks" for text index on an empty merged part
@robot-clickhouse robot-clickhouse added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Jun 23, 2026
@robot-clickhouse
robot-clickhouse merged commit 99dd10c into backport/26.5/106867 Jun 23, 2026
@robot-clickhouse
robot-clickhouse deleted the cherrypick/26.5/106867 branch June 23, 2026 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants