Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3: add RecreateWhenSlow for S3 GetObject API #59342

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Feb 8, 2025

What problem does this PR solve?

Issue Number: close #59341

Problem Summary:

What changed and how does it work?

We found a problem that in AWS Golang SDK when we don't read the HTTP connection of GetObject for a long time, the connection may be stuck. After inspecting packets from tcpdump and consulting AWS supports, we choose to reopen the HTTP connection for the slow connection as a temporary workaround. A better and future solution could be let multiple HTTP requests using the 1 TCP connection but it may need to manually enable http2 or choose AWS CRT client which is not availble in Golang.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (testing in the use case that revealed the problem)
  • No need to test
    • I checked and no code files have been changed.

image

Side effects

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

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 8, 2025
Copy link

ti-chi-bot bot commented Feb 8, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from lance6716, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

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

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

Copy link

codecov bot commented Feb 8, 2025

Codecov Report

Attention: Patch coverage is 81.92771% with 15 lines in your changes missing coverage. Please review.

Project coverage is 74.8231%. Comparing base (e4dc47f) to head (0d7620a).
Report is 12 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #59342        +/-   ##
================================================
+ Coverage   73.0960%   74.8231%   +1.7271%     
================================================
  Files          1690       1736        +46     
  Lines        467135     477451     +10316     
================================================
+ Hits         341457     357244     +15787     
+ Misses       104710      97714      -6996     
- Partials      20968      22493      +1525     
Flag Coverage Δ
integration 48.9729% <0.0000%> (?)
unit 72.2071% <81.9277%> (-0.0660%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 61.1868% <81.7073%> (+15.6751%) ⬆️

@lance6716 lance6716 changed the title [WIP]s3: add RecreateWhenSlow for S3 GetObject API s3: add RecreateWhenSlow for S3 GetObject API Feb 10, 2025
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 10, 2025
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
case <-done:
}

if err = r.recreateConn(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

it might keep recreating if new connection is also slow

Copy link
Contributor Author

@lance6716 lance6716 Feb 11, 2025

Choose a reason for hiding this comment

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

It's expected. If new connection is slow, we still can't make progress, so still recreating to see if the network is getting better. Also I will double expectedDuration to avoid the duration is set too small and always fails

Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Feb 11, 2025

@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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 kubernetes-sigs/prow repository.

@D3Hunter
Copy link
Contributor

a little messy to workaround like this, I recommend we merge it unless we have to, and let the kernel fix it.

the kernel bug not only affect TiDB, it affect every other applications require access S3 or other network endpoint, the user should better choose a distribution without the bug. Also I check some popular distribution of linux, kernel 6.x is mostly used in more recent version, it has bigger chance that it's not the mainstream version used.
see https://distrowatch.com/table.php?distribution=centos

@lance6716
Copy link
Contributor Author

lance6716 commented Feb 11, 2025

I have tested that without this fix, using Amazon Linux as OS (mimic EKS behaviour) the merge step will still stuck. This stuck is caused by S3 server deliberately choose not to send data after a TCP connection has been in a bad state for a long time. So we still need to reopen it.

AWS support says this is because S3 is not designed to serve long connection. Malicious users can use long connections to exhaust the S3 server resources. But our merge step really need the long connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

overcome the S3 GetObject slow connections
2 participants