Skip to content

Commit

Permalink
moving wal marker write to store engine
Browse files Browse the repository at this point in the history
  • Loading branch information
wchevreuil committed May 6, 2022
1 parent 3902b6a commit a469010
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1232,10 +1232,13 @@ private void writeCompactionWalRecord(Collection<HStoreFile> filesCompacted,
allowedOnPath = ".*/(HStore|TestHStore).java")
void replaceStoreFiles(Collection<HStoreFile> compactedFiles, Collection<HStoreFile> result,
boolean writeCompactionMarker) throws IOException {
if (writeCompactionMarker) {
writeCompactionWalRecord(compactedFiles, result);
}
storeEngine.replaceStoreFiles(compactedFiles, result, () -> {
storeEngine.replaceStoreFiles(compactedFiles, result,
() -> {
if (writeCompactionMarker) {
writeCompactionWalRecord(compactedFiles, result);
}
},
() -> {
synchronized (filesCompacting) {
filesCompacting.removeAll(compactedFiles);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}

/**
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a469010

Please sign in to comment.