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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]