Skip to content

binder: Avoid force-terminating BinderTransport on stale unregisterCall task - #13138

Open
jdcormie wants to merge 1 commit into
grpc:masterfrom
jdcormie:stale-unregister-call
Open

jdcormie wants to merge 1 commit into
grpc:masterfrom
jdcormie:stale-unregister-call

Conversation

@jdcormie

Copy link
Copy Markdown
Member

When an ongoing call finishes and unregisterCall() observes ongoingCalls.isEmpty(), it schedules a task on scheduledExecutorService to finish transport shutdown if the transport is in TransportState.SHUTDOWN. However, unregisterCall() runs without holding synchronized (this) and may have scheduled this task while the transport is still in TransportState.READY. If a new stream is created before the transport enters TransportState.SHUTDOWN, the previously scheduled task can execute after shutdown() and call shutdownInternal(shutdownStatus, true), force-terminating the newly started call with UNAVAILABLE: Channel shutdown invoked.

Pass forceTerminate = false to shutdownInternal() so it re-checks ongoingCalls.isEmpty() while holding synchronized (this).

…ll task

When an ongoing call finishes and `unregisterCall()` observes
`ongoingCalls.isEmpty()`, it schedules a task on
`scheduledExecutorService` to finish transport shutdown if the transport
is in `TransportState.SHUTDOWN`. However, `unregisterCall()` runs
without holding `synchronized (this)` and may have scheduled this task
while the transport is still in `TransportState.READY`. If a new stream
is created before the transport enters `TransportState.SHUTDOWN`, the
previously scheduled task can execute after `shutdown()` and call
`shutdownInternal(shutdownStatus, true)`, force-terminating the newly
started call with `UNAVAILABLE: Channel shutdown invoked`.

Pass `forceTerminate = false` to `shutdownInternal()` so it re-checks
`ongoingCalls.isEmpty()` while holding `synchronized (this)`.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant