dubbo-go icon indicating copy to clipboard operation
dubbo-go copied to clipboard

[FEATURE] Improve service-app mapping consistency, retry, and deduplication / 加强 service-app mapping 的一致性、重试与去重

Open Alanxtl opened this issue 6 months ago • 2 comments

上下文请参考 https://github.com/apache/dubbo-go/issues/3188#issuecomment-4582464870

Background

The #2534 refactor kept service-app mapping as a core part of the application-level metadata path. Providers publish interface-to-application mappings, and consumers use those mappings to discover applications. This issue only focuses on application-level service-app mapping reliability.

Related code:

  • metadata/mapping/metadata/service_name_mapping.go
  • metadata/report/nacos/report.go
  • metadata/report/zookeeper/report.go
  • metadata/report/etcd/report.go

Current Problems

The current mapping write path is relatively thin.

Specific problems:

  • retryTimes = 10 is hardcoded and has no sleep or backoff.
  • Nacos, Etcd, and Zookeeper mostly use read-modify-write with comma-separated content.
  • Concurrent writes may overwrite each other.
  • Etcd and Zookeeper use strings.Contains to detect existing app names, which can produce substring false positives.
  • Some implementations do not actually remove mapping listeners.

Suggestions

  • Replace hardcoded retry loops with configurable retry times, retry interval, and optional backoff.
  • Use CAS or version-aware updates to avoid concurrent write overwrites.
  • Parse app names as a set and use exact deduplication.
  • Complete listener removal where supported, or document unsupported behavior explicitly.
  • Add tests for concurrent mapping writes, duplicate app names, and listener removal.

背景

#2534 重构后,service-app mapping 仍是应用级 metadata 主链路的核心部分。provider 发布接口到应用名的映射,consumer 通过该映射发现应用。本 issue 只关注应用级 service-app mapping 的可靠性。

相关代码:

  • metadata/mapping/metadata/service_name_mapping.go
  • metadata/report/nacos/report.go
  • metadata/report/zookeeper/report.go
  • metadata/report/etcd/report.go

当前问题

当前 mapping 写入链路比较薄。

具体问题:

  • retryTimes = 10 是硬编码,并且没有 sleep 或 backoff。
  • Nacos、Etcd、Zookeeper 基本使用读旧值、拼逗号、写回的方式。
  • 并发写入时可能互相覆盖。
  • Etcd 和 Zookeeper 使用 strings.Contains 判断 app 是否存在,可能出现子串误判。
  • 部分实现没有真正移除 mapping listener。

建议

  • 用可配置的 retry times、retry interval 和可选 backoff 替代硬编码重试循环。
  • 使用 CAS 或版本感知更新,避免并发写覆盖。
  • 将 app names 解析为 set,并使用精确去重。
  • 在支持的实现中补齐 listener remove;不支持时明确文档化。
  • 增加并发 mapping 写入、重复 app name、listener remove 的测试。

Alanxtl avatar May 30 '26 10:05 Alanxtl

could i try it

NeverENG avatar May 30 '26 11:05 NeverENG

close via #3373

Alanxtl avatar Jun 25 '26 08:06 Alanxtl