Skip to content

Commit 063357c

Browse files
author
Joseph295
committed
HBASE-24436 The store file open and close thread pool should be shared at the region level
1 parent aacb69d commit 063357c

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ void sawNoSuchFamily() {
695695
private RegionCoprocessorHost coprocessorHost;
696696

697697
private TableDescriptor htableDescriptor = null;
698+
private ThreadPoolExecutor storeFileOpenAndCloseThreadPool;
698699
private RegionSplitPolicy splitPolicy;
699700
private FlushPolicy flushPolicy;
700701

@@ -799,6 +800,8 @@ public HRegion(final HRegionFileSystem fs, final WAL wal, final Configuration co
799800
}
800801
}
801802
}
803+
storeFileOpenAndCloseThreadPool = newStoreFileOpenAndCloseThreadPool(
804+
"StoreFileOpenAndClose-" + getRegionInfo().getEncodedName());
802805

803806
this.rsServices = rsServices;
804807
if (this.rsServices != null) {
@@ -1769,7 +1772,7 @@ public Pair<byte[], Collection<HStoreFile>> call() throws IOException {
17691772
storeCloserThreadPool.shutdownNow();
17701773
}
17711774
}
1772-
1775+
storeFileOpenAndCloseThreadPool.shutdownNow();
17731776
status.setStatus("Writing region close event to WAL");
17741777
// Always write close marker to wal even for read only table. This is not a big problem as we
17751778
// do not write any data into the region; it is just a meta edit in the WAL file.
@@ -1888,13 +1891,16 @@ protected ThreadPoolExecutor getStoreOpenAndCloseThreadPool(
18881891
return getOpenAndCloseThreadPool(maxThreads, threadNamePrefix);
18891892
}
18901893

1891-
protected ThreadPoolExecutor getStoreFileOpenAndCloseThreadPool(
1894+
public ThreadPoolExecutor getStoreFileOpenAndCloseThreadPool() {
1895+
return storeFileOpenAndCloseThreadPool;
1896+
}
1897+
1898+
protected ThreadPoolExecutor newStoreFileOpenAndCloseThreadPool(
18921899
final String threadNamePrefix) {
18931900
int numStores = Math.max(1, this.htableDescriptor.getColumnFamilyCount());
1894-
int maxThreads = Math.max(1,
1901+
int maxThreads = Math.max(numStores,
18951902
conf.getInt(HConstants.HSTORE_OPEN_AND_CLOSE_THREADS_MAX,
1896-
HConstants.DEFAULT_HSTORE_OPEN_AND_CLOSE_THREADS_MAX)
1897-
/ numStores);
1903+
HConstants.DEFAULT_HSTORE_OPEN_AND_CLOSE_THREADS_MAX));
18981904
return getOpenAndCloseThreadPool(maxThreads, threadNamePrefix);
18991905
}
19001906

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,9 @@ private List<HStoreFile> openStoreFiles(Collection<StoreFileInfo> files, boolean
555555
}
556556
// initialize the thread pool for opening store files in parallel..
557557
ThreadPoolExecutor storeFileOpenerThreadPool =
558-
this.region.getStoreFileOpenAndCloseThreadPool("StoreFileOpener-"
559-
+ this.region.getRegionInfo().getEncodedName() + "-" + this.getColumnFamilyName());
558+
this.region.getStoreFileOpenAndCloseThreadPool();
560559
CompletionService<HStoreFile> completionService =
561560
new ExecutorCompletionService<>(storeFileOpenerThreadPool);
562-
563561
int totalValidStoreFile = 0;
564562
for (StoreFileInfo storeFileInfo : files) {
565563
// open each store file in parallel
@@ -590,7 +588,7 @@ private List<HStoreFile> openStoreFiles(Collection<StoreFileInfo> files, boolean
590588
}
591589
}
592590
} finally {
593-
storeFileOpenerThreadPool.shutdownNow();
591+
594592
}
595593
if (ioe != null) {
596594
// close StoreFile readers
@@ -955,9 +953,7 @@ public ImmutableCollection<HStoreFile> close() throws IOException {
955953
if (!result.isEmpty()) {
956954
// initialize the thread pool for closing store files in parallel.
957955
ThreadPoolExecutor storeFileCloserThreadPool = this.region
958-
.getStoreFileOpenAndCloseThreadPool("StoreFileCloser-"
959-
+ this.region.getRegionInfo().getEncodedName() + "-" + this.getColumnFamilyName());
960-
956+
.getStoreFileOpenAndCloseThreadPool();
961957
// close each store file in parallel
962958
CompletionService<Void> completionService =
963959
new ExecutorCompletionService<>(storeFileCloserThreadPool);
@@ -991,7 +987,7 @@ public Void call() throws IOException {
991987
}
992988
}
993989
} finally {
994-
storeFileCloserThreadPool.shutdownNow();
990+
995991
}
996992
if (ioe != null) {
997993
throw ioe;

0 commit comments

Comments
 (0)