Open
Conversation
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Changelog category (leave one):
Improvement locking Iceberg iterator
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
What is going on:
In IcebergCluster request each replica creates pull of threads, each thread try to get next task. Each thread calls callback
All threads share the same socket, only one send request, all others wait on mutex.
Requests from each replica are sending on initiator. Initiator processes them in multiple threads, but all threads calls StorageObjectStorageStableTaskDistributor::getNextTask. This method calls three other methods with lock mutex inside each
getPreQueuedFiletries to find path for replica in already extracted paths.getMatchingFileFromIteratorcallsIcebergIterator::nextto extract next path, calculate replica for path, if it is a replica which send request, send this path as response, if this path is for other replica, puts it in list forgetPreQueuedFilegetAnyUnprocessedFileexecuted only when all paths are extracted and more nothing for current replica.When
getMatchingFileFromIteratorcallsIcebergIterator::next.IcebergIterator::nextis built overConcurrentBoundedQueue,nextwaits until something is pushed into queue or queue is finished. So when queue is empty, all threads are waiting until something is happened.In separate thread
IcebergIteratorcallsSingleThreadIcebergKeysIterator::nextto extract next path from Iceberg metadata. It can take a long time, because of reading metadata from S3, pruning files, etc.Possible scenario:
StorageObjectStorageStableTaskDistributor::getNextTask, finds path for replica 2, put it into list, finds file for replica 1, return it.SingleThreadIcebergKeysIterator::next, and it takes a dozens of seconds.StorageObjectStorageStableTaskDistributorhas an object for replica 2, butStorageObjectStorageStableTaskDistributorlocked untilSingleThreadIcebergKeysIteratornot finished work.As result, replica 2 gets path only after processing all metadata.
Solution:
IcebergIteratoris built overConcurrentBoundedQueue, sonextmethod is thread-safe. It can be called without lockStorageObjectStorageStableTaskDistributor, and replica 2 can get prequeued path without waitingSingleThreadIcebergKeysIterator::next.CI/CD Options
Exclude tests:
Regression jobs to run: