Skip to content

Conversation

@BraveheartStone
Copy link
Contributor

修复通过 nacos 发现下游服务时,下游服务重启后,会将旧的IP覆盖新的IP。导致通过shenyu调用下游服务报错Can not find healthy upstream url, please check your configuration!

  1. 缓存实例逻辑修复
  2. 新增通过 selectorId 获取健康实例方法
  3. weight 支持 set 方法
  4. 重写 Upstream equals 方法(去除 weight 参与相等校验)

issues: #6144 #6144

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

…listening to the UpstreamList, which results in errors with valid instances.

1. 缓存实例逻辑修复
2. 新增通过 selectorId 获取健康实例方法
3. weight 支持 set 方法
4. 重写 Upstream equals 方法(去除 weight 参与相等校验)

issues: apache#6144 apache#6144
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where Nacos service discovery in ShenYu would incorrectly retain old IPs after downstream service restarts, causing "Can not find healthy upstream url" errors. The fix improves the upstream instance caching logic to properly handle service restarts and IP changes.

Key changes:

  • Modified Upstream.equals() to exclude weight from equality checks, preventing duplicate instances with different weights
  • Added setWeight() method to allow weight updates for existing upstream instances
  • Refactored UpstreamCacheManager.submit() to properly handle offline instances and update weights for existing upstreams

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Upstream.java Made weight field mutable and excluded it from equals() comparison to support weight updates without affecting instance identity
UpstreamCheckTask.java Added method to retrieve healthy upstream list by selector ID for cache synchronization
UpstreamCacheManager.java Rewrote submit() logic to properly handle offline instances, update weights, and sync with healthy upstream list

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Aias00 and others added 3 commits October 21, 2025 16:21
…er/cache/UpstreamCacheManager.java

Co-authored-by: Copilot <[email protected]>
…er/cache/UpstreamCacheManager.java

Co-authored-by: Copilot <[email protected]>
…er/cache/UpstreamCacheManager.java

Co-authored-by: Copilot <[email protected]>
@Aias00 Aias00 added this to the 2.7.0.3 milestone Oct 21, 2025
@Aias00 Aias00 merged commit 082e702 into apache:master Oct 21, 2025
42 checks passed
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.

2 participants