Skip to content

rgw: Teach CompleteMultipartUpload to adhere to S3 while completing an upload. - #68980

Open
nhoad wants to merge 5 commits into
ceph:mainfrom
nhoad:CompleteMultipartUpload-keepalive-bytes
Open

nhoad wants to merge 5 commits into
ceph:mainfrom
nhoad:CompleteMultipartUpload-keepalive-bytes

Conversation

@nhoad

@nhoad nhoad commented May 18, 2026

Copy link
Copy Markdown
Contributor

Multipart uploads can sometimes take a long time to complete in S3. According to the S3 docs, to cover this S3 periodically sends whitespace characters to prevent connection timeout. This PR implements that behavior in the RGW.

It works by using a coroutine to complete the upload, while the main coroutine sends whitespace every 5 seconds.

Tracker: https://tracker.ceph.com/issues/76260

I have tested this by intentionally delaying the upload coroutine like so:

diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc
index 28dd0a55960..0eb95ffd954 100644
--- a/src/rgw/rgw_op.cc
+++ b/src/rgw/rgw_op.cc
@@ -7598,6 +7598,11 @@ void RGWCompleteMultipart::execute(optional_yield y)
 
     boost::asio::spawn(executor,
       [&](boost::asio::yield_context yield) {
+        if (getenv("GO_SLOW")) {
+          boost::asio::steady_timer hack_timer(yield.get_executor());
+          hack_timer.expires_after(std::chrono::seconds(20));
+          hack_timer.async_wait(yield);
+        }
         complete_ret =
           upload->complete(this, optional_yield{yield}, s->cct, parts->parts,
                            remove_objs, accounted_size, compressed, cs_info, ofs,

And then using this to perform a multipart upload:

set -ex

AWS="aws --endpoint-url $ENDPOINT_URL s3api"

$AWS create-bucket --bucket testbucket

# start the upload
upload_id=$($AWS create-multipart-upload --bucket testbucket --key testobj | tee /dev/stderr | jq .UploadId -r)

# upload one part
dd if=/dev/zero bs=1M count=10 of=/tmp/testpart
etag=$($AWS upload-part --bucket testbucket --key testobj --part-number 1 --upload-id $upload_id --body /tmp/testpart | tee /dev/stderr | jq .ETag -r)

# complete the upload, check strace to see the whitespace
date
strace -s 10000 -e trace=recvfrom -tt -o complete-multipart-upload.strace $AWS --debug complete-multipart-upload --bucket testbucket --key testobj --upload-id $upload_id --multipart-upload "{\"Parts\":[{\"PartNumber\":1,\"ETag\":$etag}]}"
date

We can then look at the strace output to confirm this is working:

14:57:55.063970 recvfrom(3, "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nx-amz-request-id: tx00000ca904259dfaa9c48-006a076cb2-4325-default\r\nContent-Type: application/xml\r\nServer: Ceph Object Gateway (umbrella)\r\nDate: Fri, 15 May 2026 18:57:54 GMT\r\nConnection: Keep-Alive\r\n\r\n26\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n", 8192, 0, NULL, NULL) = 290
14:58:00.062978 recvfrom(3, "1\r\n \r\n", 8192, 0, NULL, NULL) = 6
14:58:05.064269 recvfrom(3, "1\r\n \r\n", 8192, 0, NULL, NULL) = 6
14:58:10.074829 recvfrom(3, "1\r\n \r\n", 8192, 0, NULL, NULL) = 6
14:58:15.066631 recvfrom(3, "1\r\n \r\n", 8192, 0, NULL, NULL) = 6
14:58:15.078386 recvfrom(3, "118\r\n<CompleteMultipartUploadResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><Location>http://localhost:8000/testbucket/testobj</Location><Bucket>testbucket</Bucket><Key>testobj</Key><ETag>&quot;9fbaeee0ccc66f9a8e3d3641dca37281-1&quot;</ETag></CompleteMultipartUploadResult>\r\n0\r\n\r\n", 8192, 0, NULL, NULL) = 292

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@nhoad
nhoad requested a review from a team as a code owner May 18, 2026 18:54
@github-actions github-actions Bot added the rgw label May 18, 2026

@cbodley cbodley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks @nhoad! minor comments but looks wonderful overall

Comment thread src/rgw/rgw_op.cc Resolved
Comment thread src/rgw/rgw_op.cc Resolved
Comment thread src/rgw/rgw_rest_s3.cc Resolved
Comment thread src/rgw/rgw_op.cc Resolved
Comment thread src/rgw/rgw_op.cc Resolved
@nhoad

nhoad commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @cbodley! I think I've addressed all of your comments.

Also I appreciate the insight into boost::asio, that's really helpful context - I don't have much experience with asio, even if I have done a bunch of async programming 😅 thank you!

@nhoad

nhoad commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@nhoad

nhoad commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@cbodley looks like CI had a transient failure on rocky 10 default, unrelated to the change - https://shaman.ceph.com/builds/ceph/CompleteMultipartUpload-keepalive-bytes/ do I need to retrigger the build?

@cbodley

cbodley commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

@nhoad probably yeah. when that happens to my builds, i do a "git commit --amend" on the branch so it gets a new commit sha, then force-push that to ceph-ci

@nhoad

nhoad commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@cbodley

cbodley commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@cbodley

cbodley commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

i see there's a java s3test that doesn't like these changes. example from https://qa-proxy.ceph.com/teuthology/cbodley-2026-06-10_19:36:53-rgw-CompleteMultipartUpload-keepalive-bytes-distro-default-trial/283570/teuthology.log

suite > AWS4 tests > AWS4Test.testMultipartUploadIncorrectMissingPartLLAPIAWS4 STARTED
suite > AWS4 tests > AWS4Test.testMultipartUploadIncorrectMissingPartLLAPIAWS4 FAILED
java.lang.AssertionError at AWS4Test.java:692

@nhoad

nhoad commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks Casey! Will take a look.

@nhoad
nhoad force-pushed the CompleteMultipartUpload-keepalive-bytes branch from cebc186 to a735fd0 Compare June 12, 2026 14:19
@nhoad

nhoad commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Very small fix, but that test failure revealed a legitimate issue. When connection reuse was in effect we weren't setting the error code properly, so the XML response was empty. Simple fix so I've added that now.

@nhoad

nhoad commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@cbodley

cbodley commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Rescheduled QA in https://pulpito-ng.ceph.com/runs/bcs-ceph-2026-06-23_14:00:30-rgw-wip-nhoad-CompleteMultipartUpload-keepalive-bytes-distro-default-smithi

lots of "failed to install new kernel version within timeout" failures there that need a rerun. and many jobs failing s3-tests, probably because of a skew between the ceph and s3-tests repos. can you please rebase this and try again?

nhoad added 5 commits July 9, 2026 12:23
…n upload.

Multipart uploads can sometimes take a long time to complete in S3. According to the S3 docs, to cover this S3 periodically sends whitespace characters to prevent connection timeout. This PR implements that behavior in the RGW.

It works by using a coroutine to complete the upload, while the main coroutine sends whitespace every 5 seconds.

Signed-off-by: Nathan Hoad <[email protected]>
AI-Assisted: Initial implementation was done with AI.
Because the coroutine was launched with the current connection's executor, it means that
no atomic is needed. We also don't need a boolean to track whether or not the upload is
done, we can just check the error code from waiting on the timer. If we have a non-zero ec,
then the timer was canceled and the upload is complete.

Also while I'm here, remove the explicit optional_yield{yield} in favor of doing the
conversion implicitly.

Signed-off-by: Nathan Hoad <[email protected]>
…esponse

When the keepalive path is taken (sent_header == true), the error
response body was missing the error code because set_req_state_err()
was only called in the !sent_header branch. This resulted in an empty
<Code></Code> element, which the AWS SDK cannot parse as a valid error.

Signed-off-by: Nathan Hoad <[email protected]>
@BBoozmen
BBoozmen force-pushed the CompleteMultipartUpload-keepalive-bytes branch from a735fd0 to 308c065 Compare July 9, 2026 16:27
@BBoozmen BBoozmen added wip-oozmen-testing for teuthology integration testing to be used via build-integration-branch.sh and removed wip-oozmen-testing for teuthology integration testing to be used via build-integration-branch.sh labels Jul 9, 2026
@anrao19

anrao19 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-07-17-06:18.

@nhoad nhoad removed the needs-qa label Jul 17, 2026
@nhoad

nhoad commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

I've removed the needs-qa label for now - the addition of s3-tests to QA has found some more real bugs in the implementation. I'm analysing and will bring it up at the next RGW meeting.

@nhoad

nhoad commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Yes, the testing needs to be updated - the current testing only checks the async path now, so the error codes don't match what it's expecting.

I'm going to update s3-tests to test both pathways, and will likely need to introduce a new config knob for this too. I'll update here when I have something to look :)

In the meantime, please exclude this PR/branch from any more QA testing.

@anrao19

anrao19 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-07-17-06:18.

No longer part of above tracker

@anrao19

anrao19 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This PR has been removed from wip-anuchaithra-testing-20260717.061820-main.

@cbodley

cbodley commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Yes, the testing needs to be updated - the current testing only checks the async path now, so the error codes don't match what it's expecting.

I'm going to update s3-tests to test both pathways, and will likely need to introduce a new config knob for this too. I'll update here when I have something to look :)

thanks @nhoad. afaik the only way to exercise the sync path is with rgw_beast_enable_async=0, and i don't think rgw's teuthology suite covers that at all? so i wouldn't bother adding test coverage there. i'd rather our s3-tests just cover api compatibility with aws s3

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Nov 15, 2026
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.

5 participants