Fix SQLite concurrency and queue visibility - #315
Conversation
|
Warning Review limit reached
Next review available in: 38 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughSQLite initialization now requires WAL and write transactions acquire immediate locks. Cache refreshes support scheduled-job execution, process spawning preserves selected systemd user-bus variables, and the dashboard updates execution history, cache invalidation, and chat metadata display. ChangesSQLite concurrency behavior
Job execution dashboard flow
Cache refresh execution flow
Scoped process environments
Chat header metadata
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
backend/src/database.ts (1)
451-456: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winVerify the WAL switch actually succeeded.
PRAGMA journal_mode = WALis run via.run()and its result is discarded. If WAL can't be enabled for some reason (unsupported filesystem, read-only mount, etc.), SQLite silently falls back to a different journal mode with no error and no log — quietly defeating the entire point of this PR (avoiding lock-upgrade failures). The test suite already checks this viadatabase.query("PRAGMA journal_mode").get(); consider doing the same here and logging/throwing if the mode isn'twal.🛡️ Proposed fix to verify WAL mode
- initializedDatabase.run("PRAGMA journal_mode = WAL"); + const journalMode = initializedDatabase + .query("PRAGMA journal_mode = WAL") + .get() as { journal_mode: string } | undefined; + if (journalMode?.journal_mode !== "wal") { + console.warn( + `Expected WAL journal mode, got "${journalMode?.journal_mode}" for ${databasePath}` + ); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/src/database.ts` around lines 451 - 456, Verify the journal mode after the PRAGMA in the database initialization flow: query the result of “PRAGMA journal_mode” and confirm it is “wal” case-insensitively. If WAL was not enabled, log the failure or throw an initialization error before calling runSchemaSql, preserving the existing successful initialization path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@backend/src/database.ts`:
- Around line 451-456: Verify the journal mode after the PRAGMA in the database
initialization flow: query the result of “PRAGMA journal_mode” and confirm it is
“wal” case-insensitively. If WAL was not enabled, log the failure or throw an
initialization error before calling runSchemaSql, preserving the existing
successful initialization path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 20d64548-8a49-4674-a675-ab7833bf09f1
📒 Files selected for processing (20)
backend/src/chat/openClawChatSnapshotStore.tsbackend/src/database.tsbackend/src/services/backups.tsbackend/src/services/cacheRefresh.tsbackend/src/services/dockerUpdater.tsbackend/src/services/gitHygiene.tsbackend/src/services/logRotation.tsbackend/test/openClawChatSnapshotStore.test.tssrc/components/features/chat/ChatHeader.tsxsrc/components/features/dashboard/ServiceActionsCard.tsxsrc/components/features/jobs/JobExecutionQueueCard.tsxsrc/hooks/useBackups.tssrc/hooks/useCache.tssrc/hooks/useJobExecutions.tssrc/hooks/useOpsActions.tssrc/hooks/useScheduledJobs.tssrc/pages/Dashboard.tsxsrc/test/chatHeader.test.tsxsrc/test/componentBehavior.test.tsxsrc/test/frontendBehavior.test.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
- GitHub Check: Analyze JavaScript and TypeScript
- GitHub Check: backend-checks
- GitHub Check: frontend-checks
🔇 Additional comments (19)
src/hooks/useJobExecutions.ts (1)
52-60: LGTM!Also applies to: 73-76
src/hooks/useBackups.ts (1)
5-5: LGTM!Also applies to: 71-71, 92-92, 112-112, 133-133
src/hooks/useCache.ts (1)
4-4: LGTM!Also applies to: 152-152
src/hooks/useOpsActions.ts (1)
1-4: LGTM!Also applies to: 109-119
src/hooks/useScheduledJobs.ts (1)
5-5: LGTM!Also applies to: 185-185
src/components/features/jobs/JobExecutionQueueCard.tsx (1)
8-8: LGTM!Also applies to: 26-56, 183-223
src/components/features/dashboard/ServiceActionsCard.tsx (1)
17-22: LGTM!Also applies to: 158-158
src/pages/Dashboard.tsx (1)
33-33: LGTM!Also applies to: 317-320
src/test/componentBehavior.test.tsx (1)
3264-3265: LGTM!src/test/frontendBehavior.test.tsx (1)
132-132: LGTM!Also applies to: 2076-2092
src/components/features/chat/ChatHeader.tsx (1)
6-7: LGTM!Also applies to: 53-56, 93-95
src/test/chatHeader.test.tsx (1)
60-64: LGTM!backend/src/chat/openClawChatSnapshotStore.ts (1)
523-535: LGTM!Also applies to: 537-548, 661-692, 694-703
backend/src/services/backups.ts (1)
1095-1095: LGTM!backend/src/services/cacheRefresh.ts (1)
2383-2383: LGTM!backend/src/services/dockerUpdater.ts (1)
2069-2069: LGTM!Also applies to: 2806-2806
backend/src/services/gitHygiene.ts (1)
510-510: LGTM!backend/src/services/logRotation.ts (1)
1987-1987: LGTM!backend/test/openClawChatSnapshotStore.test.ts (1)
31-87: LGTM!
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc538f6ea9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/src/database.ts`:
- Around line 445-463: Update enableRequiredWalJournalMode to catch errors from
the PRAGMA journal_mode query, close databaseConnection on a best-effort basis,
and rethrow the original error. Preserve the existing journal-mode validation
and connection-closing behavior when the query succeeds but does not return
“wal”.
In `@docs/architecture/database.md`:
- Around line 104-105: The destructive reset commands in
docs/architecture/database.md lines 104-105 and docs/operations/runbooks.md
lines 62-63 must fail closed: add the same set -euo pipefail guard and
five-second SQLite busy timeout before the DELETE statements in both locations,
ensuring deletion cannot proceed after backup, permission, or integrity-check
failure.
- Around line 67-72: Resolve db_path from the service environment’s
MIRA_DASHBOARD_DB_PATH before each SQLite backup instead of hardcoding the
default path. Apply this to docs/architecture/database.md lines 67-72 and
99-103, and docs/operations/runbooks.md lines 57-61; keep each existing backup,
permission, and validation flow unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2b7856a3-ec8a-429e-a455-28e96f9a26d7
📒 Files selected for processing (16)
backend/src/database.tsbackend/src/lib/jobResources.tsbackend/src/lib/processes.tsbackend/src/routes/cacheRoutes.tsbackend/src/services/cacheRefresh.tsbackend/test/jobExecutionQueue.test.tsbackend/test/openClawChatSnapshotStore.test.tsbackend/test/serviceBehavior.test.tsdocs/architecture/database.mddocs/operations/runbooks.mddocs/setup/production-deploy.mdsrc/hooks/useBackups.tssrc/hooks/useCache.tssrc/pages/Dashboard.tsxsrc/test/frontendBehavior.test.tsxsrc/test/pageBehavior.test.tsx
💤 Files with no reviewable changes (1)
- src/pages/Dashboard.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
- src/hooks/useCache.ts
- backend/test/openClawChatSnapshotStore.test.ts
- src/hooks/useBackups.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: CodeQL
- GitHub Check: Analyze JavaScript and TypeScript
- GitHub Check: backend-checks
- GitHub Check: frontend-checks
🔇 Additional comments (20)
src/test/pageBehavior.test.tsx (1)
2999-3001: LGTM!backend/src/routes/cacheRoutes.ts (3)
11-23: LGTM!
263-291: LGTM!
351-354: LGTM!backend/test/serviceBehavior.test.ts (3)
821-824: LGTM!
863-882: LGTM!
909-934: LGTM!backend/src/lib/jobResources.ts (2)
101-124: LGTM!
141-142: LGTM!backend/src/lib/processes.ts (2)
1-1: LGTM!
66-66: LGTM!backend/test/jobExecutionQueue.test.ts (2)
6-6: LGTM!
176-214: LGTM!backend/src/database.ts (1)
473-473: LGTM!backend/src/services/cacheRefresh.ts (1)
2273-2279: LGTM!Also applies to: 2391-2391
docs/architecture/database.md (2)
25-26: LGTM!Also applies to: 28-34
74-76: LGTM!docs/setup/production-deploy.md (2)
156-172: LGTM!
196-196: LGTM!src/test/frontendBehavior.test.tsx (1)
132-132: LGTM!Also applies to: 155-155, 2077-2093, 2102-2115, 2479-2485, 3544-3557
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac0c9db49b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2decc0f6b7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99f1296c00
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad2d1e4899
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
## Summary - refresh the active Execution queue query as soon as Dashboard cache, backup, scheduled-job/log-rotation, and ops-action requests are dispatched - add one short follow-up refresh while a long request is still pending, then retain the existing completion refresh - show only the effective chat speed in the header badge, such as `Standard` instead of `Default (Standard)` - add the missing Active class icon and use the shared centered empty state in the Execution queue card ## Verification - `bun test` — 394 passed, 0 failed - `bun run lint` - `bun run build` - `bun run format:check` - `git diff --check` ## Context Focused frontend follow-up to #315 and Mira Dashboard task #367. No API changes, dependencies, or new UI/state patterns.
Summary
Why
PR #314 split the web and worker execution planes. The production rollout exposed one transient
database is lockedfailure while both processes wrote to SQLite. The Jobs queue also polled every 15 seconds while idle and only rendered active executions, so short jobs could complete without ever appearing.Verification
All local checks ran inside CPU/memory-limited systemd scopes:
backend/test/openClawChatSnapshotStore.test.ts: 13 passedsrc/test/chatHeader.test.tsx: 2 passedgit diff --check: passedFull build, typecheck, lint, and test coverage are delegated to GitHub CI to avoid resource contention on the production VPS.
Production rollout note
The live database was backed up and migrated to WAL before this PR. Both split services are active with zero restarts, queue capacity is
1/1, and a post-migration manual worker job completed successfully without a lock error. The backup is:/home/ubuntu/.local/state/mira-dashboard-rollbacks/task-367-20260723T1407CEST/mira-dashboard.pre-wal.db