From 56e7ccee82a000aab3f66fd9b114cae68da126dc Mon Sep 17 00:00:00 2001 From: Briana Augenreich Date: Wed, 20 Mar 2024 11:45:19 -0400 Subject: [PATCH 1/3] HBASE-28449 - fix backupSystemTable prefix scans --- .../hadoop/hbase/backup/impl/BackupSystemTable.java | 12 ++---------- 1 file changed, 2 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 55f225f41cf1..682757dbc404 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 @@ private Put createPutForWriteRegionServerLogTimestamp(TableName table, byte[] sm */ 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 @@ private Put createPutForRegionServerLastLogRollResult(String server, Long timest */ 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); From 4a6c411e58c8159370f1fc7558e0fc09f5305d0d Mon Sep 17 00:00:00 2001 From: Briana Augenreich Date: Mon, 25 Mar 2024 10:29:17 -0400 Subject: [PATCH 2/3] test scan changes --- .../org/apache/hadoop/hbase/backup/TestBackupSystemTable.java | 4 ++++ 1 file changed, 4 insertions(+) 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 21883fa6eaad..0f664500e741 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 @@ -192,6 +192,7 @@ public void testRegionServerLastLogRollResults() throws IOException { for (int i = 0; i < servers.length; i++) { table.writeRegionServerLastLogRollResult(servers[i], timestamps[i], "root"); + table.writeRegionServerLastLogRollResult(servers[i], timestamps[i], "root/backup"); } HashMap result = table.readRegionServerLastLogRollResult("root"); @@ -266,6 +267,7 @@ public void testRegionServerLogTimestampMap() throws IOException { rsTimestampMap.put("rs3:100", 103L); table.writeRegionServerLogTimestamp(tables, rsTimestampMap, "root"); + table.writeRegionServerLogTimestamp(tables, rsTimestampMap, "root/backup"); Map> result = table.readLogTimestampMap("root"); @@ -292,6 +294,8 @@ public void testRegionServerLogTimestampMap() throws IOException { rsTimestampMap1.put("rs3:100", 203L); table.writeRegionServerLogTimestamp(tables1, rsTimestampMap1, "root"); + table.writeRegionServerLogTimestamp(tables1, rsTimestampMap, "root/backup"); + result = table.readLogTimestampMap("root"); From 762d5936654173f188777def0032ca40b3f44913 Mon Sep 17 00:00:00 2001 From: Briana Augenreich Date: Mon, 25 Mar 2024 11:51:59 -0400 Subject: [PATCH 3/3] add comment to tests + spotless apply --- .../apache/hadoop/hbase/backup/TestBackupSystemTable.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 0f664500e741..51e266032cea 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,6 +190,8 @@ public void testRegionServerLastLogRollResults() throws IOException { 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"); @@ -266,6 +268,8 @@ public void testRegionServerLogTimestampMap() throws IOException { 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"); @@ -293,10 +297,11 @@ public void testRegionServerLogTimestampMap() throws IOException { 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"); assertTrue(5 == result.size());