Pull Request已成功合入, 合并人@CANN-robot
(感谢 youxiao 的贡献)变更摘要
本 PR 修复 LlmCommEntityMgr 中 ip_to_conns_ 的并发数据竞争:Prompt 侧 _BuiltIn_cluster_kv_data_sync_func 在 HandleRequest -> Accept 成功后会对 ip_to_conns_ 执行 emplace(持 entity_mutex_,可能触发 rehash),而 Host UnlinkClusters 经 _BuiltIn_cluster_unlink_func(ServerUnlink)在 DoServerUnlink 中通过 GetEntityByIp 对同一张 unordered_multimap 做无锁 find;这两条属不同 flow func,UDF worker 可并行执行,构成 data race。本次改动将 GetEntityByIp、Accept 路径上的查找/残留清理以及 ClearEntities 对 ip_to_conns_ 的访问统一纳入 entity_mutex_ 保护,并新增 FindServerEntityByIp 辅助方法及对应单元测试。
主要改动
GetEntityByIp加锁:GetEntityByIp内部增加std::lock_guard<std::mutex> lock(entity_mutex_),并相应去掉const限定,消除DoServerUnlink无锁find与 Accept 路径emplace/rehash 的并发冲突。- 新增
FindServerEntityByIp:HandleLinkRequest的 Accept 路径改为调用新私有方法FindServerEntityByIp(ip, cleared_residual),在锁内完成查找;命中实体则强制关闭旧连接并复用,server_entity_map_无对应实体时清理ip_to_conns_残留并标记cleared_residual,随后走新建实体流程。 ClearEntities加锁:ClearEntities中ip_to_conns_.clear()移入entity_mutex_锁保护范围内(server_entity_map_、client_entity_map_的清理原已在锁内)。- 新增单元测试:
llm_service_flow_func_utest.cpp新增get_entity_by_ip_locked_lookup用例,覆盖 CreateEntity 后按 IP 查到 conn、以及 server map 残留时清理ip_to_conns_的加锁查找行为。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ge | ✅ 张德鹏, xchu42, lining23666 (3/2) | ✅ 张德鹏 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
youyx, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [d787428938ce4610b43a911ec5d449fc][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_X86_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_dflow | ✅ SUCCESS | ||
| UT_Test_ge_common | ✅ SUCCESS | ||
| UT_Test_parser | ✅ SUCCESS | ||
| UT_Test_python | ✅ SUCCESS | >>>>> | |
| UT_Test_rt | ✅ SUCCESS | ||
| UT_Test_acl | ✅ SUCCESS | ||
| UT_Test_autofuse | ✅ SUCCESS | ||
| UT_Test_executor | ✅ SUCCESS | ||
| UT_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_dflow | ✅ SUCCESS | ||
| ST_Test_ge_common | ✅ SUCCESS | ||
| ST_Test_parser | ✅ SUCCESS | ||
| ST_Test_python | ✅ SUCCESS | >>>>> | |
| ST_Test_rt | ✅ SUCCESS | ||
| ST_Test_autofuse | ✅ SUCCESS | ||
| ST_Test_executor | ✅ SUCCESS | ||
| ST_Test_hetero | ✅ SUCCESS | ||
| ST_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_autofuse_e2e | ✅ SUCCESS | ||
| UT_Test_fe | ✅ SUCCESS | ||
| UT_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_fe | ✅ SUCCESS | ||
| ST_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_ge_common_atc | ✅ SUCCESS | ||
| UT_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_fe | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_fe | ✅ SUCCESS | >>>>> |
[2026-08-25 10:27:21] CI执行结束


流水线任务触发成功
任务链接 [8d27f678c6f541d1acfd0811d2030098][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_ARM_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-08-25 10:19:24] CI执行结束


流水线任务触发成功
任务链接 [a8de619925b142efa446dcb54ff1141a][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck_Pr | ✅ SUCCESS | ||
| antipoison | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| codecheck_dt | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |
[2026-08-25 10:17:36] CI执行结束


/lgtm


/lgtm


Pull Request
描述
Prompt 侧
_BuiltIn_cluster_kv_data_sync_func(空输入常驻调度)在HandleRequest->Accept成功后会对ip_to_conns_做emplace(持entity_mutex_,可能 rehash)。同时 HostUnlinkClusters会 Feed_BuiltIn_cluster_unlink_func(ServerUnlink),UDF 中DoServerUnlink通过GetEntityByIp无锁find同一张unordered_multimap。这两条是不同 flow func,UDF worker 可并行,构成 data race。本次将
GetEntityByIp、Accept 路径上的查找/残留清理、以及ClearEntities对ip_to_conns_的访问统一放到entity_mutex_下。变更类型
关联的Issue
无
如何测试
llm_service_flow_funcUT,覆盖get_entity_by_ip_locked_lookup:CreateEntity 后按 IP 查到 conn;server map 残留时清理ip_to_conns_。ip_to_conns_rehash 导致的崩溃。核对清单
其他信息
本地已对改动文件执行 pre-commit(clang-format / codespell / OAT)通过。