Skip to content

Commit 0c1224c

Browse files
authored
HBASE-28427 FNFE related to 'master:store' when moving archived hfiles to global archived dir (#5756)
Signed-off-by: Duo Zhang <[email protected]>
1 parent 9361ae5 commit 0c1224c

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFlusherAndCompactor.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,15 @@ private void moveHFileToGlobalArchiveDir() throws IOException {
142142
Path globalStoreArchiveDir = HFileArchiveUtil.getStoreArchivePathForArchivePath(
143143
globalArchivePath, region.getRegionInfo(), store.getColumnFamilyDescriptor().getName());
144144
try {
145-
MasterRegionUtils.moveFilesUnderDir(fs, storeArchiveDir, globalStoreArchiveDir,
146-
archivedHFileSuffix);
145+
if (fs.exists(storeArchiveDir)) {
146+
MasterRegionUtils.moveFilesUnderDir(fs, storeArchiveDir, globalStoreArchiveDir,
147+
archivedHFileSuffix);
148+
} else {
149+
LOG.warn(
150+
"Archived dir {} does not exist, there is no need to move archived hfiles from {} "
151+
+ "to global dir {} .",
152+
storeArchiveDir, storeArchiveDir, globalStoreArchiveDir);
153+
}
147154
} catch (IOException e) {
148155
LOG.warn("Failed to move archived hfiles from {} to global dir {}", storeArchiveDir,
149156
globalStoreArchiveDir, e);

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4649,6 +4649,39 @@ public void testWritesWhileScanning() throws IOException, InterruptedException {
46494649
}
46504650
}
46514651

4652+
@Test
4653+
public void testCloseAndArchiveCompactedFiles() throws IOException {
4654+
byte[] CF1 = Bytes.toBytes("CF1");
4655+
byte[] CF2 = Bytes.toBytes("CF2");
4656+
this.region = initHRegion(tableName, method, CONF, CF1, CF2);
4657+
for (int i = 0; i < 2; i++) {
4658+
int index = i;
4659+
Put put =
4660+
new Put(Bytes.toBytes(index)).addColumn(CF1, Bytes.toBytes("q"), Bytes.toBytes(index));
4661+
region.put(put);
4662+
region.flush(true);
4663+
}
4664+
4665+
region.compact(true);
4666+
4667+
HStore store1 = region.getStore(CF1);
4668+
HStore store2 = region.getStore(CF2);
4669+
store1.closeAndArchiveCompactedFiles();
4670+
store2.closeAndArchiveCompactedFiles();
4671+
4672+
int storefilesCount = region.getStores().stream().mapToInt(Store::getStorefilesCount).sum();
4673+
assertTrue(storefilesCount == 1);
4674+
4675+
FileSystem fs = region.getRegionFileSystem().getFileSystem();
4676+
Configuration conf = region.getReadOnlyConfiguration();
4677+
RegionInfo regionInfo = region.getRegionInfo();
4678+
Path store1ArchiveDir = HFileArchiveUtil.getStoreArchivePath(conf, regionInfo, CF1);
4679+
assertTrue(fs.exists(store1ArchiveDir));
4680+
// The archived dir of CF2 does not exist because this column family has no data at all
4681+
Path store2ArchiveDir = HFileArchiveUtil.getStoreArchivePath(conf, regionInfo, CF2);
4682+
assertFalse(fs.exists(store2ArchiveDir));
4683+
}
4684+
46524685
protected class PutThread extends Thread {
46534686
private volatile boolean done;
46544687
private volatile int numPutsFinished = 0;

0 commit comments

Comments
 (0)