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.38k stars 8.16k forks source link

使用RefreshScope 注解,项目在运行一段时间后失效 #3667

Closed NetRainn closed 1 week ago

NetRainn commented 1 month ago

问题描述

使用RefreshScope 注解,项目在运行一段时间后失效。 项目中使用该注解,正常情况下是可以读取到nacos上的配置变化,但是运行一段时间后就始终读取不到修改后的配置,属于偶发

排查

已排查:nacos上可以看到服务是正常运行的,没有掉,接口也是可以正常请求。服务器上本地记录也没有更新 日志没有探测到配置有变化,请问是什么情况?

未正常拉取到修改后的日志

2024-03-26 03:46:28.772  INFO 3891222 --- [cos.product-103612] [                                ] c.a.n.client.config.impl.ClientWorker    : [47291759-6e10-4748-be68-ef2a98e1f231_config-0] [server-push] config changed. dataId=java-product-trade-service-test.properties, group=DEFAULT_GROUP,tenant=test
2024-03-26 03:46:28.772  INFO 3891222 --- [cos.product-103612] [                                ] com.alibaba.nacos.common.remote.client   : [47291759-6e10-4748-be68-ef2a98e1f231_config-0] Ack server push request, request = ConfigChangeNotifyRequest, requestId = 9659

拉取到修改后的配置

2024-03-26 05:40:23.119  INFO 1561460 --- [nacos.product-1510] [                                ] c.a.n.client.config.impl.ClientWorker    : [4cfe57e9-bf24-4f70-9605-8f605e975549_config-0] [server-push] config changed. dataId=java-product-trade-service-test.properties, group=DEFAULT_GROUP,tenant=test
2024-03-26 05:40:23.119  INFO 1561460 --- [nacos.product-1510] [                                ] com.alibaba.nacos.common.remote.client   : [4cfe57e9-bf24-4f70-9605-8f605e975549_config-0] Ack server push request, request = ConfigChangeNotifyRequest, requestId = 9681

2024-03-26 05:40:23.127  INFO 1561460 --- [s.client.Worker] [                                ] c.a.n.client.config.impl.ClientWorker    : [fixed-test-server.config.nacos.product_8848] [data-received] dataId=java-product-trade-service-test.properties, group=DEFAULT_GROUP, tenant=test, md5=df735c9a5027c8ad4e18d7e89a9636bd, content=spring.cloud.nacos.discovery.server-addr=server.discovery.nacos.product:8848
spring.cloud.nacos.discove..., type=properties
2024-03-26 05:40:23.127  INFO 1561460 --- [s.client.Worker] [                                ] c.a.nacos.client.config.impl.CacheData   : [fixed-test-server.config.nacos.product_8848] [notify-listener] time cost=0ms in ClientWorker, dataId=java-product-trade-service-test.properties, group=DEFAULT_GROUP, md5=df735c9a5027c8ad4e18d7e89a9636bd, listener=com.alibaba.cloud.nacos.refresh.NacosContextRefresher$1@79c9c648 
2024-03-26 05:40:23.127  INFO 1561460 --- [ternal.notifier] [                                ] c.a.nacos.client.config.impl.CacheData   : [fixed-test-server.config.nacos.product_8848] [notify-context] dataId=java-product-trade-service-test.properties, group=DEFAULT_GROUP, md5=df735c9a5027c8ad4e18d7e89a9636bd
2024-03-26 05:40:23.529  WARN 1561460 --- [ternal.notifier] [                                ] c.a.nacos.client.logging.NacosLogging    : Load Logback Configuration of Nacos fail, message: Could not initialize Logback Nacos logging from classpath:nacos-logback.xml
2024-03-26 05:40:23.534  WARN 1561460 --- [ternal.notifier] [                                ] c.a.nacos.client.logging.NacosLogging    : Load Logback Configuration of Nacos fail, message: Could not initialize Logback Nacos logging from classpath:nacos-logback.xml
2024-03-26 05:40:23.571  WARN 1561460 --- [ternal.notifier] [                                ] c.a.nacos.client.logging.NacosLogging    : Load Logback Configuration of Nacos fail, message: Could not initialize Logback Nacos logging from classpath:nacos-logback.xml
2024-03-26 05:40:23.579  WARN 1561460 --- [ternal.notifier] [                                ] c.a.c.n.c.NacosPropertySourceBuilder     : Ignore the empty nacos configuration and get it based on dataId[java-product-trade-service] & group[DEFAULT_GROUP]
2024-03-26 05:40:23.581  WARN 1561460 --- [ternal.notifier] [                                ] c.a.c.n.c.NacosPropertySourceBuilder     : Ignore the empty nacos configuration and get it based on dataId[java-product-trade-service.properties] & group[DEFAULT_GROUP]
2024-03-26 05:40:23.585  INFO 1561460 --- [ternal.notifier] [                                ] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-java-product-trade-service-test.properties,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-java-product-trade-service.properties,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-java-product-trade-service,DEFAULT_GROUP'}]
2024-03-26 05:40:23.598  WARN 1561460 --- [ternal.notifier] [                                ] c.a.nacos.client.logging.NacosLogging    : Load Logback Configuration of Nacos fail, message: Could not initialize Logback Nacos logging from classpath:nacos-logback.xml
2024-03-26 05:40:23.599  INFO 1561460 --- [ternal.notifier] [                                ] o.s.boot.SpringApplication               : The following 1 profile is active: "test"
2024-03-26 05:40:23.612  INFO 1561460 --- [ternal.notifier] [                                ] o.s.boot.SpringApplication               : Started application in 0.482 seconds (process running for 6310.022)
2024-03-26 05:40:23.659  INFO 1561460 --- [ternal.notifier] [                                ] o.s.c.e.event.RefreshEventListener       : Refresh keys changed: [trade.pay.max.amount]
2024-03-26 05:40:23.659  INFO 1561460 --- [ternal.notifier] [                                ] c.a.nacos.client.config.impl.CacheData   : [fixed-test-server.config.nacos.product_8848] [notify-ok] dataId=java-product-trade-service-test.properties, group=DEFAULT_GROUP, md5=df735c9a5027c8ad4e18d7e89a9636bd, listener=com.alibaba.cloud.nacos.refresh.NacosContextRefresher$1@79c9c648 ,cost=532 millis. 

环境说明

系统:Ubuntu 22 Nacos版本:2.2.3 nacos-client:2.2.1 SpringBoot版本:3.0.2

ruansheng8 commented 1 month ago

需要先确认2个问题:

  1. Spring Cloud Alibaba 具体的版本号
  2. Nacos 是单机模式还是集群模式

以及可以添加一下 Nacos 调试日志,看下服务端收到的配置是否是最新的

logging:
  level:
    # 打印 Nacos 远程配置信息
    com.alibaba.cloud.nacos.configdata.NacosConfigDataLoader: debug
NetRainn commented 1 month ago
  1. Spring Cloud Alibaba 版本号2022.0.0.0
  2. 单机版
yuluo-yx commented 1 month ago

@NetRainn 社区有相关的 issue 问题,可以先试试里面的解决方案看看 https://github.com/alibaba/spring-cloud-alibaba/issues?q=is%3Aissue+RefreshScope

github-actions[bot] commented 2 weeks ago

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

github-actions[bot] commented 1 week 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.