Skip to content

stub.close() should call close() on background resources #792

@igorbernstein2

Description

@igorbernstein2

Currently generated stubs delegate close() to BackgroundResourceAggregation#shutdown(). Which will effectively end up calling channel.shutdown() followed immediately by executor.shutdown(). This can result in RPCs hanging indefinitely.

Steps leading to a hang:

future = stub.someCallable().futureCall(); // start rpc
// prevents new RPCs from starting, but existing RPCs can continue
// executor is shutdown
stub.close();
// grpc receives a response, but doesn't have executor to notify the future
// so this will hang indefinitely
future.get()

To avoid this situation, stub.close() should call close() on background resources, which wait for the channel to terminate before shutting down the executor.

See googleapis/java-bigtable#916 for more details

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.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