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.
Goals
There is a lot of confusion in the ResponseManager about when we're actually "done" with the request. This is cause the query executor completes before we've truly finished sending data -- that only happens once the message queue confirms everything has gone over the wire.
As a result it's very unclear in the code where a request ends -- has it gone over the wire or is it just done processing queries. Even most ways a request can abort still have a response code sent, meaning we need to wait till that gets sent to cleanup the request.
What's worse, cleanup tasks are spread out every where, with somewhat inconsistent implementation.
Implementation
The main change here is to add a "CompletingSend" status that tracks the time from when the query finishes executing to when the last message goes over the wire.
This makes it clearer if we're DONE DONE or still waiting for confirmation from the network queue.
We also add a method terminateRequest that cleans up the response when it's truly done, being careful to
only delete requests when they finish going over the network.
Put requests that are not processing but still going over the network in a state of CompletingSend.