Repository navigation
Cherry pick #108977 to 25.8: Fix out-of-bounds crash in ObjectStorageQueueSource::FileIterator::next - #112834
Merged
robot-clickhouse-ci-1 merged 12 commits intoAug 2, 2026
Conversation
In the unordered hash-ring batch path of FileIterator::next, file_metadatas is resized to the batch size and populated per file. When a file in the batch is non-processable (num_successful_objects < new_batch.size()) and the keeper tryMulti that sets the batch as processing then fails, the else branch clears file_metadatas. The subsequent compaction block still wrote file_metadatas[i] = file_metadatas[batch_i] and called file_metadatas.resize() on the now-empty vector, going out of bounds and aborting the server. The trailing chassert(file_metadatas.empty() || ...) already documents that an empty file_metadatas is an expected post-state. Guard the file_metadatas compaction so it only runs when file_metadatas was not cleared; new_batch is still compacted as before. Downstream code already handles an empty file_metadatas (next() returns a null FileMetadataPtr). The regression test reproduces both crash preconditions the way they occur when several consumers share one keeper path: a real processing node is pre-created in keeper for one batch file so the engine's own keeper multi fails against it (real Node exists, no faked keeper response), and a small failpoint marks another file non-processable through the same std::nullopt path the engine takes when a file is already being processed elsewhere. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The regression test polled ObjectStorageQueueFailedToBatchSetProcessing for an absolute "> 0". system.events counts for the lifetime of the server process and started_cluster is module-scoped, so an increment left by any earlier execution in the same process satisfied the predicate immediately. The test then deleted the keeper conflict node before the failing batch had run, and the compaction path the fix guards was never re-entered. Measured on a repeated run (same server process): the poll accepted a stale value of 1 after 0.24s with a baseline of 1, instead of waiting for this table's own failed multi. Snapshotting the counter before the materialized view is created (nothing consumes before that) and waiting for a strict increase makes every execution wait for its own increment: baselines advance 0, 1, 2 and the accepted values are 1, 2, 3. With the out-of-bounds guard reverted, the test fails on both the first and the repeated execution, so the assertion is live in both directions. Co-Authored-By: Claude Fable 5 <[email protected]>
The regression test injected the non-processable file by wrapping the prepareSetProcessingRequests call in FileIterator::next with a force_skip conditional, editing the normal code path just to reproduce the test condition. Move the failpoint into prepareSetProcessingRequests instead, folded into the existing "processing lock held by another consumer" branch: try_lock its result into a local, and let the ONCE failpoint clear that local so the first file after the failpoint is enabled takes the real std::nullopt path a file grabbed by another table on this server would take, including its log line. The batch loop is restored to its original auto set_processing_result = ... form. Verified: with the out-of-bounds guard present the test passes; with the guard reverted the server still aborts in FileIterator::next, so the failpoint continues to exercise the num_successful_objects < batch size compaction path. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
The test only reproduces the out-of-bounds path when the file skipped by the object_storage_queue_skip_one_file_in_batch failpoint and the pre-created Keeper processing node land in the same getCurrentBatchAndScheduleNext result. That precondition was satisfied only because the engine default list_objects_batch_size is 1000, which happens to exceed files_to_generate, so a change to that default would have turned the test green without anyone noticing. The profile event the test waits on cannot catch that: the ObjectStorageQueueFailedToBatchSetProcessing increment sits in the else branch of the tryMulti result, so it fires on the failed multi alone, whether or not a non-processable file was in the same batch. Verified with the guard reverted: pinning the batch size to 1, so the skipped file and the conflict land in different batches, makes the test pass against a binary that still aborts, while the pinned value fails it as intended. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Fix out-of-bounds crash in ObjectStorageQueueSource::FileIterator::next
…ypick/25.8/108977 # Conflicts: # src/Common/FailPoint.cpp # src/Storages/ObjectStorageQueue/ObjectStorageQueueIFileMetadata.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #108977
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.
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