binder: `ServerStream.close()` marks the stream closed before the suffix is sent, so a flow-control-deferred send failure leaks the call
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
调研方向
Start with SingleMessageServerStream.close() and MultiMessageServerStream.close(), then trace ServerInbound.onCloseSent(), Inbound.onTransportReady(), and ServerOutbound.writeSuffix() in the Binder transport. Reproduce in Robolectric with BlackHoleOneWayBinderProxy to inspect deferred-close behavior. Done means deferred failures clean up the call, callbacks do not follow closed(), and tests cover the flow-control cases described.
由索引模型根据 Issue 内容生成。
描述
What version of gRPC-Java are you using?
master at c9ee3f8a79 (1.85.0-SNAPSHOT)
What is your environment?
Android
What did you expect to see?
If the server's close (status + trailers, plus any pending unary response) is deferred by transport flow control and the deferred send later fails, the stream should still end in the same clean way:
- the client receives an out-of-band close
- the call is removed from
ongoingCallsso transport can be marked as no longer in use , and - the application is not told
onComplete()for an RPC whose close was never sent. - Once
closed()has been delivered to aServerStreamListener, no further callbacks (onReady, in particular) should follow.
What did you see instead?
Both SingleMessageServerStream.close() and MultiMessageServerStream.close() do:
synchronized (outbound) {
outbound.sendClose(status, trailers); // or sendSingleMessageAndClose(...)
}
synchronized (inbound) {
inbound.onCloseSent(status);
}
BinderTransport.isReady() is !flowController.isTransmitWindowFull(), a single 128 KiB window (TRANSACTION_BYTES_WINDOW) shared by every call on the transport. If another stream has filled it when close() runs, Outbound.canSend() is false, send() returns without writing, and the suffix stays queued until an ACKNOWLEDGE_BYTES arrives. inbound.onCloseSent() nevertheless runs immediately: it moves ServerInbound to State.CLOSED and calls listener.closed(Status.OK). Unregistration is deferred to ServerOutbound.writeSuffix(), which has not run.
When the window reopens, BinderTransport.handleAcknowledgedBytes() → Inbound.onTransportReady() first calls listener.onReady() (on a listener that has already been closed()), then outbound.onTransportReady() → sendInternal(). If that deferred send fails with a StatusException before reaching writeSuffix()'s unregister() — e.g. MetadataHelper.writeMetadata() throwing RESOURCE_EXHAUSTED: Metadata value too large for a stream-marshalled trailer value of BlockPool.BLOCK_SIZE (16 KiB) or more, an IOException from the response stream in writeMessageData(), or a RemoteException on a non-final chunk of a multi-block response — then Inbound.onTransportReady() catches it and calls closeAbnormal(se.getStatus()), which is guarded by if (!isClosed()) and is now a no-op.
Additionally, any subsequent OOB cancel from the client for that call is dropped by Inbound.handleTransaction()'s if (isClosed()) return;, so client-side cleanup cannot repair the server. If the deferred send succeeds, writeSuffix() calls unregister() before sendTransaction(), so the normal path and a RemoteException on the suffix transaction itself do not leak; only failures before that point do. If the deferred send throws an unchecked exception, it escapes into BinderTransport.handleTransaction()'s catch (RuntimeException) from #10092 and terminates the whole transport — not a leak, but a per-stream problem taking down every call on the connection.
Note that the premature closed(OK) and the post-close onReady() happen for every flow-control-deferred close, not only the ones whose deferred send later fails.
Steps to reproduce the bug
Difficult to reproduce on a real device. It can be done in robolectric using a BlackHoleOneWayBinderProxy to force flow-control to kick in.
- 主要语言
- Java
- 星标
- 12.1k
- 派生
- 4k
- 平均合并
- 2 天 6 小时
- 30 天内合并 PR
- 26
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
grpc/grpc-java 的其他 Issue
-
channelz: ServerData `calls_failed` counter not incremented upon client cancellation可能重新可做 @stdcout42 于 15 天前认领,目前没有进行中的 PR。 未关闭enhancement
难度 2/5 1-3 小时 新手友好度 88/100
grpc/grpc-java#13063 · 4 条评论 ·
维护者通常 1 天内回复
-
Android: ProxyDetectorImpl crashes when DefaultProxySelector contains an invalid proxy port可能已有人在做 @kkmurthyt21 于 30 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
grpc/grpc-java#13052 · 4 条评论 ·
维护者通常 1 天内回复
-
docs enhancement
难度 2/5 1-3 小时 新手友好度 72/100
grpc/grpc-java#10824 · 8 条评论 ·
维护者通常 1 天内回复
-
binder: RuntimeException during outbound serialization leaks the call and never notifies the peer可能已有人在做 @mvanhorn 于 4 天前认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 48/100
grpc/grpc-java#13093 · 1 条评论 ·
维护者通常 1 天内回复
-
Interest check: Peak EWMA (latency-aware P2C) LB policy可能已有人在做 @markdroth 今天认领。 未关闭enhancement Type: Feature
难度 5/5 一周以上 新手友好度 35/100
grpc/grpc-java#13092 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
Flight SQL JDBC parses boolean properties case-sensitively, silently disabling TLS for useEncryption=TRUE可能已有人在做 @Arawoof06 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
apache/arrow-java#1357 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
apache/rocketmq-dashboard#6610 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
MetricsHub/metricshub-community#1396 ·
维护者通常 1 天内回复
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
难度 2/5 1-3 小时 新手友好度 76/100
dependabot/dependabot-core#16547 ·
维护者通常 1 天内回复
-
Citationcount column sorts alphabetically instead of numerically可能已有人在做 @kpunia306 今天认领。 未关闭status: needs-triage
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复