Skip to content

Serve-path ingest updates .sc index files without a lock (pending list, signature index, drop rewrite) #260

Closed

Description

@tonibergholm-codento

Found while reviewing #254 (#230). LocalTransport::put_pack ingests a pack and then updates derived index files (.sc/signatures via append_index, .sc/transcripts, .sc/transcript-pending via note_pending and the re-evaluation rewrite) without holding RepoLock; the lock covers only update_ref. Two concurrent pushes to a thread-per-connection sc serve --http, or a push racing a local sc command in the served directory, can each read the same file and the last atomic rewrite wins, losing the other's entries.

Impact: a lost signature or transcript index line is rebuilt by sc clone reindex only; a lost pending-tombstone entry costs a push-only remote the retry (the drop line itself is appended with O_APPEND since #254 and cannot be lost this way).

Options: take the repo lock around the post-ingest index updates (check Locked behaviour for concurrent connections and for a local sc command holding the lock for its whole lifetime), or a dedicated short-lived index lock distinct from RepoLock, or make each index file append-only with O_APPEND lines.

Related: ADR-0038 addendum (#230), #257.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions