Skip to content

Commit 7b7f576

Browse files
committed
HBASE-26999 HStore should try write WAL compaction marker before repl… (#4407)
Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Andrew Purtell <apurtell@apache.org>
1 parent ad2180b commit 7b7f576

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,14 +1231,17 @@ private void writeCompactionWalRecord(Collection<HStoreFile> filesCompacted,
12311231
allowedOnPath = ".*/(HStore|TestHStore).java")
12321232
void replaceStoreFiles(Collection<HStoreFile> compactedFiles, Collection<HStoreFile> result,
12331233
boolean writeCompactionMarker) throws IOException {
1234-
storeEngine.replaceStoreFiles(compactedFiles, result, () -> {
1234+
storeEngine.replaceStoreFiles(compactedFiles, result,
1235+
() -> {
1236+
if (writeCompactionMarker) {
1237+
writeCompactionWalRecord(compactedFiles, result);
1238+
}
1239+
},
1240+
() -> {
12351241
synchronized (filesCompacting) {
12361242
filesCompacting.removeAll(compactedFiles);
12371243
}
12381244
});
1239-
if (writeCompactionMarker) {
1240-
writeCompactionWalRecord(compactedFiles, result);
1241-
}
12421245
// These may be null when the RS is shutting down. The space quota Chores will fix the Region
12431246
// sizes later so it's not super-critical if we miss these.
12441247
RegionServerServices rsServices = region.getRegionServerServices();

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreEngine.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.concurrent.locks.ReadWriteLock;
3535
import java.util.concurrent.locks.ReentrantReadWriteLock;
3636
import java.util.function.Function;
37+
3738
import org.apache.hadoop.conf.Configuration;
3839
import org.apache.hadoop.fs.Path;
3940
import org.apache.hadoop.hbase.CellComparator;
@@ -407,8 +408,7 @@ private void refreshStoreFilesInternal(Collection<StoreFileInfo> newFiles) throw
407408
List<HStoreFile> openedFiles = openStoreFiles(toBeAddedFiles, false);
408409

409410
// propogate the file changes to the underlying store file manager
410-
replaceStoreFiles(toBeRemovedStoreFiles, openedFiles, () -> {
411-
}); // won't throw an exception
411+
replaceStoreFiles(toBeRemovedStoreFiles, openedFiles, () -> {}, () -> {}); // won't throw an exception
412412
}
413413

414414
/**
@@ -491,9 +491,11 @@ public void addStoreFiles(Collection<HStoreFile> storeFiles,
491491
}
492492

493493
public void replaceStoreFiles(Collection<HStoreFile> compactedFiles,
494-
Collection<HStoreFile> newFiles, Runnable actionUnderLock) throws IOException {
494+
Collection<HStoreFile> newFiles, IOExceptionRunnable walMarkerWriter,
495+
Runnable actionUnderLock) throws IOException {
495496
storeFileTracker.replace(StoreUtils.toStoreFileInfo(compactedFiles),
496497
StoreUtils.toStoreFileInfo(newFiles));
498+
walMarkerWriter.run();
497499
writeLock();
498500
try {
499501
storeFileManager.addCompactionResults(compactedFiles, newFiles);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,14 +1018,14 @@ public void testRefreshStoreFilesNotChanged() throws IOException {
10181018
// call first time after files changed
10191019
spiedStoreEngine.refreshStoreFiles();
10201020
assertEquals(2, this.store.getStorefilesCount());
1021-
verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any(), any());
1021+
verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any(), any(), any());
10221022

10231023
// call second time
10241024
spiedStoreEngine.refreshStoreFiles();
10251025

10261026
// ensure that replaceStoreFiles is not called, i.e, the times does not change, if files are not
10271027
// refreshed,
1028-
verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any(), any());
1028+
verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any(), any(), any());
10291029
}
10301030

10311031
private long countMemStoreScanner(StoreScanner scanner) {

0 commit comments

Comments
 (0)