eye-gu opened a new issue, #3710:
URL: https://github.com/apache/dubbo-go/issues/3710
### What happened?
With failover cluster (default) on the dubbo protocol, the 2nd and
subsequent attempts
(retries) silently lose the configured timeout: it collapses to 0 and is
replaced by
the getty client's hard-coded 3s default
(`remoting/getty/getty_client.go#L229-L231`).
E.g. with `timeout=10s`, every retry aborts at ~3s with a premature read
timeout.
Root cause: `getTimeout` writes and reads the `timeout` attachment in two
formats.
- `protocol/dubbo/dubbo_invoker.go#L178` writes it as a bare millisecond
integer: `"10000"`
- `protocol/dubbo/dubbo_invoker.go#L166` re-reads it with
`time.ParseDuration`, which
requires a unit → `ParseDuration("10000")` fails, the error is discarded,
timeout = 0.
Failover makes this reachable on every retry because it passes the same
invocation
object to each attempt (`cluster/cluster/failover/cluster_invoker.go#L88`).
### How can we reproduce it?
Failing unit test (fails on current `develop`):
```go
func TestGetTimeoutAcrossAttemptsOnSameInvocation(t *testing.T) {
url, _ :=
common.NewURL("dubbo://127.0.0.1:20880/org.apache.dubbo.UserProvider?timeout=10s")
invoker := NewDubboInvoker(url, nil)
inv := invocation.NewRPCInvocation("GetUser", nil, nil)
assert.Equal(t, 10*time.Second, invoker.getTimeout(inv)) // attempt 1:
OK
assert.Equal(t, 10*time.Second, invoker.getTimeout(inv)) // retry:
FAILS, actual 0s
}
```
Suggested fix — make the read accept the bare-ms format it writes:
```go
if d, err := time.ParseDuration(attachTimeout); err == nil {
timeout = d
} else if ms, err := strconv.Atoi(attachTimeout); err == nil {
timeout = time.Duration(ms) * time.Millisecond
}
```
I'd be happy to submit a PR with the fix and the regression test above.
Please assign this issue to me.
### Environment
dubbo-go 3.3.2 / current develop
--
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]