You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: Is the fix in #3644 effective in version 2025.1.0.0? #4296
I checked the 2025.1.0.0 code path again, and I think this concern is valid.
The fix from #3644 is included in 2025.1.0.0. NacosContextRefresher stores the pushed config into NacosSnapshotConfigManager, and NacosPropertySourceBuilder can consume that snapshot before falling back to configService.getConfig(...).
However, in the default ConfigData refresh path, the reload does not appear to go through NacosPropertySourceBuilder. The Nacos refresh event is converted to a Spring Cloud RefreshEvent, and Spring Cloud refreshes the environment through ConfigDataContextRefresher. That path reloads Nacos config via NacosConfigDataLoader.
The problem is that NacosConfigDataLoader#pullConfig(...) directly calls configService.getConfig(dataId, group, timeout). It does not read from NacosSnapshotConfigManager, and it does not go through NacosPropertySourceBuilder.
So although #3644 is merged, its snapshot protection can be bypassed in the default ConfigData refresh flow in 2025.1.0.0. This means the original stale-read problem in a Nacos cluster can still happen in that path.
This is separate from #4312, which fixes file extension preservation during refresh. It does not address whether the pushed config snapshot from #3644 is consumed by the ConfigData reload path. @daguimu
I’d like to contribute a fix for the ConfigData reload path discussed here.
My understanding is that NacosContextRefresher already stores the pushed config content in NacosSnapshotConfigManager, but the default ConfigData refresh flow reloads config through NacosConfigDataLoader, which currently falls back directly to ConfigService#getConfig(...).
My proposed approach is to let NacosConfigDataLoader first consume NacosSnapshotConfigManager, and only fall back to ConfigService#getConfig(...) when no valid snapshot is available. This keeps the existing fallback behavior while applying the snapshot protection to the ConfigData path as well.
I opened PR #4319 with this change. Please let me know if this direction looks reasonable or if there are any concerns.
PR #3644 ("修复 Nacos 集群模式下获取到旧配置问题") was merged on 2024-03-08 (commit f2bb845). The changes introduced by that fix — specifically the ready guard (AtomicBoolean) and the NacosConfigRefreshEvent handling in NacosPropertySourceRefreshListener — are present in version 2025.1.0.0.
However, the fix operates on the legacy refresh path where property sources are NacosPropertySource instances. If you are using spring.config.import=nacos:... (the ConfigData path introduced in newer versions), the property sources in Environment are OriginTrackedMapPropertySource — not NacosPropertySource. In that case, the instanceof NacosPropertySource check in the listener always fails, and the refresh logic is never reached.
TL;DR: The fix from #3644 is included in 2025.1.0.0, but it may not be effective if you are using the spring.config.import configuration path. See #4337 and #4331 for details on the ConfigData-path issue.
Activity
uuuyuqi commentedon Apr 24, 2026
I checked the 2025.1.0.0 code path again, and I think this concern is valid.
The fix from #3644 is included in 2025.1.0.0.
NacosContextRefresherstores the pushed config intoNacosSnapshotConfigManager, andNacosPropertySourceBuildercan consume that snapshot before falling back toconfigService.getConfig(...).However, in the default ConfigData refresh path, the reload does not appear to go through
NacosPropertySourceBuilder. The Nacos refresh event is converted to a Spring CloudRefreshEvent, and Spring Cloud refreshes the environment throughConfigDataContextRefresher. That path reloads Nacos config viaNacosConfigDataLoader.The problem is that
NacosConfigDataLoader#pullConfig(...)directly callsconfigService.getConfig(dataId, group, timeout). It does not read fromNacosSnapshotConfigManager, and it does not go throughNacosPropertySourceBuilder.So although #3644 is merged, its snapshot protection can be bypassed in the default ConfigData refresh flow in 2025.1.0.0. This means the original stale-read problem in a Nacos cluster can still happen in that path.
This is separate from #4312, which fixes file extension preservation during refresh. It does not address whether the pushed config snapshot from #3644 is consumed by the ConfigData reload path. @daguimu
DragonFSKY commentedon May 3, 2026
I’d like to contribute a fix for the ConfigData reload path discussed here.
My understanding is that
NacosContextRefresheralready stores the pushed config content inNacosSnapshotConfigManager, but the default ConfigData refresh flow reloads config throughNacosConfigDataLoader, which currently falls back directly toConfigService#getConfig(...).My proposed approach is to let
NacosConfigDataLoaderfirst consumeNacosSnapshotConfigManager, and only fall back toConfigService#getConfig(...)when no valid snapshot is available. This keeps the existing fallback behavior while applying the snapshot protection to the ConfigData path as well.I opened PR #4319 with this change. Please let me know if this direction looks reasonable or if there are any concerns.
fix: use config snapshot in NacosConfigDataLoader to fix stale config…
fix: use config snapshot in NacosConfigDataLoader to fix stale config…
oss-sentinel-ai commentedon Jul 21, 2026
Issue Evaluation
Category:
question| Status: AnsweredPR #3644 ("修复 Nacos 集群模式下获取到旧配置问题") was merged on 2024-03-08 (commit
f2bb845). The changes introduced by that fix — specifically thereadyguard (AtomicBoolean) and theNacosConfigRefreshEventhandling inNacosPropertySourceRefreshListener— are present in version 2025.1.0.0.However, the fix operates on the legacy refresh path where property sources are
NacosPropertySourceinstances. If you are usingspring.config.import=nacos:...(the ConfigData path introduced in newer versions), the property sources inEnvironmentareOriginTrackedMapPropertySource— notNacosPropertySource. In that case, theinstanceof NacosPropertySourcecheck in the listener always fails, and the refresh logic is never reached.TL;DR: The fix from #3644 is included in 2025.1.0.0, but it may not be effective if you are using the
spring.config.importconfiguration path. See #4337 and #4331 for details on the ConfigData-path issue.Automated evaluation by github-manager-bot