Skip to content

fix(cli): Implement reader/writer lock API and improve cache handling#94

Merged
misonijnik merged 15 commits intomainfrom
misonijnik/fix-lock
Apr 17, 2026
Merged

fix(cli): Implement reader/writer lock API and improve cache handling#94
misonijnik merged 15 commits intomainfrom
misonijnik/fix-lock

Conversation

@misonijnik
Copy link
Copy Markdown
Member

No description provided.

Move os.Truncate before flock.RLock in Downgrade so that a concurrent
prune reading ReadLockMeta in the narrow window after the kernel mode
transitions to LOCK_SH never sees a stale writer PID. If the truncate
fails the kernel mode is not touched, preserving the exclusive hold.
Expand the comment to document gofrs dual-flag (f.l + f.r) state that
results from calling RLock on an already-exclusive fd.
Lowercase the Downgrade non-exclusive error to follow Go convention
(output.Humanize capitalizes at the display boundary), drop the
redundant Downgrade no-op test that duplicated the happy path, and
route cached-marker path through CompileCompleteMarkerPath so callers
and tests share one source of truth for the marker location.
The .cache.lock file created during the prune scan remained in the
project cache directory after DeleteArtifacts removed the model, so
removeEmptyParents could never clear the now-orphaned project dir.
Re-acquire the cache lock exclusively before deletion and remove the
whole project cache dir (model + lock file) in one shot; fall back to
removing only project-model/ if another holder grabbed the lock
between scan and delete.
@misonijnik misonijnik merged commit b1eb579 into main Apr 17, 2026
13 checks passed
@misonijnik misonijnik deleted the misonijnik/fix-lock branch April 17, 2026 15:30
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.

1 participant