Skip to content

fix: use config snapshot in NacosConfigDataLoader to fix stale config in cluster mode#4333

Open
EvanYao826 wants to merge 1 commit into
alibaba:2025.1.xfrom
EvanYao826:fix/nacos-config-data-loader-snapshot
Open

fix: use config snapshot in NacosConfigDataLoader to fix stale config in cluster mode#4333
EvanYao826 wants to merge 1 commit into
alibaba:2025.1.xfrom
EvanYao826:fix/nacos-config-data-loader-snapshot

Conversation

@EvanYao826

Copy link
Copy Markdown

What does this PR do?

Fixes #4296: the config snapshot mechanism from PR #3644 is not effective in 2025.1.0.0.

Root Cause

In Spring Boot 3.x (2025.x), config loading goes through NacosConfigDataLoader.pullConfig() instead of NacosPropertySourceBuilder.loadNacosData(). The snapshot mechanism was only integrated into the old path.

Changes

  • NacosConfigDataLoader.pullConfig(): Check NacosSnapshotConfigManager before calling configService.getConfig()
  • Added import for NacosSnapshotConfigManager

Assisted-by: Hermes Agent

@CLAassistant

CLAassistant commented May 21, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@EvanYao826

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@EvanYao826 EvanYao826 force-pushed the fix/nacos-config-data-loader-snapshot branch from d352f17 to 868ea6a Compare May 21, 2026 13:09
@xuxiaowei-com-cn

Copy link
Copy Markdown
Collaborator

I have read the CLA Document and I hereby sign the CLA

  • But there might be issues in some places.
  • Please sign again, and after signing, click recheck.

@EvanYao826

Copy link
Copy Markdown
Author

Thanks for the heads up! I have rechecked and signed the CLA. Please let me know if there are any further issues.

@xuxiaowei-com-cn

Copy link
Copy Markdown
Collaborator

Thanks for the heads up! I have rechecked and signed the CLA. Please let me know if there are any further issues.

It has been found that you have not signed the CLA. After signing, the CLA will appear green instead of the current yellow.

@EvanYao826

Copy link
Copy Markdown
Author

I have rechecked and signed the CLA. The status should be updated now. Please let me know if there are any other issues. @xuxiaowei-com-cn

@xuxiaowei-com-cn

Copy link
Copy Markdown
Collaborator

I have rechecked and signed the CLA. The status should be updated now. Please let me know if there are any other issues. @xuxiaowei-com-cn

After signing, the CLA will appear green instead of the current yellow.

image

@EvanYao826

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@xuxiaowei-com-cn I have signed the CLA again. The commit email is correctly set to the noreply format (155432245+EvanYao826@users.noreply.github.com). Could you please check if the CLA status has been updated? If it still shows as not signed, I may need to click the recheck link again.

@xuxiaowei-com-cn

Copy link
Copy Markdown
Collaborator

I have read the CLA Document and I hereby sign the CLA

@xuxiaowei-com-cn I have signed the CLA again. The commit email is correctly set to the noreply format (155432245+EvanYao826@users.noreply.github.com). Could you please check if the CLA status has been updated? If it still shows as not signed, I may need to click the recheck link again.

After you have completed the signing process, please click recheck.

@xuxiaowei-com-cn

Copy link
Copy Markdown
Collaborator

GitHub Actions run has been approved.

@uuuyuqi

uuuyuqi commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Hi @EvanYao826, thanks for the PR. This overlaps with #4319, which was opened earlier and also fixes #4296, while additionally covering a few related consistency concerns (atomic read-and-remove of the snapshot, distinguishing an empty snapshot from a missing one, namespace-aware key, plus unit tests). We're going to move forward with #4319 to close out the issue, so this PR will be closed in favor of that one.

Before submitting future PRs, a quick scan of open PRs and issue comments helps avoid duplicate work — but the effort here is appreciated regardless.

… in cluster mode

Fixes alibaba#4296. The config snapshot mechanism from PR alibaba#3644 was not applied to the
Spring Boot 3.x ConfigData API path (NacosConfigDataLoader). In Nacos cluster mode,
when a config change notification arrives from one node but the fetch goes to another
node that hasn't synced yet, the client gets stale config.

Assisted-by: Hermes Agent
@EvanYao826 EvanYao826 force-pushed the fix/nacos-config-data-loader-snapshot branch from 868ea6a to 4522b14 Compare May 25, 2026 11:31
@EvanYao826

Copy link
Copy Markdown
Author

Rebased onto latest 2025.1.x and resolved merge conflicts. The upstream already merged #4319 with a similar config snapshot fix — my PR now builds on top of that, adding the isEmpty() null-safety check and a debug log for snapshot cache hits.

@EvanYao826

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@EvanYao826

Copy link
Copy Markdown
Author

Hi @uuuyuqi, thanks for the review! You're right that this overlaps with #4319. After rebasing onto the latest 2025.1.x, the upstream already merged #4319's config snapshot fix. My PR now adds incremental improvements on top:

  1. isEmpty() null-safety check for the snapshot
  2. Debug-level logging for snapshot cache hits

If these additions are useful, I'm happy to keep this PR open. Otherwise, feel free to close it if the team considers #4319 sufficient. Let me know!

@EvanYao826

Copy link
Copy Markdown
Author

Hi, friendly ping — CLA is signed and all CI checks are passing. Could a maintainer take a look when available? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question: Is the fix in #3644 effective in version 2025.1.0.0?

4 participants