Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-28427 FNFE related to 'master:store' when moving archived hfiles to global archived dir #5756

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,15 @@ private void moveHFileToGlobalArchiveDir() throws IOException {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4648,6 +4648,39 @@ public void testWritesWhileScanning() throws IOException, InterruptedException {
}
}

@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;
Expand Down