Unexpected cancellation when subsequent message in client stream exceeds max size
- 主要言語
- Java
- スター
- 12.1k
- フォーク
- 4k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 37
説明
This is *almost* a duplicate of #3996. That issue was ostensibly fixed in #11073. (And that same PR also seems to have fixed the issue reported in #10971.)
*However*, that fix seems to only work reliably when the error pertains to the **first** request message in a stream. So it works fine for unary and server-stream RPCs. However, for client-stream and bidi-stream RPCs, if some message in the request stream *after the first one* exceeds the configured max size, the old behavior still exists:
* A warning is logged with an exception that indicates the expected/correct error code:
```
WARNING: Exception processing message
io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size 204800: 204810
at io.grpc.Status.asRuntimeException(Status.java:525)
at io.grpc.internal.MessageDeframer.processHeader(MessageDeframer.java:392)
at io.grpc.internal.MessageDeframer.deliver(MessageDeframer.java:272)
at io.grpc.internal.MessageDeframer.request(MessageDeframer.java:162)
at io.grpc.internal.AbstractStream$TransportState$1RequestRunnable.run(AbstractStream.java:264)
at io.grpc.netty.NettyServerStream$TransportState$1.run(NettyServerStream.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)
```
- But then a RST_STREAM frame is sent and the client instead observes a CANCELLED code.
コントリビューションガイド
調査の方向性
まずスタックトレースのエントリポイントである MessageDeframer.processHeader、AbstractStream、NettyServerStream から調査を始め、その後、client-stream と bidi-stream の呼び出しにおける最初の request メッセージと後続メッセージの処理を比較します。サイズ超過した後続メッセージを再現し、クライアントが CANCELLED ではなく RESOURCE_EXHAUSTED を受け取ることを確認します。両方のストリーミングモードを対象とするテストを追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- grpc, java
- 領域
- backend-api-design, networking
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100