Repository navigation
Conversation
RUSTYGET_TEST_STATE_SYNC_DELAY_MS delays every sync of a saved state file and of its directory, as a disk busy with a post-processing move does (6790: 0.4-3.5 s per fdatasync). queuesyncslow downloads six files with that delay at 1 s and FlushQueue=yes and bounds the time: while the queue coordinator waits for those syncs it hands out no articles. This commit alone shows the slowdown; the fix follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
The queue coordinator saves the partial states, the progress and the queue once a second under the queue lock. With FlushQueue=yes each save syncs the file and its directory; on 6790 a post-processing move kept the queue disk busy, a single fdatasync took 0.4-3.5 s, and while the coordinator waited it handed out no articles (108 MB/s fell to 4-20 MB/s, 10-50 of 205 connections busy). The content is still serialized under the lock, so every file is a consistent snapshot, but the write, the sync, the rename and the directory sync now run on a queue-saver thread (statesaver.rs) for the coordinator thread. Jobs run first in, first out; a newer save of a file still queued replaces its content in place, so partial states, progress and queue land in the order they were saved, and a delete goes behind the writes it follows. Crash safety is as before: .new, sync, rename, directory sync. Other threads write inline as before, after the jobs queued for the same file. Readers (restart, a file's article list reloaded) first run or wait for the file's queued job and read with no save touching it. The coordinator drains the saver before it exits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
A panic in a background save no longer kills the queue-saver thread (later saves and the coordinator's drain would wait for it forever). The message log n<id>.log is appended and read directly, so its delete stays inline instead of queueing behind other saves. The module doc states what crash-time ordering across files is (not) kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
queuesyncslow still took 37-41 s (bound 30 s, 86 s before) on Linux x86_64, arm64 and macOS: other threads (the API adding an NZB, post- processing, twin and dupe work, file completion) save the queue and the file infos inline under the queue lock, and the coordinator waits for that lock; and a coordinator reading a file whose save was queued ran that save, sync included, itself. While the coordinator runs, the saves of every thread are now queued; before and after (startup, the final saves of a shutdown) they run inline as before, and leaving the scope drains the queue. A reader of a file whose write is queued reads that content from memory instead of waiting for the sync; a queued delete runs at once (no sync). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
historyeditlist failed at 6846969d (x86_64 and arm64): an API edit's queue save was queued, the call answered, and a kill right after lost the change. Queuing every thread's saves made acknowledged changes non-durable, even against a plain process crash. Now only the coordinator's saves are queued and never waited for. A save another thread makes under the queue lock is queued too, and that thread waits for it right after it releases the lock (qqueue::CurrentQueueLock drop -> statesaver::queue_lock_released): the coordinator never waits for the lock during someone's sync, and an edit or an added NZB is on disk, synced as before, when the caller gets its answer. A write coalesced into a queued one keeps the older sequence number, so a waiter for the older save waits for the newer. Other saves (no queue lock held) run inline as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
settled(), an inline save superseding a queued one and a reader running a queued delete took the job off the queue and then waited, with the saver lock released, for an older save of the same file. In that gap the job was neither queued nor running, so a thread waiting for its save could return before the content was on disk. They now wait until the file is idle first and take and mark the job in one hold. Also fixes the indentation of one Job literal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
Codex Review Summary: ✅ CompletedThis 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. |
State files are queued to a FIFO saver thread instead of written inline under the queue lock, so slow syncs no longer stall the coordinator. A write coalesces into its first queued position, a delete goes to the back. While the coordinator runs every thread's saves are queued; a non-coordinator thread's save under the queue lock is waited for after unlock. Readers settle or read queued content from memory. Adds the RUSTYGET_TEST_STATE_SYNC_DELAY_MS hook and the queuesyncslow scenario. Squash of six reviewed commits (clean-room and delta reviews G2G). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
|
Merged as the locally signed squash commit 17d15f1 (verified on GitHub), fast-forward onto main 80c3fcd; tree identical to the reviewed head 7fb1871. Gate heads: farm Linux x86_64 + arm64 green (cargo 0, test-daemon 0, all scenarios) on c87bc1a3 (and earlier 08745810), review G2G. The final rebase onto 80c3fcd was patch-identical (range-diff all "=") over non-overlapping main commits. Farm runs on 7fb1871 continue as post-merge evidence. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7fb1871248
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Some(i) => { | ||
| st.queue.remove(i); | ||
| st.queue.push_back(job); | ||
| st.next_seq |
There was a problem hiding this comment.
Preserve outstanding tickets when replacing a queued job
When a non-coordinator thread queues a save under the queue lock and another thread replaces it with a delete before it runs (or replaces a delete with a write), this branch discards the original sequence number. wait_for only considers jobs whose sequence is less than or equal to the saved ticket, so it ignores the replacement and can return while that replacement is still queued or running. With a slow saver, the API caller can therefore receive its response while disk still contains the state preceding both operations, contrary to the promised durability after queue-lock release. Preserve the oldest outstanding sequence number when moving a replacement to the back, or explicitly transfer its waiters to the replacement.
Useful? React with 👍 / 👎.
Owner: 6790-keeper (deploys after merge).
What
State files (queue, progress, history, etc.) are written on a background saver thread (FIFO; a write coalesces into its first queued position, a delete goes to the back) instead of inline under the queue lock, so slow disk syncs no longer stall the coordinator. RsStateFile begin/finish_write go through it; readers settle or read queued content from memory. While the coordinator runs, every thread's saves are queued; a non-coordinator thread's save under the queue lock is queued with a ticket and waited for after unlock, so it is on disk before that thread goes on.
Test hook RUSTYGET_TEST_STATE_SYNC_DELAY_MS plus scenario queuesyncslow (FAIL before: 37-86 s vs bound 30 s; PASS after: x86_64 12.9 s, macOS 14.9 s).
Accepted durability notes (by design)
Review
Clean-room full review G2G plus delta reviews G2G on every fix. The final rebases onto main are patch-identical (range-diff all "="); main's changes do not touch these files.
Validation (GCE farm; Actions unavailable)
Per-head pass lines are in the comments. Earlier head 08745810 (base ba93ae1): x86_64 433/433, arm64 433/433, cargo_exit=0, daemon_exit=0. Rebased head c87bc1a3 (base e00226f): x86_64 436/436 after one flaky rerun (clientthreads, passed alone), arm64 436/436, cargo and test-daemon 0 on both. Evidence: ~/rustyget-requests/evidence/queue-saver-offthread/.
macOS: cargo test passes; known m5air-wrapper failures (directunpacksimple, fleetprobebusy, streammaxrun, quotafutureday, livepartrusted, livepartrustedtemp) also fail on unrelated heads (e.g. #735), pass on Linux; triaged separately.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM