vitess icon indicating copy to clipboard operation
vitess copied to clipboard

prevent vtctld from creating tons of S3 connections

Open rvrangel opened this issue 2 years ago • 3 comments

Description

This fixes the issue described in #15335. It seems the bug was introduced in #4200.

The default transport was changed in favour of one were we could skip validating S3 certificates, but instead of cloning the default transport and adjusting the settings, we are creating a new transport from scratch but not setting any defaults (see current Go defaults for DefaultTransport). By doing so, we don't set keepalives, timeouts, max idle connections, etc and other values in Transport and since some default to zero it basically means "no limit". To make matters worse, since we are creating a new transport for every client (in this case, for each request from what I understand), there is no sharing of connections between different requests, so the first call to GetBackups() will open some S3 connections and keep them on its private transport instead of sharing it across different requests.

After this fix, the number of established connections seems to be consistently below 5, and from initial testing it seems S3 connection errors seem to be gone.

Related Issue(s)

Checklist

  • [ ] "Backport to:" labels have been added if this change should be back-ported to release branches
  • [ ] If this change is to be back-ported to previous releases, a justification is included in the PR description
  • [ ] Tests were added or are not required
  • [ ] Did the new or modified tests pass consistently locally and on CI?
  • [ ] Documentation was added or is not required

Deployment Notes

rvrangel avatar Feb 20 '24 13:02 rvrangel

Review Checklist

Hello reviewers! :wave: Please follow this checklist when reviewing this Pull Request.

General

  • [x] Ensure that the Pull Request has a descriptive title.
  • [x] Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • [x] Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • [ ] Apply the release notes (needs details) label if users need to know about this change.
  • [ ] New features should be documented.
  • [ ] There should be some code comments as to why things are implemented the way they are.
  • [ ] There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • [ ] Is this flag really necessary?
  • [ ] Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • [ ] Each item in Jobs should be named in order to mark it as required.
  • [ ] If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • [ ] Protobuf changes should be wire-compatible.
  • [ ] Changes to _vt tables and RPCs need to be backward compatible.
  • [ ] RPC changes should be compatible with vitess-operator
  • [ ] If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • [ ] vtctl command output order should be stable and awk-able.

vitess-bot[bot] avatar Feb 20 '24 13:02 vitess-bot[bot]

Codecov Report

Attention: Patch coverage is 85.71429% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 65.44%. Comparing base (696fe0e) to head (13a3911). Report is 68 commits behind head on main.

Files Patch % Lines
go/vt/mysqlctl/s3backupstorage/s3.go 85.71% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15296      +/-   ##
==========================================
- Coverage   67.41%   65.44%   -1.98%     
==========================================
  Files        1560     1562       +2     
  Lines      192752   193914    +1162     
==========================================
- Hits       129952   126906    -3046     
- Misses      62800    67008    +4208     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 20 '24 13:02 codecov[bot]

thanks @deepthi , I created #15335 and mentioned it here in the PR description

rvrangel avatar Feb 22 '24 15:02 rvrangel

This is a really great contribution @rvrangel! Thank you.

deepthi avatar Mar 04 '24 19:03 deepthi