Skip to content

Backport #126549 to 26.9: Limit the total size of text bloom filter indexes and track their memory - #131059

Merged
clickhouse-gh[bot] merged 3 commits into
26.9from
backport/26.9/126549
Nov 13, 2026
Merged

clickhouse-gh[bot] merged 3 commits into
26.9from
backport/26.9/126549

Conversation

@robot-clickhouse-ci-2

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #126549
Cherry-pick pull-request #130568

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.9.28.163

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels Nov 12, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [b3dfa87]

Summary: ✅

@rschu1ze

Copy link
Copy Markdown
Member

Destroyed

@rschu1ze rschu1ze closed this Nov 13, 2026
@maxknv
maxknv deleted the backport/26.9/126549 branch November 13, 2026 13:03
alexey-milovidov and others added 3 commits November 13, 2026 15:18
The text bloom filter skip indexes (`tokenbf_v1`, `ngrambf_v1`, `sparse_grams`)
checked only the size of a single filter (at most `MAX_BLOOM_FILTER_SIZE`, 1 GiB),
but every granule of the index eagerly allocates one filter per indexed column.
Also, the filter was stored in a `std::vector` with the default allocator, and
implicit `operator new` allocations are not refused by the memory tracker by
default, so a one-row `INSERT` into a table with large filters could allocate
past the available RAM and get the server killed by the OOM killer.

- `BloomFilter::Container` now uses `AllocatorWithMemoryTracking`, so the
  allocation of a filter respects the memory limits and fails with
  `MEMORY_LIMIT_EXCEEDED`. This covers all users of `BloomFilter`, including
  the `bloom_filter` index and runtime filters.
- `bloomFilterIndexTextValidator` rejects indexes where the filter size multiplied
  by the number of indexed columns exceeds `MAX_BLOOM_FILTER_SIZE`. The check is
  skipped on `ATTACH`, so existing tables still load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address review: an index inherited from the old metadata (for example, of a table
attached after being created by an older version) is revalidated with `attach = false`
on every `ALTER` by `MergeTreeData::checkProperties`, so the check in
`bloomFilterIndexTextValidator` made unrelated alters of such tables fail. Move the
check to `bloomFilterIndexTextCheckTotalSize`, called from `checkProperties`, which
accepts an inherited index as long as its total size does not grow.

Also use `VectorWithMemoryTracking` for `BloomFilter::Container`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rschu1ze
rschu1ze restored the backport/26.9/126549 branch November 13, 2026 15:54
@rschu1ze rschu1ze reopened this Nov 13, 2026
@rschu1ze
rschu1ze force-pushed the backport/26.9/126549 branch from 83c6873 to b3dfa87 Compare November 13, 2026 15:54
@clickhouse-gh
clickhouse-gh Bot merged commit a217927 into 26.9 Nov 13, 2026
43 of 44 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.9/126549 branch November 13, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants