Repository navigation
fix: bypass idle check for all index creation and update task paths - #301
Johnson-zs wants to merge 1 commit into
Conversation
Reviewer's GuideUses of the APIPass forceBypass=true for silent-start creation and D-Bus CreateIndexTask and UpdateIndexTask calls in both text and OCR services so these tasks bypass the idle check.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[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 |
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>
**Full indexing ignores power safeguards**
When silent startup starts with a missing index database while the device is on battery or in power-save mode, or enters either state during the scan, `forceBypass` makes `TaskManager::canRun()` accept the Heavy Create and `onEnvStateChanged()` skip pausing it, so the full scan and optimization consume resources despite the power policy.
Change the forced-create path so it bypasses only the idle gate and still honors battery and power-save checks and pauses.
</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 leave index uncreated**
When a configured indexed directory is temporarily unavailable when silent startup launches the forced Create, such as while a mount is still coming online, `CreateIndexHandler` returns failure when an indexed directory is unavailable, and the silent-start `call_once` has already consumed its only attempt. Later file-list events are skipped while the database is not ready, so the index remains absent after the directory becomes available.
Defer or retry the Create when its source directories become available instead of consuming the one-time startup attempt on a missing path.
</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 · Full indexing ignores power safeguards
When silent startup starts with a missing index database while the device is on battery or in power-save mode, or enters either state during the scan, forceBypass makes TaskManager::canRun() accept the Heavy Create and onEnvStateChanged() skip pausing it, so the full scan and optimization consume resources despite the power policy.
Change the forced-create path so it bypasses only the idle gate and still honors battery and power-save checks and pauses.
Prompt for AI agents
In `src/index/dbus/textindexdbus.cpp` at line 123:
**Full indexing ignores power safeguards**
When silent startup starts with a missing index database while the device is on battery or in power-save mode, or enters either state during the scan, `forceBypass` makes `TaskManager::canRun()` accept the Heavy Create and `onEnvStateChanged()` skip pausing it, so the full scan and optimization consume resources despite the power policy.
Change the forced-create path so it bypasses only the idle gate and still honors battery and power-save checks and pauses.| 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 leave index uncreated
When a configured indexed directory is temporarily unavailable when silent startup launches the forced Create, such as while a mount is still coming online, CreateIndexHandler returns failure when an indexed directory is unavailable, and the silent-start call_once has already consumed its only attempt. Later file-list events are skipped while the database is not ready, so the index remains absent after the directory becomes available.
Defer or retry the Create when its source directories become available instead of consuming the one-time startup attempt on a missing path.
Prompt for AI agents
In `src/index/dbus/textindexdbus.cpp` at line 123:
**Unavailable paths leave index uncreated**
When a configured indexed directory is temporarily unavailable when silent startup launches the forced Create, such as while a mount is still coming online, `CreateIndexHandler` returns failure when an indexed directory is unavailable, and the silent-start `call_once` has already consumed its only attempt. Later file-list events are skipped while the database is not ready, so the index remains absent after the directory becomes available.
Defer or retry the Create when its source directories become available instead of consuming the one-time startup attempt on a missing path.b71a32c to
d9fbd8c
Compare
1. Root cause: handleSilentStart(), CreateIndexTask(), and UpdateIndexTask() in both TextIndexDBus and OcrIndexDBus call startTask() with default forceBypass=false; Create auto-grades to Heavy, canRun() requires env.idle, so the task is queued and currentIndexStatus() returns "WaitingIdle" instead of executing. On new machines the daemon triggers CreateIndexTask within seconds via D-Bus, long before the 180s handleSilentStart timer fires. 2. Fix: pass forceBypass=true in all three paths: handleSilentStart (existing), CreateIndexTask, and UpdateIndexTask, so index creation and update bypass the idle check and execute immediately. Consistent with ForceUpdateIndex which already passes forceBypass=true. 3. Impact: affects index creation and update when invoked via D-Bus by the daemon or silent start, for both text and OCR index services. ForceUpdateIndex path unchanged (already had forceBypass=true). Manual update via UI already worked correctly. fix: 修复所有索引创建和更新任务路径的空闲检查阻塞问题 1. 根因:TextIndexDBus 和 OcrIndexDBus 的 handleSilentStart()、 CreateIndexTask()、UpdateIndexTask() 调用 startTask() 使用默认参数 forceBypass=false,Create 任务自动分级为 Heavy,canRun() 要求用户 空闲才放行,任务被入队导致 currentIndexStatus() 返回"WaitingIdle" 而非执行。新装机器上 daemon 通过 D-Bus 在数秒内触发 CreateIndexTask,远早于 handleSilentStart 的 180 秒定时器。 2. 方案:在三条路径中均传入 forceBypass=true:handleSilentStart (已有)、CreateIndexTask、UpdateIndexTask,使索引创建和更新绕过 空闲检查立即执行,与已传 forceBypass=true 的 ForceUpdateIndex 保持 一致。 3. 影响:影响 daemon 通过 D-Bus 调用或静默启动触发的索引创建和更新 路径,覆盖文本索引和 OCR 索引服务。ForceUpdateIndex 路径不变(已有 forceBypass=true),UI 手动更新功能无变化。 Log: Fixed index showing "waiting for idle" instead of creating on new machines Influence: - Test index creation on a fresh machine with no index database and user active - Test CreateIndexTask D-Bus call bypasses idle check for both text and OCR - Test UpdateIndexTask D-Bus call bypasses idle check for both text and OCR - Test handleSilentStart still creates index when database is missing - Verify normal index update flow via UI still works as expected Log: 修复新装机器上索引显示"等待空闲"而非创建的问题 Influence: - 测试新装机器无索引数据库且用户活跃时索引创建行为 - 测试 CreateIndexTask D-Bus 调用绕过空闲检查(文本和 OCR) - 测试 UpdateIndexTask D-Bus 调用绕过空闲检查(文本和 OCR) - 测试 handleSilentStart 在数据库不存在时仍创建索引 - 验证通过 UI 正常更新索引流程无回归 PMS: BUG-384711
d9fbd8c to
28d5741
Compare
fix: bypass idle check for silent start create task when index DB missing
forceBypass=false; Create auto-grades to Heavy, canRun() requires
env.idle, so the task is queued and currentIndexStatus() returns
"WaitingIdle" instead of executing
check and executes immediately when the index database is missing
returns false; manual update and other paths unchanged
fix: 修复静默启动时索引数据库不存在导致等待空闲的问题
forceBypass=false,Create 任务自动分级为 Heavy,canRun() 要求
用户空闲才放行,任务被入队导致 currentIndexStatus() 返回
"WaitingIdle" 而非执行创建
在索引数据库不存在时立即执行创建
的分支,手动更新及其他路径不受影响
Log: Fixed index showing "waiting for idle" instead of creating when database is missing
Influence:
Log: 修复索引数据库不存在时静默启动显示"等待空闲"而非创建的问题
Influence:
PMS: BUG-384711
Summary by Sourcery
Allow index creation tasks to bypass idle checks so missing databases are initialized immediately.
Bug Fixes: