Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #730 +/- ##
============================================
+ Coverage 74.59% 74.97% +0.38%
- Complexity 3640 3671 +31
============================================
Files 392 393 +1
Lines 16554 16618 +64
Branches 1748 1757 +9
============================================
+ Hits 12349 12460 +111
+ Misses 3592 3532 -60
- Partials 613 626 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Release gRPC stream call messages that are no longer needed
Problem
Two gRPC stream call classes in core keep possibly large messages in memory long after they're needed:
ReadWriteStreamCallqueues outgoing messages inmessagesQueuewhile the transport isn't ready to send, for example when the network is slow. Once the call is half-closed, cancelled, or closed by the server, those messages can never be sent: gRPC'sClientCall.isReady()returnsfalseafterhalfClose(), soflush()never empties the queue. But nothing cleared the queue either, and messages passed tosendNext()after closing were added to it too.WriteRequestpossibly dozens megabytes-long. After a reconnect the writer re-sends the same message data on a new stream, so the dead queue kept the payloads in memory even after the server acknowledged them.ReadStreamCallstores its request in a final field for the whole lifetime of the stream, but only uses it once, instart(). For server-streaming calls with large requests (for example, queries with big parameters), the request stayed in memory until the last response arrived.Fix
ReadWriteStreamCall:close(),cancel()andonClose()now mark the call as stopped and clear the queue, andsendNext()drops messages once the call is stopped. Nothing changes in what gets delivered: these messages were never sent before either.ReadStreamCall: the request field is set tonullright aftersendMessage().