Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

客户端发起调用时配置重试次数时不生效 #2598

Open
EndlessSeeker opened this issue Feb 28, 2024 · 4 comments
Open

客户端发起调用时配置重试次数时不生效 #2598

EndlessSeeker opened this issue Feb 28, 2024 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@EndlessSeeker
Copy link

Environment

  • Server: dubbo-go 3.2
  • Client: dubbo-go 3.2
  • Protocol: triple

Issue description

在尝试客户端调用服务端,服务端报错的case时,发现客户端会默认重试3次,但是我指定服务调用的重试次数为1时,仍然会进行3次调用,重试的配置没有生效

	resp, err = svc.Greet(context.Background(), &greet.GreetRequest{Name: "wrong name"}, client.WithCallRetries(1))
	if err != nil {
		logger.Errorf("call Greet failed, err: %s", err.Error())
	}

Logs

client log

2024-02-28 17:57:49	ERROR	logger/logging.go:52	call Greet failed, err: [Failed to invoke the method Greet in the service greet.GreetService. Tried 2 times of the providers [tri://:@127.0.0.1:20000/?interface=greet.GreetService&group=&version= tri://:@127.0.0.1:20000/?interface=greet.GreetService&group=&version= tri://:@127.0.0.1:20000/?interface=greet.GreetService&group=&version=] (3/1)from the registry tri://127.0.0.1:20000/greet.GreetService?app.version=&application=dubbo.io&async=false&bean.name=greet.GreetService&cluster=failover&config.tracing=&environment=&generic=&group=&interface=greet.GreetService&loadbalance=&metadata-type=local&module=sample&name=dubbo.io&organization=dubbo-go&owner=dubbo-go&peer=true&provided-by=&reference.filter=cshutdown&registry.role=0&release=dubbo-golang-3.2.0&remote.timestamp=&retries=&serialization=protobuf&side=consumer&sticky=false&timestamp=1709114268&version= on the consumer 30.221.146.234 using the dubbo version 3.2.0. Last error is unknown: name is not right: wrong name.: unknown: name is not right: wrong name]

server log

2024-02-28 17:57:49     ERROR   logger/logging.go:32    [name is not right: wrong name]
2024-02-28 17:57:49     ERROR   logger/logging.go:32    [name is not right: wrong name]
2024-02-28 17:57:49     ERROR   logger/logging.go:32    [name is not right: wrong name]

@Phixsura
Copy link

Phixsura commented Feb 29, 2024

func getRetries(invokers []protocol.Invoker, methodName string) int {
if len(invokers) <= 0 {
return constant.DefaultRetriesInt
}
url := invokers[0].GetURL()
retries := url.GetMethodParamIntValue(methodName, constant.RetriesKey,
url.GetParamByIntValue(constant.RetriesKey, constant.DefaultRetriesInt))
if retries < 0 {
return constant.DefaultRetriesInt
}
return retries
}

默认走的是failover,可以看看这段代码,他实际上拿的是client上默认的retries,所以为重试2次

if retries, ok := invocation.GetAttachment(constant.RetriesKey); ok {
rInt, _ := strconv.Atoi(retries)
task.maxRetries = int64(rInt)

有意思的是,从源码可以看出WithCallRetries在failback策略是起作用的,反而WithClientRetries在failback不起作用

那么如果WithCallRetries的初衷是希望让本次调用走指定的次数,那么这里存在着bug
且如果WithCallRetries是默认让端上所有未定义的请求走指定次数,那这或许也存在bug,如果我理解没问题的话

@chickenlj
Copy link
Contributor

chickenlj commented Mar 5, 2024

那么如果WithCallRetries的初衷是希望让本次调用走指定的次数,那么这里存在着bug
且如果WithCallRetries是默认让端上所有未定义的请求走指定次数,那这或许也存在bug,如果我理解没问题的话

我觉得你的理解是正确的,这么做是合理的

@chickenlj chickenlj modified the milestones: 3.1.2, v3.2.0-rc2 Mar 5, 2024
@chickenlj chickenlj added the bug Something isn't working label Mar 6, 2024
@binksBrew
Copy link

resp, err := svc.Greet(context.Background(), &greet.GreetRequest{Name: "correct name"}, client.WithCallRetries(1))
if err != nil {
logger.Errorf("call Greet failed, err: %s", err.Error())
}

@FoghostCn
Copy link
Contributor

is this issue resolved already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants