Skip to content

lore-revision: Preserve batch error reason on lock acquire failure#114

Open
parkjaeuk0210 wants to merge 1 commit into
EpicGames:mainfrom
parkjaeuk0210:fix/lock-acquire-preserve-denial-reason
Open

lore-revision: Preserve batch error reason on lock acquire failure#114
parkjaeuk0210 wants to merge 1 commit into
EpicGames:mainfrom
parkjaeuk0210:fix/lock-acquire-preserve-denial-reason

Conversation

@parkjaeuk0210

Copy link
Copy Markdown

What

lore lock acquire now surfaces the server's denial reason when lock batches fail, instead of a generic "Failed to acquire the lock".

Why

The per-batch error returned by the lock service carries the actual reason — e.g. message: "resource already locked" — but the aggregation loop in lore-revision/src/lock/file/acquire.rs only counted failures and returned a freshly constructed generic error, so the reason never reached the user.

Reproduce with two users against one server:

userA$ lore lock acquire Map.umap        # succeeds
userB$ lore lock acquire Map.umap
[Error] Failed to lock-acquire 1 batch(es) out of 1
[Error] Failed to acquire the lock       # <- reason discarded

With this change userB instead sees the underlying error chain ending in message: "resource already locked", and any richer denial reasons a lock store or hook produces flow through unchanged.

How

  • Extract the batch aggregation into fold_batch_results, which keeps the first batch error alongside the acquired locks and counters.
  • Return that error from both failure paths: all batches failed, and partial failure (after the existing release of partially acquired locks).
  • Add unit tests for the fold: the first error is preserved verbatim; successful batches still collect locks.

cargo +nightly fmt, cargo clippy -p lore-revision --all-targets -- -D warnings --no-deps, and cargo test -p lore-revision pass.

🤖 Generated with Claude Code

When every lock-acquire batch fails, acquire() replaced the batch
error with a freshly constructed generic "Failed to acquire the
lock", discarding the server's denial reason (for example lock
contention naming the conflict). Fold the batch results keeping the
first error and return it from both failure paths — all batches
failed, and partial failure after releasing partial acquisitions —
so the reason reaches the caller and the user.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: onlain <gana06720@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant