Repository navigation
Cherry pick #126549 to 26.9: Limit the total size of text bloom filter indexes and track their memory - #130568
Conversation
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]>
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]>
…al-size Limit the total size of text bloom filter indexes and track their memory
|
@groeneai Resolve the conflicts |
|
Resolved. The only conflict is in Validated on the 26.9 tree with clang-22, debug build: The merge is on my fork and its first parent is this PR's head, so applying it is a fast-forward: (resolved head |
|
@groeneai There are still merge conflicts. Resolve them. |
|
I can't push to (resolved head |
|
🕵 Applied @groeneai's resolution (merge of |
Original pull-request #126549
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-picklocally.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.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
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:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job