Skip to content

fix(s3): pin direct reads to the opened revision - #460

Open
ravi-pplx wants to merge 1 commit into
block:mainfrom
perplexityai:fix/s3-pin-direct-reads
Open

ravi-pplx wants to merge 1 commit into
block:mainfrom
perplexityai:fix/s3-pin-direct-reads

Conversation

@ravi-pplx

@ravi-pplx ravi-pplx commented Nov 22, 2026 •

Copy link
Copy Markdown

S3.Open stats the object, builds the response headers from that revision (Content-Length, the ETag and the stored headers), and then streams the body. Ranged reads and parallel full reads send the statted S3 ETag as If-Match, so they never mix revisions. The direct full read doesn't. It serves every object no larger than download-part-size-mb (32 MiB by default), and every full read when download-concurrency = 1. minio sends that GET on the first Read, so if the key is rewritten after Open returns, the caller gets the new body with the old revision's headers, including a Content-Length that may not match it.

Change

  • The direct read now sends the statted ETag as If-Match, like rangeGetReader and the parallel windows. If the object was rewritten, the read fails with S3's PreconditionFailed instead of returning the other revision.
  • cachetest.Soak counts PreconditionFailed as a miss, the same way it already counts an object deleted between Open and Read. Without this, TestS3CacheSoak (run with SOAK_TEST=1) fails intermittently on the new error, because 30% of its writes overwrite existing keys.

Behaviour changes

  • A direct S3 read of an object rewritten between Open and the first Read returns an error instead of the rewritten body. Ranged and parallel reads already do this.

Testing

  • TestS3OpenPinsDirectReads opens an object, rewrites it, and expects the read to fail with PreconditionFailed. It covers a small object and download-concurrency = 1. On main, both cases read the rewritten body without an error.

Created with Perplexity

Open takes the response headers, including Content-Length and the ETag,
from the object it stats, then streams the body. Ranged reads and
parallel full reads send the statted S3 ETag as If-Match, but the direct
full read, used for objects up to one download part and when
download-concurrency is 1, did not. minio issues that GET on the first
Read, so a key rewritten in between was served with the new body under
the old revision's headers.

The direct read now sends If-Match too, so a rewrite fails the read
with S3's PreconditionFailed, as the other read paths already do. The
soak test counts that error as a miss, like a delete between Open and
Read.

Signed-off-by: Ravi Agarwal <ravi@perplexity.ai>
Co-authored-by: Perplexity <noreply@perplexity.ai>
@ravi-pplx
ravi-pplx requested a review from a team as a code owner November 22, 2026 03:58
@ravi-pplx
ravi-pplx requested review from inez and removed request for a team November 22, 2026 03:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T04:00:23.355689Z 0156d5e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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