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

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

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


##########
phoenix-core/src/test/java/org/apache/phoenix/cache/ServerMetadataCacheTest.java:
##########
@@ -420,6 +423,126 @@ public void 
testInvalidateCacheForBaseTableWithUpdateIndexStatement() throws Exc
     }
 
 
+    /**
+     *  Test that we invalidate the cache for parent table and update the last 
ddl timestamp
+     *  of the parent table while we add an index.
+     *  Test that we invalidate the cache for parent table and index when we 
drop an index.
+     *  Also we update the last ddl timestamp for parent table when we drop an 
index.
+     * @throws Exception
+     */
+    @Test
+    public void testUpdateLastDDLTimestampTableAfterIndexCreation() throws 
Exception {
+        String tableName = generateUniqueName();
+        byte[] tableNameBytes = Bytes.toBytes(tableName);
+        String indexName = generateUniqueName();
+        byte[] indexNameBytes = Bytes.toBytes(indexName);
+        ServerMetadataCache cache = ServerMetadataCache.getInstance(config);
+        String ddl =
+                "create table  " + tableName + " ( k integer PRIMARY KEY," + " 
v1 integer,"
+                        + " v2 integer)";
+        String createIndexDDL = "create index  " + indexName + " on " + 
tableName + " (v1)";
+        String dropIndexDDL = "DROP INDEX " + indexName + " ON " + tableName;
+        try (Connection conn = DriverManager.getConnection(getUrl());
+             Statement stmt = conn.createStatement()) {
+            conn.setAutoCommit(true);
+            stmt.execute(ddl);
+            long tableLastDDLTimestampBeforeIndexCreation = 
getLastDDLTimestamp(tableName);
+            // Populate the cache
+            assertNotNull(cache.getLastDDLTimestampForTable(null, null, 
tableNameBytes));
+            Thread.sleep(1);

Review Comment:
   We are generating the last ddl timestamp using 
`EnvironmentEdgeManager.currentTimeMillis()` when we create/drop an index. I 
just want to be very sure that we don't create the same time when we created an 
index as well as when we dropped an index. So I sleep for 1 milliseconds in 
between.





> Update the LAST_DDL_TIMESTAMP of the parent table/view when we add/drop an 
> index.
> ---------------------------------------------------------------------------------
>
>                 Key: PHOENIX-7056
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-7056
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Rushabh Shah
>            Assignee: Rushabh Shah
>            Priority: Major
>
> Update the LAST_DDL_TIMESTAMP of the parent table/view when we add/drop an 
> index.



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

Reply via email to