fix: 避免引擎日志重复写入 - #848
Merged
dengyh merged 1 commit intoAug 3, 2026
Merged
Conversation
dengyh
force-pushed
the
ai/fix-duplicate-engine-logs
branch
from
August 3, 2026 07:18
2fb326d to
89891fe
Compare
There was a problem hiding this comment.
代码审查总结
这个 PR 修复了引擎日志重复写入 root handler 的问题,思路清晰,实现正确:
propagate: False—pipeline、bamboo_engine、pipeline_engine这三个 logger 已经显式包含roothandler,设置propagate: False避免日志再通过传播链到达 root logger 造成重复输出。- 移除空 handler 回退逻辑 — 在非 DATABASE 模式下,
pipeline.eri.log的 handler 被过滤为空后,会通过propagate: True传播到父级pipeline(已有roothandler),不需要额外回退。 - 新增测试覆盖 — 测试用例验证了所有引擎 logger 在 DATABASE 和 PaaS3 模式下均只写入
roothandler 一次,且 DATABASE 模式下专用 handler 保持正常工作。
✅ 逻辑正确,无 Critical/Important 级别问题。代码简洁,测试充分。
There was a problem hiding this comment.
增量审查
本次 synchronize 事件触发后重新审查了 PR diff,当前变更内容与上次审查一致(单次提交 89891fe)。
上次审查结论仍然有效:
- ✅
propagate: False设置正确,三个 logger 已显式绑定roothandler,关闭传播避免重复写入 - ✅ 移除空 handler 回退逻辑合理——PaaS3 模式下
pipeline.eri.log的 handler 被过滤为空后,通过propagate: True传播到父级pipeline(已有roothandler) - ✅ 测试覆盖充分,验证了 DATABASE/PaaS3 两种模式下的日志路由正确性
无新增 Critical/Important 问题。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #848 +/- ##
==========================================
+ Coverage 83.10% 83.12% +0.02%
==========================================
Files 307 307
Lines 18167 18165 -2
==========================================
+ Hits 15098 15100 +2
+ Misses 3069 3065 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题原因
bamboo_engine、pipeline_engine和pipeline在自身绑定rootHandler 后仍向父 logger 传播,导致同一个 Handler 沿 logger 继承链被重复调用。PaaS3 日志模式下,pipeline.eri.log的数据库 Handler 被移除后又补上rootHandler,最多会将同一条日志写入三次。修改内容
bamboo_engine、pipeline_engine和pipeline设为对应日志链路的传播终点。pipeline.eri.log使用空 Handler 并传播到pipeline,避免重复绑定root。影响范围
仅调整 Python logging Handler 的传播路径,不修改日志内容、级别、格式、Trace 信息、节点信息或日志查询接口。合法的重复业务日志不会被过滤。
验证
pytest tests/project_settings tests/engine/task/test_node_log.py -q --no-cov:25 passed。pre-commit run --files config/default.py tests/project_settings/test_logging_settings.py:全部通过。