PDGGK opened a new pull request, #3790:
URL: https://github.com/apache/dubbo-go/pull/3790

   ### Description
   
   Fixes #3789
   
   With the forking cluster, every call slower than 1 second fails, whatever 
timeout is configured. Calling a provider that answers in 1.5s with 
`WithRequestTimeout(5 * time.Second)` (program in the issue):
   
   ```
   # before
   failover returned after 1.5s, err: <nil>
   forking  returned after 1s, err: failed to forking invoke provider 
[0x412c5dac39e0], but no luck to perform the invocation. Last error is: queue: 
poll timed out
   
   # after
   failover returned after 1.5s, err: <nil>
   forking  returned after 1.5s, err: <nil>
   ```
   
   The result is the same when the provider is discovered through ZooKeeper.
   
   `forkingClusterInvoker` read the wait time with `GetParamInt(timeout, 
1000)`. The timeout is stored as a duration string (`timeout=5s`), so the parse 
always failed and forking waited 1000ms. With a registry it also read the 
directory URL, which is the registry URL. That URL has `registry.timeout` but 
neither `timeout` nor `forks`, so `forks` set on the reference was ignored as 
well.
   
   This change reads both settings from the invoker URL, as `getRetries` in the 
failover cluster does, and parses the timeout as a duration. A per-call timeout 
(`client.WithCallRequestTimeout`) takes precedence, because that is the timeout 
the forked calls run with. When the URL has no timeout, forking still waits 
1000ms.
   
   Tests:
   
   - `TestForkingInvokeConfiguredTimeout`: a provider that answers in 1.5s, 
with the timeout set on the reference, on the reference behind a registry-style 
directory, or per call, plus a 200ms timeout that must end the call early. 
Without the change, the first three fail with `queue: poll timed out` and the 
last one waits the full 1s.
   - `TestForkingInvokeForksBehindRegistry`: `forks=1` behind a registry-style 
directory calls one of two providers. Without the change it calls both.
   
   Run locally:
   
   - `go test -count=1 ./cluster/cluster/forking/`, plain and with `-race`: 
pass.
   - `gofmt`, `go vet`, imports-formatter, modernize and golangci-lint v2.7.2 
on the changed package: no changes, 0 issues.
   - The reproduction above before and after the change, with a direct URL and 
with a ZooKeeper 3.8 registry.
   
   Left to CI: the full `make test` run.
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [ ] I have run `make fmt` to format my code (ran its gofmt, 
imports-formatter and modernize steps on the changed package; no changes)
   - [ ] I have run `make test` to run local tests (ran the changed package's 
tests, see above)
   - [x] I have added tests that prove my fix is effective or that my feature 
works
   


-- 
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