PDGGK opened a new issue, #3789: URL: https://github.com/apache/dubbo-go/issues/3789
### What happened? With the forking cluster, every call that takes longer than 1 second fails, whatever request timeout is configured. Expected: with `client.WithClusterForking()` and `client.WithRequestTimeout(5 * time.Second)`, a call to a provider that answers in 1.5s succeeds, as it does with the default failover cluster. Actual: ``` 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 ``` The same happens when the provider is discovered through ZooKeeper. Cause: [`forkingClusterInvoker.Invoke`](https://github.com/apache/dubbo-go/blob/926e617517e11c59eea5df0d8f2ed6739a973545/cluster/cluster/forking/cluster_invoker.go#L61-L62) reads the wait time with `GetParamInt(constant.TimeoutKey, constant.DefaultTimeout)`. dubbo-go stores the timeout as a duration string (the reference URL has `timeout=5s`), so the parse fails and forking [waits `DefaultTimeout`, 1000ms](https://github.com/apache/dubbo-go/blob/926e617517e11c59eea5df0d8f2ed6739a973545/cluster/cluster/forking/cluster_invoker.go#L84). With a registry there is a second problem: forking reads `timeout` and `forks` from the directory URL, which is the registry URL. That URL has `registry.timeout` but neither `timeout` nor `forks`, so a `forks` value set on the reference is ignored too. The failover cluster reads its settings from the invoker URL instead. ### How can we reproduce it? (optional) <details><summary>main.go</summary> ```go package main import ( "context" "fmt" "net" "strconv" "time" ) import ( "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/wrapperspb" ) import ( dubbo "dubbo.apache.org/dubbo-go/v3" "dubbo.apache.org/dubbo-go/v3/client" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" _ "dubbo.apache.org/dubbo-go/v3/imports" "dubbo.apache.org/dubbo-go/v3/protocol" tri "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol" "dubbo.apache.org/dubbo-go/v3/server" ) const service = "com.example.SlowService" type SlowService struct{} func (s *SlowService) Reference() string { return service } // SayHello answers after 1.5s. func (s *SlowService) SayHello(context.Context, *emptypb.Empty) (*wrapperspb.StringValue, error) { time.Sleep(1500 * time.Millisecond) return wrapperspb.String("hello"), nil } func main() { l, _ := net.Listen("tcp", "127.0.0.1:0") port := l.Addr().(*net.TCPAddr).Port _ = l.Close() ins, _ := dubbo.NewInstance(dubbo.WithName("forking-timeout"), dubbo.WithProtocol(protocol.WithTriple(), protocol.WithIp("127.0.0.1"), protocol.WithPort(port))) srv, _ := ins.NewServer() svc := &SlowService{} _ = srv.Register(svc, &common.ServiceInfo{ InterfaceName: service, ServiceType: svc, Methods: []common.MethodInfo{{ Name: "SayHello", Type: constant.CallUnary, ReqInitFunc: func() any { return &emptypb.Empty{} }, MethodFunc: func(ctx context.Context, args []any, handler any) (any, error) { res, err := handler.(*SlowService).SayHello(ctx, args[0].(*emptypb.Empty)) return tri.NewResponse(res), err }, }}, }, server.WithInterface(service), server.WithNotRegister()) _ = srv.GetServiceOptions(service).Export() time.Sleep(500 * time.Millisecond) // let the server start listening // Consumer: 5s request timeout, failover vs forking. cli, _ := ins.NewClient() for _, c := range []struct { name string cluster client.ReferenceOption }{ {"failover", client.WithClusterFailOver()}, {"forking", client.WithClusterForking()}, } { conn, _ := cli.DialWithInfo(service, &client.ClientInfo{InterfaceName: service, MethodNames: []string{"SayHello"}}, c.cluster, client.WithProtocolTriple(), client.WithRequestTimeout(5*time.Second), client.WithURL("tri://127.0.0.1:"+strconv.Itoa(port))) start := time.Now() err := conn.CallUnary(context.Background(), []any{&emptypb.Empty{}}, new(wrapperspb.StringValue), "SayHello") fmt.Printf("%-8s returned after %s, err: %v\n", c.name, time.Since(start).Round(100*time.Millisecond), err) } } ``` </details> `go run .` prints the output above. ### Environment - dubbo-go v3.3.2, and `develop` at 926e617517e11c59eea5df0d8f2ed6739a973545 - Go 1.26.1, macOS arm64 - Triple protocol; direct URL, and ZooKeeper 3.8 as the registry -- 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]
