abhishek-chouhan commented on a change in pull request #685: PHOENIX-5676
Inline-verification from IndexTool does not handle TTL/r…
URL: https://github.com/apache/phoenix/pull/685#discussion_r367141985
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
##########
@@ -510,6 +508,72 @@ public void testIndexToolOnlyVerifyOption() throws
Exception {
}
}
+ @Test
+ public void testIndexToolVerifyWithExpiredIndexRows() throws Exception {
+ if (localIndex || transactional || !directApi || useSnapshot) {
+ return;
+ }
+ String schemaName = generateUniqueName();
+ String dataTableName = generateUniqueName();
+ String dataTableFullName = SchemaUtil.getTableName(schemaName,
dataTableName);
+ String indexTableName = generateUniqueName();
+ String indexTableFullName = SchemaUtil.getTableName(schemaName,
indexTableName);
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.createStatement().execute("CREATE TABLE " + dataTableFullName
+ + " (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR, CODE
VARCHAR) COLUMN_ENCODED_BYTES=0");
+ // Insert a row
+ conn.createStatement()
+ .execute("upsert into " + dataTableFullName + " values (1,
'Phoenix', 'A')");
+ conn.commit();
+ conn.createStatement()
+ .execute(String.format("CREATE INDEX %s ON %s (NAME)
INCLUDE (CODE) ASYNC",
+ indexTableName, dataTableFullName));
+ runIndexTool(directApi, useSnapshot, schemaName, dataTableName,
indexTableName, null, 0,
+ IndexTool.IndexVerifyType.ONLY);
+ Cell cell =
+ getErrorMessageFromIndexToolOutputTable(conn,
dataTableFullName,
+ indexTableFullName);
+ byte[] expectedValueBytes = Bytes.toBytes("Missing index rows -
Expected: 1 Actual: 0");
+ assertTrue(Bytes.compareTo(cell.getValueArray(),
cell.getValueOffset(),
+ cell.getValueLength(), expectedValueBytes, 0,
expectedValueBytes.length) == 0);
+
+ // Run the index tool to populate the index while verifying rows
+ runIndexTool(directApi, useSnapshot, schemaName, dataTableName,
indexTableName, null, 0,
+ IndexTool.IndexVerifyType.AFTER);
+
+ // Set ttl of index table ridiculously low so that all data is
expired
+ Admin admin =
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();
+ TableName indexTable = TableName.valueOf(indexTableFullName);
+ HColumnDescriptor desc =
admin.getTableDescriptor(indexTable).getColumnFamilies()[0];
+ desc.setTimeToLive(1);
+ admin.modifyColumn(indexTable, desc);
+ Thread.sleep(1000);
Review comment:
The first sleep was handling both the things of ttl expiry as well as giving
reasonable time for most cases of the admin operation to succeed. The
alternative is to use edge just for the ttl of 1 second but still have the
retries in place since we actually need to wait for the admin operation. No
particular reason of having the retry interval large, thought 40 seconds
overall for the test should be enough to have it running reasonably
deterministic on the most flaky of hardwares. Let me know if you strongly feel
about changing these and i can work on them.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services