Repository navigation
Conversation
DSGApplication::getId() asks dde-application-manager to identify a PID. Any process that is not part of a desktop application - processes of other users, system services, short-lived helpers - makes the ApplicationManager answer with an error reply. That is a normal negative answer of a query API, not a failure. Logging it at warning level turns every caller that enumerates processes into a journal flood. Measured on UOS 25 (dtkcore 6.7.47, AM 1.2.59): a single process, deepin-defender-session-daemon, produced ~470k "Identify from AM failed" lines per day, ~180 lines/s at peak, and the session became unresponsive while systemd-journald was saturated. Keep the warning for real transport failures (no reply, timeout, disconnected bus, service unknown). The ordinary "not an application" answer remains available with QT_LOGGING_RULES="dtk.core.dsg.debug=true". Signed-off-by: wurongjie <wurongjie@uniontech.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: myml The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideImplementationKeep warnings for selected D-Bus transport failures while demoting other Identify errors to debug, without changing the empty return value.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/dsgapplication.cpp" line_range="219" />
<code_context>
+ || dbus_error_has_name(error.get(), DBUS_ERROR_SERVICE_UNKNOWN)) {
+ qCWarning(dsgApp) << "Identify from AM failed:" << error->message;
+ } else {
+ qCDebug(dsgApp) << "Identify from AM failed:" << error->message;
+ }
return QByteArray();
</code_context>
<issue_to_address>
**AM failures lose warning visibility**
When identify returns a D-Bus error outside the four listed names, `callDBusIdentifyMethod` routes the error to `qCDebug`, which release logging suppresses; it then returns an empty ID, leaving operators without a warning for the failure.
Log every Identify error reply at warning level instead of routing unlisted errors to `qCDebug`.
Also at `src/dsgapplication.cpp:213-216`.
</issue_to_address>| || dbus_error_has_name(error.get(), DBUS_ERROR_SERVICE_UNKNOWN)) { | ||
| qCWarning(dsgApp) << "Identify from AM failed:" << error->message; | ||
| } else { | ||
| qCDebug(dsgApp) << "Identify from AM failed:" << error->message; |
There was a problem hiding this comment.
🟡 Medium · AM failures lose warning visibility
When identify returns a D-Bus error outside the four listed names, callDBusIdentifyMethod routes the error to qCDebug, which release logging suppresses; it then returns an empty ID, leaving operators without a warning for the failure.
Log every Identify error reply at warning level instead of routing unlisted errors to qCDebug.
Also at src/dsgapplication.cpp:213-216.
Prompt for AI agents
In `src/dsgapplication.cpp` at line 219:
**AM failures lose warning visibility**
When identify returns a D-Bus error outside the four listed names, `callDBusIdentifyMethod` routes the error to `qCDebug`, which release logging suppresses; it then returns an empty ID, leaving operators without a warning for the failure.
Log every Identify error reply at warning level instead of routing unlisted errors to `qCDebug`.
Also at `src/dsgapplication.cpp:213-216`.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议:若未来需要检查的错误类型增多,可考虑将错误名列表提取为数组并循环检查,减少重复代码。当前4个条件无需重构。'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 当前代码已为最佳实践,无需修改。
// 若未来需要更灵活的错误分类,可考虑如下重构:
//
// static const char *transport_errors[] = {
// DBUS_ERROR_NO_REPLY,
// DBUS_ERROR_TIMEOUT,
// DBUS_ERROR_DISCONNECTED,
// DBUS_ERROR_SERVICE_UNKNOWN,
// };
//
// bool is_transport_error = false;
// for (const char *err_name : transport_errors) {
// if (dbus_error_has_name(error.get(), err_name)) {
// is_transport_error = true;
// break;
// }
// }
//
// if (is_transport_error) {
// qCWarning(dsgApp) << "Identify from AM failed:" << error->message;
// } else {
// qCDebug(dsgApp) << "Identify from AM failed:" << error->message;
// }本报告由 AI 代码审查工具自动生成 |
|
TAG Bot New tag: 6.7.54 |
标题
fix: demote expected Identify failures to debug level
正文
问题
DSGApplication::getId(pid)是 dtkcore 提供给所有应用的查询接口:给一个 PID,问dde-application-manager这是哪个桌面应用。对于不属于任何桌面应用的进程(其他用户的进程、
system.slice下的系统服务、短命的helper/子进程),AM 会正常回一个 D-Bus error(
Identify failed.)。这是查询接口的正常否定结果,但 dtkcore 在
src/dsgapplication.cpp:204用qCWarning打成警告:调用方只要按 PID 批量查询,就会把 journal 刷满。
实测影响(UOS 25 Professional,dtkcore 6.7.47 / dde-application-manager 1.2.59)
deepin-defender-session-daemon单进程产生的该行日志AppId is fetched from AM)journald 被这条日志打满后,所有 journald 客户端(dde-shell、kwin、桌面托盘)一起变慢,
现象是桌面卡死、鼠标拖影、
MemAvailable却还有 15 GiB——很容易被误判成内存问题。同一时刻 AM 侧还会为每次查询再打一条
process CGroups file failed.,即一次探测两条日志,所以两边都需要修(AM 侧的 PR 另提)。
改动
qCWarning;qCDebug。dsgApp分类在 release 构建下的默认级别是QtInfoMsg(见文件头Q_LOGGING_CATEGORY(dsgApp, "dtk.core.dsg", QtInfoMsg)),所以默认不会再输出;需要排查时:行为兼容性:返回值完全不变(仍然是空
QByteArray),只改日志级别,任何调用方都无需改动。验证
g++ -fsyntax-only通过(Qt 6.8.0 + libdbus-1);dbus_error_has_name/DBUS_ERROR_*宏在 libdbus-1 头文件中均可用,无新增依赖;journalctl --since "1 min ago" | wc -l从~22,000 行/分钟降到正常量级。
说明
更彻底的方案是在 AM 侧让
Identify对"非应用进程"返回成功 + 空 id,而不是 D-Bus error。但那会改变公开 D-Bus 接口语义、影响所有调用方,所以这里先做零风险的日志级别修正。
Summary by Sourcery
Reduce noise from expected desktop application identification failures while retaining visibility for genuine D-Bus transport errors.
Bug Fixes: