apache / dubbo-samples

samples for Apache Dubbo
Apache License 2.0
2.27k stars 1.93k forks source link

dubbo-samples-shop项目中,dubbo的服务治理规则未生效(以动态配置为例) #855

Open liamashes opened 1 year ago

liamashes commented 1 year ago

按照官方文档 https://cn.dubbo.apache.org/zh-cn/overview/tasks/traffic-management/retry/,调整了重试次数后,依然没有生效,配置已经成功地推送到了相应的微服务

dubbo-admin的动态配置: image

Nacos中查看到该配置: image

shop-frontend容器中也找到了该配置文件: image

但是访问demo页面时,其重试规则仍未生效:

image

同时,已经尝试了访问日志、条件路由、标签路由,均未达到预期效果。

以下为相关工具的版本 dubbo-admin:0.5.0 dubbo: 3.0.8 nacos: 2.2.3

AlbumenJ commented 1 year ago

@chickenlj PTA:

chickenlj commented 1 year ago

以下为相关工具的版本 dubbo-admin:0.5.0 dubbo: 3.0.8 nacos: 2.2.3

为保证功能完整,请使用 Dubbo 框架 3.2.0 及以上版本进行验证;

规则体中的 configVersion 请固定为 configVersion: v3.0

liamashes commented 1 year ago

以下为相关工具的版本 dubbo-admin:0.5.0 dubbo: 3.0.8 nacos: 2.2.3

为保证功能完整,请使用 Dubbo 框架 3.2.0 及以上版本进行验证;

规则体中的 configVersion 请固定为 configVersion: v3.0

我尝试了3.2.0-beta.4,也尝试将configVersion固定为v3.0,但是依然没有任何效果。期间也没有抛出任何异常。 请问有什么排查思路吗,比如在idea中,在启动的某行代码进行断点debug来查看获取动态配置的过程 @chickenlj

chickenlj commented 1 year ago

针对重试,可以尝试在 org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker#calculateInvokeTimes 处打断点确认一下url上的 retries 值,是否已经生效。 @liamashes

liamashes commented 1 year ago

看代码中url取自consumerUrl,于是查看其中的retries属性,一共发现两处 image

第一个extra_params中依然是0

第二个config看起来与代码中的配置一致 image

此外,我还查看了其他地方的retries属性,似乎都是0 我对于这个数据模型不是很了解,可以帮分析一下吗 @chickenlj image

robocanic commented 1 year ago

我也遇到了类似的问题,请问@liamashes 您解决了吗

chickenlj commented 1 year ago

@robocanic @liamashes 请确保使用的是 3.2.x 版本,如 3.2.5

chickenlj commented 1 year ago

image

这里看到的工作版本是 3.0.8 版本

robocanic commented 1 year ago

我测试的版本的是3.2.0(也是仓库代码中master分支的dubbo版本),使用deploy>ALL.yml 在k8s集群上部署的(部署时也有问题,dubbo admin的端口应该是8080,38080不能运行,修改之后可以正常运行) image

robocanic commented 1 year ago

在dubbo官方文档>任务>流量管控>调整超时时间这个task中,我按照指示创建了一个动态配置: image 在容器内的config文件也得到了更新: image 但是在前端页面点击timeoutLogin完全没有预期的效果,且查看容器日志,也看到timeout还是1000: image

robocanic commented 1 year ago

再次在dubbo admin中修改timeout为3000: image nacos中配置得到了更新: image

对应的shop-user的日志如下,也推送到了对应的服务:

2023-08-29T08:49:35.824Z INFO 1 --- [stem.svc-105273] com.alibaba.nacos.common.remote.client : [64b0be3f-b73b-4f36-963c-c46308b23ece_config-0] Receive server push request, request = ConfigChangeNotifyRequest, requestId = 524
2023-08-29T08:49:35.824Z INFO 1 --- [stem.svc-105273] c.a.n.client.config.impl.ClientWorker : [64b0be3f-b73b-4f36-963c-c46308b23ece_config-0] [server-push] config changed. dataId=org.apache.dubbo.samples.UserService::.configurators, group=dubbo,tenant=null
2023-08-29T08:49:35.824Z INFO 1 --- [stem.svc-105273] com.alibaba.nacos.common.remote.client : [64b0be3f-b73b-4f36-963c-c46308b23ece_config-0] Ack server push request, request = ConfigChangeNotifyRequest, requestId = 524
2023-08-29T08:49:35.831Z INFO 1 --- [s.client.Worker] c.a.n.client.config.impl.ClientWorker : [fixed-nacos.dubbo-system.svc_8848] [data-received] dataId=org.apache.dubbo.samples.UserService::.configurators, group=dubbo, tenant=, md5=3bfbf45f6eeb879febdbfd1a04f049b3, content=configVersion: v3.0
configs:
- addresses:
- 0.0.0.0
enabled: false
parameters:
timeout: 30..., type=text
2023-08-29T08:49:35.832Z INFO 1 --- [s.client.Worker] c.a.nacos.client.config.impl.CacheData : [fixed-nacos.dubbo-system.svc_8848] [notify-listener] time cost=1ms in ClientWorker, dataId=org.apache.dubbo.samples.UserService::.configurators, group=dubbo, md5=3bfbf45f6eeb879febdbfd1a04f049b3, listener=org.apache.dubbo.configcenter.support.nacos.NacosDynamicConfiguration$NacosConfigListener@37c073a7
2023-08-29T08:49:35.832Z INFO 1 --- [ternal.notifier] c.a.nacos.client.config.impl.CacheData : [fixed-nacos.dubbo-system.svc_8848] [notify-context] dataId=org.apache.dubbo.samples.UserService::.configurators, group=dubbo, md5=3bfbf45f6eeb879febdbfd1a04f049b3
2023-08-29T08:49:35.832Z INFO 1 --- [ternal.notifier] o.a.d.r.i.AbstractConfiguratorListener : [DUBBO] Notification of overriding rule, change type is: MODIFIED, raw config content is:
configVersion: v3.0
configs:
- addresses:
- 0.0.0.0
enabled: false
parameters:
timeout: 3000
side: provider
enabled: true
key: org.apache.dubbo.samples.UserService
scope: service
, dubbo version: 3.2.0-beta.5-SNAPSHOT, current host: 10.255.91.36
2023-08-29T08:49:35.835Z INFO 1 --- [ternal.notifier] o.a.d.r.i.AbstractConfiguratorListener : [DUBBO] Notification of overriding rule, change type is: MODIFIED, raw config content is:
configVersion: v3.0
configs:
- addresses:
- 0.0.0.0
enabled: false
parameters:
timeout: 3000
side: provider
enabled: true
key: org.apache.dubbo.samples.UserService
scope: service
, dubbo version: 3.2.0-beta.5-SNAPSHOT, current host: 10.255.91.36
2023-08-29T08:49:35.836Z INFO 1 --- [ternal.notifier] c.a.nacos.client.config.impl.CacheData : [fixed-nacos.dubbo-system.svc_8848] [notify-ok] dataId=org.apache.dubbo.samples.UserService::.configurators, group=dubbo, md5=3bfbf45f6eeb879febdbfd1a04f049b3, listener=org.apache.dubbo.configcenter.support.nacos.NacosDynamicConfiguration$NacosConfigListener@37c073a7 ,cost=4 millis.

然后再次在前端点击timeout login,查看shop-user的日志如下,timeout还是没有变:

2023-08-29T08:52:26.007Z WARN 1 --- [0884-thread-199] o.a.d.rpc.filter.ProfilerServerFilter : [DUBBO] [Dubbo-Provider] execute service org.apache.dubbo.samples.UserService:0.0.0#timeoutLogin cost 1100.650112 ms, this invocation almost (maybe already) timeout. Timeout: 1000ms
client: 10.255.91.24:33198
invocation context:
input=669;
path=org.apache.dubbo.samples.UserService;
remote.application=shop-frontend;
sw8-x=0- ;
sw8=1-ZWZhYzEwZDZjYWRlNDNjYWI2M2QzMDU5NDViMGRjMGQuMTA5LjE2OTMyOTkxNDQ5MDMwMDYz-ZWZhYzEwZDZjYWRlNDNjYWI2M2QzMDU5NDViMGRjMGQuMTA5LjE2OTMyOTkxNDQ5MDMwMDYy-1-c2hvcDo6c2hvcC1mcm9udGVuZA==-NTUwMTYzNmQwOWQzNGI5MTk3OWE4M2QxMjE3MzljMzRAMTAuMjU1LjkxLjI0-R0VUOi90aW1lb3V0TG9naW4=-MTAuMjU1LjkxLjI0OjA=;
dubbo=2.0.2;
sw8-correlation=;
interface=org.apache.dubbo.samples.UserService;
version=0.0.0;
timeout=1000;
token=1be8c126-8fe3-47e2-87f6-5108654ea23e;
thread info:
Start time: 16695110105605411
+-[ Offset: 0.000000ms; Usage: 1100.650112ms, 100% ] Receive request. Server invoke begin.
+-[ Offset: 0.326706ms; Usage: 1100.137247ms, 99% ] Receive request. Server biz impl invoke begin., dubbo version: 3.2.0-beta.5-SNAPSHOT, current host: 10.255.91.36, error code: 3-7. This may be caused by , go to https://dubbo.apache.org/faq/3/7 to find instructions.

这个问题我也排查了几天,应该是配置没能覆盖,请问@chickenlj这个问题还有什么排查方向吗

chickenlj commented 1 year ago

image

这里看上去是enabled: false,有可能是规则被关闭了

chickenlj commented 1 year ago

建议直接在nacos中改一下看,跳过admin先排除admin写入规则的问题。把上面的enabled: false 清理掉

robocanic commented 1 year ago

直接在nacos中修改配置,无论是将红圈处的enabled: false直接删掉还是改为enabled: true,都没能生效。配置下发后在容器内能够看到配置下发的日志,但是在前端页面点击timeout Login后还是会超时,且对应的shop-user实例容器内的日志显示timeout还是1000。😩😩😩