Skip to content

Commit 4b2a54f

Browse files
authored
reschedule all operations if meet shoud retry exceptions (#408)
1 parent 922117b commit 4b2a54f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,20 @@ private Row calculateRowKey(ObPair<Integer, ObTableSingleOp> operationPair) {
414414
return rowKey;
415415
}
416416

417-
private BatchIdxOperationPairList extractOperations(TabletOperationsMap tabletOperationsMap) {
417+
private BatchIdxOperationPairList extractOperations(Map.Entry<Long, TabletOperationsMap> currentEntry,
418+
Iterator<Map.Entry<Long, TabletOperationsMap>> iterator) {
419+
// only reschedule operations from the current entry to avoid repeatedly executing operations
418420
BatchIdxOperationPairList operationsWithIndex = new BatchIdxOperationPairList();
419-
for (ObPair<ObTableParam, BatchIdxOperationPairList> pair : tabletOperationsMap.values()) {
421+
TabletOperationsMap currentTabletMap = currentEntry.getValue();
422+
for (ObPair<ObTableParam, BatchIdxOperationPairList> pair : currentTabletMap.values()) {
420423
operationsWithIndex.addAll(pair.getRight());
421424
}
425+
while (iterator.hasNext()) {
426+
currentTabletMap = iterator.next().getValue();
427+
for (ObPair<ObTableParam, BatchIdxOperationPairList> pair : currentTabletMap.values()) {
428+
operationsWithIndex.addAll(pair.getRight());
429+
}
430+
}
422431
return operationsWithIndex;
423432
}
424433

@@ -847,16 +856,17 @@ private void executeWithRetries(ObTableSingleOpResult[] results,
847856
}
848857
boolean allPartitionsSuccess = true;
849858

850-
for (Map.Entry<Long, TabletOperationsMap> currentEntry : currentPartitions.entrySet()) {
859+
Iterator<Map.Entry<Long, TabletOperationsMap>> iterator = currentPartitions.entrySet().iterator();
860+
while (iterator.hasNext()) {
861+
Map.Entry<Long, TabletOperationsMap> currentEntry = iterator.next();
851862
try {
852863
partitionExecute(results, currentEntry);
853864
} catch (Exception e) {
854865
if (shouldRetry(e)) {
855866
retryCount++;
856867
errCode = ((ObTableNeedFetchMetaException) e).getErrorCode();
857868
errMsg = e.getMessage();
858-
BatchIdxOperationPairList failedOperations = extractOperations(currentEntry
859-
.getValue());
869+
BatchIdxOperationPairList failedOperations = extractOperations(currentEntry, iterator); // reschedule failed and sequent operations
860870
currentPartitions = prepareOperations(failedOperations);
861871
allPartitionsSuccess = false;
862872
break;

0 commit comments

Comments
 (0)