Skip to content

fix: bound copy concurrency process-wide; unify run exit codes - #248

Merged
asthetik merged 1 commit into
mainfrom
fix/process-wide-copy-concurrency
Sep 6, 2026
Merged

fix: bound copy concurrency process-wide; unify run exit codes#248
asthetik merged 1 commit into
mainfrom
fix/process-wide-copy-concurrency

Conversation

@asthetik

@asthetik asthetik commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Follow-up to the #247 review: fixes the one Important finding plus the cheap Minors.

Changes

  • Process-wide copy boundrun_jobs now shares one Semaphore(COPY_CONCURRENCY) across all jobs; execute_item_async acquires one permit per in-flight item (copies and deletes). Before this, the per-job buffer_unordered(64) bounds stacked across concurrent jobs: measured 111 in-flight copies with 3 directory jobs, enough to hit EMFILE on macOS's default 256-fd soft limit. After: saturates at exactly 64. run_job standalone keeps its own fresh pool; compression jobs bypass the semaphore by design (fd usage O(1) per job).
  • Unified failure exit codesbk run -i failures now exit 1 (was 74 / EX_IOERR) like every other run mode, routed through run_jobs for identical per-job id reporting. ⚠️ Behavior change for scripts matching 74 specifically.
  • Empty HBACKUP_CONFIG is now ignored instead of resolving the config to a relative ./config.toml in the CWD; also fixed the non-macOS config_dir() error message naming the wrong directory.
  • Removed the unused criterion dev-dependency (no bench targets; lockfile pruned ~290 lines).

Tests

  • New run_jobs_bounds_concurrent_copies_process_wide unit test measures real concurrency via cfg(test) instrumentation in copy_async (compiled out of release/integration builds): red at 111 pre-fix, green at ≤ 64 post-fix, with a lower-bound assert so it can't rot into a vacuous pass.
  • run_single_failing_job_exits_non_zero now pins exit code 1 + the Failed to run job with id N message.
  • New empty_hbackup_config_env_falls_back_to_absolute_default integration test.
  • cargo fmt / clippy -D warnings clean; all 65 tests pass.

Follow-up candidates (out of scope here)

  • bk run -i 1 99 with a nonexistent id exits 0 today (stderr warning only) — for a data-preservation tool, a requested-but-not-run id arguably warrants a non-zero exit.

- share one semaphore(COPY_CONCURRENCY) across all jobs in run_jobs so
  multi-job directory runs cannot exhaust file descriptors: the per-job
  buffer_unordered bounds stacked up (measured 111 in flight with 3
  jobs before the fix) and EMFILE'd on low-ulimit systems
- bk run -i failures now exit 1 like every other run mode instead of
  EX_IOERR (74), with the same per-job id reporting as bk run
- ignore an empty HBACKUP_CONFIG instead of resolving the config to a
  relative ./config.toml in the current directory
- fix the config_dir error message naming the wrong directory
- drop the unused criterion dev-dependency
@asthetik
asthetik merged commit 4ef63d9 into main Sep 6, 2026
11 checks passed
@asthetik
asthetik deleted the fix/process-wide-copy-concurrency branch September 6, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant