Skip to content

Commit e5d47b9

Browse files
authored
pubsub: reconnect with old executor (#2498)
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.
1 parent 43d8c48 commit e5d47b9

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/StreamingSubscriberConnection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ public void run() {
250250
backoffMillis,
251251
TimeUnit.MILLISECONDS);
252252
}
253-
},
254-
executor);
253+
});
255254
}
256255

257256
private boolean isAlive() {

0 commit comments

Comments
 (0)