binder: `ServerStream.close()` marks the stream closed before the suffix is sent, so a flow-control-deferred send failure leaks the call
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Bereich
- backend-api-design
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Java
- Sterne
- 12.1k
- Forks
- 4k
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 48
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus grpc/grpc-java
-
docs enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
grpc/grpc-java#10824 · 8 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
xds: CdsLoadBalancer2 keeps stale READY picker after EDS update with no usable endpointsEvtl. vergeben @lujiajing1126 hat das vor 1 Tag übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 64/100
Maintainer antworten meist innerhalb von 1 Tag
-
question
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
grpc/grpc-java#13129 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
binder: RuntimeException during outbound serialization leaks the call and never notifies the peerEvtl. vergeben @mvanhorn hat das vor 20 Tagen übernommen. Offenbug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
grpc/grpc-java#13093 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Interest check: Peak EWMA (latency-aware P2C) LB policyEvtl. vergeben @markdroth hat das vor 16 Tagen übernommen. Offenenhancement Type: Feature
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
grpc/grpc-java#13092 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
priority: p2 type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
googleapis/java-genai#1372 ·
Maintainer antworten meist innerhalb von 1 Tag
-
GeoSeries scale and skew tests fail with pytest 9.2.0Evtl. vergeben @jiayuasu hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
priority: medium Review effort [1-5]: 3 status: needs-triage type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
carlos-emr/carlos#5431 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Integration tests: jetty:run fails with WELD-001408 for CountryJpaServiceEvtl. vergeben @viniciusmachak hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
primefaces/primefaces#15431 ·
Maintainer antworten meist innerhalb von 1 Tag
-
test(multi-tenancy): assert cross-tenant vulnerability reads are refused in the CWE isolation testOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
OpenAEV-Platform/openaev#8792 ·
Maintainer antworten meist innerhalb von 2 Tagen