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

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

shahrs87 commented on code in PR #1807:
URL: https://github.com/apache/phoenix/pull/1807#discussion_r1473634705


##########
phoenix-core-client/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java:
##########
@@ -162,7 +162,11 @@ public void addTable(PTable table, long resolvedTime) 
throws SQLException {
             metaData.put(table.getKey(), tableRef);
         }
         for (PTable index : table.getIndexes()) {
-            metaData.put(index.getKey(), tableRefFactory.makePTableRef(index, 
this.timeKeeper.getCurrentTime(), resolvedTime));
+            PTable indexPTable = index;

Review Comment:
   We add an index to the cache at L160 and L162 above. 
   There is a specific check whether the table is an index or not at L133 
above. 
   If the table  is an index, then codepath between L133-L156 is executed where 
we will miss adding the parent link to the cache.





> Changes made to base table directly are not visible to the view.
> ----------------------------------------------------------------
>
>                 Key: PHOENIX-7190
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-7190
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Rushabh Shah
>            Assignee: Palash Chauhan
>            Priority: Major
>
> Steps to reproduce:
> 1. Create base table table1 with columns: PK1, V0, V1, V2
> 2. Create view view1 on the base table as SELECT * from table1;
> 3. Run SELECT * from view1; --> This will cache PTable of view1 on the client 
> side. This will  resolve all the columns of the base table and cache it in 
> view's PTable.
> 4. Run ALTER table table1 DROP COLUMN V1;
> This will update the last ddl timestamp of table1
> 5. Run SELECT * from table1;
> Server will throw StaleMetadataCacheException and it will fetch the latest 
> PTable of the base table from server and cache it on client.
> 6. Run SELECT V1 from view1;
>  
> Expected behavior:
> Client should encounter ColumnNotFoundException since we remove V1 from the 
> base table.
>  
> Actual behavior:
> Client doesn't throw any Exception
>  
> Why?
> The client is using the PTable object of view1 which was cached after step 3.
> During the query execution, client will validate last ddl timestamp of the 
> table and the view.
> Client has upto date last ddl timestamp of the view1 after step 3
> Client has upto date last ddl timestamp of the base table after 5.
> Thats why the select query in step6 didn't fail.
> Solution:
> While caching the view on the client side, we should also store the last ddl 
> timestamp of the whole hierarchy inside view's PTable object. While 
> validating last ddl timestamp of the view, we should validate the last ddl 
> timestamp of the hierarchy which is cached inside view's PTable but the view 
> was resolved sometime in the past.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to