diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java index e910f3c0e55..41f18382073 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java @@ -1229,13 +1229,14 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, allowedOnPath = ".*/(HStore|TestHStore).java") void replaceStoreFiles(Collection compactedFiles, Collection result, boolean writeCompactionMarker) throws IOException { - storeEngine.replaceStoreFiles(compactedFiles, result); + storeEngine.replaceStoreFiles(compactedFiles, result, () -> { + synchronized(filesCompacting) { + filesCompacting.removeAll(compactedFiles); + } + }); if (writeCompactionMarker) { writeCompactionWalRecord(compactedFiles, result); } - synchronized (filesCompacting) { - filesCompacting.removeAll(compactedFiles); - } // 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(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreEngine.java index ddb52d10ffd..d85553ac808 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreEngine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreEngine.java @@ -410,7 +410,8 @@ public abstract class StoreEngine 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 } /** @@ -493,12 +494,13 @@ public abstract class StoreEngine compactedFiles, - Collection newFiles) throws IOException { + Collection newFiles, Runnable actionUnderLock) throws IOException { storeFileTracker.replace(StoreUtils.toStoreFileInfo(compactedFiles), StoreUtils.toStoreFileInfo(newFiles)); writeLock(); try { storeFileManager.addCompactionResults(compactedFiles, newFiles); + actionUnderLock.run(); } finally { writeUnlock(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java index bdee770732b..0440a8c966c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java @@ -1034,14 +1034,14 @@ public class TestHStore { // call first time after files changed spiedStoreEngine.refreshStoreFiles(); assertEquals(2, this.store.getStorefilesCount()); - verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any()); + verify(spiedStoreEngine, times(1)).replaceStoreFiles(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()); + verify(spiedStoreEngine, times(1)).replaceStoreFiles(any(), any(), any()); } private long countMemStoreScanner(StoreScanner scanner) {