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

store/tikv: forward requests by BatchCommands #23243

Merged
merged 10 commits into from
Mar 18, 2021

Conversation

youjiali1995
Copy link
Contributor

@youjiali1995 youjiali1995 commented Mar 10, 2021

Signed-off-by: youjiali1995 zlwgx1023@gmail.com

What problem does this PR solve?

Problem Summary:

Support forwarding requests by BatchCommands. Based on #23362.

What is changed and how it works?

What's Changed:

Create a BatchCommands for each forwarded host in a single connection.

How it Works:

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Release note

  • No release note

@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 10, 2021
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@youjiali1995 youjiali1995 force-pushed the support-redirection-metadata branch from ee58a24 to d00ce77 Compare March 10, 2021 12:45
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 16, 2021
@youjiali1995 youjiali1995 force-pushed the support-redirection-metadata branch from af07828 to b1bb6af Compare March 16, 2021 06:10
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@youjiali1995 youjiali1995 force-pushed the support-redirection-metadata branch from b1bb6af to e56fed4 Compare March 16, 2021 06:31
Copy link
Contributor

@tiancaiamao tiancaiamao left a comment

Choose a reason for hiding this comment

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

If "forwardedHost" is set, the request is sent to that host, instead of the node specified by the "addr"?

So why not simply modify the SendRequest function:

func (c *RPCClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error) {
     if req.ForwardedHost != nil {
        return originalSendRequest(ctx, req.ForwardedHost, ...)
     }
     originalSendRequest(ctx, addr, ...) 
}

Add forwardedClients map[string]*batchCommandsStream to batchCommandsClient to gain the ability to send requests to other(any) nodes looks weird.

store/tikv/client.go Outdated Show resolved Hide resolved
store/tikv/client_batch.go Outdated Show resolved Hide resolved
@youjiali1995
Copy link
Contributor Author

If "forwardedHost" is set, the request is sent to that host, instead of the node specified by the "addr"?

No. The request is sent to the node with the address at "addr". If "forwardedHost" is set, the request will be forwarded to the "forwardedHost" by the node as a proxy, i.e. TiDB -> TiKV(addr) -> TiKV(forwardedHost) @tiancaiamao

BTW, I will split this PR into 2. One is to forward requests by unary-calls and the second is to forward requests by BatchCommands. The second one lacks tests and I will add it today.

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@youjiali1995 youjiali1995 changed the title store/tikv: support redirection metadata store/tikv: forward requests by BatchCommands Mar 17, 2021
…-redirection-metadata

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@youjiali1995
Copy link
Contributor Author

/run-all-tests

@youjiali1995
Copy link
Contributor Author

/run-unit-test

…-redirection-metadata

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@youjiali1995
Copy link
Contributor Author

/run-all-tests

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@youjiali1995
Copy link
Contributor Author

/run-all-tests

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@youjiali1995
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor

/LGTM

I have to point out that the complexity of supporting the batch mode maybe not worth its value.
There might be a huge burden for future maintenance work.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 18, 2021
Copy link
Contributor

@MyonKeminta MyonKeminta left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot
Copy link
Member

@MyonKeminta: Please use /LGTM instead of LGTM when you want to approve the pull request by comment.
If you use the GitHub review feature, please approve the PR directly, the comment will not take effect in the GitHub review feature.
If you have any qustions please refer to lgtm command help or lgtm plugin design.

If you have approved this PR, please ignore this reply. This reply is being used as a temporary reply during the migration of the new bot and will be removed on April 1.

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.

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • MyonKeminta
  • tiancaiamao

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 18, 2021
@youjiali1995
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 94ace66

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

/run-unit-test

@youjiali1995
Copy link
Contributor Author

[2021-03-18T15:13:37.242Z] ----------------------------------------------------------------------
[2021-03-18T15:13:37.242Z] FAIL: simple_test.go:606: testSuite3.TestDropPartitionStats
[2021-03-18T15:13:37.242Z] 
[2021-03-18T15:13:37.242Z] simple_test.go:631:
[2021-03-18T15:13:37.242Z]     tk.MustExec("analyze table t")
[2021-03-18T15:13:37.242Z] /home/jenkins/agent/workspace/tidb_ghpr_unit_test/go/src/github.com/pingcap/tidb/util/testkit/testkit.go:217:
[2021-03-18T15:13:37.242Z]     tk.c.Assert(err, check.IsNil, check.Commentf("sql:%s, %v, error stack %v", sql, args, errors.ErrorStack(err)))
[2021-03-18T15:13:37.242Z] ... value *errors.withStack = [stats]: some partition level statistics are not in statistics version 2, please set tidb_analyze_version to 2 and analyze the this table ("[stats]: some partition level statistics are not in statistics version 2, please set tidb_analyze_version to 2 and analyze the this table")
[2021-03-18T15:13:37.242Z] ... sql:analyze table t, [], error stack [stats]: some partition level statistics are not in statistics version 2, please set tidb_analyze_version to 2 and analyze the this table
[2021-03-18T15:13:37.242Z] github.com/pingcap/errors.AddStack
[2021-03-18T15:13:37.242Z] 	/home/jenkins/agent/workspace/tidb_ghpr_unit_test/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20201126102027-b0a155152ca3/errors.go:174
[2021-03-18T15:13:37.242Z] github.com/pingcap/errors.Trace
[2021-03-18T15:13:37.242Z] 	/home/jenkins/agent/workspace/tidb_ghpr_unit_test/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20201126102027-b0a155152ca3/juju_adaptor.go:15
[2021-03-18T15:13:37.242Z] github.com/pingcap/tidb/util/testkit.(*TestKit).Exec
[2021-03-18T15:13:37.242Z] 	/home/jenkins/agent/workspace/tidb_ghpr_unit_test/go/src/github.com/pingcap/tidb/util/testkit/testkit.go:176
[2021-03-18T15:13:37.242Z] github.com/pingcap/tidb/util/testkit.(*TestKit).MustExec
[2021-03-18T15:13:37.242Z] 	/home/jenkins/agent/workspace/tidb_ghpr_unit_test/go/src/github.com/pingcap/tidb/util/testkit/testkit.go:216
[2021-03-18T15:13:37.242Z] github.com/pingcap/tidb/executor_test.(*testSuite3).TestDropPartitionStats
[2021-03-18T15:13:37.242Z] 	/home/jenkins/agent/workspace/tidb_ghpr_unit_test/go/src/github.com/pingcap/tidb/executor/simple_test.go:631
[2021-03-18T15:13:37.242Z] reflect.Value.call
[2021-03-18T15:13:37.242Z] 	/usr/local/go/src/reflect/value.go:460
[2021-03-18T15:13:37.242Z] reflect.Value.Call
[2021-03-18T15:13:37.242Z] 	/usr/local/go/src/reflect/value.go:321
[2021-03-18T15:13:37.242Z] github.com/pingcap/check.(*suiteRunner).forkTest.func1
[2021-03-18T15:13:37.242Z] 	/home/jenkins/agent/workspace/tidb_ghpr_unit_test/go/pkg/mod/github.com/pingcap/check@v0.0.0-20200212061837-5e12011dc712/check.go:850
[2021-03-18T15:13:37.242Z] github.com/pingcap/check.(*suiteRunner).forkCall.func1
[2021-03-18T15:13:37.242Z] 	/home/jenkins/agent/workspace/tidb_ghpr_unit_test/go/pkg/mod/github.com/pingcap/check@v0.0.0-20200212061837-5e12011dc712/check.go:739
[2021-03-18T15:13:37.242Z] runtime.goexit
[2021-03-18T15:13:37.242Z] 	/usr/local/go/src/runtime/asm_amd64.s:1357
[2021-03-18T15:13:37.242Z] 

@ti-chi-bot ti-chi-bot merged commit 3813da0 into pingcap:master Mar 18, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Mar 18, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #23420

@youjiali1995 youjiali1995 deleted the support-redirection-metadata branch March 18, 2021 15:44
@youjiali1995
Copy link
Contributor Author

/run-cherry-picker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tikv needs-cherry-pick-release-5.0 sig/transaction SIG:Transaction 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