Repository navigation
Run the hourly database vacuum in chunks that yield to requests - #5193
Merged
Merged
Conversation
One synchronous incremental_vacuum(20000) blocked the server event loop for 9-69s every hour on an 8 GB database. Vacuum the same 20,000 pages in 256-page chunks and yield to the event loop between them. Fixes #5192 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
…l-vacuum # Conflicts: # apps/server/test/services/database-maintenance-sweep.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
The hourly maintenance sweep ran one synchronous
PRAGMA incremental_vacuum(20000)on the server’s main thread. The investigation in #5192 recorded request stalls of 9–69 seconds on an 8 GB database with 4.2 GB of free pages.What changed
How you verified
45398863d60f7af26bc9aba0301dba9bc99ca151; no open P0/P1 findings.45398863d60f7af26bc9aba0301dba9bc99ca151, including six maintenance tests on Linux and Windows.Real end-to-end comparison: measurements, commands, and limits
Compared main
f9eae1c44cd67e3dcbf807809bda8999926f7967with candidate45398863d60f7af26bc9aba0301dba9bc99ca151on Node v24.21.0. Each ran its separately built server with fresh data and loopback ports, plus an enrolled built host daemon. Main source came fromgit archive; unchanged workspace dependency packages were shared.The synthetic 1.71 GB database contained 196,608 rows of 8 KiB blobs with alternating rows deleted. Both scheduled sweeps began with 195,937 free pages and reclaimed 20,000. The real scheduler triggered the hourly job on its first 10-second tick; no timer patch, test route, or direct maintenance invocation was used.
Three real GET requests ran every 20 ms for 18 seconds:
/api/v1/system/config,/api/v1/hosts, and/api/v1/hosts/:id/files/:absoluteProofPath. File reads traversed the connected daemon and returned verified contents. Both daemons remained connected afterward.The PR completed 526 responses inside the maintenance window; main completed one just before its synchronous vacuum. Main logged a 1,717 ms
incremental_vacuum(20000)call. The PR logged no vacuum/checkpoint statement above the existing 100 ms slow-query threshold.The measurement window starts at server listening + 10 seconds and ends at the maintenance completion log. It includes preceding sweep jobs; distributions include requests overlapping that window. The window lasted 1,754 ms on main and 3,599 ms on the PR. Yielding improves responsiveness but adds total sweep time; the worst PR request remained 1,330 ms under approximately 150 requests/second. This does not claim tail latency is eliminated.
Commands used from the candidate checkout (QA scripts and raw logs retained in this thread’s
.qa-5193/directory):The driver creates its data root using
mktemp -d .qa-5193/data.XXXXXX, seeds SQLite, startsnode apps/server/dist/index.js, enrolls viaPOST /internal/hosts/enroll-key, and startsnode apps/host-daemon/dist/index.js. Both processes receive explicit isolatedBB_DATA_DIRand port settings. All owned processes were cleaned up; no production data was used.Coverage is the core API, scheduled maintenance, and real daemon RPC. Targeted builds lacked bundled plugin artifacts and emitted equivalent startup warnings; plugin/provider/UI behavior is outside this pass. Remote CI ran the tests; local builds only supported real-product QA.
Recommendation: SHIP this candidate, subject to the user’s merge decision. Nothing has been merged.
Part of #5192 (row 1: hourly vacuum)
BB-Thread: Investigate slow command lookup
BB-Thread-ID: thr_vg2ig7xcqm