Skip to content

🐛 fix(soft): finish settled stale rollback - #1082

Merged
gaborbernat merged 3 commits into
mainfrom
fix/stale-rollback-cleanup-tbm
Nov 20, 2026
Merged

gaborbernat merged 3 commits into
mainfrom
fix/stale-rollback-cleanup-tbm

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

A stale-break rollback could settle while another process changed its break name. Deleting that name then raised, so the soft lock left its own marker at the lock path despite reporting no hold. A later acquire could time out on that marker. The soft lock now receives the settled result before break-name cleanup and removes its pending marker by descriptor identity. Fixes #1025.

The cleanup error hid a settled rollback

exchange_back used to unlink the break name before returning. Path.unlink() raises on a directory, so a replaced break name hid the settled result from the caller. exchange_back now lets the soft-lock caller defer that unlink. The caller attempts the name cleanup after receiving settlement and checks the remaining names against its open descriptor before removing its pending marker.

sequenceDiagram
    participant P as Peer
    participant C as Contender
    participant A as Break name
    participant L as Lock path
    activate C
    rect rgb(255, 214, 214)
        C->>+A: Before: rollback settles
        A-->>-C: name missing
        P->>A: replace name
        C->>+A: unlink changed name
        A-->>-C: error
        Note over C,L: Contender's marker stays at lock path
    end
    rect rgb(216, 243, 220)
        C->>+A: After: rollback settles
        A-->>-C: settled result
        P->>A: replace name
        C->>A: attempt name cleanup
        C->>L: remove pending marker by inode
    end
    deactivate C
Loading

Behavior changes

On POSIX filesystems with atomic name exchange, SoftFileLock, MarkerSoftFileLock, and SoftFileLease can retry after this race without a marker naming the unsuccessful contender. An account that can place a directory at the lock path can still block acquires directly; this change removes the contender-owned residue. Windows does not use this exchange path. The other exchange_back caller still propagates break-name deletion errors.

Reported by OSS Scanner: ANT-2026-TBM12ZIH.

A replaced break name could make unlink raise after rollback had settled.
The soft lock now receives that verdict before name cleanup, so it removes
its own pending marker by descriptor identity.

Fixes #1025
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 15:32
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 18:17
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 20:22
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 20:24
@gaborbernat
gaborbernat merged commit bfdf8aa into main Nov 20, 2026
50 of 87 checks passed
@gaborbernat
gaborbernat deleted the fix/stale-rollback-cleanup-tbm branch November 20, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed stale-marker rollback leaves a live marker at the lock path

1 participant