@@ -514,16 +514,18 @@ private void executeWithRetries(ObTableOperationResult[] results, Map.Entry<Long
514514
515515 Map <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableOperation >>>> currentPartitions = new HashMap <>();
516516 currentPartitions .put (entry .getKey (), entry .getValue ());
517-
518- while (retryCount < maxRetries && !success ) {
517+ int errCode = ResultCodes .OB_SUCCESS .errorCode ;
518+ String errMsg = null ;
519+ while (retryCount <= maxRetries && !success ) {
519520 boolean allPartitionsSuccess = true ;
520-
521521 for (Map .Entry <Long , ObPair <ObTableParam , List <ObPair <Integer , ObTableOperation >>>> currentEntry : currentPartitions .entrySet ()) {
522522 try {
523523 partitionExecute (results , currentEntry );
524524 } catch (Exception e ) {
525525 if (shouldRetry (e )) {
526526 retryCount ++;
527+ errCode = ((ObTableNeedFetchAllException )e ).getErrorCode ();
528+ errMsg = e .getMessage ();
527529 List <ObTableOperation > failedOperations = extractOperations (currentEntry .getValue ().getRight ());
528530 currentPartitions = prepareOperations (failedOperations );
529531 allPartitionsSuccess = false ;
@@ -540,7 +542,9 @@ private void executeWithRetries(ObTableOperationResult[] results, Map.Entry<Long
540542 }
541543
542544 if (!success ) {
543- throw new ObTableUnexpectedException ("Failed to execute operation after retrying " + maxRetries + " times." );
545+ errMsg = "Failed to execute operation after retrying " + maxRetries + " times. Last error Msg:" +
546+ "[errCode=" + errCode +"] " + errMsg ;
547+ throw new ObTableUnexpectedException (errMsg );
544548 }
545549 }
546550
0 commit comments