Run jobs side by side, up to --max-parallel #10

Merged
sophie merged 5 commits from pixel/594-run-jobs-side-by-side-up-to-max-parallel into main 2026-12-04 00:59:47 +11:00
Collaborator

Jobs can now run side by side: --max-parallel <N> (or RCLONE_MANAGER_MAX_PARALLEL), default 1, which behaves as before.

What changes

  • Runner: Run() starts N workers that take jobs off the scheduler's queue in the order they were queued. RunState holds Running (per job: rclone job id, stats, start time), Queue and History.
  • Scheduler: keeps an ordered record of what waits (Queued()); the same job is never queued or run twice, for "run now" too. poll and Trigger now share one enqueue under one lock, which also closes an old gap where a "run now" between poll's check and its send could queue a job twice.
  • Web: /api/state gains running (array) and queue (array). current is kept for older clients: it is running[0], or null. The page shows one card per running job and a Queue section; queued jobs are marked in the schedule.
  • TUI: one block per running job and a QUEUED: line.
  • bisync "all files changed" check: reads the failed attempt's own stats.
  • Error messages: rclone's daemon log does not say which job a line belongs to. A failed job that ran alongside another job at any point no longer gets the log's ERROR lines; a job that ran alone gets them as before. bisync's own log, which rclone returns with the job (output.output), is now read as well: "Must run --resync" appears only there and in the daemon log, so without it an overlapped bisync would stop resyncing by itself.
  • Shutdown: Stop ends every worker; shutdown waits (up to 5 s) for them to record their interrupted runs before the daemon stops. Interrupted runs stay out of the metrics.
  • README: the flag, the costs (connections per remote and memory add up across jobs), the error-message rule, the /api/state fields. just max_parallel=2 run passes the flag.

How it was checked

  • go vet ./... and go test -race -count=5 ./... pass. New tests: two jobs overlap with 2 workers while a third waits in the queue; the same job is not started twice; with 1 worker three jobs run in queue order, one at a time; Stop with two running jobs; the bisync check with another job's large stats beside it; the daemon-log rule (alone / overlapped); metrics with interleaved and concurrent runs; scheduler queue order; config validation.
  • On real rclone (v1.74), three copy jobs from a throttled local HTTP source with --max-parallel 2: two ran side by side with their own rclone job ids and stats, the third was in queue, "run now" for a queued and for a running job answered 409, and SIGTERM with two jobs running exited cleanly with no rclone rcd left.

Not checked

  • The justfile change (just is not installed where this was built).
  • The TUI was checked by rendering its view in a test, not in a live terminal.
  • The "Safety abort" text was not reproduced on real rclone; only "Must run --resync" was.

🤖 Generated with Claude Code

Jobs can now run side by side: `--max-parallel <N>` (or `RCLONE_MANAGER_MAX_PARALLEL`), default 1, which behaves as before. ## What changes - **Runner**: `Run()` starts N workers that take jobs off the scheduler's queue in the order they were queued. `RunState` holds `Running` (per job: rclone job id, stats, start time), `Queue` and `History`. - **Scheduler**: keeps an ordered record of what waits (`Queued()`); the same job is never queued or run twice, for "run now" too. `poll` and `Trigger` now share one enqueue under one lock, which also closes an old gap where a "run now" between poll's check and its send could queue a job twice. - **Web**: `/api/state` gains `running` (array) and `queue` (array). `current` is kept for older clients: it is `running[0]`, or `null`. The page shows one card per running job and a Queue section; queued jobs are marked in the schedule. - **TUI**: one block per running job and a `QUEUED:` line. - **bisync "all files changed" check**: reads the failed attempt's own stats. - **Error messages**: rclone's daemon log does not say which job a line belongs to. A failed job that ran alongside another job at any point no longer gets the log's ERROR lines; a job that ran alone gets them as before. bisync's own log, which rclone returns with the job (`output.output`), is now read as well: "Must run --resync" appears only there and in the daemon log, so without it an overlapped bisync would stop resyncing by itself. - **Shutdown**: `Stop` ends every worker; shutdown waits (up to 5 s) for them to record their interrupted runs before the daemon stops. Interrupted runs stay out of the metrics. - **README**: the flag, the costs (connections per remote and memory add up across jobs), the error-message rule, the `/api/state` fields. `just max_parallel=2 run` passes the flag. ## How it was checked - `go vet ./...` and `go test -race -count=5 ./...` pass. New tests: two jobs overlap with 2 workers while a third waits in the queue; the same job is not started twice; with 1 worker three jobs run in queue order, one at a time; Stop with two running jobs; the bisync check with another job's large stats beside it; the daemon-log rule (alone / overlapped); metrics with interleaved and concurrent runs; scheduler queue order; config validation. - On real rclone (v1.74), three copy jobs from a throttled local HTTP source with `--max-parallel 2`: two ran side by side with their own rclone job ids and stats, the third was in `queue`, "run now" for a queued and for a running job answered 409, and SIGTERM with two jobs running exited cleanly with no `rclone rcd` left. ## Not checked - The `justfile` change (`just` is not installed where this was built). - The TUI was checked by rendering its view in a test, not in a live terminal. - The "Safety abort" text was not reproduced on real rclone; only "Must run --resync" was. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jobCh cannot be looked into, so the scheduler now also keeps what sits on
it, in order: Queued() returns it and MarkStarted (unused until now) takes
a job off it when a worker picks it up. poll and Trigger share one enqueue
that checks inflight, sends and records under one lock; before, a Trigger
landing between poll's check and its send could queue the same job twice.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
--max-parallel N (or RCLONE_MANAGER_MAX_PARALLEL, default 1) starts N
workers that take jobs off the scheduler's queue in order. RunState holds
a list of running jobs, each with its own rclone job id, stats and start
time, and the queue; the web page and the TUI show all of them.
/api/state gains running and queue, and keeps current (running[0]) for
older clients.

Two places mixed jobs up once runs overlap: the bisync 'all files changed'
check now reads the failed attempt's own stats, and a failed job that ran
alongside another no longer gets the daemon's log lines in its error, as
they cannot be told apart by job. bisync's own log, which rclone returns
with the job, is read instead, so the automatic resync still works.

Stop ends every worker, and shutdown waits for them to record their
interrupted runs before the daemon is stopped.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
pixel-board requested changes 2026-12-03 22:23:08 +11:00
Dismissed
pixel-board left a comment

Read the whole diff, plus the scheduler and runner code around it. Ran go vet ./... and go test -race -count=3 ./...: both pass. The worker pool, the scheduler's enqueue/Queued/MarkStarted under one lock, the per-job Running entries, the bisync stats fix, Stop/shutdown ordering, the metrics, and the web/TUI/README for the flag and the API all match what task #594 asks, and I found no problem in them.

Must change: bisync's output.output is not that job's own log. rclone captures it by redirecting the daemon's global logger while the bisync runs, so it holds every job's lines from that time. I checked this on real rclone v1.74.3: a bisync that overlapped a failing copy for about 1 s came back with 10,795 of the copy's ERROR lines in its output. Fed through buildErrorMessage as a failed, overlapped run, that becomes a 2.2 MB error made of the copy job's errors. So an overlapped bisync is still given another job's errors, which the task asks to prevent. And because nothing caps the output, even a bisync that ran alone can now record an unbounded error string, where the daemon log used to be capped at 30 lines. That string goes into History, into /api/state every second, and into the TUI.

What would be right: use the output only to spot bisync's retry markers when the run overlapped, and cap the lines taken from it in every case. Correct the README sentence and the code comment that say the output belongs to the job alone. Add a test with a foreign ERROR line in the fake's output. Details are in the line comments.

Not checked: the justfile change, and the TUI in a live terminal.

Review by pixel: task #609, round 1 of 3, commit c4a4910aa3.

Read the whole diff, plus the scheduler and runner code around it. Ran `go vet ./...` and `go test -race -count=3 ./...`: both pass. The worker pool, the scheduler's `enqueue`/`Queued`/`MarkStarted` under one lock, the per-job `Running` entries, the bisync stats fix, Stop/shutdown ordering, the metrics, and the web/TUI/README for the flag and the API all match what task #594 asks, and I found no problem in them. **Must change:** bisync's `output.output` is not that job's own log. rclone captures it by redirecting the daemon's global logger while the bisync runs, so it holds every job's lines from that time. I checked this on real rclone v1.74.3: a bisync that overlapped a failing copy for about 1 s came back with 10,795 of the copy's ERROR lines in its output. Fed through `buildErrorMessage` as a failed, overlapped run, that becomes a 2.2 MB error made of the copy job's errors. So an overlapped bisync is still given another job's errors, which the task asks to prevent. And because nothing caps the output, even a bisync that ran alone can now record an unbounded error string, where the daemon log used to be capped at 30 lines. That string goes into History, into `/api/state` every second, and into the TUI. What would be right: use the output only to spot bisync's retry markers when the run overlapped, and cap the lines taken from it in every case. Correct the README sentence and the code comment that say the output belongs to the job alone. Add a test with a foreign ERROR line in the fake's output. Details are in the line comments. Not checked: the `justfile` change, and the TUI in a live terminal. Review by pixel: task #609, round 1 of 3, commit c4a4910aa3226a1491602a38c522317b711ee688.
README.md Outdated
@ -24,0 +48,4 @@
do not say which job they came from, so for a job that ran alongside
another job at any point, they are left out (it would otherwise risk
showing another job's errors); the error then holds only what rclone's API
reported for that job. bisync is the exception: rclone hands each bisync
Collaborator

"rclone hands each bisync run its own log back" is not true when jobs overlap: the output is the daemon's whole log while the bisync ran, every job's lines included (see the comment on runner/runner.go:484). This needs to change along with the code, and so does the comment at runner/runner.go:479-483 ("it belongs to this job alone").

"rclone hands each bisync run its own log back" is not true when jobs overlap: the output is the daemon's whole log while the bisync ran, every job's lines included (see the comment on `runner/runner.go:484`). This needs to change along with the code, and so does the comment at `runner/runner.go:479-483` ("it belongs to this job alone").
Author
Collaborator

Fixed in 3dc787e: the README now says the returned log is everything rclone logged while the bisync ran, that only the two retry lines are read from it, and that with another bisync alongside none is read and there is no automatic retry in that run. The code comment is corrected too.

Fixed in 3dc787e: the README now says the returned log is everything rclone logged while the bisync ran, that only the two retry lines are read from it, and that with another bisync alongside none is read and there is no automatic retry in that run. The code comment is corrected too.
@ -0,0 +363,4 @@
// bisync's own log comes back in its job/status output; the retry decision
// reads it there, so it works even when the daemon's log is left out because
// another job ran alongside.
func TestBisyncResyncDetectedFromItsOwnOutputWhenOverlapped(t *testing.T) {
Collaborator

The fake's output here contains only the bisync's own lines, so this test rests on the very assumption that real rclone breaks. Add a foreign ERROR line (another job's) to output and assert that h.Error / the retry decision does not quote it. With the code as it is, that assertion fails.

The fake's `output` here contains only the bisync's own lines, so this test rests on the very assumption that real rclone breaks. Add a foreign `ERROR` line (another job's) to `output` and assert that `h.Error` / the retry decision does not quote it. With the code as it is, that assertion fails.
Author
Collaborator

Fixed in 3dc787e. The test is replaced by TestBisyncRetryMarkerReadFromOutputWhenOverlappedByCopy: the fake's output holds a copy job's ERROR : f17528: Failed to copy line beside the markers, and it asserts the retry happens and the final error does not quote the foreign line. Added TestBisyncNotRetriedWhenOverlappedByAnotherBisync and TestBisyncOutputCappedWhenAlone (100 ERROR lines, only the last 30 used).

Fixed in 3dc787e. The test is replaced by `TestBisyncRetryMarkerReadFromOutputWhenOverlappedByCopy`: the fake's output holds a copy job's `ERROR : f17528: Failed to copy` line beside the markers, and it asserts the retry happens and the final error does not quote the foreign line. Added `TestBisyncNotRetriedWhenOverlappedByAnotherBisync` and `TestBisyncOutputCappedWhenAlone` (100 ERROR lines, only the last 30 used).
@ -365,0 +481,4 @@
// reason lives: status.Error says only "bisync aborted", while "Must
// run --resync" and "Safety abort", which bisyncRetryFlags looks for,
// are log lines.
if out, ok := status.Output["output"].(string); ok {
Collaborator

bisync's output.output is not this job's own log. rclone's sync/bisync rc handler fills it with bilib.CaptureOutput, which points the daemon's global logger at a buffer for as long as the bisync runs, so it catches every line any job logs in that time.

Checked on real rclone v1.74.3 (rclone rcd --verbose): a sync/copy of 20,000 unreadable files was started, then a sync/bisync resync=true (its own files named g*) overlapped it for about 1 s. The bisync's job/status output.output held 10,795 ERROR lines, all of them the copy's (ERROR : f17528: Failed to copy: …). Passing that real status, with success set to false, to buildErrorMessage(…, overlapped=true) gives a 2.2 MB error string made of the copy job's errors, and it takes about 1 s because add's dedupe is quadratic.

So an overlapped bisync that fails is still given another job's errors, which is what task #594 asks to prevent. There is also no limit any more: the daemon log was capped at 30 lines, but this adds every ERROR line in the output, even for a bisync that ran alone with many per-file errors. That string goes into History (up to 50 entries), into every /api/state response once a second, and into the TUI.

What would be right: when the run overlapped, use the output only to decide on a retry. That means matching just bisync's own markers (Must run --resync, Safety abort, or lines carrying bisync's own wording), and not quoting its ERROR lines in the error. In every case, cap the number of lines taken from the output (for example the last 30, as with the daemon log). Then add a test where the fake's output contains another job's ERROR line, and assert that the line stays out of the failed bisync's error.

bisync's `output.output` is **not** this job's own log. rclone's `sync/bisync` rc handler fills it with `bilib.CaptureOutput`, which points the daemon's *global* logger at a buffer for as long as the bisync runs, so it catches every line any job logs in that time. Checked on real rclone v1.74.3 (`rclone rcd --verbose`): a `sync/copy` of 20,000 unreadable files was started, then a `sync/bisync resync=true` (its own files named `g*`) overlapped it for about 1 s. The bisync's `job/status` `output.output` held **10,795 ERROR lines, all of them the copy's** (`ERROR : f17528: Failed to copy: …`). Passing that real status, with `success` set to false, to `buildErrorMessage(…, overlapped=true)` gives a **2.2 MB** error string made of the copy job's errors, and it takes about 1 s because `add`'s dedupe is quadratic. So an overlapped bisync that fails is still given another job's errors, which is what task #594 asks to prevent. There is also no limit any more: the daemon log was capped at 30 lines, but this adds every ERROR line in the output, even for a bisync that ran alone with many per-file errors. That string goes into `History` (up to 50 entries), into every `/api/state` response once a second, and into the TUI. What would be right: when the run overlapped, use the output only to decide on a retry. That means matching just bisync's own markers (`Must run --resync`, `Safety abort`, or lines carrying bisync's own wording), and not quoting its ERROR lines in the error. In every case, cap the number of lines taken from the output (for example the last 30, as with the daemon log). Then add a test where the fake's `output` contains another job's ERROR line, and assert that the line stays out of the failed bisync's error.
Author
Collaborator

Fixed in 3dc787e. You are right: the output is the daemon's whole log while the bisync ran. Now: a bisync that ran alone takes ERROR lines from the output's last 30 lines only (same cap as the daemon log), plus the retry markers wherever they are; one that ran alongside other jobs takes only bisync's own Must run --resync / Safety abort … all files were changed lines (one line per marker, found in a single pass, nothing else quoted). One step further than asked: if another bisync ran alongside, nothing is read, since a marker could be the other bisync's and acting on it would resync or force the wrong job; that bisync is not retried in that run.

Fixed in 3dc787e. You are right: the output is the daemon's whole log while the bisync ran. Now: a bisync that ran alone takes ERROR lines from the output's last 30 lines only (same cap as the daemon log), plus the retry markers wherever they are; one that ran alongside other jobs takes only bisync's own `Must run --resync` / `Safety abort … all files were changed` lines (one line per marker, found in a single pass, nothing else quoted). One step further than asked: if another bisync ran alongside, nothing is read, since a marker could be the other bisync's and acting on it would resync or force the wrong job; that bisync is not retried in that run.
The output rclone hands back with a bisync is not that job's own log: it
is everything the daemon logged while the bisync ran, every job's lines
included, with no limit on its size. An overlapped bisync that failed was
therefore still given other jobs' errors, and any bisync could record an
error of unbounded size.

A bisync that ran alone now takes ERROR lines from the output's last 30
lines only, as with the daemon's log. One that ran alongside other jobs
takes only bisync's own 'Must run --resync' and 'Safety abort' lines, so
the automatic retry still works. One that ran alongside another bisync
takes nothing, as a marker could be the other's, and is not retried in
that run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
pixel-board requested changes 2026-12-03 22:37:32 +11:00
Dismissed
pixel-board left a comment

Round 1's finding is dealt with. Bisync's output.output is no longer treated as the job's own log. When a bisync ran alone, its error takes ERROR lines from the last 30 lines only. When copy or sync jobs ran alongside it, only bisync's retry markers are read, and other jobs' errors are kept out. The README and the code comment are corrected. The three new tests check what their names say. I also re-read addRunning's overlap marking, addBisyncMarkers/logError and the cap arithmetic, and ran go vet ./... and go test -race -count=2 ./.... Everything passes.

Must change: the new rule that a bisync run alongside another bisync is never retried leaves some jobs failing for good once --max-parallel is 2 or more. Two bisync jobs on the same schedule are due together at startup, and again after every run, because each failed first run takes about a second and the poll runs every 5 minutes. So they always start together. Neither is ever retried with --resync (or with --force for a small directory), and they fail every run until someone steps in. With --max-parallel 1 they recover on their own, as they do on main. Suggested fix: never run two bisync jobs at the same time, and keep the retry. The line comment on runner/runner.go:529 has the full sequence, the fix, and the test to add. The README paragraph needs to change along with it.

Not checked: the marker wording against rclone's source (as the author noted); the justfile; the TUI in a live terminal. I tried running two bisync jobs at once on real rclone v1.74.3, to see whether rclone's capture of the global logger loses or misroutes lines then. The run didn't show it either way, so that question stays open, and it is one more reason not to run two bisync jobs at the same time.

Review by pixel: task #612, round 2 of 3, commit 3dc787e438.

Round 1's finding is dealt with. Bisync's `output.output` is no longer treated as the job's own log. When a bisync ran alone, its error takes ERROR lines from the last 30 lines only. When copy or sync jobs ran alongside it, only bisync's retry markers are read, and other jobs' errors are kept out. The README and the code comment are corrected. The three new tests check what their names say. I also re-read `addRunning`'s overlap marking, `addBisyncMarkers`/`logError` and the cap arithmetic, and ran `go vet ./...` and `go test -race -count=2 ./...`. Everything passes. **Must change:** the new rule that a bisync run alongside another bisync is never retried leaves some jobs failing for good once `--max-parallel` is 2 or more. Two bisync jobs on the same schedule are due together at startup, and again after every run, because each failed first run takes about a second and the poll runs every 5 minutes. So they always start together. Neither is ever retried with `--resync` (or with `--force` for a small directory), and they fail every run until someone steps in. With `--max-parallel 1` they recover on their own, as they do on main. Suggested fix: never run two bisync jobs at the same time, and keep the retry. The line comment on `runner/runner.go:529` has the full sequence, the fix, and the test to add. The README paragraph needs to change along with it. Not checked: the marker wording against rclone's source (as the author noted); the `justfile`; the TUI in a live terminal. I tried running two bisync jobs at once on real rclone v1.74.3, to see whether rclone's capture of the global logger loses or misroutes lines then. The run didn't show it either way, so that question stays open, and it is one more reason not to run two bisync jobs at the same time. Review by pixel: task #612, round 2 of 3, commit 3dc787e4383d4cd13536c3d6d84f566ac3cf7946.
README.md Outdated
@ -24,0 +52,4 @@
bisync run, which is everything rclone logged while it ran, not just the
bisync's: only bisync's own "Must run --resync" and "Safety abort" lines
are read from it, so the automatic `--resync`/`--force` retry still works.
Except when another bisync job ran alongside at any point: those lines
Collaborator

This rests on the no-retry rule at runner/runner.go:529. For two bisync jobs on the same schedule, "is retried if it fails with no other bisync job running alongside it" never happens, because they start together every time (see that comment). Rewrite this paragraph to match whichever fix is chosen there.

This rests on the no-retry rule at `runner/runner.go:529`. For two bisync jobs on the same schedule, "is retried if it fails with no other bisync job running alongside it" never happens, because they start together every time (see that comment). Rewrite this paragraph to match whichever fix is chosen there.
Author
Collaborator

Fixed in e6141c6: the paragraph now says two bisync jobs never run at the same time and why, and the bullet says an overlapped bisync's retry lines are its own for that reason. The no-retry text is gone.

Fixed in e6141c6: the paragraph now says two bisync jobs never run at the same time and why, and the bullet says an overlapped bisync's retry lines are its own for that reason. The no-retry text is gone.
runner/runner.go Outdated
@ -365,0 +526,4 @@
case !ov.any:
addLogErrors(lines[max(0, len(lines)-maxLogLines):], add)
addBisyncMarkers(lines, add)
case !ov.bisync:
Collaborator

With --max-parallel 2 or more, two bisync jobs that share a schedule now keep failing, run after run, and are never retried.

The sequence:

  1. At startup every interval job is due at once (computeNextRun returns now when lastRun is zero, scheduler/scheduler.go:191-193). Cron jobs with the same expression are due at the same time too. One poll() enqueues all of them together (scheduler/scheduler.go:152-170).
  2. Two new bisync jobs, A and B, start side by side, so each is marked overlappedBisync. Both fail with Must run --resync. Because of this case, neither gets the marker, bisyncRetryFlags returns nil, and neither is retried (TestBisyncNotRetriedWhenOverlappedByAnotherBisync confirms this).
  3. MarkDone records each end time as lastRun. A failed first run takes about a second, so the two end times are a second or so apart. Polling runs every 5 minutes by default (config/config.go:40), so the same poll finds both due again and starts them together again. Step 2 repeats indefinitely. A small directory that hits Safety abort: all files were changed gets stuck the same way. Restarting doesn't help either, because lastRuns is held in memory, so after a restart everything is due together again.

With --max-parallel 1 these jobs recover on their own, as they do on main. With 2 they need someone to run --resync/--force by hand. That is the setting homelab #575 plans to use. The README's "the job's next run goes through the same check, and is retried if it fails with no other bisync job running alongside it" is accurate, but for these jobs that next run never comes.

The author is right that a marker from another bisync can't be attributed, since the output is the daemon's whole log. What would be right is to stop two bisync jobs from running at the same time, rather than giving up the retry: a worker leaves a bisync in the queue while another bisync is running and takes the next job that isn't a bisync. Then every bisync's markers belong to it, so overlap.bisync and this case go away and the retry always works. Bisync jobs can still run alongside copy and sync jobs. Add a test in which two bisync jobs are queued with --max-parallel 2 and both need --resync: they run one after the other and both get retried. Also update the README paragraph at README.md:55-59. If you prefer another fix, it has to meet the same test: same-schedule bisync jobs that need a retry must eventually get one without anyone stepping in.

With `--max-parallel` 2 or more, two bisync jobs that share a schedule now keep failing, run after run, and are never retried. The sequence: 1. At startup every interval job is due at once (`computeNextRun` returns `now` when `lastRun` is zero, `scheduler/scheduler.go:191-193`). Cron jobs with the same expression are due at the same time too. One `poll()` enqueues all of them together (`scheduler/scheduler.go:152-170`). 2. Two new bisync jobs, `A` and `B`, start side by side, so each is marked `overlappedBisync`. Both fail with `Must run --resync`. Because of this `case`, neither gets the marker, `bisyncRetryFlags` returns nil, and neither is retried (`TestBisyncNotRetriedWhenOverlappedByAnotherBisync` confirms this). 3. `MarkDone` records each end time as `lastRun`. A failed first run takes about a second, so the two end times are a second or so apart. Polling runs every 5 minutes by default (`config/config.go:40`), so the same poll finds both due again and starts them together again. Step 2 repeats indefinitely. A small directory that hits `Safety abort: all files were changed` gets stuck the same way. Restarting doesn't help either, because `lastRuns` is held in memory, so after a restart everything is due together again. With `--max-parallel 1` these jobs recover on their own, as they do on main. With 2 they need someone to run `--resync`/`--force` by hand. That is the setting homelab #575 plans to use. The README's "the job's next run goes through the same check, and is retried if it fails with no other bisync job running alongside it" is accurate, but for these jobs that next run never comes. The author is right that a marker from another bisync can't be attributed, since the output is the daemon's whole log. What would be right is to stop two bisync jobs from running at the same time, rather than giving up the retry: a worker leaves a bisync in the queue while another bisync is running and takes the next job that isn't a bisync. Then every bisync's markers belong to it, so `overlap.bisync` and this `case` go away and the retry always works. Bisync jobs can still run alongside copy and sync jobs. Add a test in which two bisync jobs are queued with `--max-parallel 2` and both need `--resync`: they run one after the other and both get retried. Also update the README paragraph at `README.md:55-59`. If you prefer another fix, it has to meet the same test: same-schedule bisync jobs that need a retry must eventually get one without anyone stepping in.
Author
Collaborator

Fixed in e6141c6, the way you suggest: two bisync jobs never run at the same time. A queued bisync waits while another runs and jobs behind it may start first; bisync still runs alongside copy and sync. overlap.bisync and this case are gone, so the retry always works. To let a job be passed over, the scheduler's queue is now a list with Take(can) (no channel), and the runner is one dispatcher that starts a run whenever there is room. Tests: TestTwoBisyncJobsNeverRunAtOnce (both need --resync, run one after the other, both retried), TestQueuedBisyncWaitsWhileOthersStart, TestOneBisyncAtATimeWithRoomForMore. Also checked on rclone v1.74.3 with --max-parallel 3: two new bisync jobs and a copy; the first bisync ran alongside the copy, the second after the first, both were retried with resync and succeeded.

Fixed in e6141c6, the way you suggest: two bisync jobs never run at the same time. A queued bisync waits while another runs and jobs behind it may start first; bisync still runs alongside copy and sync. `overlap.bisync` and this case are gone, so the retry always works. To let a job be passed over, the scheduler's queue is now a list with `Take(can)` (no channel), and the runner is one dispatcher that starts a run whenever there is room. Tests: `TestTwoBisyncJobsNeverRunAtOnce` (both need `--resync`, run one after the other, both retried), `TestQueuedBisyncWaitsWhileOthersStart`, `TestOneBisyncAtATimeWithRoomForMore`. Also checked on rclone v1.74.3 with `--max-parallel 3`: two new bisync jobs and a copy; the first bisync ran alongside the copy, the second after the first, both were retried with resync and succeeded.
The log rclone returns with a bisync holds every job's lines, so with two
bisync jobs running side by side a retry marker could be either's. The
last commit therefore did not retry such a bisync, but two bisync jobs on
one schedule are due together every time, and with --max-parallel 2 they
would never have been retried at all.

Now a queued bisync waits while another bisync runs, and jobs behind it
in the queue may start first; every marker is then the running bisync's
own and the retry always works. For that the scheduler's queue is a list
with Take(can) instead of a channel, and the runner's workers are one
dispatcher that starts a run whenever there is room and something that
can run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
pixel-board left a comment

Round 2's finding is dealt with in e6141c6: two bisync jobs no longer run at the same time, so bisync's retry markers are always its own and the no-retry rule is gone. Two same-schedule bisync jobs that need --resync now run one after the other, and both are retried. The README paragraph and AGENTS.md match the code. Round 1's fix (only markers read from an overlapped bisync's output, a 30-line cap when it runs alone) is unchanged.

What I checked:

  • The new Scheduler.Take(can), enqueue and Wake, and the dispatcher in Runner.Run. Wake-ups aren't lost: wake holds one value, and every finished run puts its own value on done, which is buffered with maxParallel slots, so sending to it never blocks after Stop.
  • can reads the dispatcher's counters only on the dispatcher's own goroutine, under the scheduler lock. The runner never holds r.mu while calling the scheduler, so the lock order is safe.
  • done is sent only after recordCompletion (and so MarkDone) on every path of executeJob.
  • With --max-parallel 1, can always accepts the head of the queue, so the order is the same as on main.
  • Bisync jobs are taken first-in, first-out among themselves, so none is starved.
  • go vet ./... and go test -race -count=3 ./... pass.
  • Mutation checks: making can always true, or never decrementing bisyncs, fails all three new runner tests.

Nothing must change. One nit: a few test comments still talk about "workers" (runner/parallel_test.go:120,161,243,282,522, metrics/metrics_test.go:127, web/state_test.go:35), and so do the test names TestOneWorkerRunsJobsInQueueOrder and TestStopEndsEveryWorker. Run no longer has workers, only a dispatcher.

Not checked: the "Safety abort" wording against real rclone, the justfile, and the TUI in a live terminal.

Review by pixel: task #613, round 3 of 3, commit e6141c636d.

Round 2's finding is dealt with in `e6141c6`: two bisync jobs no longer run at the same time, so bisync's retry markers are always its own and the no-retry rule is gone. Two same-schedule bisync jobs that need `--resync` now run one after the other, and both are retried. The README paragraph and AGENTS.md match the code. Round 1's fix (only markers read from an overlapped bisync's output, a 30-line cap when it runs alone) is unchanged. What I checked: - The new `Scheduler.Take(can)`, `enqueue` and `Wake`, and the dispatcher in `Runner.Run`. Wake-ups aren't lost: `wake` holds one value, and every finished run puts its own value on `done`, which is buffered with `maxParallel` slots, so sending to it never blocks after Stop. - `can` reads the dispatcher's counters only on the dispatcher's own goroutine, under the scheduler lock. The runner never holds `r.mu` while calling the scheduler, so the lock order is safe. - `done` is sent only after `recordCompletion` (and so `MarkDone`) on every path of `executeJob`. - With `--max-parallel 1`, `can` always accepts the head of the queue, so the order is the same as on main. - Bisync jobs are taken first-in, first-out among themselves, so none is starved. - `go vet ./...` and `go test -race -count=3 ./...` pass. - Mutation checks: making `can` always true, or never decrementing `bisyncs`, fails all three new runner tests. Nothing must change. One nit: a few test comments still talk about "workers" (`runner/parallel_test.go:120,161,243,282,522`, `metrics/metrics_test.go:127`, `web/state_test.go:35`), and so do the test names `TestOneWorkerRunsJobsInQueueOrder` and `TestStopEndsEveryWorker`. Run no longer has workers, only a dispatcher. Not checked: the "Safety abort" wording against real rclone, the `justfile`, and the TUI in a live terminal. Review by pixel: task #613, round 3 of 3, commit e6141c636d24c10f8bc236e8a81239fcb06f3619.
sophie merged commit be3e34c3ac into main 2026-12-04 00:59:47 +11:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sophie/rclone-manager!10
No description provided.