Skip to content

br: add content length for multi part upload#19358

Merged
ti-chi-bot[bot] merged 7 commits intotikv:masterfrom
Leavrth:content_length_for_multi_part_upload
Feb 15, 2026
Merged

br: add content length for multi part upload#19358
ti-chi-bot[bot] merged 7 commits intotikv:masterfrom
Leavrth:content_length_for_multi_part_upload

Conversation

@Leavrth
Copy link
Contributor

@Leavrth Leavrth commented Feb 10, 2026

What is changed and how it works?

Issue Number: Close #19352

What's Changed:

add Content-Length into HTTP Request Header to make it compatible with GCP S3 compatible service.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Release note

None

Summary by CodeRabbit

  • Bug Fixes

    • Improved S3 multipart upload behavior so multipart uploads, completes, and aborts include correct HTTP length handling, reducing multipart upload errors.
  • Tests

    • Added tests covering multipart abort flows and updated tests for multipart uploads.
    • Adjusted timing metric tests to verify upload-part histogram behavior and ensure reliable histogram tracking.

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
Copilot AI review requested due to automatic review settings February 10, 2026 08:37
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 10, 2026
Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Adds request customization to set explicit Content-Length headers for S3 multipart operations (create, upload part, complete, abort) and extends tests to assert those headers and add an abort-after-part multipart test with histogram checks.

Changes

Cohort / File(s) Summary
S3 multipart implementation & tests
components/cloud/aws/src/s3.rs
Adds request customize/mutate_request hooks to set Content-Length (0 for create/abort, explicit values for upload parts and complete). Updates tests to assert Content-Length in mocked requests, inject header values for begin/parts/complete, adds test_s3_storage_multi_part_abort, and adjusts histogram assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nudged the bytes to count each part,
Set lengths so uploads make a start.
If pieces fall and transfers abort,
I tidy up and keep the port.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title correctly identifies the main change: adding Content-Length header for multipart uploads in S3.
Description check ✅ Passed The description follows the template, includes the required Issue Number linking to #19352, specifies what changed with a commit message, and provides a release note.
Linked Issues check ✅ Passed The code changes directly address issue #19352 by adding Content-Length headers to multipart upload requests for GCP S3 compatibility.
Out of Scope Changes check ✅ Passed All changes focus on adding Content-Length headers to S3 multipart upload requests and updating related tests, which are within scope of issue #19352.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds explicit Content-Length headers to S3 multipart-upload related requests in TiKV’s AWS cloud storage implementation to improve compatibility with GCP’s S3-compatible service (which can return HTTP 411 when Content-Length is missing).

Changes:

  • Customize create_multipart_upload, complete_multipart_upload, and abort_multipart_upload requests to add Content-Length.
  • Update multipart upload tests to include Content-Length expectations.
  • Add a new test covering abort behavior on multipart upload failure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@components/cloud/aws/src/s3.rs`:
- Around line 1069-1089: The mocked abort multipart upload response currently
uses a CompleteMultipartUploadResult XML which is semantically incorrect; locate
the ReplayEvent::new that builds the Request with query
x-id=AbortMultipartUpload (the URI containing
"x-id=AbortMultipartUpload&uploadId=1") and replace the response body in its
http::Response::builder() call to be an empty body (or a minimal empty XML) to
accurately represent AbortMultipartUpload semantics instead of the
CompleteMultipartUploadResult payload.
- Around line 1018-1019: The inline comment above the multipart test referencing
"split magic_contents into 3 parts, so we mock 5 requests here(1 begin + 3 part
+ 1 complete)" is a copy-paste artifact and should be corrected to reflect the
abort path exercised by the test: update the comment to mention "1 abort" (or "1
abort request") instead of "1 complete" and optionally note that the mocked
requests are 1 begin + 3 part + 1 abort; locate the comment near the
magic_contents split in the multipart upload test in s3.rs and change the
wording accordingly.
- Around line 1107-1114: The histogram assertion reads a process-global metric
CLOUD_REQUEST_HISTOGRAM_VEC via
get_metric_with_label_values(...).get_sample_count() and compares to an absolute
value, which is flaky because other tests (e.g., test_s3_storage_multi_part)
also observe "upload_part"; change the test to snapshot the prior count by
calling get_sample_count() before the operation, run the upload/abort steps,
then re-read get_sample_count() and assert the difference (new - old) equals the
expected number of observations ((magic_contents.len() / multi_part_size) as
u64); apply the same delta-assertion pattern to test_s3_storage_multi_part as
well so both tests compare deltas instead of absolute counts.
🧹 Nitpick comments (2)
components/cloud/aws/src/s3.rs (2)

947-955: Minor inconsistency: the 3rd upload_part mock is missing the content-length header, while parts 1 and 2 include it.

Parts 1 and 2 explicitly assert header("content-length", "2"), but part 3 (also a 2-byte body "90") omits it. This doesn't break the test (the SDK sets the header via .content_length() on the builder anyway), but for consistency and completeness:

Proposed fix
             ReplayEvent::new(
                 http::Request::builder()
+                    .header("content-length", "2")
                     .uri(Uri::from_static(
                         "https://s3.cn-north-1.amazonaws.com.cn/mybucket/mykey?x-id=UploadPart&partNumber=3&uploadId=1"
                     ))

1060-1066: Same inconsistency as in the success test: 3rd upload_part mock is missing content-length header.

Same issue as noted in test_s3_storage_multi_part — part 3's mock should include .header("content-length", "2") for consistency with parts 1 and 2.

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Feb 12, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Feb 15, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: v01dstar, YuJuncen

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 15, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Feb 15, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-02-12 10:25:45.623758442 +0000 UTC m=+100498.703749137: ☑️ agreed by YuJuncen.
  • 2026-02-15 06:55:49.600356327 +0000 UTC m=+81602.615049797: ☑️ agreed by v01dstar.

@ti-chi-bot ti-chi-bot bot merged commit faed5a7 into tikv:master Feb 15, 2026
10 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone Feb 15, 2026
@Leavrth Leavrth added needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. labels Feb 15, 2026
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #19375.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #19376.

@Leavrth
Copy link
Contributor Author

Leavrth commented Feb 15, 2026

/cherry-pick release-8.5-20260215-v8.5.5

@ti-chi-bot
Copy link
Member

@Leavrth: new pull request created to branch release-8.5-20260215-v8.5.5: #19377.

Details

In response to this:

/cherry-pick release-8.5-20260215-v8.5.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

v01dstar pushed a commit that referenced this pull request Feb 15, 2026
* draft

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>

* add unit tests

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>

* fix typos

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>

* make clippy

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>

* fix unit test

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>

---------

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
Co-authored-by: Jianjun Liao <jianjun.liao@outlook.com>
ti-chi-bot bot pushed a commit that referenced this pull request Mar 5, 2026
close #19352

add Content-Length into HTTP Request Header to make it compatible with GCP S3 compatible service.

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>

Co-authored-by: Jianjun Liao <jianjun.liao@outlook.com>
mittalrishabh pushed a commit to mittalrishabh/tikv that referenced this pull request Mar 7, 2026
close tikv#19352

add Content-Length into HTTP Request Header to make it compatible with GCP S3 compatible service.

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
mittalrishabh pushed a commit to mittalrishabh/tikv that referenced this pull request Mar 7, 2026
close tikv#19352

add Content-Length into HTTP Request Header to make it compatible with GCP S3 compatible service.

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
Signed-off-by: rishabh mittal <mittalrishabh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws-sdk-rust doesn't support GCP s3 API server

5 participants