binder: `ServerStream.close()` marks the stream closed before the suffix is sent, so a flow-control-deferred send failure leaks the call
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 45/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Domínio
- backend-api-design
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Java
- Estrelas
- 12.1k
- Forks
- 4k
- Merge médio
- 2d 9h
- PRs com merge (30d)
- 44
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de grpc/grpc-java
-
channelz: ServerData `calls_failed` counter not incremented upon client cancellationTalvez já em andamento @JoeCqupt assumiu há 8 dias. Abertaenhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
grpc/grpc-java#13063 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Support of `dns:name` URIsAbertadocs enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
grpc/grpc-java#10824 · 8 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 42/100
grpc/grpc-java#13137 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
question
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
Mantenedores costumam responder em até 1 dia
-
xds: duplicate endpoint addresses across localities are ACKed and can panic outlier detectionTalvez já em andamento @valeter assumiu há 8 dias. Aberta
Dificuldade 3/5 Meio dia Facilidade para iniciantes 45/100
Mantenedores costumam responder em até 1 dia
Todas as issues de grpc/grpc-java
Issues semelhantes
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
-
[Bug]: REST API URL starting with "http" but no scheme (e.g. httpbin.org/get) is not given an http:// prefixTalvez já em andamento @ItsDeadlyProgrammer assumiu há 1 dia. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
appsmithorg/appsmith#42471 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
code-maintenance
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
-
bug priority: medium Review effort [1-5]: 3 status: needs-triage type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
carlos-emr/carlos#5258 ·
Mantenedores costumam responder em até 1 dia