joshelser commented on a change in pull request #740: HBASE-23197
'IllegalArgumentException: Wrong FS' on edits replay when…
URL: https://github.com/apache/hbase/pull/740#discussion_r346402361
##########
File path:
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
##########
@@ -676,6 +678,60 @@ public void testToShowNPEOnRegionScannerReseek() throws
Exception {
scanner1.close();
}
+ @Test
+ public void testArchiveRecoveredEditsReplay() throws Exception {
+ byte[] family = Bytes.toBytes("family");
+ this.region = initHRegion(tableName, method, CONF, family);
+ final WALFactory wals = new WALFactory(CONF, method);
+ try {
+ Path regiondir = region.getRegionFileSystem().getRegionDir();
+ FileSystem fs = region.getRegionFileSystem().getFileSystem();
+ byte[] regionName = region.getRegionInfo().getEncodedNameAsBytes();
+
+ Path recoveredEditsDir =
WALSplitUtil.getRegionDirRecoveredEditsDir(regiondir);
+
+ long maxSeqId = 1050;
+ long minSeqId = 1000;
+
+ for (long i = minSeqId; i <= maxSeqId; i += 10) {
+ Path recoveredEdits = new Path(recoveredEditsDir,
String.format("%019d", i));
+ fs.create(recoveredEdits);
+ WALProvider.Writer writer = wals.createRecoveredEditsWriter(fs,
recoveredEdits);
+
+ long time = System.nanoTime();
+ WALEdit edit = new WALEdit();
+ edit.add(new KeyValue(row, family, Bytes.toBytes(i), time,
KeyValue.Type.Put, Bytes
+ .toBytes(i)));
+ writer.append(new WAL.Entry(new WALKeyImpl(regionName, tableName, i,
time,
+ HConstants.DEFAULT_CLUSTER_ID), edit));
+
+ writer.close();
+ }
+ MonitoredTask status = TaskMonitor.get().createStatus(method);
+ Map<byte[], Long> maxSeqIdInStores = new
TreeMap<>(Bytes.BYTES_COMPARATOR);
+ for (HStore store : region.getStores()) {
+ maxSeqIdInStores.put(Bytes.toBytes(store.getColumnFamilyName()),
minSeqId - 1);
+ }
+ CONF.set("hbase.region.archive.recovered.edits", "true");
+ CONF.set(CommonFSUtils.HBASE_WAL_DIR, "/custom_wal_dir");
+ long seqId = region.replayRecoveredEditsIfAny(maxSeqIdInStores, null,
status);
+ assertEquals(maxSeqId, seqId);
+ region.getMVCC().advanceTo(seqId);
+ String fakeFamilyName = recoveredEditsDir.getName();
+ Path rootDir = new Path(CONF.get(HConstants.HBASE_DIR));
+ Path storeArchiveDir =
HFileArchiveUtil.getStoreArchivePathForRootDir(rootDir,
+ region.getRegionInfo(), Bytes.toBytes(fakeFamilyName));
+ FileStatus[] list =
TEST_UTIL.getTestFileSystem().listStatus(storeArchiveDir);
+ assertEquals(6, list.length);
Review comment:
> here the edits are on same FS from WALs dir
Isn't this checking the wrong place then? Should be..
`HFileArchiveUtil.getStoreArchivePathForRootDir(new Path("/custom_wal_dir"),
region.getRegionInfo(), Bytes.toBytes(fakeFamilyName));`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services