pubsub: reconnect with old executor #2498
Merged
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.
We register a callback to reconnect connection when old connection closes.
When we shut down the subscriber, we close all connections and
begin to shutdown executor.
There is a race: if the callback is called after executor closes,
an exception occurs and we print a scary stack trace.
It doesn't do anything bad; the subscriber is going to go away anyway,
but the stack trace is still confusing.
This commit avoids registering new jobs on executors.
When a connection closes, the callback to determine whether we should
reconnect is called in the RPC thread.
If the connection closes due to some error, the callback should quickly
determine whether we should reconnection. If so, we register the actual
reconnection job on a separate thread. This does not block RPC thread,
and everyone should be happy.
If the connection closes because we're shutting down,
the callback running on RPC thread should determine that we should NOT
reconnect, not register a reconnection job, and we shouldn't see
a stack trace.
Fixes #2485.