Skip to content

Commit d532842

Browse files
committed
revert odp operations to old client version, do not send tablet_id to odp
1 parent 31f3549 commit d532842

File tree

4 files changed

+59
-103
lines changed

4 files changed

+59
-103
lines changed

src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,6 @@ private <T> T execute(String tableName, TableExecuteCallback<T> callback, ObServ
618618
throw new IllegalArgumentException("table name is null");
619619
}
620620
boolean needRefreshTableEntry = false;
621-
boolean needRenew = false;
622621
boolean needFetchAllRouteInfo = false;
623622
int tryTimes = 0;
624623
long startExecute = System.currentTimeMillis();
@@ -636,7 +635,7 @@ private <T> T execute(String tableName, TableExecuteCallback<T> callback, ObServ
636635
ObPair<Long, ObTableParam> obPair = null;
637636
try {
638637
if (odpMode) {
639-
obPair = getODPTableWithRowKeyValue(tableName, callback.getRowKey(), needRenew);
638+
obPair = new ObPair<Long, ObTableParam>(0L, new ObTableParam(odpTable));
640639
} else {
641640
obPair = getTable(tableName, callback.getRowKey(),
642641
needRefreshTableEntry, tableEntryRefreshIntervalWait,
@@ -654,17 +653,9 @@ private <T> T execute(String tableName, TableExecuteCallback<T> callback, ObServ
654653
"execute while meet Exception, errorCode: {} , errorMsg: {}, try times {}",
655654
((ObTableException) ex).getErrorCode(), ex.getMessage(),
656655
tryTimes);
657-
// if the cause is that ODP partition meta have expired, try to fetch new one
658-
if (ex instanceof ObTablePartitionChangeException
659-
&& ((ObTablePartitionChangeException) ex).getErrorCode() == OB_ERR_KV_ROUTE_ENTRY_EXPIRE.errorCode) {
660-
needRenew = true;
661-
} else {
662-
throw ex;
663-
}
664656
} else {
665657
logger.warn("execute while meet Exception, errorMsg: {}, try times {}",
666658
ex.getMessage(), tryTimes);
667-
throw ex;
668659
}
669660
} else {
670661
RUNTIME.error("retry failed with exception", ex);
@@ -686,7 +677,7 @@ private <T> T execute(String tableName, TableExecuteCallback<T> callback, ObServ
686677
} else if (ex instanceof ObTableException
687678
&& ((ObTableException) ex).isNeedRefreshTableEntry()) {
688679
needRefreshTableEntry = true;
689-
680+
690681
if (retryOnChangeMasterTimes && (tryTimes - 1) < runtimeRetryTimes) {
691682
if (ex instanceof ObTableNeedFetchAllException) {
692683
needFetchAllRouteInfo = true;
@@ -787,7 +778,7 @@ private <T> T execute(String tableName, OperationExecuteCallback<T> callback,
787778
throw new IllegalArgumentException("table name is null");
788779
}
789780
boolean needRefreshTableEntry = false;
790-
boolean needRenew = false;
781+
boolean needFetchAllRouteInfo = false;
791782
int tryTimes = 0;
792783
long startExecute = System.currentTimeMillis();
793784
while (true) {
@@ -804,7 +795,7 @@ private <T> T execute(String tableName, OperationExecuteCallback<T> callback,
804795
ObPair<Long, ObTableParam> obPair = null;
805796
try {
806797
if (odpMode) {
807-
obPair = getODPTableWithRowKey(tableName, callback.getRowKey(), needRenew);
798+
obPair = new ObPair<Long, ObTableParam>(0L, new ObTableParam(odpTable));
808799
} else {
809800
if (null != callback.getRowKey()) {
810801
// in the case of retry, the location always needs to be refreshed here
@@ -837,20 +828,10 @@ private <T> T execute(String tableName, OperationExecuteCallback<T> callback,
837828
"execute while meet Exception, errorCode: {} , errorMsg: {}, try times {}",
838829
((ObTableException) ex).getErrorCode(), ex.getMessage(),
839830
tryTimes);
840-
// if the cause is that ODP partition meta have expired, try to fetch new one
841-
if (ex instanceof ObTablePartitionChangeException
842-
&& ((ObTablePartitionChangeException) ex).getErrorCode() == OB_ERR_KV_ROUTE_ENTRY_EXPIRE.errorCode) {
843-
needRenew = true;
844-
} else {
845-
RUNTIME.error("execute while meet exception", ex);
846-
throw ex;
847-
}
848831
} else {
849832
logger.warn(
850-
"execute while meet Exception, exception: {}, try times {}", ex,
851-
tryTimes);
852-
RUNTIME.error("execute while meet exception", ex);
853-
throw ex;
833+
"execute while meet Exception, exception: {}, try times {}", ex,
834+
tryTimes);
854835
}
855836
} else {
856837
RUNTIME.error("retry failed with exception", ex);
@@ -870,7 +851,7 @@ private <T> T execute(String tableName, OperationExecuteCallback<T> callback,
870851
}
871852
} else if (ex instanceof ObTableException
872853
&& ((ObTableException) ex).isNeedRefreshTableEntry()) {
873-
// if the problem is the lack of row key name, throw directly
854+
// if the problem is the lack of row key name, throw directly
874855
if (tableRowKeyElement.get(tableName) == null) {
875856
logger.warn("tableRowKeyElement not found table name: {}", ex.getMessage());
876857
RUNTIME.error("tableRowKeyElement not found table name", ex);
@@ -880,7 +861,7 @@ private <T> T execute(String tableName, OperationExecuteCallback<T> callback,
880861
if (retryOnChangeMasterTimes && (tryTimes - 1) < runtimeRetryTimes) {
881862
if (ex instanceof ObTableNeedFetchAllException) {
882863
getOrRefreshTableEntry(tableName, true, true, true);
883-
// reset failure count while fetch all route info
864+
// reset failure count while fetch all route info
884865
this.resetExecuteContinuousFailureCount(tableName);
885866
}
886867
} else {
@@ -1374,13 +1355,13 @@ public TableEntry refreshTableLocationByTabletId(TableEntry tableEntry, String t
13741355
if (info == null) {
13751356
throw new ObTableEntryRefreshException("Partition info is null for tabletId=" + tabletId);
13761357
}
1377-
1358+
13781359
long lastRefreshTime = info.getLastUpdateTime();
13791360
long currentTime = System.currentTimeMillis();
13801361
if (currentTime - lastRefreshTime < tableEntryRefreshIntervalCeiling) {
13811362
return tableEntry;
13821363
}
1383-
1364+
13841365
Lock lock = info.refreshLock;
13851366
boolean acquired = false;
13861367
try {
@@ -1400,7 +1381,7 @@ public TableEntry refreshTableLocationByTabletId(TableEntry tableEntry, String t
14001381
if (currentTime - lastRefreshTime < tableEntryRefreshIntervalCeiling) {
14011382
return tableEntry;
14021383
}
1403-
1384+
14041385
tableEntry = loadTableEntryLocationWithPriority(
14051386
serverRoster,
14061387
tableEntryKey,
@@ -1412,7 +1393,7 @@ public TableEntry refreshTableLocationByTabletId(TableEntry tableEntry, String t
14121393
serverAddressCachingTimeout,
14131394
sysUA
14141395
);
1415-
1396+
14161397
tableEntry.prepareForWeakRead(serverRoster.getServerLdcLocation());
14171398

14181399
} finally {
@@ -1430,7 +1411,7 @@ public TableEntry refreshTableLocationByTabletId(TableEntry tableEntry, String t
14301411
RUNTIME.error(LCD.convert("01-00020"), tableEntryKey, tableEntry, e);
14311412
throw new ObTableEntryRefreshException(errorMsg, e);
14321413
}
1433-
1414+
14341415
tableLocations.put(tableName, tableEntry);
14351416
tableEntryRefreshContinuousFailureCount.set(0);
14361417
return tableEntry;
@@ -1655,7 +1636,7 @@ private ObPair<Long, ReplicaLocation> getPartitionReplica(TableEntry tableEntry,
16551636
private ReplicaLocation getPartitionLocation(TableEntry tableEntry, long partId,
16561637
ObServerRoute route) {
16571638
// In all cases for 3.x and for non-partitioned tables in 4.x, partId will not change.
1658-
// If it is 4.x, it will be converted to tablet id.
1639+
// If it is 4.x, it will be converted to tablet id.
16591640
partId = getTabletIdByPartId(tableEntry, partId);
16601641
return tableEntry.getPartitionEntry().getPartitionLocationWithTabletId(partId)
16611642
.getReplica(route);
@@ -1980,9 +1961,9 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
19801961
obPartitionLocationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
19811962
replica = getPartitionLocation(obPartitionLocationInfo, route);
19821963
/**
1983-
* Normally, getOrRefreshPartitionInfo makes sure that a thread only continues if it finds the leader
1984-
* during a route refresh. But sometimes, there might not be a leader yet. In this case, the thread
1985-
* is released, and since it can't get the replica, it throws an no master exception.
1964+
* Normally, getOrRefreshPartitionInfo makes sure that a thread only continues if it finds the leader
1965+
* during a route refresh. But sometimes, there might not be a leader yet. In this case, the thread
1966+
* is released, and since it can't get the replica, it throws an no master exception.
19861967
*/
19871968
if (replica == null && obPartitionLocationInfo.getPartitionLocation().getLeader() == null) {
19881969
RUNTIME.error(LCD.convert("01-00028"), partitionId, tableEntry.getPartitionEntry(), tableEntry);
@@ -2023,14 +2004,14 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
20232004
tableEntry = getOrRefreshTableEntry(tableName, true, waitForRefresh, false);
20242005
}
20252006
}
2026-
2007+
20272008
if (ObGlobal.obVsnMajor() >= 4) {
20282009
obPartitionLocationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
20292010
replica = getPartitionLocation(obPartitionLocationInfo, route);
20302011
} else {
20312012
replica = getPartitionReplica(tableEntry, partitionId, route).getRight();
20322013
}
2033-
2014+
20342015
addr = replica.getAddr();
20352016
obTable = tableRoster.get(addr);
20362017

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/AbstractQueryStreamResult.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger,
116116
ObPayload result;
117117
ObTable subObTable = partIdWithIndex.getRight().getObTable();
118118
boolean needRefreshTableEntry = false;
119-
boolean odpNeedRenew = false;
120119
int tryTimes = 0;
121120
long startExecute = System.currentTimeMillis();
122121
Set<String> failedServerList = null;
@@ -138,9 +137,7 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger,
138137
try {
139138
if (tryTimes > 1) {
140139
if (client.isOdpMode()) {
141-
subObTable = client
142-
.getODPTableWithPartId(tableName, partIdWithIndex.getLeft(),
143-
odpNeedRenew).getRight().getObTable();
140+
subObTable = client.getOdpTable();
144141
} else {
145142
if (route == null) {
146143
route = client.getReadRoute();
@@ -192,24 +189,16 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger,
192189
"tablename:{} stream query execute while meet Exception needing retry, errorCode: {}, errorMsg: {}, try times {}",
193190
indexTableName, ((ObTableException) e).getErrorCode(),
194191
e.getMessage(), tryTimes);
195-
if (e instanceof ObTablePartitionChangeException
196-
&& ((ObTablePartitionChangeException) e).getErrorCode() == ResultCodes.OB_ERR_KV_ROUTE_ENTRY_EXPIRE.errorCode) {
197-
odpNeedRenew = true;
198-
} else {
199-
throw e;
200-
}
201192
} else if (e instanceof IllegalArgumentException) {
202193
logger
203194
.warn(
204195
"tablename:{} stream query execute while meet Exception needing retry, try times {}, errorMsg: {}",
205196
indexTableName, tryTimes, e.getMessage());
206-
throw e;
207197
} else {
208198
logger
209199
.warn(
210200
"tablename:{} stream query execute while meet Exception needing retry, try times {}",
211201
indexTableName, tryTimes, e);
212-
throw e;
213202
}
214203
} else {
215204
throw e;

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientBatchOpsImpl.java

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -262,20 +262,12 @@ public Map<Long, ObPair<ObTableParam, List<ObPair<Integer, ObTableOperation>>>>
262262
for (int j = 0; j < rowKeySize; j++) {
263263
rowKey[j] = rowKeyObject.getObj(j).getValue();
264264
}
265-
ObPair<Long, ObTableParam> tableObPair = null;
266-
if (!obTableClient.isOdpMode()) {
267-
tableObPair = obTableClient.getTable(tableName, rowKey,
268-
false, false, obTableClient.getRoute(batchOperation.isReadOnly()));
269-
} else {
270-
tableObPair = obTableClient.getODPTableWithRowKeyValue(tableName, rowKey, false);
271-
}
272-
if (tableObPair == null) {
273-
throw new ObTableUnexpectedException("fail to get table pair in batch");
274-
}
275-
final ObPair<Long, ObTableParam> tmpTableObPair = tableObPair;
265+
ObPair<Long, ObTableParam> tableObPair = obTableClient.getTable(
266+
tableName, rowKey, false, false,
267+
obTableClient.getRoute(batchOperation.isReadOnly()));
276268
ObPair<ObTableParam, List<ObPair<Integer, ObTableOperation>>> obTableOperations = partitionOperationsMap
277-
.computeIfAbsent(tmpTableObPair.getLeft(), k -> new ObPair<>(
278-
tmpTableObPair.getRight(), new ArrayList<>()));
269+
.computeIfAbsent(tableObPair.getLeft(), k -> new ObPair<>(
270+
tableObPair.getRight(), new ArrayList<>()));
279271
obTableOperations.getRight().add(new ObPair<>(i, operation));
280272
}
281273
return partitionOperationsMap;
@@ -351,16 +343,12 @@ public void partitionExecute(ObTableOperationResult[] results,
351343
}
352344
tryTimes++;
353345
try {
354-
if (tryTimes > 1) {
355-
if (obTableClient.isOdpMode()) {
356-
ObTableParam newParam = obTableClient.getODPTableWithPartId(tableName,
357-
originPartId, odpNeedRenew).getRight();
358-
subObTable = newParam.getObTable();
359-
subRequest.setPartitionId(newParam.getPartitionId());
360-
subRequest.setTableId(newParam.getTableId());
361-
} else {
362-
// getTable() when we need retry
363-
// we should use partIdx to get table
346+
if (obTableClient.isOdpMode()) {
347+
subObTable = obTableClient.getOdpTable();
348+
} else {
349+
// getTable() when we need retry
350+
// we should use partIdx to get table
351+
if (tryTimes > 1) {
364352
if (route == null) {
365353
route = obTableClient.getRoute(batchOperation.isReadOnly());
366354
}
@@ -403,17 +391,13 @@ public void partitionExecute(ObTableOperationResult[] results,
403391
} catch (Exception ex) {
404392
if (obTableClient.isOdpMode()) {
405393
if ((tryTimes - 1) < obTableClient.getRuntimeRetryTimes()) {
394+
assert ex instanceof ObTableException;
406395
logger
407396
.warn(
408397
"batch ops execute while meet Exception, tablename:{}, errorMsg: {}, try times {}",
409398
tableName, ex.getMessage(),
410399
tryTimes);
411-
if (ex instanceof ObTablePartitionChangeException
412-
&& ((ObTablePartitionChangeException) ex).getErrorCode() == ResultCodes.OB_ERR_KV_ROUTE_ENTRY_EXPIRE.errorCode) {
413-
odpNeedRenew = true;
414-
}
415400
} else {
416-
RUNTIME.error("retry fail when normal batch executing", ex);
417401
throw ex;
418402
}
419403
} else if (ex instanceof ObTableReplicaNotReadableException) {

0 commit comments

Comments
 (0)