Skip to content

PubSub: Subscriber doesn't close connections after stopAsync  #28

@kegorof

Description

@kegorof

Environment details

  1. PubSub: google-cloud-pubsub-1.98.0
  2. Ubuntu 19.04, x64
  3. Java version: zulu8.38.0.13-ca-jdk8.0.212-linux_x64
  4. google-cloud-java version(s): google-cloud-core-1.91.3.jar, google-cloud-core-grpc-1.91.3.jar, google-cloud-pubsub-1.98.0.jar

Steps to reproduce

  1. Configure Subscriber
  2. Start Subscriber, receive several messages, send ack.
  3. Stop Subscriber, await termination.
  4. Don's stop JVM, check connections using nenstat, for example: netstat -natp | grep java | grep 443
  5. There is at least one established connection.
  6. Also logs contain messages like following:

io.grpc.internal.AbstractClientStream$TransportState inboundDataReceived
INFO: Received data on closed stream

  1. There are several runnable threads "grpc-default-worker-ELG-..."

Code example

// configure subscriber (from samples)
subscriber.startAsync().awaitRunning();
Thread.sleep(30000); //some messages are received
subscriber.stopAsync().awaitTerminated();
// do other job, check connections using netstat
Thread.sleep(Long.MAX_VALUE);

It looks like that the Subscriber instance doesn't shutdown the field com.google.cloud.pubsub.v1.Subscriber#subStub. This field isn't added to the backgroundResources, also shutdown() or shutdownNow() method isn't called. That's why grpc channel isn't closed.
Whey I call subStub.shutdownNow() using java reflection, the problem disappears.

Metadata

Metadata

Labels

api: pubsubIssues related to the googleapis/java-pubsub API.priority: p2Moderately-important priority. Fix may not be included in next release.status: duplicateDuplicate.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions