Skip to content

Library: preserve concurrent changes during conditional save and move #480

Open

Description

@andersalm

User impact

A Library operation can overwrite a newer save or remove newer source bytes while reporting success. This is a proposed 0.8.0 release-blocking data-integrity finding from the systematic review in #93. Source review confirms the race; installed reproduction and its frequency remain unmeasured.

Source evidence

Checked on fetched develop 3beb816438fd567145a8d725e22465bd83277cf0 and local release candidate 460b1888d344f52cebd1c25866be88ff4085f035. Two independent reviewers and the lead checked the call path.

  • In published develop, Library conditional write checks the expected revision before calling the unconditional protected-object writer at line 3718. Candidate equivalents are library.rs:3774,3789.
  • The protected-object writer acquires its mutation lock after that check. Two callers can both accept revision R and then both save, so one acknowledged change is lost.
  • Candidate library.rs:7194-7206 reads a source, writes the destination, then removes the source. An upload between the read and removal can be acknowledged and then lost. The develop equivalent starts at line 6630.
  • Ordinary object-provider messages are serial, but gateway raw upload and chunk completion call the Library write path directly (api/gateway_provider_proxy.rs:439-448,802-811). That path can overlap the separate object-provider process. The auth mutation mutex is process-local.
  • Documents already holds a mutation guard across its revision check and write. Library needs one ownership boundary that also covers its gateway/provider split.

Smallest repair and proof

Keep user-visible operation semantics. Make revision validation and commit one operation. Give move/copy explicit source and destination ownership, and preserve a newer source version if another writer changes it. A lock confined to only one process is insufficient for the current paths.

  • A deterministic write/write test admits only one request using the same old revision; the other receives a conflict.
  • Move/upload and copy/destination-create tests preserve all acknowledged data and report a clear conflict.
  • Destination failure leaves the original source intact.
  • Exercise gateway upload together with the external object-provider path.
  • Installed Mac and Linux checks cover two concurrent clients and restart/recovery.
  • Independent review and exact-candidate acceptance are recorded before closure.

Deduplication: #450 covers opening/lazy protection, #445 listing, #449 extraction, and PR #428 UI behavior. This issue owns mutation atomicity. Searches of open and closed issues found no matching owner. This issue is queued for release triage; the audit started no implementation work.

Activity

  1. added this to the 0.8.0 milestone on Oct 22, 2026
  2. andersalm commented on Oct 22, 2026

    @andersalm
    ContributorAuthor

    Triage (22 Oct, OMP): this does not block the 0.8.0 source freeze; the Thu 29 Oct go/no-go decides it.

    The race is confirmed in source on candidate 460b1888d: library.rs:3774 checks the revision, and the write at :3789 takes the lock after that check; move reads, writes and removes at :7194-7206 without one lock. Develop 3beb81643 has the same code (library.rs:3704/3718, :6630-6642), so the train did not introduce it. One more writer in the Runtime process reaches the same write path: Documents saving a Library file (viewer_gateway.rs:516 → library.rs:787). A fix only inside the Runtime process (one lock across check and write, and a source re-check before removal) leaves the object-provider process uncovered. The complete fix changes the lock that every protected writer uses, so its design gets reviewed before any code.

    For the go/no-go, OMP recommends that 0.8.0 ships with this as a known gap and the fix comes first after the release. The independent check recommends that the final release waits for a repair or an effective containment, because acknowledged data can be lost. Anders decides at the go/no-go.

  3. andersalm commented on Oct 22, 2026

    @andersalm
    ContributorAuthor

    Security lane status (22 Oct, OMP). Main excluded #480 from alpha.25 after three failed cross-family review rounds (disposition), as this lane recommended. The branch fix/480-library-atomic (df5d85949, 380b11e48, c19747093) stays as it is. The triage decision still applies: the Thu 29 Oct go/no-go decides how 0.8.0 states the remaining risk.

    Irzhy reviews the design before more code. The security lane proposes these requirements for that review:

    • Locking: one lock for each validated target root, kept apart from the sign-in secrets, that every writer of that root takes. A writer waits for it for a short, fixed time and then gets a retryable "Library is busy" error, so one person's long Library change leaves other people on the same Home free to work.
    • App folders: the filesystem boundary details stay in the private review record.
    • Other writers: Library: every Home folder writer takes the Library lock #488 owns the writers outside the lock. Each one gets a reviewed change or a stated known gap.

    The three open dispositions from the reviews of 380b11e48 and c19747093 move into this design review.

  4. andersalm commented on Oct 22, 2026

    @andersalm
    ContributorAuthor

    Disposition for the 0.8.0-alpha.25 freeze (22 Oct, OMP train owner): the candidate branch fix/480-library-atomic (df5d85949, 380b11e48, c19747093) is not in alpha.25.

    • Reviews: three cross-family rounds each found remaining gaps (libatomic1–3). The latest found ways around the app-folder refusal: entries in a selected-archive extraction, symlinked parents, and Unicode case aliases on case-insensitive disks.
    • Design question: the cross-process lock adds shared waiting whose timeout and recovery behaviour is unverified. The security lane's dispositions for this branch are also still open.
    • Next: this goes to a reviewed design (one lock for every protected writer, and a filesystem-level boundary for app folders) with Irzhy, tracked here and in Library: every Home folder writer takes the Library lock #488. The Thu 29 Oct go/no-go decides how 0.8.0 states the remaining risk.
    • Branch: kept as is for that work.
  5. modified the milestones: 0.8.0, 2.1.0 on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions