This is an automated email from the ASF dual-hosted git repository.

tkhurana pushed a commit to branch 5.2
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.2 by this push:
     new 6c9b681c66 PHOENIX-7448 Phoenix Compaction can miss retaining some 
cells when there is a gap more than TTL
6c9b681c66 is described below

commit 6c9b681c660deccddd6859a4c6f90fa497994d41
Author: tkhurana <[email protected]>
AuthorDate: Tue Oct 22 15:53:11 2024 -0700

    PHOENIX-7448 Phoenix Compaction can miss retaining some cells when there is 
a gap more than TTL
    
    Co-authored-by: Tanuj Khurana <[email protected]>
---
 .../phoenix/coprocessor/CompactionScanner.java     |  3 ++-
 .../org/apache/phoenix/end2end/TableTTLIT.java     | 31 ++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git 
a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java
 
b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java
index 64bebca166..23f1866ce2 100644
--- 
a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java
+++ 
b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java
@@ -934,7 +934,8 @@ public class CompactionScanner implements InternalScanner {
                             trimmedRow.add(cell);
                         }
                     }
-                    lastRowVersion = trimmedRow;
+                    lastRowVersion.clear();
+                    lastRowVersion.addAll(trimmedRow);
                     trimmedEmptyColumn.clear();;
                     for (Cell cell : emptyColumn) {
                         if (cell.getTimestamp() >= minTimestamp) {
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableTTLIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableTTLIT.java
index 11819772fe..2ab39fb11b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableTTLIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableTTLIT.java
@@ -300,6 +300,37 @@ public class TableTTLIT extends BaseTest {
             injectEdge.incrementValue(1000);
         }
     }
+
+    @Test
+    public void testMultipleRowsWithUpdatesMoreThanTTLApart() throws Exception 
{
+        // for the purpose of this test only considering cases when 
maxlookback is 0
+        try (Connection conn = DriverManager.getConnection(getUrl())) {
+            String tableName = generateUniqueName();
+            createTable(tableName);
+            conn.createStatement().execute("Alter Table " + tableName + " set 
\"phoenix.max.lookback.age.seconds\" = 0");
+            conn.commit();
+            long startTime = System.currentTimeMillis() + 1000;
+            startTime = (startTime / 1000) * 1000;
+            EnvironmentEdgeManager.injectEdge(injectEdge);
+            injectEdge.setValue(startTime);
+            updateRow(conn, tableName, "a1");
+            updateRow(conn, tableName, "a2");
+            updateRow(conn, tableName, "a3");
+            //advance the time to create a gap > TTL
+            injectEdge.incrementValue((ttl + 1) * 1000);
+            updateColumn(conn, tableName, "a1", 2, "col2");
+            updateColumn(conn, tableName, "a2", 3, "col3");
+            updateColumn(conn, tableName, "a3", 5, "col5");
+            conn.commit();
+            flush(TableName.valueOf(tableName));
+            majorCompact(TableName.valueOf(tableName));
+            String dql = "SELECT count(*) from " + tableName;
+            ResultSet rs = conn.createStatement().executeQuery(dql);
+            assertTrue(rs.next());
+            assertEquals(3, rs.getInt(1));
+        }
+    }
+
     private void flush(TableName table) throws IOException {
         Admin admin = getUtility().getAdmin();
         admin.flush(table);

Reply via email to