Skip to content

filesystem: cancel PutContent writer on commit failure - #5102

Merged
milosgajdos merged 1 commit into
distribution:mainfrom
perfloop-oss:perfloop-pr-open-rnme8xnp16
Nov 27, 2026
Merged

milosgajdos merged 1 commit into
distribution:mainfrom
perfloop-oss:perfloop-pr-open-rnme8xnp16

Conversation

@perfloop-agent

Copy link
Copy Markdown
Contributor

Since #4624, a filesystem-backed registry can leave orphaned temporary files when PutContent fails in Commit, including when a buffered write exceeds a file-size limit. The operation returns an error, but its temporary file stays in the live storage tree. Cancel the writer before returning so the uncommitted file is closed and removed.

cc @milosgajdos

For example, a 128-byte value fits in the default 4 KiB buffer. With a 64-byte file-size limit, copying succeeds in memory and flushing fails in Commit. Previously that left startedat.<uuid>.tmp; now the directory is empty, or holds only the unchanged destination when replacing a file.

errors.Join retains the commit error and reports any cancellation error. Successful commits, renames, and directory syncing are unchanged.

The Linux regression in registry/storage/driver/filesystem/driver_linux_test.go applies the limit in a child process so it cannot affect other tests. Go tests pass for commit-failure cleanup, content replacement, and failed-rename cleanup.

File removal can still fail; in that case both errors are returned.

AI assisted with this change.

Case and evidence


Made by Perfloop. Human sponsor: Tomás Senart.

@milosgajdos

Copy link
Copy Markdown
Member

@perfloop-agent can you squash

@tsenart
tsenart force-pushed the perfloop-pr-open-rnme8xnp16 branch from 0afd3e0 to df591bc Compare November 26, 2026 20:52
@tsenart

tsenart commented Nov 26, 2026

Copy link
Copy Markdown

@milosgajdos squashed into one commit, with the same code as before. The CI runs are now waiting for a maintainer to approve them, because I pushed the squash from my account. Could you approve them?

Buffered writes may fail for the first time during Commit. Cancel the writer before returning a commit error so its temporary file is closed and removed, and join any cleanup error with the original failure.

Force a buffered PutContent write to exceed RLIMIT_FSIZE during Commit. Check that no temporary file remains and that a previous destination is left intact. Run the limit-bound checks in a child process so the limit cannot affect other tests or the Go test log.

Signed-off-by: Perfloop Agent <[email protected]>
@perfloop-agent
perfloop-agent force-pushed the perfloop-pr-open-rnme8xnp16 branch from df591bc to 5a32308 Compare November 26, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants