You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bb...@apache.org on 2023/01/04 02:15:04 UTC

[hbase] branch master updated: HBASE-26300 Skip archived master wals during incremental backups (#4932)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new c8eb1963a6b HBASE-26300 Skip archived master wals during incremental backups (#4932)
c8eb1963a6b is described below

commit c8eb1963a6b7afd987c3649d3c5a79809bdd7a9e
Author: Jarryd Lee <ja...@gmail.com>
AuthorDate: Tue Jan 3 18:14:53 2023 -0800

    HBASE-26300 Skip archived master wals during incremental backups (#4932)
    
    Signed-off-by: Bryan Beaudreault <bb...@apache.org>
---
 .../hadoop/hbase/backup/util/BackupUtils.java      |  5 ++++
 .../hadoop/hbase/backup/TestBackupUtils.java       | 28 +++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
index ef97b195e28..7afc7a840f7 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
@@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.RegionInfo;
 import org.apache.hadoop.hbase.client.TableDescriptor;
+import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
 import org.apache.hadoop.hbase.tool.BulkLoadHFiles;
 import org.apache.hadoop.hbase.util.CommonFSUtils;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@@ -360,6 +361,10 @@ public final class BackupUtils {
    * @return host name
    */
   public static String parseHostFromOldLog(Path p) {
+    // Skip master wals
+    if (p.getName().endsWith(MasterRegionFactory.ARCHIVED_WAL_SUFFIX)) {
+      return null;
+    }
     try {
       String n = p.getName();
       int idx = n.lastIndexOf(LOGNAME_SEPARATOR);
diff --git a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java
index 7bf7a55c599..a55720777c4 100644
--- a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java
+++ b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java
@@ -24,8 +24,14 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.backup.util.BackupUtils;
+import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.apache.hadoop.hbase.util.Addressing;
+import org.apache.hadoop.hbase.util.CommonFSUtils;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.junit.Assert;
 import org.junit.ClassRule;
@@ -45,7 +51,7 @@ public class TestBackupUtils {
   protected static Configuration conf = TEST_UTIL.getConfiguration();
 
   @Test
-  public void TestGetBulkOutputDir() {
+  public void testGetBulkOutputDir() {
     // Create a user who is not the current user
     String fooUserName = "foo1234";
     String fooGroupName = "group1";
@@ -78,4 +84,24 @@ public class TestBackupUtils {
     // Make sure the directory is in foo1234's home directory
     Assert.assertTrue(bulkOutputDir.toString().startsWith(fooHomeDirectory.toString()));
   }
+
+  @Test
+  public void testFilesystemWalHostNameParsing() throws IOException {
+    String host = "localhost";
+    int port = 60030;
+    ServerName serverName = ServerName.valueOf(host, port, 1234);
+    Path walRootDir = CommonFSUtils.getWALRootDir(conf);
+    Path oldLogDir = new Path(walRootDir, HConstants.HREGION_OLDLOGDIR_NAME);
+
+    Path testWalPath = new Path(oldLogDir,
+      serverName.toString() + BackupUtils.LOGNAME_SEPARATOR + EnvironmentEdgeManager.currentTime());
+    Path testMasterWalPath =
+      new Path(oldLogDir, testWalPath.getName() + MasterRegionFactory.ARCHIVED_WAL_SUFFIX);
+
+    String parsedHost = BackupUtils.parseHostFromOldLog(testMasterWalPath);
+    Assert.assertNull(parsedHost);
+
+    parsedHost = BackupUtils.parseHostFromOldLog(testWalPath);
+    Assert.assertEquals(parsedHost, host + Addressing.HOSTNAME_PORT_SEPARATOR + port);
+  }
 }