Skip to content
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

core: Delay client listener exception notification until normal close #7187

Merged
merged 1 commit into from Jul 9, 2020

Conversation

ejona86
Copy link
Member

@ejona86 ejona86 commented Jul 7, 2020

This should avoid messages being leaked when a Listener throws an exception and
the executor is shut down immediately after the call completes. This is related
to #7105 but a different scenario and we aren't aware of any user having
observed the previous behavior.

Note also this does not fix the similar case of reordering caused by
delayedCancelOnDeadlineExceeded().

CC @njhill

This should avoid messages being leaked when a Listener throws an exception and
the executor is shut down immediately after the call completes. This is related
to grpc#7105 but a different scenario and we aren't aware of any user having
observed the previous behavior.

Note also this does _not_ fix the similar case of reordering caused by
delayedCancelOnDeadlineExceeded().
Copy link
Contributor

@voidzcy voidzcy left a comment

Choose a reason for hiding this comment

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

LGTM.

Just to make sure I understood the issue correctly:

When the call executor has multiple ClientStreamListener events enqueued, if running one of them that invokes ClientCall.Listener callback throws an exception, ClientCall.Listener.onClose() is invoked and may shut down the call executor. Then the remaining ClientStreamListener events are never executed.

With your change, ClientCall.Listener.onClose() is only invoked when running ClientStreamListener's closed event, which is the last stream callback. So after that, nothing is left in the call executor.

@ejona86
Copy link
Member Author

ejona86 commented Jul 9, 2020

When the call executor has multiple ClientStreamListener events enqueued, if running one of them that invokes ClientCall.Listener callback throws an exception, ClientCall.Listener.onClose() is invoked and may shut down the call executor. Then the remaining ClientStreamListener events are never executed.

No. In that case the following events are probably executed, because SerializingExecutor will finish draining its queue. The bigger problem is when a throwing event is queued, it throws, and then another event is queued after it throws. After we deliver onClose() we can'd depend on queuing any more events.

@voidzcy
Copy link
Contributor

voidzcy commented Jul 9, 2020

SerializingExecutor will finish draining its queue. The bigger problem is when a throwing event is queued, it throws, and then another event is queued after it throws.

I see. SerializingExecutor's run() will complete the current batch while there is still an interleave between the two runQueue checks and events being queued after finishing the current batch.

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.

None yet

2 participants