[
https://issues.apache.org/jira/browse/PHOENIX-7212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17817151#comment-17817151
]
ASF GitHub Bot commented on PHOENIX-7212:
-----------------------------------------
palashc commented on code in PR #1823:
URL: https://github.com/apache/phoenix/pull/1823#discussion_r1488546718
##########
phoenix-core-client/src/main/java/org/apache/phoenix/util/ViewUtil.java:
##########
@@ -484,7 +484,8 @@ public static void addIndexesFromParent(PhoenixConnection
connection, PTable vie
.setTableName(modifiedIndexName)
.setViewStatement(viewStatement)
.setUpdateCacheFrequency(view.getUpdateCacheFrequency())
- .setTenantId(view.getTenantId())
+ //retain the tenantId from the index being
inherited
+ .setTenantId(index.getTenantId())
Review Comment:
Added the test.
> I think they will now point to the same entry in the metadata cache.
Yes. There was only one entry in the cache for the index with modified name
and tenant id is null. Both tenant view PTables also have the index ptable with
the modified name and no tenant id.
> Handle inherited indexes for tenant views when validating LAST_DDL_TIMESTAMPS
> -----------------------------------------------------------------------------
>
> Key: PHOENIX-7212
> URL: https://issues.apache.org/jira/browse/PHOENIX-7212
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: Palash Chauhan
> Assignee: Palash Chauhan
> Priority: Major
>
> When a tenant view is resolved and it inherits an index from its parent
> view/table, a PTable object for the inherited index is added to the list of
> index PTables in the tenant view PTable object. This PTable object has a
> modified name of the form `TenantView#Index` and has its tenantId attribute
> set to that of the tenant view.
> During a query/upsert, along with the table/view, we also add the indexes of
> the table/view to the request for validating LAST_DDL_TIMESTAMP. We provide
> the key of the PTables i.e. (tenantId, schemaName, tableName) to the server.
> Server looks up its cache based on this key to find out the
> LAST_DDL_TIMESTAMP and if the key is not present, it fetches the table from
> SYSCAT.
> Suppose we perform a query on a tenant view which has inherited an index
> still in BUILDING state. After the query finishes, server would have cached
> (tenantId,schema,table) for the actual global index. The index is then built
> and its state changes to ACTIVE. Cache invalidation happens for the key
> (null, schema, table). A subsequent query on the tenant view will
> successfully validate the inherited index and will not learn about the state
> change.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)