[ 
https://issues.apache.org/jira/browse/PHOENIX-6681?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17521299#comment-17521299
 ] 

ASF GitHub Bot commented on PHOENIX-6681:
-----------------------------------------

gokceni commented on code in PR #1413:
URL: https://github.com/apache/phoenix/pull/1413#discussion_r848780886


##########
phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java:
##########
@@ -232,7 +232,15 @@ public static void serialize(PTable dataTable, 
ImmutableBytesWritable ptr,
         }
         int nIndexes = indexes.size();
         if (dataTable.getTransformingNewTable() != null) {
-            nIndexes++;
+            boolean disabled = 
dataTable.getTransformingNewTable().getIndexState()!= null &&
+                    
dataTable.getTransformingNewTable().getIndexState().isDisabled();
+            if (disabled && nIndexes == 0) {
+                ptr.set(ByteUtil.EMPTY_BYTE_ARRAY);
+                return;
+            }
+            if (!disabled) {
+                nIndexes++;

Review Comment:
   We are reusing index maintainer code path and TransformMaintainer is the 
subclass of IndexMaintainer. So, we are treating it as an index. 



##########
phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java:
##########
@@ -248,11 +256,15 @@ public static void serialize(PTable dataTable, 
ImmutableBytesWritable ptr,
                     output.write(protoBytes);
             }
             if (dataTable.getTransformingNewTable() != null) {
-                ServerCachingProtos.TransformMaintainer proto = 
TransformMaintainer.toProto(
-                        
dataTable.getTransformingNewTable().getTransformMaintainer(dataTable, 
connection));
-                byte[] protoBytes = proto.toByteArray();
-                WritableUtils.writeVInt(output, protoBytes.length);
-                output.write(protoBytes);
+                boolean disabled = 
dataTable.getTransformingNewTable().getIndexState()!= null &&

Review Comment:
   yes





> Enable new indexes to be optionally created in CREATE_DISABLED state 
> ---------------------------------------------------------------------
>
>                 Key: PHOENIX-6681
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6681
>             Project: Phoenix
>          Issue Type: New Feature
>            Reporter: Gokcen Iskender
>            Assignee: Gokcen Iskender
>            Priority: Major
>
> When we create/drop some indexes in one datacenter, the replication pair 
> doesn't immediately have this index and Hbase throws a replication error when 
> we try to write into indexes that don't have a matching table on the 
> replication pair.
> To remediate this issue, we can optionally create them in CREATE_DISABLED 
> state and enable them after all the replication peers have the table.
> Same is true for dropping indexes. When they are dropped we can first disable 
> them and drop them later.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to