Fix #16344: graceful HTTP/2 GOAWAY migration to eliminate request failure window#16345
Open
devjue wants to merge 1 commit into
Open
Fix #16344: graceful HTTP/2 GOAWAY migration to eliminate request failure window#16345devjue wants to merge 1 commit into
devjue wants to merge 1 commit 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.80% 60.82% +0.01%
- Complexity 15 11771 +11756
============================================
Files 1953 1953
Lines 89208 89239 +31
Branches 13458 13459 +1
============================================
+ Hits 54245 54276 +31
+ Misses 29397 29395 -2
- Partials 5566 5568 +2
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:
|
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.