Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 6219075ce -> 81e72e4c6


PHOENIX-4028 Provide option to not throw index write failure back to client


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/81e72e4c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/81e72e4c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/81e72e4c

Branch: refs/heads/4.x-HBase-1.1
Commit: 81e72e4c6691cfbf91567c435655b6b4b2960814
Parents: 6219075
Author: James Taylor <[email protected]>
Authored: Tue Jul 18 21:56:33 2017 -0700
Committer: James Taylor <[email protected]>
Committed: Tue Jul 18 22:00:15 2017 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/index/PhoenixIndexFailurePolicy.java    | 5 ++++-
 .../java/org/apache/phoenix/index/PhoenixIndexMetaData.java    | 6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/81e72e4c/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
index a4f1f29..82360f7 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
@@ -146,7 +146,10 @@ public class PhoenixIndexFailurePolicy extends 
DelegateIndexFailurePolicy {
         } finally {
             if (!throwing) {
                IOException ioException = 
ServerUtil.wrapInDoNotRetryIOException("Unable to update the following indexes: 
" + attempted.keySet(), cause, timestamp);
-               if (throwIndexWriteFailure) {
+               Mutation m = attempted.entries().iterator().next().getValue();
+               boolean isIndexRebuild = 
PhoenixIndexMetaData.isIndexRebuild(m.getAttributesMap());
+               // Always throw if rebuilding index since the rebuilder needs 
to know if it was successful
+               if (throwIndexWriteFailure || isIndexRebuild) {
                        throw ioException;
                } else {
                     LOG.warn("Swallowing index write failure", ioException);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/81e72e4c/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexMetaData.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexMetaData.java 
b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexMetaData.java
index fa2fed2..83201ba 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexMetaData.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexMetaData.java
@@ -90,6 +90,10 @@ public class PhoenixIndexMetaData implements IndexMetaData {
 
     }
 
+    public static boolean isIndexRebuild(Map<String,byte[]> attributes) {
+        return 
attributes.get(BaseScannerRegionObserver.IGNORE_NEWER_MUTATIONS) != null;
+    }
+    
     public PhoenixIndexMetaData(RegionCoprocessorEnvironment env, 
Map<String,byte[]> attributes) throws IOException {
         this.indexMetaDataCache = getIndexMetaData(env, attributes);
         boolean isImmutable = true;
@@ -98,7 +102,7 @@ public class PhoenixIndexMetaData implements IndexMetaData {
         }
         this.isImmutable = isImmutable;
         this.attributes = attributes;
-        this.ignoreNewerMutations = 
attributes.get(BaseScannerRegionObserver.IGNORE_NEWER_MUTATIONS) != null;
+        this.ignoreNewerMutations = isIndexRebuild(attributes);
     }
     
     public PhoenixTransactionContext getTransactionContext() {

Reply via email to