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

kv/client: add global grpc connection pool #2511

Merged
merged 11 commits into from
Aug 15, 2021

Conversation

amyangfei
Copy link
Contributor

@amyangfei amyangfei commented Aug 12, 2021

What problem does this PR solve?

Add global gRPC connection pool in cdc server.

What is changed and how it works?

  • The gRPC pool is shared by all kv clients in a capture, the pool is created before a capture starts running and destroyed after a capture suicides or exits.
  • The gPRC pool maintains a bucket of gPRC connections for each TiKV store, the bucket is increased in a lazy way.
  • The gPRC pool provides a builtin recycle method, which is used to collect idle connections periodically.

Check List

Tests

  • Unit test
  • Integration test

Release note

Add a global gRPC connection pool and share gRPC connections among kv clients.

@amyangfei amyangfei added component/kv-client TiKV kv log client component. needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. needs-cherry-pick-release-5.2 Should cherry pick this PR to release-5.2 branch. labels Aug 12, 2021
@amyangfei amyangfei added this to the v5.2.0 milestone Aug 12, 2021
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 12, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • liuzix
  • overvenus

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 12, 2021
@ti-chi-bot ti-chi-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 12, 2021
@amyangfei
Copy link
Contributor Author

/run-all-tests

@amyangfei
Copy link
Contributor Author

/run-integration-tests

Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

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

Rest LGTM

// reference of the shared connection
type GrpcPool interface {
// GetConn returns an available gRPC ClientConn
GetConn(ctx context.Context, target string) (*sharedConn, error)
Copy link
Member

Choose a reason for hiding this comment

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

When we cancel the ctx are on-going connections also cancelled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add bounded context in grpc pool

cdc/kv/client.go Show resolved Hide resolved
cdc/kv/client.go Outdated Show resolved Hide resolved
@amyangfei
Copy link
Contributor Author

/run-all-tests

@amyangfei
Copy link
Contributor Author

/run-leak-tests

@amyangfei
Copy link
Contributor Author

/run-all-tests

@amyangfei
Copy link
Contributor Author

/run-all-tests

@amyangfei
Copy link
Contributor Author

/run-kafka-tests

@amyangfei
Copy link
Contributor Author

PTAL @overvenus @liuzix

Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

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

LGTM

@amyangfei
Copy link
Contributor Author

/run-all-tests

@amyangfei
Copy link
Contributor Author

/run-all-tests

@amyangfei
Copy link
Contributor Author

/run-integration-tests

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2021

Codecov Report

Merging #2511 (ab1bb18) into master (21c466c) will decrease coverage by 0.2201%.
The diff coverage is 65.2519%.

@@               Coverage Diff                @@
##             master      #2511        +/-   ##
================================================
- Coverage   56.1544%   55.9342%   -0.2202%     
================================================
  Files           169        169                
  Lines         20465      20567       +102     
================================================
+ Hits          11492      11504        +12     
- Misses         7848       7938        +90     
  Partials       1125       1125                

@amyangfei
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 2669675

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 15, 2021
@amyangfei
Copy link
Contributor Author

/run-integration-tests
/run-kafka-tests

1 similar comment
@amyangfei
Copy link
Contributor Author

/run-integration-tests
/run-kafka-tests

@amyangfei
Copy link
Contributor Author

/run-integration-tests

@ti-chi-bot ti-chi-bot merged commit 4f7c0b9 into pingcap:master Aug 15, 2021
ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Aug 15, 2021
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #2531.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #2533.

@amyangfei amyangfei deleted the global-grpc-pool branch August 15, 2021 09:31
ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Aug 15, 2021
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #2534.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #2535.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/kv-client TiKV kv log client component. needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. needs-cherry-pick-release-5.2 Should cherry pick this PR to release-5.2 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants