Skip to content

Prevent concurrent writers on the same Git repository - #1277

Merged
clementbiron merged 7 commits into
mainfrom
writer-lock
Sep 24, 2026
Merged

clementbiron merged 7 commits into
mainfrom
writer-lock

Conversation

@Ndpnt

@Ndpnt Ndpnt commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Two writers on the same Git repository, typically a second ota track started by hand while the scheduled tracker runs, race the working tree and the index: one fails, or its clean up discards the uncommitted changes of the other. #1273 made the readers safe, this handles the writers.

A writer now takes a lock file in .git/ota-writer.lock, holding its PID, and keeps it until the process exits. A second writer refuses to start with an error naming the holder. A lock left by a killed process is detected as stale and taken over atomically.

The index.lock left behind by a killed Git operation is also removed at each run, as it made the tracker fail at every restart.

@clementbiron

Copy link
Copy Markdown
Member

Seen in sync with @Ndpnt

Ndpnt and others added 7 commits September 24, 2026 10:27
A lock left by a killed process whose PID is reused by its replacement, such as the same container restarted, was acquired again silently but never registered, so it was not released when that replacement exited. It then outlived every writer and, with a lingering PID, refused the next one for no reason.
@clementbiron
clementbiron merged commit 58e0ab1 into main Sep 24, 2026
8 checks passed
@clementbiron
clementbiron deleted the writer-lock branch September 24, 2026 08:47
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.

2 participants