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

[to #555] enable api v2 #575

Merged
merged 38 commits into from
Jun 2, 2022
Merged

[to #555] enable api v2 #575

merged 38 commits into from
Jun 2, 2022

Conversation

iosmanthus
Copy link
Member

@iosmanthus iosmanthus commented Mar 24, 2022

Signed-off-by: iosmanthus myosmanthustree@gmail.com

What problem does this PR solve?

  • attach API version to context to AbstractRegionStoreClient, RegionStoreClient, LockResolverClientV4.
  • simple API conf check.

Issue Number: close #555 , and tracked by #582

Check List for Tests

This PR has been tested by at least one of the following methods:

  • Unit test
    • RawKV compatibility
    • TxnKV compatibility
  • Integration test

Related changes

  • Need to cherry-pick the release branch: v3.3

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@@ -155,6 +156,42 @@ public boolean onStoreUnreachable(BackOffer backOffer) {
return false;
}

public ByteString buildRequestKey(ByteString key) {
switch (conf.getApiVersion()) {
Copy link
Member

Choose a reason for hiding this comment

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

can we get the cluster version and tikv configuration from PD? so that we don't need to add one more config in the java client and the java client can automatically adjust the encode/decode methods according to the cluster it is connected to.

Copy link
Member Author

Choose a reason for hiding this comment

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

By design, the client should not read the TiKV configuration from PD or themself. Because:

  1. TiKV configurations could be different from each other due to the restart process.
  2. TiDB use client-go, which should have the same behaviour as the client-java, however, TiDB would never use API v2 but use API v1 instead, due to they have a key prefix with m or t. Thus, client-go should not read the API version from the cluster components, instead, just set the version to 1.

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@codecov
Copy link

codecov bot commented Mar 28, 2022

Codecov Report

Merging #575 (629d4fa) into master (774ee50) will increase coverage by 0.38%.
The diff coverage is 79.72%.

@@             Coverage Diff              @@
##             master     #575      +/-   ##
============================================
+ Coverage     34.11%   34.50%   +0.38%     
- Complexity     1369     1411      +42     
============================================
  Files           270      278       +8     
  Lines         17244    17342      +98     
  Branches       1958     1970      +12     
============================================
+ Hits           5882     5983     +101     
+ Misses        10752    10747       -5     
- Partials        610      612       +2     
Impacted Files Coverage Δ
src/main/java/org/tikv/common/ConfigUtils.java 0.00% <ø> (ø)
src/main/java/org/tikv/common/StoreVersion.java 69.76% <ø> (ø)
...ikv/common/operation/iterator/RawScanIterator.java 82.75% <ø> (ø)
.../java/org/tikv/txn/AbstractLockResolverClient.java 15.00% <0.00%> (-10.00%) ⬇️
src/main/java/org/tikv/txn/Lock.java 0.00% <0.00%> (ø)
...c/main/java/org/tikv/txn/LockResolverClientV4.java 4.54% <0.00%> (ø)
...java/org/tikv/common/operation/KVErrorHandler.java 39.47% <50.00%> (-3.77%) ⬇️
...va/org/tikv/common/apiversion/RequestKeyCodec.java 53.33% <53.33%> (ø)
src/main/java/org/tikv/common/TiConfiguration.java 67.37% <75.00%> (+0.50%) ⬆️
src/main/java/org/tikv/common/TiSession.java 70.23% <76.92%> (-0.06%) ⬇️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 774ee50...629d4fa. Read the comment docs.

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@iosmanthus iosmanthus changed the title [to #555] [WIP] enable api v2 [to #555] enable api v2 Apr 19, 2022
import org.tikv.common.TiConfiguration.ApiVersion;
import org.tikv.raw.RawKVClient;

public class ApiVersionTest {
Copy link
Member Author

Choose a reason for hiding this comment

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

@pingyu PTAL on this compatible test for API v2.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM~

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
…aster' of github.com:tikv/client-java into api-v2

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
…n api v2

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Copy link
Contributor

@zhangyangyu zhangyangyu left a comment

Choose a reason for hiding this comment

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

Much better! One thing I am curious is the usage of Pair. There are many places using it, like encodeRange. Why not directly use the Range type?

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@iosmanthus
Copy link
Member Author

The Range type will use the default comparator for the elements, it tends to be an actual range that use to compute if an element is between the min and max. The Pair type tells us that the return value is a tuple, nothing more.

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
xuanyu66
xuanyu66 previously approved these changes Jun 2, 2022
@ti-srebot
Copy link
Collaborator

@xuanyu66, Thanks for your review. The bot only counts LGTMs from Reviewers and higher roles, but you're still welcome to leave your comments. You are not a reviewer or committer or co-leader or leader.

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@ti-srebot
Copy link
Collaborator

@zhangyangyu, Thanks for your review. The bot only counts LGTMs from Reviewers and higher roles, but you're still welcome to leave your comments. You are not a reviewer or committer or co-leader or leader.

@iosmanthus
Copy link
Member Author

/auto-merge

@iosmanthus
Copy link
Member Author

/merge

@ti-srebot
Copy link
Collaborator

/run-all-tests

@iosmanthus iosmanthus merged commit 9ce52d3 into tikv:master Jun 2, 2022
@iosmanthus iosmanthus deleted the api-v2 branch June 2, 2022 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support TiKV API V2
7 participants