Pull Request has been successfully merged by CANN-robot.
(Thank you for zhaowenrui's contribution.)变更摘要
本次变更针对动态组(GroupPolicy::DYNAMIC)在构建调度请求时可能抛出 std::bad_alloc 的问题:在 GroupEntity::ReprocessInTryPush 中对 std::make_shared 及 decisions/dsts 的 emplace_back 扩容进行异常捕获,异常发生时清空 dynamicRequest、记录错误日志并返回 FSM_FAILED。为此将 Entity::ReprocessInTryPush 虚接口及 GroupEntity 实现的返回类型由 void 调整为 FsmStatus,TryPushState::PreProcess 据此在失败时提前结束处理,避免发送部分请求或进入等待决策状态,复用既有 FSM_FAILED 处理路径。
主要改动
ReprocessInTryPush接口返回值调整:Entity与GroupEntity中的ReprocessInTryPush由void改为返回FsmStatus,基类默认实现返回FSM_SUCCESS,非动态组策略同样返回成功,使调用方能够感知失败。- 内存分配异常捕获:
GroupEntity::ReprocessInTryPush引入<new>并用try/catch (const std::bad_alloc&)包裹请求对象创建与目的组追加逻辑,捕获后执行dynamicRequest.reset()、输出DGW_LOG_ERROR并返回FSM_FAILED,不再依赖原DGW_CHECK_RET_VOID空指针校验。 TryPushState::PreProcess失败短路:在遍历reprocessDstEntities时检查ReprocessInTryPush的返回状态,非FSM_SUCCESS时直接返回该状态,从而跳过SendRequestForDynamicGroup及后续状态设置。- 回归测试覆盖分配失败场景:
entity_utest.cpp新增ExhaustChildAddressSpace辅助函数(通过RLIMIT_AS限制并耗尽分配器存储),在子进程内验证请求对象分配失败与dsts扩容失败均返回FSM_FAILED且dynamicRequest被清空。 - 上层行为测试:
queue_schedule_utest.cpp新增用例,通过桩替换GroupEntity::ReprocessInTryPush返回FSM_FAILED,验证ChangeState(FSM_TRY_PUSH_STATE)返回失败、SendRequest未被调用、发送数据列表为空且未进入等待决策状态。
🧩 本次 Review 已使用自定义 Skill:




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 |
|---|---|---|
| src/queue_schedule | ✅ ZhaiPeiChao, LiWei79 (2/2) | ✅ ZhaiPeiChao (1/1) |
| tests/ut/queue_schedule | ✅ ZhaiPeiChao, LiWei79 (2/2) | ✅ ZhaiPeiChao (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhaowenrui666, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm
/approve


/lgtm


Pull Request
描述
动态组构建调度请求时,make_shared 或 vector 扩容抛出的 std::bad_alloc 原本会沿调用链向外传播。
在 TryPushState::PreProcess 的动态组请求构建循环外增加 try/catch,捕获 std::bad_alloc、记录错误并返回已有的 FSM_FAILED。失败时不进入发送请求、设置等待决策状态或挂入发送列表的路径,局部请求与 DataObj 随返回自动释放。保持 ReprocessInTryPush 接口及各实体实现不变。
只修改一个业务文件,新增一个回归用例,验证调用抛出 bad_alloc 时返回失败、不下发请求且不遗留等待状态或发送对象;已有动态组成功路径用例继续覆盖正常行为。
变更类型
关联的Issue
#1341
如何测试
重新编译后,2 个相关套件共 153 个用例全部通过。build/tests/ut/queue_schedule/ut/queue_schedule_main_ut --gtest_filter='EntityUTest.*:QueueScheduleUTest.*'核对清单
其他信息
本次仅保护 TryPushState 中的动态组请求构建循环,未扩展为整个事件循环的内存不足恢复机制。采用已有 CMake 目标构建规则完成 Host UT 验证,未运行真实设备测试。