Skip to content

Conversation

@pongad
Copy link
Contributor

@pongad pongad commented Oct 10, 2017

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.

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.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 10, 2017
@garrettjonesgoogle
Copy link
Member

LGTM

@pongad pongad merged commit e5d47b9 into googleapis:master Oct 11, 2017
@pongad pongad deleted the pubsub-spam branch October 11, 2017 23:33
schmidt-sebastian pushed a commit to FirebasePrivate/google-cloud-java that referenced this pull request Nov 9, 2017
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 googleapis#2485.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

com.google.cloud.pubsub.v1.Subscriber how to await stop signal?

3 participants