-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[WIP] Implement chunked fetch streaming with circuit breaker integration #139124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
DaveCTurner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it :)
| totalDocs | ||
| ); | ||
|
|
||
| writer.writeResponseChunk(chunk, ActionListener.running(() -> {})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't chased this through completely but ActionListener.running(() -> {}) suggests you're sending all the chunks at once without any kind of backpressure mechanism. It's a good idea to use some amount of parallelism here but please make sure there's a (configurable?) bound on the amount of in-flight data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you need to handle a failure here - e.g. a network disconnect might deserve a retry, or else failing the rest of the search, but there's no point in carrying on with the rest of the process regardless. The coordinating node might not even know that one of these requests failed in the case of a network disconnect, so we have to send back a failure response at the end of the process.
| * | |<---[START_RESPONSE chunk]----------------| | ||
| * | |----[ACK (Empty)]------------------------>| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this happen concurrently with sending the hits chunks? Could this be combined with the first chunk of hits?
| * | | [Accumulate in stream] | | ||
| * | |----[ACK (Empty)]------------------------>| | ||
| * | | | | ||
| * | |<--FetchSearchResult----------------------| --[Completion Phase] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we send the last chunk in this response message? That way e.g. if the response fits into a single chunk then it's just one network round trip still.
This is
WIP, and its intention is to implement chunked streaming for thefetch phaseto reduce memory pressure during large result set fetches. Instead of accumulating all search hits in memory on the data node before sending to the coordinator, hits are now streamed in configurable chunks as they are produced.This follows the paradigm of
TransportRepositoryVerifyIntegrityCoordinationActionbut it streams only between the coordinator and data-nodes.Coordinator's
FetchPhaseResponseStreamintegrates circuit breaker accounting for all shards' incoming traffic to prevent OOM.