Skip to content

refactor: add more params when calculating the revision.#3224

Open
yangpixi wants to merge 4 commits intoapache:developfrom
yangpixi:fix-revision
Open

refactor: add more params when calculating the revision.#3224
yangpixi wants to merge 4 commits intoapache:developfrom
yangpixi:fix-revision

Conversation

@yangpixi
Copy link

@yangpixi yangpixi commented Feb 24, 2026

Description

Fixes #3223

目前revision计算机制考虑的参数过少,导致不同服务可能会计算出相同的revision,进而导致冲突

java部分计算代码:

public synchronized String calRevision() {
        StringBuilder sb = new StringBuilder();
        sb.append(app);
        for (Map.Entry<String, ServiceInfo> entry : new TreeMap<>(services).entrySet()) {
            sb.append(entry.getValue().toDescString());
        }
        return RevisionResolver.calRevision(sb.toString());
    }
public String toDescString() {
            return this.getMatchKey() + port + path + new TreeMap<>(getParams());
        }
public static String calRevision(String metadata) {
        return md5Utils.getMd5(metadata);
    }

该代码将字符串拼接起来后再计算md5,golang不方便拼接所有params,所以选取了几个特征参数计算

Checklist

  • I confirm the target branch is develop
  • Code has passed local testing
  • I have added tests that prove my fix is effective or that my feature works

@codecov-commenter
Copy link

codecov-commenter commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.88%. Comparing base (60d1c2a) to head (5450ab5).
⚠️ Report is 739 commits behind head on develop.

Files with missing lines Patch % Lines
...iscovery/customizer/service_revision_customizer.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3224      +/-   ##
===========================================
+ Coverage    46.76%   47.88%   +1.11%     
===========================================
  Files          295      463     +168     
  Lines        17172    33730   +16558     
===========================================
+ Hits          8031    16151    +8120     
- Misses        8287    16273    +7986     
- Partials       854     1306     +452     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

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

把java对应计算方式的源码地址贴到注释里面,并且在评论区里也发一份我们对照着review一下

@yangpixi
Copy link
Author

把java对应计算方式的源码地址贴到注释里面,并且在评论区里也发一份我们对照着review一下

ok

Copy link
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

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

把这两个相同的代码段抽成一个公共的方法放在metadata/info/metadata_info.go或者其他合适的地方吧,然后补写一下新方法的单元测试

@Alanxtl
Copy link
Contributor

Alanxtl commented Feb 25, 2026

另外constant.InterfaceKey这个字段需不需要加入到计算的过程中呀

@yangpixi
Copy link
Author

另外constant.InterfaceKey这个字段需不需要加入到计算的过程中呀

u.Path获取的value和interface是一样的,应该不需要考虑了

@sonarqubecloud
Copy link

@yangpixi
Copy link
Author

把这两个相同的代码段抽成一个公共的方法放在metadata/info/metadata_info.go或者其他合适的地方吧,然后补写一下新方法的单元测试

考虑了一下,没有必要再计算一次revision,直接将已经计算出来的revision赋值给metaInfo这个变量就行

Copy link
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

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

lgtm

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] dubbo计算revision的时候参与计算的参数过少,导致无法正确区分不同服务

3 participants