Skip to content

PS-10416 / PS-11509: Send Content-MD5 header for S3 uploads to support Object Lock - #42

Open
kamil-holubicki wants to merge 1 commit into
mysql:masterfrom
kamil-holubicki:CUSTOM-264
Open

PS-10416 / PS-11509: Send Content-MD5 header for S3 uploads to support Object Lock#42
kamil-holubicki wants to merge 1 commit into
mysql:masterfrom
kamil-holubicki:CUSTOM-264

Conversation

@kamil-holubicki

Copy link
Copy Markdown

https://bugs.mysql.com/bug.php?id=119568

Problem:
util.dumpInstance() to an AWS S3 bucket with Object Lock enabled fails because S3 requires a client-side checksum on every payload-bearing PUT that creates a new object version. Without Content-MD5 (or an x-amz-checksum-* header) both single-shot PutObject and multipart UploadPart are rejected with 400 'Content-MD5 OR x-amz-checksum-* HTTP header is required ... with Object Lock parameters'.

Cause:
Neither PutObject nor UploadPart was emitting a client-side checksum header. Small dumps that fit in a single-shot PutObject and larger dumps that go through the multipart UploadPart path were failing for the same underlying reason.

Solution:
Inject Content-MD5 once, at signing time, inside the AWS request signer. Every payload-bearing S3 request funnels through that signer - it is where the SigV4 authorization header and the x-amz-content-sha256 payload hash are already assembled - so a single addition there covers both PutObject and UploadPart without touching any bucket, container, or backend class.

The injection is guarded so it only fires when the request carries a client-side body, leaving no-body operations (HeadObject, GetObject, DeleteObject, CopyObject, UploadPartCopy, CreateBucket) untouched, and it preserves any Content-MD5 the caller already set - notably the one that S3_bucket::delete_objects computes over its batch-delete XML body. The signature-caching layer already bypasses the cache whenever the request carries a body, so the MD5 is recomputed fresh whenever the payload changes.

Anonymous access short-circuits earlier and bypasses signing; that is intentional and safe because S3 rejects anonymous PUT/UploadPart against an Object-Lock bucket as unauthorized before Object Lock is evaluated.

…t Object Lock

https://perconadev.atlassian.net/browse/PS-10416
https://perconadev.atlassian.net/browse/PS-11509

Problem:
util.dumpInstance() to an AWS S3 bucket with Object Lock enabled fails
because S3 requires a client-side checksum on every payload-bearing PUT
that creates a new object version. Without Content-MD5 (or an
x-amz-checksum-* header) both single-shot PutObject and multipart
UploadPart are rejected with 400 'Content-MD5 OR x-amz-checksum-* HTTP
header is required ... with Object Lock parameters'.

Cause:
Neither PutObject nor UploadPart was emitting a client-side checksum
header. Small dumps that fit in a single-shot PutObject and larger dumps
that go through the multipart UploadPart path were failing for the same
underlying reason.

Solution:
Inject Content-MD5 once, at signing time, inside the AWS request signer.
Every payload-bearing S3 request funnels through that signer - it is
where the SigV4 authorization header and the x-amz-content-sha256
payload hash are already assembled - so a single addition there covers
both PutObject and UploadPart without touching any bucket, container,
or backend class.

The injection is guarded so it only fires when the request carries a
client-side body, leaving no-body operations (HeadObject, GetObject,
DeleteObject, CopyObject, UploadPartCopy, CreateBucket) untouched, and
it preserves any Content-MD5 the caller already set - notably the one
that S3_bucket::delete_objects computes over its batch-delete XML body.
The signature-caching layer already bypasses the cache whenever the
request carries a body, so the MD5 is recomputed fresh whenever the
payload changes.

Anonymous access short-circuits earlier and bypasses signing; that is
intentional and safe because S3 rejects anonymous PUT/UploadPart against
an Object-Lock bucket as unauthorized before Object Lock is evaluated.
@mysql-oca-bot

Copy link
Copy Markdown

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

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