GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — plumbing: format/packfile, use ReadAt in FSObject.Reader() for concurrency safety. by cedric-appdirect · Pull Request #1998 · go-git/go-git

Conversation

@cedric-appdirect

@cedric-appdirect cedric-appdirect commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Replace Seek+Read with io.SectionReader backed by ReadAt in FSObject.Reader(). ReadAt does not modify the file's seek cursor (it maps to pread(2) on POSIX), so multiple goroutines can safely call Reader() on FSObjects that share the same packfile handle. The billy.File interface already requires io.ReaderAt, and both osfs (via os.File) and memfs implementations are documented as safe for concurrent ReadAt calls.

The closed-file recovery path now uses a 1-byte ReadAt probe instead of Seek to detect stale descriptors without mutating shared state.

A zero-length ReadAt is insufficient because os.File returns (0, nil) for empty reads even on closed files.

This PR is necessary to enable parallel checkout from PR #1749 which will help resolving #1956

Assisted-by: OpenCode with Claude Opus 4.6 [email protected]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cedric-appdirect
cedric-appdirect force-pushed the fsobject-readerat branch from aeea23a to 294da28 Compare April 15, 2026 16:28
@cedric-appdirect
cedric-appdirect force-pushed the fsobject-readerat branch 4 times, most recently from 77aa230 to bdd7073 Compare May 1, 2026 16:28
@cedric-appdirect
cedric-appdirect force-pushed the fsobject-readerat branch from bdd7073 to af503bd Compare May 11, 2026 16:17
pjbgf
pjbgf reviewed May 12, 2026
View reviewed changes

@pjbgf pjbgf left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cedric-appdirect thanks for working on this, below are a few nits.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread plumbing/format/packfile/fsobject_test.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread plumbing/format/packfile/fsobject_test.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread plumbing/format/packfile/fsobject_test.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@cedric-appdirect
cedric-appdirect force-pushed the fsobject-readerat branch from af503bd to 4843eb2 Compare May 12, 2026 17:46
pjbgf
pjbgf reviewed May 12, 2026
View reviewed changes
Comment thread plumbing/format/packfile/fsobject.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@cedric-appdirect @cursoragent
plumbing: format/packfile, use ReadAt in FSObject.Reader() for concur…
c37bc6f
…rency safety.

Replace Seek+Read with io.SectionReader backed by ReadAt in
FSObject.Reader(). ReadAt does not modify the file's seek cursor
(it maps to pread(2) on POSIX), so multiple goroutines can safely
call Reader() on FSObjects that share the same packfile handle.
The billy.File interface already requires io.ReaderAt, and both osfs
(via os.File) and memfs implementations are documented as safe for
concurrent ReadAt calls.

The closed-file recovery path now uses a 1-byte ReadAt probe instead
of Seek to detect stale descriptors without mutating shared state.
Non-ErrClosed errors from the probe are propagated to the caller.

A zero-length ReadAt is insufficient because os.File returns (0, nil)
for empty reads even on closed files.

Assisted-by: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Cedric BAIL <[email protected]>
Co-authored-by: Cursor <[email protected]>
@cedric-appdirect
cedric-appdirect force-pushed the fsobject-readerat branch from 4843eb2 to c37bc6f Compare May 13, 2026 21:22
@cedric-appdirect
cedric-appdirect requested a review from pjbgf May 13, 2026 21:22
pjbgf
pjbgf approved these changes May 18, 2026
View reviewed changes

@pjbgf pjbgf left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cedric-appdirect thanks for working on this. 🙇

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pjbgf
pjbgf merged commit f7d8537 into go-git:main May 18, 2026
17 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@pjbgf pjbgf mentioned this pull request May 18, 2026
*: Fix pack file race conditions and checksum mismatches #2094
Closed
@AriehSchneier AriehSchneier mentioned this pull request May 19, 2026
storage: filesystem, fix concurrent access to index map #2139
Open
@SchrodingerzApe SchrodingerzApe mentioned this pull request Jul 22, 2026
worktree: Optimize checkout performance for worktree creation and branch switching #1956
Open
1 of 8 tasks
@cedric-appdirect
cedric-appdirect deleted the fsobject-readerat branch November 23, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pjbgf pjbgf pjbgf approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@cedric-appdirect @pjbgf
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.