Skip to content

Add git database locks and db_dir config#307

Open
micprog wants to merge 4 commits into
masterfrom
database_locks
Open

Add git database locks and db_dir config#307
micprog wants to merge 4 commits into
masterfrom
database_locks

Conversation

@micprog
Copy link
Copy Markdown
Member

@micprog micprog commented May 28, 2026

  • Filesystem locks: wrap git_database and checkout_git in a cross-process flock (fs4) keyed per dependency, so concurrent bender invocations against the same dep serialize safely. Locks live at <database>/git/locks/ and are released by the kernel on process exit.
  • db_dir config field: new optional setting that overrides only the bare-repo and lock paths, leaving checkouts under database. Lets a single shared Bender.local enable cross-project cache reuse without forcing per-project workspace.checkout_dir. Older bender versions silently ignore the field and fall back to per-project caches — safer than the legacy database:-only sharing recipe in mixed-version setups.
  • Clippy cleanup: separate commit fixing pre-existing warnings (collapsible_match, redundant .into_iter(), args(&[...])). cargo clippy --all-targets -- -D warnings now passes.

Docs updated: configuration.md (new db_dir entry), workflow/ci.md (db_dir is now the recommended sharing recipe; retires the concurrent-runs caveat), local.md, CHANGELOG.md.

micprog and others added 2 commits May 28, 2026 15:00
Modeled on memora-rs's RAII flock pattern: introduces an `FsLock` guard
in `src/lock.rs` backed by `fs4`, and takes a per-`(name, url)` exclusive
lock under `<database>/git/locks/` around `git_database` and `checkout_git`.
Locks released automatically on drop (and by the kernel on crash).
`clone` and `snapshot` subcommands intentionally remain unguarded.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds an optional `db_dir` config field that overrides only the bare-repo
and lock-file locations (`<db_dir>/git/db/` and `<db_dir>/git/locks/`),
while working-tree checkouts and everything else continue to derive from
`database`. This lets a single shared config enable cross-project cache
sharing without forcing same-named projects to commit a
`workspace.checkout_dir` in their `Bender.yml`.

The field is purely additive and unknown to older Bender versions, which
silently ignore it and fall back to their per-project default — strictly
safer than today's shared-`database:` recipe in mixed-version setups.

Docs updated: `book/src/configuration.md` documents the new field;
`book/src/workflow/ci.md` rewrites the shared-cache recipe around
`db_dir` and retires the now-fixed concurrent-runs caveat;
`book/src/local.md` mentions it in the example block.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@micprog micprog requested review from creinwar and fischeti May 28, 2026 14:03
- src/progress.rs: collapse nested `if self.git_op == Submodule { ... }`
  blocks into match guards on the relevant arms; the existing `_ => {}`
  wildcard now handles the non-submodule case.
- src/config.rs: collapse the inner glob/non-glob `if` in `glob_file`
  into a match guard; the pre-existing `_ => Ok(vec![self])` arm covers
  the fall-through.
- Drop redundant `.into_iter()` on values passed to `.chain()`
  in `src/sess.rs`, `src/src.rs`, and `src/config.rs`.
- tests/cli_regression.rs: pass an array directly to `Command::args`
  instead of borrowing it.

`cargo clippy --all-targets -- -D warnings` is clean; `cargo test`
unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Honoured only when no configuration file sets `db_dir`; any
`Bender.local`/`.bender.yml`/user/system config still wins. Empty
strings are treated as unset.

Lets a CI runner export the shared cache path once instead of
maintaining a `Bender.local` next to every project.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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