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

Thomas D'Silva commented on PHOENIX-4229:
-----------------------------------------

In SystemCatalogWALEntryFilter you only check for isChildLinkToTenantView if 
isTenantRowCell is false. I think this would miss tenant views that have child 
views. 
You should also check that the cell value is equal to the serialized value of  
PTable.LinkType.Child.

{code}
+    boolean isTenantRowCell = key.get()[key.getOffset()] != 
QueryConstants.SEPARATOR_BYTE;
+
+    /* In addition to the tenant view rows, there are parent-child links (see 
PHOENIX-2051) that
+     * provide an efficient way for a parent table or view to look up its 
children. These rows override
+     * SYSTEM_CATALOG.COLUMN_NAME with the child tenant_id, if any, and 
contain only a single Cell, LINK_TYPE,
+     * which is of PTable.LinkType.Child
+     */
+    boolean isChildLinkToTenantView = false;
+    if (!isTenantRowCell) {
+      ImmutableBytesWritable columnQualifier = new 
ImmutableBytesWritable(cell.getQualifierArray(),
+          cell.getQualifierOffset(), cell.getQualifierLength());
+      boolean isChildLink = 
columnQualifier.compareTo(PhoenixDatabaseMetaData.LINK_TYPE_BYTES) == 0;
+      if (isChildLink) {
+        byte[][] rowViewKeyMetadata = new byte[5][];
+        SchemaUtil.getVarChars(key.get(), key.getOffset(), key.getLength(), 0, 
rowViewKeyMetadata);
+        //if the child link is to a tenant-owned view, the COLUMN_NAME field 
will be the byte[] of the tenant
+        //otherwise, it will be an empty byte array (NOT 
QueryConstants.SEPARATOR_BYTE, but a byte[0])
+        isChildLinkToTenantView = 
rowViewKeyMetadata[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX].length != 0;
+      }
+
+    }
+    return isTenantRowCell || isChildLinkToTenantView;
{code}

> Parent-Child linking rows in System.Catalog break tenant view replication
> -------------------------------------------------------------------------
>
>                 Key: PHOENIX-4229
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4229
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.11.0, 4.12.0
>            Reporter: Geoffrey Jacoby
>            Assignee: Geoffrey Jacoby
>             Fix For: 4.13.0
>
>         Attachments: PHOENIX-4229.patch
>
>
> PHOENIX-2051 introduced new Parent-Child linking rows to System.Catalog that 
> speed up view deletion. Unfortunately, this breaks assumptions in 
> PHOENIX-3639, which gives a way to replicate tenant views from one cluster to 
> another. (It assumes that all the metadata for a tenant view is owned by the 
> tenant -- the linking rows are not.) 
> PHOENIX-3639 was a workaround in the first place to the more fundamental 
> design problem that Phoenix places the metadata for both table schemas -- 
> which should never be replicated -- in the same table and column family as 
> the metadata for tenant views, which should be replicated. 
> Note that the linking rows also make it more difficult to ever split these 
> two datasets apart, as proposed in PHOENIX-3520.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to