Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues and pull requests.
This is the unresolved exponential-backoff case previously identified in closed, unmerged #8088 and its review. The merged #7777 fixed the equivalent problem for fixed backoff. No open follow-up was found for exponential backoff.
Current Behavior
For an ordinary Divide rule with retryStrategy=failover and retryBackOffSpec=exponential, the HTTP client never selects the healthy standby:
- A GET whose first upstream returns HTTP 503 fails immediately with
ShenyuUpstreamStatusException; no retry is attempted. - A GET whose first upstream disconnects before response headers is retried against the same failed upstream, then fails without contacting the standby.
Both Netty and WebClient reproduce this behavior. Changing only retryBackOffSpec to default or fixed successfully reaches the standby in both scenarios.
These are independently selectable settings exposed by Admin. DivideRuleHandle stores both fields, and DividePlugin propagates both to the exchange. No Canary configuration is needed to reproduce this problem.
Expected Behavior
Changing the retry delay policy should preserve the selected routing policy. Eligible GET failures with retryStrategy=failover should select another healthy, untried upstream after the configured exponential delay.
The existing 500 ms initial delay, 5 s cap, 50% jitter, retry budget, GET-only safety policy and timeout budget should remain in effect. Exhausting the eligible upstream pool should fail explicitly rather than retrying an already attempted upstream.
Steps To Reproduce
-
Provide two local HTTP upstreams. The primary either returns 503 or accepts a request and closes the connection before sending headers. The standby returns 200 with body
standby-success. -
Configure a Divide selector containing both upstreams, with no Canary configuration. Configure this rule handle:
{ "loadBalance": "roundRobin", "retryStrategy": "failover", "retryBackOffSpec": "exponential", "retry": 1, "timeout": 3000 } -
Send GET requests to
/test?mode=retryand inspect a request whose first selected upstream is the primary. It fails without contacting the standby. -
Repeat with
retryBackOffSpec=defaultand thenfixed. Each reaches the standby and returnsstandby-success.
For a deterministic local reproduction, I also exercised each HTTP plugin's public execute() entry point with the initial URI pinned to the primary and both upstreams published in the real UpstreamCacheManager. The HTTP transports connected to real ephemeral loopback servers; they were not mocked. Reactor Netty's own connection retry was disabled in the probe, so the request counts below measure ShenYu retry behavior. The same path and query reached the standby in every passing control.
Environment
- ShenYu:
master@a87a3613f5ef1694f0624911002a821ab3587a45,2.7.3-SNAPSHOT. - Both
NettyHttpClientPluginandWebClientPlugin. - Local loopback reproduction; no Docker, external service or full Bootstrap deployment is claimed.
Debug logs
The 12 baseline scenarios produced the following request counts. Results are identical for both HTTP clients:
| Primary failure | Backoff | Primary requests | Standby requests | Result |
|---|---|---|---|---|
| HTTP 503 | default | 1 | 1 | standby-success |
| HTTP 503 | fixed | 1 | 1 | standby-success |
| HTTP 503 | exponential | 1 | 0 | ShenyuUpstreamStatusException |
| Disconnect before headers | default | 1 | 1 | standby-success |
| Disconnect before headers | fixed | 1 | 1 | standby-success |
| Disconnect before headers | exponential | 2 | 0 | Transport error |
For the last row, Mono.block() exposes ReactiveException for Netty and WebClientRequestException for WebClient. In both cases, the recorded paths are [primary:/test?mode=retry, primary:/test?mode=retry].
Anything else?
ExponentialRetryBackoffStrategy.execute() unconditionally calls response.retryWhen(retrySpec), so retries resubscribe the original URI. Its filter admits transient network failures but does not admit the clients' explicit 5xx failover signal. By contrast, FixedRetryStrategy uses DefaultRetryStrategy.executeFailover() when failover is configured.
Credit to @SouthwestAsiaFloat's #8088 and @Aias00's review for identifying and proposing this routing correction. #8088 was closed without merging; the separate #8076 merge did not modify ExponentialRetryBackoffStrategy. This report provides a focused follow-up with real-client reproduction. It does not propose changes to Canary validation or partition routing.
Activity
fix (httpclient) : preserve failover with exponential retry backoff. (a…