You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2019/07/17 01:10:17 UTC
[hbase] branch branch-2.1 updated: HBASE-22643 : Delete region
without archiving only if regiondir is present
This is an automated email from the ASF dual-hosted git repository.
apurtell pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 8b37958 HBASE-22643 : Delete region without archiving only if regiondir is present
8b37958 is described below
commit 8b37958161d3e1c188e536ff5688aa132c466ed9
Author: Viraj Jasani <vj...@salesforce.com>
AuthorDate: Mon Jul 1 00:08:56 2019 +0530
HBASE-22643 : Delete region without archiving only if regiondir is present
Signed-off-by: Wellington Chevreuil <wc...@apache.org>
Signed-off-by: Xu Cang <xu...@apache.org>
---
.../apache/hadoop/hbase/backup/HFileArchiver.java | 4 +-
.../hadoop/hbase/backup/TestHFileArchiving.java | 44 ++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java
index c64ce08..e6099db 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/HFileArchiver.java
@@ -121,7 +121,9 @@ public class HFileArchiver {
if (tableDir == null || regionDir == null) {
LOG.error("No archive directory could be found because tabledir (" + tableDir
+ ") or regiondir (" + regionDir + "was null. Deleting files instead.");
- deleteRegionWithoutArchiving(fs, regionDir);
+ if (regionDir != null) {
+ deleteRegionWithoutArchiving(fs, regionDir);
+ }
// we should have archived, but failed to. Doesn't matter if we deleted
// the archived files correctly or not.
return false;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestHFileArchiving.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestHFileArchiving.java
index f6c7b2e..1162dff 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestHFileArchiving.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestHFileArchiving.java
@@ -517,6 +517,50 @@ public class TestHFileArchiving {
}
}
+ @Test
+ public void testArchiveRegionTableAndRegionDirsNull() throws IOException {
+ Path rootDir = UTIL.getDataTestDirOnTestFS("testCleaningRace");
+ FileSystem fileSystem = UTIL.getTestFileSystem();
+ // Try to archive the file but with null regionDir, can't delete sourceFile
+ assertFalse(HFileArchiver.archiveRegion(fileSystem, rootDir, null, null));
+ }
+
+ @Test
+ public void testArchiveRegionWithTableDirNull() throws IOException {
+ Path regionDir = new Path(FSUtils.getTableDir(new Path("./"),
+ TableName.valueOf(name.getMethodName())), "xyzabc");
+ Path familyDir = new Path(regionDir, "rd");
+ Path rootDir = UTIL.getDataTestDirOnTestFS("testCleaningRace");
+ Path file = new Path(familyDir, "1");
+ Path sourceFile = new Path(rootDir, file);
+ FileSystem fileSystem = UTIL.getTestFileSystem();
+ fileSystem.createNewFile(sourceFile);
+ Path sourceRegionDir = new Path(rootDir, regionDir);
+ fileSystem.mkdirs(sourceRegionDir);
+ // Try to archive the file
+ assertFalse(HFileArchiver.archiveRegion(fileSystem, rootDir, null, sourceRegionDir));
+ assertFalse(fileSystem.exists(sourceRegionDir));
+ }
+
+ @Test
+ public void testArchiveRegionWithRegionDirNull() throws IOException {
+ Path regionDir = new Path(FSUtils.getTableDir(new Path("./"),
+ TableName.valueOf(name.getMethodName())), "elgn4nf");
+ Path familyDir = new Path(regionDir, "rdar");
+ Path rootDir = UTIL.getDataTestDirOnTestFS("testCleaningRace");
+ Path file = new Path(familyDir, "2");
+ Path sourceFile = new Path(rootDir, file);
+ FileSystem fileSystem = UTIL.getTestFileSystem();
+ fileSystem.createNewFile(sourceFile);
+ Path sourceRegionDir = new Path(rootDir, regionDir);
+ fileSystem.mkdirs(sourceRegionDir);
+ // Try to archive the file but with null regionDir, can't delete sourceFile
+ assertFalse(HFileArchiver.archiveRegion(fileSystem, rootDir, sourceRegionDir.getParent(),
+ null));
+ assertTrue(fileSystem.exists(sourceRegionDir));
+ fileSystem.delete(sourceRegionDir, true);
+ }
+
private void clearArchiveDirectory() throws IOException {
UTIL.getTestFileSystem().delete(
new Path(UTIL.getDefaultRootDirPath(), HConstants.HFILE_ARCHIVE_DIRECTORY), true);