Repository navigation
fix: bypass idle check for silent start create task - #305
Conversation
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideImplementationClear incremental work queued during a successful force-bypass full scan before corrupted-index handling can return early, and pass the force-bypass setting to any Create rebuild so it inherits the same queue-clearing behavior.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/index/dbus/textindexdbus.cpp" line_range="123" />
<code_context>
if (!q->IndexDatabaseExists()) {
qInfo() << "TextIndexDBus: Index database does not exist, starting create task for:" << pathsToProcess;
- runtime->taskManager()->startTask(IndexTask::Type::Create, pathsToProcess);
+ runtime->taskManager()->startTask(IndexTask::Type::Create, pathsToProcess, IndexTask::Grade::None, true);
return;
}
</code_context>
<issue_to_address>
**Heavy scans ignore power limits**
When the silent-start Create task starts on battery or in power-save mode, or either state begins while it is running, `forceBypass` makes `TaskManager::canRun()` skip the battery and power-save checks, and `onEnvStateChanged()` skips pausing bypassed tasks, so the full scan runs and consumes resources instead of waiting.
Do not bypass the environment checks for this automatic Create task, so it is deferred or paused in those states.
</issue_to_address>
### Comment 2
<location path="src/index/dbus/textindexdbus.cpp" line_range="123" />
<code_context>
if (!q->IndexDatabaseExists()) {
qInfo() << "TextIndexDBus: Index database does not exist, starting create task for:" << pathsToProcess;
- runtime->taskManager()->startTask(IndexTask::Type::Create, pathsToProcess);
+ runtime->taskManager()->startTask(IndexTask::Type::Create, pathsToProcess, IndexTask::Grade::None, true);
return;
}
</code_context>
<issue_to_address>
**Unavailable paths prevent startup retry**
When a configured indexed directory is temporarily unavailable when silent start runs, such as a mount that is not ready yet, `CreateIndexHandler` returns failure when a configured source directory is temporarily unavailable, while `handleSilentStart` has already consumed its `call_once`; task completion records the failure but does not retry, so indexing remains absent until another request or service restart.
Retry silent creation after transient path failures, or defer consuming the one-shot until creation succeeds.
</issue_to_address>| if (!q->IndexDatabaseExists()) { | ||
| qInfo() << "TextIndexDBus: Index database does not exist, starting create task for:" << pathsToProcess; | ||
| runtime->taskManager()->startTask(IndexTask::Type::Create, pathsToProcess); | ||
| runtime->taskManager()->startTask(IndexTask::Type::Create, pathsToProcess, IndexTask::Grade::None, true); |
There was a problem hiding this comment.
🟡 Medium · Heavy scans ignore power limits
When the silent-start Create task starts on battery or in power-save mode, or either state begins while it is running, forceBypass makes TaskManager::canRun() skip the battery and power-save checks, and onEnvStateChanged() skips pausing bypassed tasks, so the full scan runs and consumes resources instead of waiting.
Do not bypass the environment checks for this automatic Create task, so it is deferred or paused in those states.
Prompt for AI agents
In `src/index/dbus/textindexdbus.cpp` at line 123:
**Heavy scans ignore power limits**
When the silent-start Create task starts on battery or in power-save mode, or either state begins while it is running, `forceBypass` makes `TaskManager::canRun()` skip the battery and power-save checks, and `onEnvStateChanged()` skips pausing bypassed tasks, so the full scan runs and consumes resources instead of waiting.
Do not bypass the environment checks for this automatic Create task, so it is deferred or paused in those states.| if (!q->IndexDatabaseExists()) { | ||
| qInfo() << "TextIndexDBus: Index database does not exist, starting create task for:" << pathsToProcess; | ||
| runtime->taskManager()->startTask(IndexTask::Type::Create, pathsToProcess); | ||
| runtime->taskManager()->startTask(IndexTask::Type::Create, pathsToProcess, IndexTask::Grade::None, true); |
There was a problem hiding this comment.
🟡 Medium · Unavailable paths prevent startup retry
When a configured indexed directory is temporarily unavailable when silent start runs, such as a mount that is not ready yet, CreateIndexHandler returns failure when a configured source directory is temporarily unavailable, while handleSilentStart has already consumed its call_once; task completion records the failure but does not retry, so indexing remains absent until another request or service restart.
Retry silent creation after transient path failures, or defer consuming the one-shot until creation succeeds.
Prompt for AI agents
In `src/index/dbus/textindexdbus.cpp` at line 123:
**Unavailable paths prevent startup retry**
When a configured indexed directory is temporarily unavailable when silent start runs, such as a mount that is not ready yet, `CreateIndexHandler` returns failure when a configured source directory is temporarily unavailable, while `handleSilentStart` has already consumed its `call_once`; task completion records the failure but does not retry, so indexing remains absent until another request or service restart.
Retry silent creation after transient path failures, or defer consuming the one-shot until creation succeeds.7bc01ab to
af70ebf
Compare
1. Root cause: ForceUpdateIndex starts a force-bypass Update task that clears the queue at launch. During near-instant zero-file execution, FS events enqueue incremental tasks (forceBypass=false). When the Update task fails with a corrupted index, handleCorruptedIndex() starts a Create rebuild and returns true, causing onTaskFinished to return early. The queue-clearing logic placed in finalizeIndexState is never reached because it sits after the handleCorruptedIndex guard. Even when the Create rebuild finishes, finalizeIndexState may return early if result.success is false, leaving the queue non-empty. currentIndexStatus() returns "WaitingIdle" instead of "Idle" 2. Fix: move the queue-clearing block from finalizeIndexState into onTaskFinished, placed before the handleCorruptedIndex call. This guarantees the queue is cleared regardless of whether handleCorruptedIndex returns true or false. Also pass wasForceBypass through to handleCorruptedIndex so the Create rebuild inherits forceBypass, ensuring the queue is cleared again when the rebuild finishes 3. Impact: only affects force-bypass full-scan tasks (Create/Update) that are not interrupted; non-force-bypass tasks and interrupted tasks are unchanged fix: 将队列清空逻辑移至 onTaskFinished 中 handleCorruptedIndex 之前 1. 根因:ForceUpdateIndex 启动的 forceBypass Update 任务在启动时清空 队列,但零文件场景下任务近乎瞬时完成,执行期间 FS 事件触发的增量 任务(forceBypass=false)被入队。当 Update 任务失败且索引损坏时, handleCorruptedIndex() 启动 Create 重建并返回 true,导致 onTaskFinished 提前返回。队列清空逻辑位于 finalizeIndexState 中, 在 handleCorruptedIndex 守卫之后,永远不会被执行到。即使 Create 重建完成,若 result.success 为 false,finalizeIndexState 也会提前 返回,队列仍非空。currentIndexStatus() 返回"等待空闲"而非"空闲" 2. 方案:将队列清空逻辑从 finalizeIndexState 移至 onTaskFinished 中 handleCorruptedIndex 调用之前,确保无论 handleCorruptedIndex 返回 true 还是 false,队列都能被清空。同时将 wasForceBypass 传递给 handleCorruptedIndex,使 Create 重建继承 forceBypass,确保重建完成 时再次清空队列 3. 影响:仅影响非中断的 forceBypass 全量任务(Create/Update); 非 forceBypass 任务及中断任务行为不变 Log: Fixed index showing "waiting idle" instead of "idle" after force update with no files to index Influence: - Test clicking "update index now" with no indexable files, verify status shows "idle" - Test clicking "update index now" with indexable files, verify index updates normally - Verify incremental file changes still trigger correct tasks after force update Log: 修复无待索引文件时点击"立即更新索引"后状态显示"等待空闲"而非"空闲"的问题 Influence: - 测试无待索引文件时点击"立即更新索引",验证状态显示"空闲" - 测试有待索引文件时点击"立即更新索引",验证索引正常更新 - 验证强制更新后增量文件变更仍能正确触发任务 PMS: BUG-384711 Change-Id: I6cd10d69c4b7dc787a561a66c82220ed56f85748
af70ebf to
2a815a3
Compare
|
/forcemerge |
7db884c
into
linuxdeepin:develop/snipe
|
This pr force merged! (status: unstable, merge_method: rebase) |
Root Cause Analysis
After system upgrade, clicking "Update Index Now" shows "WaitingIdle" instead of creating the index. The root cause is in
handleSilentStart()(textindexdbus.cpp:123), which callsstartTask(Create, paths)with defaultforceBypass=false. The Create task is auto-graded asHeavy, andcanRun(Heavy, false, env)returns false when the system is not idle, causing the task to be enqueued andcurrentIndexStatus()to return "WaitingIdle" instead of executing immediately.Fix
Explicitly pass
forceBypass=truetostartTask()inhandleSilentStart(), matching the existing pattern inForceUpdateIndex()(line 331) which already usesforceBypass=truefor user-initiated index operations. The change is a single-line parameter addition:startTask(Create, pathsToProcess, IndexTask::Grade::None, true).Change Safety Assessment
Code Safety
handleSilentStart()Create branch; no signature changes, no new interfaces, no public API changes8d481bcd), not a prior bug fix — this change does not revert any historical fixBusiness Impact Scope
handleSilentStart()andForceUpdateIndex()are unaffectedVerification Suggestion
根因分析
系统升级后点击"立即更新索引"显示"等待空闲"而非创建索引。根因位于
handleSilentStart()(textindexdbus.cpp:123),调用startTask(Create, paths)时使用默认参数forceBypass=false。Create 任务被自动分级为 Heavy,非空闲状态下canRun(Heavy, false, env)返回 false,任务入队,currentIndexStatus()返回"等待空闲"而非立即执行。修复方案
在
handleSilentStart()中显式传入forceBypass=true,与ForceUpdateIndex()(line 331)既有用法一致。改动为单行参数追加:startTask(Create, pathsToProcess, IndexTask::Grade::None, true)。改动安全评估
代码安全评估
handleSilentStart()Create 分支单行参数追加,无签名变更、无新增接口、无公开 API 变更8d481bcd),非历史 bug 修复产物,本次改动不撤销任何已有修复业务影响范围
handleSilentStart()Update 分支及ForceUpdateIndex()不受影响验证建议
Summary by Sourcery
Keep force-bypass full-scan and index-rebuild operations from being delayed or followed by redundant incremental work.
Bug Fixes: