chaoyoung opened a new issue, #16582:
URL: https://github.com/apache/dubbo/issues/16582

   ### Pre-check
   
   - [x] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   3.3.8-SNAPSHOT, 3.3 branch at 1cf125c421691ab2b3f1b82f0125be03eff338c9; 
OpenJDK 25.0.4.1, macOS aarch64
   
   ### Steps to reproduce this issue
   
   ## Apache Dubbo component
   
   Java SDK (`apache/dubbo`), Triple HTTP/2 write batching in 
`dubbo-remoting-http12`.
   
   ## Version
   
   Reproduced on `3.3` at `1cf125c421691ab2b3f1b82f0125be03eff338c9` 
(`3.3.8-SNAPSHOT`), using the repository's managed dependencies, OpenJDK 
25.0.4.1, Maven 3.9.16, macOS aarch64.
   
   ## Steps to reproduce
   
   Use a client/server pair of Netty `EmbeddedChannel`s with `Http2FrameCodec` 
and `Http2MultiplexHandler`, and the server's real `HttpWriteQueueHandler`:
   
   1. Complete the HTTP/2 handshake and open two request streams.
   2. Send initial response headers on both server streams and drain setup 
traffic.
   3. Close the second server stream and drain the resulting reset traffic.
   4. Enqueue two commands in the same queue drain: terminal response headers 
on the first, live stream, then terminal response headers on the closed stream.
   5. Run the server event-loop tasks and inspect outbound bytes and the first 
write's future **before** any additional explicit connection flush or peer 
pumping.
   
   Expected: the live stream's earlier write is flushed and completes, while 
the write to the closed stream fails independently.
   
   Actual: the server has no outbound response bytes and the live write remains 
pending. The same fixture passes when the second stream remains open. This is a 
deterministic transport-level reproduction; it does not measure production 
occurrence frequency.
   
   The regression is `HttpWriteQueueHandlerTest` in the accompanying patch. Run 
it after adding only the test to the base revision:
   
   ```sh
   mvn -pl dubbo-remoting/dubbo-remoting-http12 -am \
     -Dtest=HttpWriteQueueHandlerTest \
     -Dsurefire.failIfNoSpecifiedTests=false -Dspotless.skip=true test
   ```
   
   The initial live/closed pair produced 2 tests, 1 failure, 0 errors. The 
closed-last case failed with:
   
   ```text
   the earlier live stream must reach the connection outbound buffer ==> 
expected: not <null>
   ```
   
   ## Cause and suggested fix
   
   `HttpWriteQueue.flush(item)` runs the last command and then calls 
`item.getHttpChannel().flush()`. For HTTP/2, that delegates to the last 
command's child stream. Once that child is closed, flushing it does not flush 
the earlier sibling's pending connection output.
   
   Give the queue a batch flush callback bound to the channel that owns 
`HttpWriteQueueHandler`, and invoke that callback at the existing batch 
boundaries. Start flushing at the owning channel's pipeline tail so existing 
codecs and flush consolidation handlers participate. Retain the original queue 
constructor's behavior for other callers.
   
   ## Related discussion
   
   [Issue #11929](https://github.com/apache/dubbo/issues/11929) proposed using 
the TCP parent channel for Triple batch flushes and is closed. This report 
supplies a concrete closed-last-stream failure on the current `3.3` 
implementation; it is narrower than that earlier refactoring proposal.
   
   ## Scope
   
   The fixture uses real HTTP/2 child channels and codec output, without a 
network socket or a full RPC service. It asserts behavior before any artificial 
parent flush. The patch also tests live/closed last streams with and without 
flush consolidation, and verifies command order and existing chunk boundaries. 
HTTP/3 and WebSocket integration are not exercised by this reproduction.
   
   
   ### What you expected to happen
   
   Flush the earlier live stream's response and complete its write future even 
when the final batch command targets a closed sibling. Currently no connection 
outbound response bytes appear and the live write stays pending.
   
   ### Anything else
   
   Deterministic paired Netty HTTP/2 codec reproduction, with live-last 
negative control. Fix and tests: 
https://github.com/chaoyoung/dubbo/tree/codex/triple-closed-stream-flush . 
After fix: 40 http12 tests, no failures/errors, two existing Linux-only XML 
test skips on macOS. AI assistance was used to prepare the reproduction and 
proposed fix.
   
   ### Do you have a (mini) reproduction demo?
   
   - [x] Yes, I have a minimal reproduction demo to help resolve this issue 
more effectively!
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to