Skip to content

core: fix RejectedExecutionException in Retriable Stream#9626

Merged
YifeiZhuang merged 4 commits intogrpc:masterfrom
YifeiZhuang:inflight-substream-counter
Nov 22, 2022
Merged

core: fix RejectedExecutionException in Retriable Stream#9626
YifeiZhuang merged 4 commits intogrpc:masterfrom
YifeiZhuang:inflight-substream-counter

Conversation

@YifeiZhuang
Copy link
Copy Markdown
Member

@YifeiZhuang YifeiZhuang commented Oct 14, 2022

fix #9547

revision 1

Add big negative integer to pending stream count when cancelled. The count is used to delay closing master listener until streams fully drained.
Increment pending stream count before creating one. The count is also used to indicate callExecutor is safe to be used. New stream not created if big negative number was added, i.e. stream cancelled. New stream is created if not cancelled, callExecutor is safe to be used, because cancel will be delayed.

revision 2

  1. incrementing pending stream count only when cancel is not called, otherwise no op. This is to prevent the count never goes to Integer.MIN_VALUE.
  2. create new streams (retry, hedging) is moved to the main thread, before callExecutor calls drain.
  3. minor refactor the masterListener.close() scenario.

@YifeiZhuang YifeiZhuang requested a review from ejona86 October 14, 2022 22:11
@YifeiZhuang
Copy link
Copy Markdown
Member Author

@ejona86 , do you want to approve? So that we can try import next monday. global tap seems fine.

Copy link
Copy Markdown
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After changes for my two comments, the relationship with createSubstream()+inFlightSubStreams+callExecutor becomes more clear. We could end up moving the inFlightSubStreams increment to createSubstream() itself, maybe returning null if the increment fails.

Comment thread core/src/main/java/io/grpc/internal/RetriableStream.java Outdated
Comment thread core/src/main/java/io/grpc/internal/RetriableStream.java
@YifeiZhuang YifeiZhuang requested a review from ejona86 November 15, 2022 21:49
Comment thread core/src/main/java/io/grpc/internal/RetriableStream.java
Comment thread core/src/main/java/io/grpc/internal/RetriableStream.java Outdated
@YifeiZhuang YifeiZhuang merged commit b593871 into grpc:master Nov 22, 2022
@YifeiZhuang YifeiZhuang deleted the inflight-substream-counter branch November 22, 2022 21:04
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RejectedExecution exception after call closed

2 participants