Fix #16344: graceful HTTP/2 GOAWAY migration to eliminate request failure window#16345
Open
devjue wants to merge 2 commits into
Open
Fix #16344: graceful HTTP/2 GOAWAY migration to eliminate request failure window#16345devjue wants to merge 2 commits into
devjue wants to merge 2 commits into
Conversation
…st failure window Keep the old channel alive after a GOAWAY frame and bring up a new connection asynchronously on the connectivity executor; atomically swap the channel reference via a closeFuture CAS so the old channel's close listener cannot wipe a freshly swapped-in new channel. - NettyConnectionHandler: schedule attemptGracefulMigration on connectivityExecutor with GRACEFUL_RECONNECT_DELAY_MS=200ms; one retry on failure, then fall back to AbstractNettyConnectionClient#onGoaway. - NettyConnectionClient#initBootstrap: closeFuture listener now compareAndClearNettyChannel(ch) instead of clearNettyChannel(). - AbstractNettyConnectionClient: add compareAndClearNettyChannel, plus package-private getConnectivityExecutor / getReconnectDuration. - NettyChannel#getChannelIfPresent: lookup-only API used by channelInactive. - TripleGoAwayHandler: log errorCode and lastStreamId. Signed-off-by: Jue Zhang <devjue@gmail.com>
b111c6d to
02e4fa9
Compare
|
@chickenlj PTAL |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16345 +/- ##
============================================
+ Coverage 60.83% 60.84% +0.01%
- Complexity 15 11761 +11746
============================================
Files 1953 1953
Lines 89208 89239 +31
Branches 13458 13459 +1
============================================
+ Hits 54270 54299 +29
+ Misses 29365 29363 -2
- Partials 5573 5577 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
We would appreciate if you add testcases to https://github.com/apache/dubbo-samples for this PR. |
LI123456mo
reviewed
Jun 23, 2026
Contributor
There was a problem hiding this comment.
@zrlw , have been going through the PR , seen the changes made , tried to run the changes locally,test the changes, and it worked,
@Test
void testGoawayCausesNoChannelFailure() throws Throwable {
final AbstractConnectionClient connectionClient =
connectionManager.connect(url, new DefaultPuHandler());
Assertions.assertTrue(
connectionClient.isAvailable(),
"Precondition: connection should be available before GOAWAY"
);
io.netty.channel.Channel channelBeforeGoaway = connectionClient.getChannel(true);
NettyConnectionHandler handler = new NettyConnectionHandler(
(AbstractNettyConnectionClient) connectionClient);
handler.onGoAway(channelBeforeGoaway);
io.netty.channel.Channel channelAfterGoaway = connectionClient.getChannel(true);
Assertions.assertNotNull(
channelAfterGoaway,
"Channel should NOT be null immediately after GOAWAY " +
"— old channel should stay alive until new one is ready"
);
await().atMost(Duration.ofSeconds(10))
.until(() -> connectionClient.isAvailable());
Assertions.assertTrue(
connectionClient.isAvailable(),
"Connection should be available after GOAWAY migration completes"
);
connectionClient.close();
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fixes #16344.
Eliminate the single-request failure window that occurs every time a Dubbo Triple Consumer receives an HTTP/2
GOAWAY(errorCode=0, lastStreamId=MAX_INT)frame from gateways / reverse proxies / providers that gracefully rotate connections (e.g.max_requests_per_connection,idle_timeout, hot-restart drain).Previously,
AbstractNettyConnectionClient#onGoawaynulled the channel reference immediately andNettyConnectionHandler#onGoAwaythen scheduled a reconnect, leaving a brief window in whichAbstractClusterInvoker#checkInvokersthrowsRpcExceptionbefore FailoverCluster's retry loop — soretries=Ndid NOT mitigate the issue. This PR implements graceful migration: keep the old channel serving until a new channel is ready, then atomically swap.Brief changelog
NettyConnectionHandler#onGoAway: keep old channel alive; scheduleattemptGracefulMigrationonconnectivityExecutorafterGRACEFUL_RECONNECT_DELAY_MS = 200ms; one retry on failure, then fall back toAbstractNettyConnectionClient#onGoaway.NettyConnectionClient#initBootstrap:closeFuturelistener now callscompareAndClearNettyChannel(ch)instead ofclearNettyChannel()— prevents the old channel's close listener from wiping a freshly swapped-in new channel.AbstractNettyConnectionClient: addcompareAndClearNettyChannel, plus package-privategetConnectivityExecutor()/getReconnectDuration()accessors.NettyChannel#getChannelIfPresent: lookup-only API used bychannelInactiveto avoid allocating a transientNettyChannelpurely for logging.TripleGoAwayHandler: logerrorCodeandlastStreamIdso the GOAWAY trigger is observable.Verifying this change
Validated against a local Triple demo with sustained 1 QPS traffic:
No provider availableerrors and zero request failures.:45956 → :45110 → :53222 → :58366 → :56372 → :55436 → :55188 → :52926 → :50682 → :48682 → :47626 → :44014 → :43116 → :45044 → :48602 → :51880 → :50992 → :51672dubbo-remoting-netty4anddubbo-rpc-tripleunit tests.Does this pull request potentially affect one of the following parts
connectivityExecutor; does NOT introduce new threads)Backward-compatible: defaults are unchanged; the only observable difference is that GOAWAY frames no longer cause a request failure window.
Documentation
Happy to backport to
3.2once this lands on3.3.