Skip to content

fix: suppress zero-event log noise in fs event collector - #306

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
Johnson-zs:agent/bugfix/1add8f43e8c1
Dec 1, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
Johnson-zs:agent/bugfix/1add8f43e8c1

Conversation

@Johnson-zs

@Johnson-zs Johnson-zs commented Dec 1, 2026 •

Copy link
Copy Markdown

Root Cause Analysis

FSEventCollector::flushCollectedEvents() and FSEventController::onFlushFinished() unconditionally emit qDebug statistics every flush cycle (default 180s), even when all event lists (Created/Deleted/Modified/Moved) are empty. This produces ~180 lines of meaningless log per hour. The three unconditional qDebug calls are at fseventcollector.cpp:541, fseventcontroller.cpp:311, and fseventcontroller.cpp:316. Root cause confirmed by minimal reproduction (repro/demo/demo.cpp → 3 cycles × 3 lines of zero-event logs) and toggle experiment (adding guard → logs disappear, removing → logs reappear).

Fix

Added a guard condition in flushCollectedEvents() so statistics are logged only when at least one event list is non-empty. In onFlushFinished(), moved the "Flush finished, processing events" log after the empty-check and removed the "No file system events to process" log — when there are no events, the function silently returns. Implementation matches the fix suggestion in analysis-report.md section 10 with no deviation.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • No function signatures changed, no new interfaces, no control flow changes — only log output conditions modified
  • flushFinished signal still emitted normally; requestProcessFileChanges and requestProcessFileMoves still triggered normally
  • Both code locations introduced by commit 8d481bc, no subsequent modifications — no historical fix being reverted

Business Impact Scope

Affects the deepin-anything-index service's file system event monitoring module. When the file system is idle (no create/delete/modify/move events), debug logs are no longer printed. Event processing behavior is unchanged — file indexing continues to work as before. Users will notice reduced log noise in journalctl for the deepin-anything-index service.

Verification Suggestion

Verify that journalctl -u deepin-anything-index produces no "Flushing events" / "Flush finished" / "No file system events to process" logs when the file system is idle. Then create/modify/delete files and confirm event statistics logs still appear with correct counts.


根因分析

FSEventCollector::flushCollectedEvents() 和 FSEventController::onFlushFinished() 每次 flush 周期(默认 180 秒)无条件输出 qDebug 统计日志,即使 Created/Deleted/Modified/Moved 四个事件列表均为空。每小时产生约 180 行无意义日志。三处无条件 qDebug 调用分别位于 fseventcollector.cpp:541、fseventcontroller.cpp:311、fseventcontroller.cpp:316。根因经最小载体复现(repro/demo/demo.cpp → 3 周期 × 3 行全 0 事件日志)与翻转实验(添加守卫→日志消失,移除→日志复现)确认。

修复方案

在 flushCollectedEvents() 中添加守卫条件,仅当至少一个事件列表非空时才输出统计日志。在 onFlushFinished() 中,将 "Flush finished, processing events" 日志移到空检查之后,删除 "No file system events to process" 日志——无事件时静默返回。实现与分析报告第十节修复建议完全一致,无偏离。

改动安全评估

代码安全评估

  • 风险等级: 低
  • 不改变函数签名,不新增接口,不改变控制流——仅修改日志输出条件
  • flushFinished 信号仍正常发射;requestProcessFileChanges 和 requestProcessFileMoves 仍正常触发
  • 两处代码均由提交 8d481bc 引入,无后续修改——不存在撤销历史修复的风险

业务影响范围

影响 deepin-anything-index 服务的文件系统事件监控模块。文件系统空闲时(无创建/删除/修改/移动事件)不再打印调试日志。事件处理行为不变——文件索引功能继续正常工作。用户将在 journalctl 中看到 deepin-anything-index 服务的日志噪音显著减少。

验证建议

验证文件系统空闲时 journalctl -u deepin-anything-index 不再出现 "Flushing events" / "Flush finished" / "No file system events to process" 日志。然后创建/修改/删除文件,确认事件统计日志仍正常输出且计数正确。

Summary by Sourcery

Bug Fixes:

  • Suppress zero-event debug statistics during filesystem event flushes while retaining logs when events are present.

1. Root cause: FSEventCollector::flushCollectedEvents() and
   FSEventController::onFlushFinished() unconditionally emit qDebug
   statistics every flush cycle (default 180s), even when all event
   lists are empty, producing ~180 lines of meaningless log per hour
2. Fix: add a guard condition so statistics are logged only when at
   least one event list is non-empty; remove the "No file system
   events to process" log and silently return when there are no events
3. Impact: no behavior change for event processing; only redundant
   debug logs are suppressed when the filesystem is idle

fix: 抑制文件系统事件收集器的全0事件日志噪音

1. 根因:FSEventCollector::flushCollectedEvents() 和
   FSEventController::onFlushFinished() 每次 flush 周期(默认180秒)
   无条件输出 qDebug 统计日志,即使所有事件列表均为空,
   每小时产生约180行无意义日志
2. 方案:添加守卫条件,仅当至少一个事件列表非空时才输出统计
   日志;删除"No file system events to process"日志,无事件时
   静默返回
3. 影响:不影响事件处理逻辑,仅在文件系统空闲时抑制冗余调试日志

Log: Suppressed redundant debug logs when no filesystem events are collected
Influence:
  - Verify logs are silent when the filesystem is idle
  - Verify event statistics still appear when files are created, deleted, modified, or moved
  - Confirm no regression in file indexing functionality
Log: 文件系统空闲时不再输出无意义的事件收集日志
Influence:
  - 验证文件系统空闲时日志静默
  - 验证文件创建、删除、修改、移动时统计日志正常输出
  - 确认文件索引功能无回归
PMS: TASK-399323
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Suppress flush statistics when no events were collected, in both the collector and controller, while retaining logging for non-empty batches.

  • src/index/fsmonitor/fseventcollector.cpp L540-546
  • src/index/fsmonitor/fseventcontroller.cpp L311 (removed lines), L314 (removed lines), L317-318

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@Johnson-zs

Copy link
Copy Markdown
Author

/forcemerge

@deepin-bot
deepin-bot Bot merged commit 1218d28 into linuxdeepin:develop/snipe Dec 1, 2026
18 of 20 checks passed
@deepin-bot

deepin-bot Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable, merge_method: rebase)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants