-
Notifications
You must be signed in to change notification settings - Fork 244
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
Refactor RegionStoreClient logic #989
Conversation
/run-all-tests |
/run-all-tests |
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
others LGTM
tikv-client/src/main/java/com/pingcap/tikv/operation/iterator/ConcreteScanIterator.java
Outdated
Show resolved
Hide resolved
tikv-client/src/main/java/com/pingcap/tikv/operation/iterator/ScanIterator.java
Outdated
Show resolved
Hide resolved
tikv-client/src/main/java/com/pingcap/tikv/operation/iterator/ScanIterator.java
Outdated
Show resolved
Hide resolved
/run-all-tests |
tikv-client/src/main/java/com/pingcap/tikv/operation/KVErrorHandler.java
Outdated
Show resolved
Hide resolved
tikv-client/src/main/java/com/pingcap/tikv/operation/iterator/ScanIterator.java
Outdated
Show resolved
Hide resolved
private boolean loadCache() { | ||
if (endOfScan) { | ||
return false; | ||
abstract TiRegion loadCurrentRegionToCache() throws GrpcException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by the name of the method.
if (currentCache.size() < session.getConf().getScanBatchSize()) { | ||
// Current region done, start new batch from next region | ||
startKey = region.getEndKey(); | ||
if (currentCache.size() < conf.getScanBatchSize()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this if check?
tikv-client/src/main/java/com/pingcap/tikv/region/RegionStoreClient.java
Show resolved
Hide resolved
/run-all-tests |
1 similar comment
/run-all-tests |
/run-all-tests |
* 2.2.0 -> 2.3.0 (#947) * Add tests for primary key (#948) * add changelog (#955) * add multi-column tests (#954) * fix range partition throw UnsupportedSyntaxException error (#960) * fix view parsing problem (#953) * make tispark can read from a hash partition table (#966) * increase ci worker number (#965) * update readme for tispark-2.1.2 release (#968) * update document for pyspark (#975) * fix one jar bug (#972) * adding common port number used by spark cluster (#973) * fix cost model in table scan (#977) * create an UninitializedType for TypeDecimal (#979) * update sparkr doc (#976) * use spark-2.4.3 to run ut (#978) * use spark-2.4.3 to run ut * fix ci * a better design for get auto table id (#980) * fix bug: ci SpecialTiDBTypeTestSuite failed with tidb-3.0.1 (#984) * improve TiConfiguration getPdAddrsString function (#963) * bump grpc to 1.17 (#982) * Add multiple-column PK tests (#970) * add retry for batchGet (#986) * use tispark self-made m2 cahce file (#990) * add spark sql document for batch write (#991) * add auto mode for test.data.load (#994) * fix typo (#996) * fix index scan bug (#995) * refine doc (#1003) * add tidb-3.0 compatibility document (#998) * add tidb-3.0 compatibility document * address code review * address code review * add log4j config document (#1008) * refactor batch write region pre-split (#999) * add ci simple mode (#1012) * clean up redundant code (#997) * prohibit agg or groupby pushdown on double read (#1004) * remove split region code (#1015) * add supported scala version (#1013) * Fix scala compiler version (#1010) * fix reflection bug for hdp release (#1017) (#1018) (cherry picked from commit 118b12e) * check by grammarly (#1022) * add benchmark result for batch write (#1025) * release tispark 2.1.3 (#1026) (#1035) (cherry picked from commit 107eb2b) * support setting random seed in daily regression test (#1032) * Remove create in tisession (#1021) * set tikv region size from 96M to 1M (#1031) * adding unique indices test for batch write (#1014) * use one unique seed (#1043) * remove unused code (#1030) * adding batch write pk insertion test (#1044) * fix table not found bug in TiSession because of synchronization (#1041) * fix test failure (#1051) * fix reflection bug: pass in different arguments for different version of same function (#1037) (#1052) (cherry picked from commit a5462c2) * Adding pk and unique index test for batch write (#1049) * fix distinct without alias bug: disable pushdown aggregate with alias (#1054) * improve the doc (#1053) * Refactor RegionStoreClient logic (#989) * using stream rather removeIf (#1057) * Remove redundant pre-write/commit logic in LockResolverTest (#1062) * adding recreate flag when create tisession (#1064) * fix issue 1047 (#1066) * cleanup code in TiBatchWrite (#1067) * release tispark-2.1.4 (#1068) (#1069) (cherry picked from commit fd8068a) * update document for tispark-2.1.4 release (#1070)
What problem does this PR solve?
An alternative enhancement against #986.
Provide an example solution for #987.
Fix #988
What is changed and how it works?
IMPORTANT: SEE TODO IN COMMENTS
Try to change the RegionStoreClient interface so that it should only deal with retryable errors in one region and one store(as it is named). This PR does part of the job by first making
RegionStoreClient.get()
throw an error whenever an un-retryable exception is encountered, so that it will not need to fetch the region again.We introduce a new API for all those who want to continue to use RegionStoreClient directly: KVClient. In upper logics such as KVClient and TxnClient, developers should implement the logic of resolving un-retryable exceptions, for instance, re-splitting keys across regions. It will make the error handling more concise for reviewers.
The PR also moves ResolveLock logic to ErrorHandler so that the ErrorHandler should be integrated to handle all kinds of manageable errors.
Changes are made to ScanIterator because it should deal with more circumstances such as scanning a range of keys, and resolve locks when they were present during scan.
Logic fixed in LockResolverTest, the test was incorrectly set according to #988. @zhexuany We may discuss it again later.
Check List
Tests
Related changes