You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2024/03/18 13:49:19 UTC
(hbase) branch branch-2.5 updated: HBASE-28427 FNFE related to 'master:store' when moving archived hfiles to global archived dir (#5756)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new 26b9e3209b5 HBASE-28427 FNFE related to 'master:store' when moving archived hfiles to global archived dir (#5756)
26b9e3209b5 is described below
commit 26b9e3209b504b284585a43cbd13cc283f9410e2
Author: guluo <lu...@qq.com>
AuthorDate: Mon Mar 18 21:26:15 2024 +0800
HBASE-28427 FNFE related to 'master:store' when moving archived hfiles to global archived dir (#5756)
Signed-off-by: Duo Zhang <zh...@apache.org>
(cherry picked from commit 0c1224cc9a844025d483085cd1a4a9c43d17a26f)
---
.../region/MasterRegionFlusherAndCompactor.java | 11 ++++++--
.../hadoop/hbase/regionserver/TestHRegion.java | 33 ++++++++++++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFlusherAndCompactor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFlusherAndCompactor.java
index 3d4bfea146e..c06420ea992 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFlusherAndCompactor.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFlusherAndCompactor.java
@@ -142,8 +142,15 @@ class MasterRegionFlusherAndCompactor implements Closeable {
Path globalStoreArchiveDir = HFileArchiveUtil.getStoreArchivePathForArchivePath(
globalArchivePath, region.getRegionInfo(), store.getColumnFamilyDescriptor().getName());
try {
- MasterRegionUtils.moveFilesUnderDir(fs, storeArchiveDir, globalStoreArchiveDir,
- archivedHFileSuffix);
+ if (fs.exists(storeArchiveDir)) {
+ MasterRegionUtils.moveFilesUnderDir(fs, storeArchiveDir, globalStoreArchiveDir,
+ archivedHFileSuffix);
+ } else {
+ LOG.warn(
+ "Archived dir {} does not exist, there is no need to move archived hfiles from {} "
+ + "to global dir {} .",
+ storeArchiveDir, storeArchiveDir, globalStoreArchiveDir);
+ }
} catch (IOException e) {
LOG.warn("Failed to move archived hfiles from {} to global dir {}", storeArchiveDir,
globalStoreArchiveDir, e);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
index 9d78ee24867..5d38fae8e90 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
@@ -4651,6 +4651,39 @@ public class TestHRegion {
}
}
+ @Test
+ public void testCloseAndArchiveCompactedFiles() throws IOException {
+ byte[] CF1 = Bytes.toBytes("CF1");
+ byte[] CF2 = Bytes.toBytes("CF2");
+ this.region = initHRegion(tableName, method, CONF, CF1, CF2);
+ for (int i = 0; i < 2; i++) {
+ int index = i;
+ Put put =
+ new Put(Bytes.toBytes(index)).addColumn(CF1, Bytes.toBytes("q"), Bytes.toBytes(index));
+ region.put(put);
+ region.flush(true);
+ }
+
+ region.compact(true);
+
+ HStore store1 = region.getStore(CF1);
+ HStore store2 = region.getStore(CF2);
+ store1.closeAndArchiveCompactedFiles();
+ store2.closeAndArchiveCompactedFiles();
+
+ int storefilesCount = region.getStores().stream().mapToInt(Store::getStorefilesCount).sum();
+ assertTrue(storefilesCount == 1);
+
+ FileSystem fs = region.getRegionFileSystem().getFileSystem();
+ Configuration conf = region.getReadOnlyConfiguration();
+ RegionInfo regionInfo = region.getRegionInfo();
+ Path store1ArchiveDir = HFileArchiveUtil.getStoreArchivePath(conf, regionInfo, CF1);
+ assertTrue(fs.exists(store1ArchiveDir));
+ // The archived dir of CF2 does not exist because this column family has no data at all
+ Path store2ArchiveDir = HFileArchiveUtil.getStoreArchivePath(conf, regionInfo, CF2);
+ assertFalse(fs.exists(store2ArchiveDir));
+ }
+
protected class PutThread extends Thread {
private volatile boolean done;
private volatile int numPutsFinished = 0;