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

bbeaudreault pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 120a36535c8e44f8099dd5de1014d91779074233
Author: Bri Augenreich <bbcr...@vt.edu>
AuthorDate: Mon Mar 25 15:07:31 2024 -0400

    HBASE-28449 Fix backupSystemTable prefix scans (#5768)
    
    Signed-off-by: Bryan Beaudreault <bbeaudrea...@apache.org>
---
 .../apache/hadoop/hbase/backup/impl/BackupSystemTable.java   | 12 ++----------
 .../apache/hadoop/hbase/backup/TestBackupSystemTable.java    |  9 +++++++++
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git 
a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
 
b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
index 42168d46551..b64587b6fca 100644
--- 
a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
+++ 
b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
@@ -1438,11 +1438,7 @@ public final class BackupSystemTable implements 
Closeable {
    */
   private Scan createScanForReadLogTimestampMap(String backupRoot) {
     Scan scan = new Scan();
-    byte[] startRow = rowkey(TABLE_RS_LOG_MAP_PREFIX, backupRoot);
-    byte[] stopRow = Arrays.copyOf(startRow, startRow.length);
-    stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1);
-    scan.withStartRow(startRow);
-    scan.withStopRow(stopRow);
+    scan.setStartStopRowForPrefixScan(rowkey(TABLE_RS_LOG_MAP_PREFIX, 
backupRoot, NULL));
     scan.addFamily(BackupSystemTable.META_FAMILY);
 
     return scan;
@@ -1479,11 +1475,7 @@ public final class BackupSystemTable implements 
Closeable {
    */
   private Scan createScanForReadRegionServerLastLogRollResult(String 
backupRoot) {
     Scan scan = new Scan();
-    byte[] startRow = rowkey(RS_LOG_TS_PREFIX, backupRoot);
-    byte[] stopRow = Arrays.copyOf(startRow, startRow.length);
-    stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1);
-    scan.withStartRow(startRow);
-    scan.withStopRow(stopRow);
+    scan.setStartStopRowForPrefixScan(rowkey(RS_LOG_TS_PREFIX, backupRoot, 
NULL));
     scan.addFamily(BackupSystemTable.META_FAMILY);
     scan.readVersions(1);
 
diff --git 
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSystemTable.java
 
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSystemTable.java
index 301ae2a5985..9f7f81cb3f3 100644
--- 
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSystemTable.java
+++ 
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSystemTable.java
@@ -190,8 +190,11 @@ public class TestBackupSystemTable {
     String[] servers = new String[] { "server1", "server2", "server3" };
     Long[] timestamps = new Long[] { 100L, 102L, 107L };
 
+    // validate the prefix scan in readRegionServerlastLogRollResult will get 
the right timestamps
+    // when a backup root with the same prefix is present
     for (int i = 0; i < servers.length; i++) {
       table.writeRegionServerLastLogRollResult(servers[i], timestamps[i], 
"root");
+      table.writeRegionServerLastLogRollResult(servers[i], timestamps[i], 
"root/backup");
     }
 
     HashMap<String, Long> result = 
table.readRegionServerLastLogRollResult("root");
@@ -265,7 +268,10 @@ public class TestBackupSystemTable {
     rsTimestampMap.put("rs2:100", 101L);
     rsTimestampMap.put("rs3:100", 103L);
 
+    // validate the prefix scan in readLogTimestampMap will get the right 
timestamps
+    // when a backup root with the same prefix is present
     table.writeRegionServerLogTimestamp(tables, rsTimestampMap, "root");
+    table.writeRegionServerLogTimestamp(tables, rsTimestampMap, "root/backup");
 
     Map<TableName, Map<String, Long>> result = 
table.readLogTimestampMap("root");
 
@@ -291,7 +297,10 @@ public class TestBackupSystemTable {
     rsTimestampMap1.put("rs2:100", 201L);
     rsTimestampMap1.put("rs3:100", 203L);
 
+    // validate the prefix scan in readLogTimestampMap will get the right 
timestamps
+    // when a backup root with the same prefix is present
     table.writeRegionServerLogTimestamp(tables1, rsTimestampMap1, "root");
+    table.writeRegionServerLogTimestamp(tables1, rsTimestampMap, 
"root/backup");
 
     result = table.readLogTimestampMap("root");
 

Reply via email to