swaroopak commented on a change in pull request #679: PHOENIX-5645 - BaseScannerRegionObserver should prevent compaction from purg… URL: https://github.com/apache/phoenix/pull/679#discussion_r366619860
########## File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/MaxLookbackIT.java ########## @@ -105,60 +129,52 @@ public void testTooLowSCNWithMaxLookbackAge() throws Exception { public void testRecentlyDeletedRowsNotCompactedAway() throws Exception { try (Connection conn = DriverManager.getConnection(getUrl())) { String dataTableName = generateUniqueName(); - String indexStem = generateUniqueName(); - createTableAndIndexes(conn, dataTableName, indexStem); - String fullIndexName = indexStem + "1"; + createTable(dataTableName); + injectEdge.incValue(WAIT_AFTER_TABLE_CREATION); TableName dataTable = TableName.valueOf(dataTableName); - TableName indexTable = TableName.valueOf(fullIndexName); - assertRawRowCount(conn, indexTable, ROWS_POPULATED); - assertTableHasTtl(conn, indexTable, Integer.MAX_VALUE); - long beforeDeleteSCN = org.apache.phoenix.util.EnvironmentEdgeManager.currentTimeMillis(); - Thread.sleep(1); //make sure we delete at a different ts + populateTable(dataTableName); + //make sure we're after the inserts have been committed + injectEdge.incValue(1); + long beforeDeleteSCN = EnvironmentEdgeManager.currentTimeMillis(); + injectEdge.incValue(10); //make sure we delete at a different ts Statement stmt = conn.createStatement(); stmt.execute("DELETE FROM " + dataTableName + " WHERE " + " id = 'a'"); Assert.assertEquals(1, stmt.getUpdateCount()); conn.commit(); //select stmt to get row we deleted - String sql = String.format("SELECT * FROM %s WHERE val1 = 'ab'", dataTableName); - assertExplainPlan(conn, sql, dataTableName, fullIndexName); + String sql = String.format("SELECT * FROM %s WHERE id = 'a'", dataTableName); int rowsPlusDeleteMarker = ROWS_POPULATED; - assertRawRowCount(conn, indexTable, rowsPlusDeleteMarker); assertRowExistsAtSCN(getUrl(), sql, beforeDeleteSCN, true); flush(dataTable); - flush(indexTable); - assertRawRowCount(conn, indexTable, rowsPlusDeleteMarker); assertRowExistsAtSCN(getUrl(), sql, beforeDeleteSCN, true); - long beforeFirstCompactSCN = EnvironmentEdgeManager.currentTime(); - Thread.sleep(1); - majorCompact(indexTable, beforeFirstCompactSCN); - assertRawRowCount(conn, indexTable, rowsPlusDeleteMarker); + long beforeFirstCompactSCN = EnvironmentEdgeManager.currentTimeMillis(); + injectEdge.incValue(1); //new ts for major compaction + majorCompact(dataTable, beforeFirstCompactSCN); + assertRawRowCount(conn, dataTable, rowsPlusDeleteMarker); assertRowExistsAtSCN(getUrl(), sql, beforeDeleteSCN, true); //wait for the lookback time. After this compactions should purge the deleted row - Thread.sleep(MAX_LOOKBACK_AGE * 1000); - long beforeSecondCompactSCN = org.apache.phoenix.util.EnvironmentEdgeManager.currentTimeMillis(); + injectEdge.incValue(MAX_LOOKBACK_AGE * 1000); + long beforeSecondCompactSCN = EnvironmentEdgeManager.currentTimeMillis(); String notDeletedRowSql = - String.format("SELECT * FROM %s WHERE val1 = 'bc'", dataTableName); - assertExplainPlan(conn, notDeletedRowSql, dataTableName, fullIndexName); + String.format("SELECT * FROM %s WHERE id = 'b'", dataTableName); assertRowExistsAtSCN(getUrl(), notDeletedRowSql, beforeSecondCompactSCN, true); - assertRawRowCount(conn, indexTable, ROWS_POPULATED); assertRawRowCount(conn, dataTable, ROWS_POPULATED); conn.createStatement().execute("upsert into " + dataTableName + " values ('c', 'cd', 'cde', 'cdef')"); conn.commit(); - majorCompact(indexTable, beforeSecondCompactSCN); majorCompact(dataTable, beforeSecondCompactSCN); assertRawRowCount(conn, dataTable, ROWS_POPULATED); //deleted row should be gone, but not deleted row should still be there. assertRowExistsAtSCN(getUrl(), sql, beforeSecondCompactSCN, false); assertRowExistsAtSCN(getUrl(), notDeletedRowSql, beforeSecondCompactSCN, true); //1 deleted row should be gone - assertRawRowCount(conn, indexTable, ROWS_POPULATED); + assertRawRowCount(conn, dataTable, ROWS_POPULATED); } } @Test(timeout=60000L) Review comment: does this value change now? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services