alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.47k stars 8.19k forks source link

Spring-cloud-alibaba框架未正确处理nacos-client收到的配置推送 #3322

Closed chickenlj closed 4 months ago

chickenlj commented 1 year ago

Spring Cloud Alibaba 2.1.1.RELEASE版本 + Nacos 组合,当 Nacos 配置有变更时, SCA 未正确收到配置变更。

spring-cloud-alibaba 框架未加载到正确配置

初步定位原因在spring-cloud-alibaba框架未正确处理nacos-client收到的配置推送

image

configInfo为最新的配置推送值,但此处sca的listener实现没有使用它,内容被丢弃。 查看代码确认SCA通过主动getConfig获取配置内容

image

重新获取配置有概率得到旧值

SCA收到更新事件后,直接使用getConfig得到配置内容可能是旧值(原因见后文图示)

通过服务端推送日志时间序列可以证实该种情况:

2023-05-22 11:31:39,487  pod-4 persist

2023-05-22 11:31:39,505  pod-3 dump (将最新配置推送给客户端)

2023-05-22 11:31:39,513  pod-0 pull (收到变更推送时没有使用新值,主动查询时查到了pod-0的旧值)

2023-05-22 11:31:39,516  pod-0 pull

....

2023-05-22 11:31:39,526  pod-4 dump

2023-05-22 11:31:39,529  pod-2 dump

2023-05-22 11:31:40,540  pod-0 dump

2023-05-22 11:31:39,585  pod-1 dump

问题发生过程如下图所示:

image

yuluo-yx commented 1 year ago

What version of the component are you using?

steverao commented 1 year ago

该问题与当前Spring Cloud Alibaba配置监听逻辑实现有关,当前实现是启动时会主动订阅配置,配置变更后,再主动拉取新配置更新内存中所有对象配置值。在配置中心server多节点时当出现主动刷新配置操作请求的是未完成同步的实例会造成未正常更新配置现象(该问题Nacos Client 1.x短连接模式易出现,2.x长链接难出现,因为第一次接受配置变更通知与第二次主动拉取配置在长链接未发生断开情况下会一直使用同一个连接访问到对应产生配置更新的配置中心实例)。如果遇到相关问题,建议可以先按照版本说明进行升级,采用 Nacos Client 2.x版本可较大限度规避该问题。后续社区会对当前问题进行对应的修复。

steverao commented 1 year ago

What version of the component are you using?

他用的 2.1.1.RELEASE,对应的Nacos Client 为 1.x。

github-actions[bot] commented 11 months ago

This issue has been open 30 days with no activity. This will be closed in 7 days.

chickenlj commented 11 months ago

Ping

github-actions[bot] commented 10 months ago

This issue has been open 30 days with no activity. This will be closed in 7 days.

chickenlj commented 10 months ago

keep it open

github-actions[bot] commented 9 months ago

This issue has been open 30 days with no activity. This will be closed in 7 days.

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it hasn't had any recent activity.If you think this should still be open, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up. Thank you for your interest and contribution to the Sping Cloud Alibaba Community.

shiyiyue1102 commented 6 months ago

problem is not solved

github-actions[bot] commented 5 months ago

This issue has been open 30 days with no activity. This will be closed in 7 days.

github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it hasn't had any recent activity.If you think this should still be open, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up. Thank you for your interest and contribution to the Sping Cloud Alibaba Community.

ruansheng8 commented 4 months ago

i will solve it