You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/11/21 21:00:02 UTC

[GitHub] [phoenix] m2je commented on a change in pull request #921: PHOENIX-6187 Avoid swallowing UPSERT... ON DUPLICATION KEY UPDATE failures

m2je commented on a change in pull request #921:
URL: https://github.com/apache/phoenix/pull/921#discussion_r528242126



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/Indexer.java
##########
@@ -311,7 +311,17 @@ public Result preIncrementAfterRowLock(final ObserverContext<RegionCoprocessorEn
           if (!mutations.isEmpty()) {
               Region region = e.getEnvironment().getRegion();
               // Otherwise, submit the mutations directly here
-                region.batchMutate(mutations.toArray(new Mutation[0]));
+              OperationStatus[] batchMutationStatus = region.batchMutate(

Review comment:
       Done

##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java
##########
@@ -118,6 +122,33 @@ else if (cause == null || cause instanceof IOException) {
         }
     }
 
+    /**
+     * Converts a batch operation status into an IOException if the operation failed partially or completely. In cases
+     * of multiple failures, non-retriable errors are prioritized. If any part of the batch operation failed in a way
+     * that isn't retriable, an instance of the corresponding DoNotRetryIOException subtype is returned, even if other
+     * retriable errors are present. If all parts were completed successfully, null will be returned.
+     */
+    public static IOException createIOException(OperationStatus[] batchOperationStatus) {
+        IOException retriableException = null;
+        for (int i = 0; i < batchOperationStatus.length; i++) {
+            OperationStatus status = batchOperationStatus[i];
+            switch (status.getOperationStatusCode()) {
+                case SUCCESS:
+                    break;
+                case BAD_FAMILY:
+                    return new NoSuchColumnFamilyException(status.getExceptionMsg());
+                case SANITY_CHECK_FAILURE:
+                    return new FailedSanityCheckException(status.getExceptionMsg());
+                case STORE_TOO_BUSY:
+                    retriableException = new RegionTooBusyException(status.getExceptionMsg());
+                    break;
+                default:
+                    return new DoNotRetryIOException(status.getExceptionMsg());

Review comment:
       By looking at Hbase's code it does seem that `FAILURE` is not a retriable state, [example](https://github.com/apache/hbase/blob/branch-2.1/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java#L3765)
   
   Added a retry for `NOT_RUN` (which if I understand correctly is used when mutation was never executed)  




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org