Repository navigation
Wait for the owner replica before giving its files to another one - #125611
Conversation
When the iterator is exhausted, the distributor gave the files queued for replicas that have not asked for tasks yet to whoever asked first. The initiator's own replica asks for `max_threads` tasks at once before the other replicas receive the query, so three files on three nodes were read by one node (3/0/0 tasks). The distributor now waits up to one second for the owner of a file to connect before giving the file to another replica. Among replicas that are already working, it takes a file from the one with the most remaining bytes, kept as a per-replica counter, so stealing does not scan all unprocessed files. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [5260922] Summary: ✅
AI ReviewSummaryThe PR adds an optional owner-arrival wait for object-storage cluster reads and chooses a stealing source using per-replica task weights. Reviewed head PR MetadataThe
Findings❌ Blockers
💡 Nits
Tests
Missing context / blind spots
Final Verdict❌ Block. Make the wait asynchronous and cancellable, add focused progress/cancellation coverage, and reconcile the byte-weight policy with iterators that do not supply sizes. |
The time the distributor waits for a replica to ask for tasks before giving its files to other replicas was hardcoded to one second. It is now a setting with the same default; `0` restores the previous behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| std::lock_guard lock(mutex); | ||
| unprocessed_files.emplace(file_identifier, object_info); | ||
| if (unprocessed_files.emplace(file_identifier, object_info).second) | ||
| remaining_bytes[file_replica_idx] += getTaskWeight(object_info); |
There was a problem hiding this comment.
getTaskWeight() does not see real byte sizes on the main *Cluster path. StorageObjectStorageCluster::getTaskIteratorExtension still builds the iterator with skip_object_metadata=true (src/Storages/ObjectStorage/StorageObjectStorageCluster.cpp:463), and KeysIterator::next then returns the placeholder metadata with size_bytes == 0 / is_fetched == false unless a specialized iterator overrides getFileSizeHint() (src/Storages/ObjectStorage/StorageObjectStorageSource.cpp:2352). For ordinary object-storage queries this counter is therefore just counting files, not bytes, so the new stealing policy can still leave the largest files concentrated on one replica despite the new test passing with synthetic metadata. Can we plumb real sizes into this iterator path, or adjust the heuristic/tests to match the data that is actually available here?
Build profile diff (arm_release)Commit See the job log for details. |
| return next_file; | ||
| } | ||
|
|
||
| replica_seen_cv.wait_until(lock, *stealing_allowed_since); |
There was a problem hiding this comment.
better to add a comment for the exit conditions
…ment exit conditions The wait is now disabled by default, which keeps the previous behaviour unless the setting is enabled explicitly. Also add a comment describing the exit conditions of the loop in `getAnyUnprocessedFile`, as requested in the review. Related: #125611 Co-Authored-By: Claude Opus 5.5 <[email protected]>
| return next_file; | ||
| } | ||
|
|
||
| replica_seen_cv.wait_until(lock, *stealing_allowed_since); |
There was a problem hiding this comment.
❌ Make the owner wait asynchronous and cancellable
This wait runs synchronously inside RemoteQueryExecutor::processReadTaskRequest. Both read and readAsync hold was_cancelled_mutex while processing that packet, and RemoteQueryExecutor::cancel needs the same mutex. If an owner has not requested a task, setting cluster_function_wait_for_replica_ms = 60000 therefore makes cancellation block for up to a minute: neither cancellation nor a query timeout wakes this condition variable, and the cancellation sweep cannot reach the remaining processors until this call returns.
The same blocking call also occupies a pipeline worker. With max_threads = 1, the sole worker cannot handle another replica's pending request to mark it in replica_seen, so the wait necessarily expires and then steals that owner's files even if its request is already on the socket.
Please suspend the pending task response through the asynchronous scheduling path, allowing other replica requests and cancellation to run, and wake/terminate pending waits on cancellation. Add coverage for cancellation during the wait and owner arrival with one initiator worker.
…tting-improvements Most of this branch landed through separate PRs: #125611 #125615 #125636 Their versions are kept. Bucket splitting by `min_buckets` is applied on top of the greedy splitter of master, the weight of a byte range bucket is capped by the file size, byte ranges are gated by `cluster_table_function_split_by_split_offsets`, and the duplicate test of the filter pushdown is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the iterator is exhausted, the distributor gave the files queued for replicas that have not asked for tasks yet to whoever asked first. The initiator's own replica asks for
max_threadstasks at once before the other replicas receive the query, so three files on three nodes were read by one node (3/0/0 tasks).The distributor can now wait for the owner of a file to connect before giving the file to another replica. The wait is controlled by the new setting
cluster_function_wait_for_replica_ms, which is0(disabled) by default. Among replicas that are already working, it takes a file from the one with the most remaining bytes, kept as a per-replica counter, so stealing does not scan all unprocessed files.Part 2: #124890
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Wait for the owner replica before giving its files to another one
Workflow [PR]
Sync PR [sync-upstream/pr/125611]
Version info
26.10.1.2492-master(included in26.10and later)