Skip to content

Commit c8eb196

Browse files
authored
HBASE-26300 Skip archived master wals during incremental backups (#4932)
Signed-off-by: Bryan Beaudreault <[email protected]>
1 parent bfc9fc9 commit c8eb196

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.apache.hadoop.hbase.client.Connection;
5454
import org.apache.hadoop.hbase.client.RegionInfo;
5555
import org.apache.hadoop.hbase.client.TableDescriptor;
56+
import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
5657
import org.apache.hadoop.hbase.tool.BulkLoadHFiles;
5758
import org.apache.hadoop.hbase.util.CommonFSUtils;
5859
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@@ -360,6 +361,10 @@ public static <T> Long getMinValue(Map<T, Long> map) {
360361
* @return host name
361362
*/
362363
public static String parseHostFromOldLog(Path p) {
364+
// Skip master wals
365+
if (p.getName().endsWith(MasterRegionFactory.ARCHIVED_WAL_SUFFIX)) {
366+
return null;
367+
}
363368
try {
364369
String n = p.getName();
365370
int idx = n.lastIndexOf(LOGNAME_SEPARATOR);

hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@
2424
import org.apache.hadoop.fs.Path;
2525
import org.apache.hadoop.hbase.HBaseClassTestRule;
2626
import org.apache.hadoop.hbase.HBaseTestingUtil;
27+
import org.apache.hadoop.hbase.HConstants;
28+
import org.apache.hadoop.hbase.ServerName;
2729
import org.apache.hadoop.hbase.backup.util.BackupUtils;
30+
import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
2831
import org.apache.hadoop.hbase.testclassification.SmallTests;
32+
import org.apache.hadoop.hbase.util.Addressing;
33+
import org.apache.hadoop.hbase.util.CommonFSUtils;
34+
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
2935
import org.apache.hadoop.security.UserGroupInformation;
3036
import org.junit.Assert;
3137
import org.junit.ClassRule;
@@ -45,7 +51,7 @@ public class TestBackupUtils {
4551
protected static Configuration conf = TEST_UTIL.getConfiguration();
4652

4753
@Test
48-
public void TestGetBulkOutputDir() {
54+
public void testGetBulkOutputDir() {
4955
// Create a user who is not the current user
5056
String fooUserName = "foo1234";
5157
String fooGroupName = "group1";
@@ -78,4 +84,24 @@ public Path run() {
7884
// Make sure the directory is in foo1234's home directory
7985
Assert.assertTrue(bulkOutputDir.toString().startsWith(fooHomeDirectory.toString()));
8086
}
87+
88+
@Test
89+
public void testFilesystemWalHostNameParsing() throws IOException {
90+
String host = "localhost";
91+
int port = 60030;
92+
ServerName serverName = ServerName.valueOf(host, port, 1234);
93+
Path walRootDir = CommonFSUtils.getWALRootDir(conf);
94+
Path oldLogDir = new Path(walRootDir, HConstants.HREGION_OLDLOGDIR_NAME);
95+
96+
Path testWalPath = new Path(oldLogDir,
97+
serverName.toString() + BackupUtils.LOGNAME_SEPARATOR + EnvironmentEdgeManager.currentTime());
98+
Path testMasterWalPath =
99+
new Path(oldLogDir, testWalPath.getName() + MasterRegionFactory.ARCHIVED_WAL_SUFFIX);
100+
101+
String parsedHost = BackupUtils.parseHostFromOldLog(testMasterWalPath);
102+
Assert.assertNull(parsedHost);
103+
104+
parsedHost = BackupUtils.parseHostFromOldLog(testWalPath);
105+
Assert.assertEquals(parsedHost, host + Addressing.HOSTNAME_PORT_SEPARATOR + port);
106+
}
81107
}

0 commit comments

Comments
 (0)