Skip to content
Permalink
Browse files
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>
  • Loading branch information
wchevreuil committed May 9, 2022
1 parent e8b44d9 commit f6e9d3e1dd6546663319c436286ab58dd0e731ed
Showing 3 changed files with 14 additions and 9 deletions.
@@ -1232,14 +1232,17 @@ private void writeCompactionWalRecord(Collection<HStoreFile> filesCompacted,
allowedOnPath = ".*/(HStore|TestHStore).java")
void replaceStoreFiles(Collection<HStoreFile> compactedFiles, Collection<HStoreFile> result,
boolean writeCompactionMarker) throws IOException {
storeEngine.replaceStoreFiles(compactedFiles, result, () -> {
storeEngine.replaceStoreFiles(compactedFiles, result,
() -> {
if (writeCompactionMarker) {
writeCompactionWalRecord(compactedFiles, result);
}
},
() -> {
synchronized (filesCompacting) {
filesCompacting.removeAll(compactedFiles);
}
});
if (writeCompactionMarker) {
writeCompactionWalRecord(compactedFiles, result);
}
// These may be null when the RS is shutting down. The space quota Chores will fix the Region
// sizes later so it's not super-critical if we miss these.
RegionServerServices rsServices = region.getRegionServerServices();
@@ -34,6 +34,7 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Function;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.CellComparator;
@@ -407,8 +408,7 @@ private void refreshStoreFilesInternal(Collection<StoreFileInfo> newFiles) throw
List<HStoreFile> openedFiles = openStoreFiles(toBeAddedFiles, false);

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

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

public void replaceStoreFiles(Collection<HStoreFile> compactedFiles,
Collection<HStoreFile> newFiles, Runnable actionUnderLock) throws IOException {
Collection<HStoreFile> newFiles, IOExceptionRunnable walMarkerWriter,
Runnable actionUnderLock) throws IOException {
storeFileTracker.replace(StoreUtils.toStoreFileInfo(compactedFiles),
StoreUtils.toStoreFileInfo(newFiles));
walMarkerWriter.run();
writeLock();
try {
storeFileManager.addCompactionResults(compactedFiles, newFiles);
@@ -1017,14 +1017,14 @@ public void testRefreshStoreFilesNotChanged() throws IOException {
// call first time after files changed
spiedStoreEngine.refreshStoreFiles();
assertEquals(2, this.store.getStorefilesCount());
verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any(), any());
verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any(), any(), any());

// call second time
spiedStoreEngine.refreshStoreFiles();

// ensure that replaceStoreFiles is not called, i.e, the times does not change, if files are not
// refreshed,
verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any(), any());
verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any(), any(), any());
}

private long countMemStoreScanner(StoreScanner scanner) {

0 comments on commit f6e9d3e

Please sign in to comment.