Handle exceptions during draining pending calls / streams#12737
Open
kannanjgithub wants to merge 5 commits intogrpc:masterfrom
Open
Handle exceptions during draining pending calls / streams#12737kannanjgithub wants to merge 5 commits intogrpc:masterfrom
kannanjgithub wants to merge 5 commits intogrpc:masterfrom
Conversation
…handled framing exception during the draining of DelayedStream. When MessageFramer throws an exception (e.g., RESOURCE_EXHAUSTED), it bubbles up through DelayedStream.drainPendingCalls and is eventually caught and swallowed by ThreadlessExecutor.runQuietly. This leaves the DelayedStream in an inconsistent state (where passThrough is still false), and the responseFuture never completes, causing the blocking call to hang forever. I have implemented a fix that adds proper exception handling to the draining loops in both DelayedStream and DelayedClientCall. When an exception occurs during draining: 1. The realStream (or realCall) is explicitly cancelled with the error. 2. The pending calls are cleared. 3. The stream/call transitions to passThrough = true to prevent getting stuck. 4. The listener's pending callbacks are drained, ensuring that any closure notifications are delivered to the application.
…Stream and DelayedClientCall
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.
The reported hang in issue #12109 in
blockingUnaryCallwas caused by an unhandled framing exception during the draining ofDelayedStream. WhenMessageFramerthrows anexception (e.g., RESOURCE_EXHAUSTED), it bubbles up through
DelayedStream.drainPendingCallsand is eventually caught and swallowed byThreadlessExecutor.runQuietly. This leaves theDelayedStreamin an inconsistent state (where passThrough is still false), and theresponseFuturenever completes, causing the blocking call to hang forever.This fix adds proper exception handling to the draining loops in both
DelayedStreamandDelayedClientCall. When an exception occurs during draining: