Skip to content

Commit 89ce5d1

Browse files
authored
HBASE-22163 Should not archive the compacted store files when region warmup (#122)
* HBASE-22163 Should not archive the compacted store files when region warmup
1 parent ad81d25 commit 89ce5d1

File tree

17 files changed

+228
-66
lines changed

17 files changed

+228
-66
lines changed

hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestRefreshHFilesEndpoint.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ public List<HStore> getStores() {
109109
}
110110

111111
public static class HStoreWithFaultyRefreshHFilesAPI extends HStore {
112-
public HStoreWithFaultyRefreshHFilesAPI(final HRegion region, final ColumnFamilyDescriptor family,
113-
final Configuration confParam) throws IOException {
114-
super(region, family, confParam);
112+
public HStoreWithFaultyRefreshHFilesAPI(final HRegion region,
113+
final ColumnFamilyDescriptor family, final Configuration confParam) throws IOException {
114+
super(region, family, confParam, false);
115115
}
116116

117117
@Override

hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public Path getTempDir() {
191191
}
192192
};
193193
HRegion region = new HRegion(regionFs, null, conf, htd, null);
194-
return new HStore(region, htd.getColumnFamily(Bytes.toBytes(familyName)), conf);
194+
return new HStore(region, htd.getColumnFamily(Bytes.toBytes(familyName)), conf, false);
195195
}
196196
}
197197

hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
import org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil;
135135
import org.apache.hadoop.hbase.master.procedure.ModifyTableProcedure;
136136
import org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch;
137+
import org.apache.hadoop.hbase.master.procedure.ProcedureSyncWait;
137138
import org.apache.hadoop.hbase.master.procedure.RecoverMetaProcedure;
138139
import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
139140
import org.apache.hadoop.hbase.master.procedure.TruncateTableProcedure;
@@ -2025,13 +2026,15 @@ public void move(final byte[] encodedRegionName, byte[] destServerName) throws H
20252026
if (this.cpHost != null) {
20262027
this.cpHost.preMove(hri, rp.getSource(), rp.getDestination());
20272028
}
2029+
2030+
TransitRegionStateProcedure proc =
2031+
this.assignmentManager.createMoveRegionProcedure(rp.getRegionInfo(), rp.getDestination());
20282032
// Warmup the region on the destination before initiating the move. this call
20292033
// is synchronous and takes some time. doing it before the source region gets
20302034
// closed
20312035
serverManager.sendRegionWarmup(rp.getDestination(), hri);
2032-
20332036
LOG.info(getClientIdAuditPrefix() + " move " + rp + ", running balancer");
2034-
Future<byte []> future = this.assignmentManager.moveAsync(rp);
2037+
Future<byte[]> future = ProcedureSyncWait.submitProcedure(this.procedureExecutor, proc);
20352038
try {
20362039
// Is this going to work? Will we throw exception on error?
20372040
// TODO: CompletableFuture rather than this stunted Future.

hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ public long unassign(RegionInfo regionInfo) throws IOException {
592592
return proc.getProcId();
593593
}
594594

595-
private TransitRegionStateProcedure createMoveRegionProcedure(RegionInfo regionInfo,
595+
public TransitRegionStateProcedure createMoveRegionProcedure(RegionInfo regionInfo,
596596
ServerName targetServer) throws HBaseIOException {
597597
RegionStateNode regionNode = this.regionStates.getRegionStateNode(regionInfo);
598598
if (regionNode == null) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ public class HMobStore extends HStore {
104104
private final byte[] refCellTags;
105105

106106
public HMobStore(final HRegion region, final ColumnFamilyDescriptor family,
107-
final Configuration confParam) throws IOException {
108-
super(region, family, confParam);
107+
final Configuration confParam, boolean warmup) throws IOException {
108+
super(region, family, confParam, warmup);
109109
this.family = family;
110110
this.mobFileCache = region.getMobFileCache();
111111
this.homePath = MobUtils.getMobHome(conf);

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,11 @@ private long initializeRegionInternals(final CancelableProgressable reporter,
10521052
*/
10531053
private long initializeStores(CancelableProgressable reporter, MonitoredTask status)
10541054
throws IOException {
1055+
return initializeStores(reporter, status, false);
1056+
}
1057+
1058+
private long initializeStores(CancelableProgressable reporter, MonitoredTask status,
1059+
boolean warmup) throws IOException {
10551060
// Load in all the HStores.
10561061
long maxSeqId = -1;
10571062
// initialized to -1 so that we pick up MemstoreTS from column families
@@ -1069,7 +1074,7 @@ private long initializeStores(CancelableProgressable reporter, MonitoredTask sta
10691074
completionService.submit(new Callable<HStore>() {
10701075
@Override
10711076
public HStore call() throws IOException {
1072-
return instantiateHStore(family);
1077+
return instantiateHStore(family, warmup);
10731078
}
10741079
});
10751080
}
@@ -1129,7 +1134,7 @@ private void initializeWarmup(final CancelableProgressable reporter) throws IOEx
11291134
// Initialize all the HStores
11301135
status.setStatus("Warming up all the Stores");
11311136
try {
1132-
initializeStores(reporter, status);
1137+
initializeStores(reporter, status, true);
11331138
} finally {
11341139
status.markComplete("Done warming up.");
11351140
}
@@ -5814,17 +5819,17 @@ private static boolean isZeroLengthThenDelete(final FileSystem fs, final Path p)
58145819
return true;
58155820
}
58165821

5817-
protected HStore instantiateHStore(final ColumnFamilyDescriptor family) throws IOException {
5822+
protected HStore instantiateHStore(final ColumnFamilyDescriptor family, boolean warmup)
5823+
throws IOException {
58185824
if (family.isMobEnabled()) {
58195825
if (HFile.getFormatVersion(this.conf) < HFile.MIN_FORMAT_VERSION_WITH_TAGS) {
5820-
throw new IOException("A minimum HFile version of "
5821-
+ HFile.MIN_FORMAT_VERSION_WITH_TAGS
5822-
+ " is required for MOB feature. Consider setting " + HFile.FORMAT_VERSION_KEY
5823-
+ " accordingly.");
5826+
throw new IOException("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS +
5827+
" is required for MOB feature. Consider setting " + HFile.FORMAT_VERSION_KEY +
5828+
" accordingly.");
58245829
}
5825-
return new HMobStore(this, family, this.conf);
5830+
return new HMobStore(this, family, this.conf, warmup);
58265831
}
5827-
return new HStore(this, family, this.conf);
5832+
return new HStore(this, family, this.conf, warmup);
58285833
}
58295834

58305835
@Override

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

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
241241
* @throws IOException
242242
*/
243243
protected HStore(final HRegion region, final ColumnFamilyDescriptor family,
244-
final Configuration confParam) throws IOException {
244+
final Configuration confParam, boolean warmup) throws IOException {
245245

246246
this.fs = region.getRegionFileSystem();
247247

@@ -303,7 +303,7 @@ protected HStore(final HRegion region, final ColumnFamilyDescriptor family,
303303
}
304304

305305
this.storeEngine = createStoreEngine(this, this.conf, this.comparator);
306-
List<HStoreFile> hStoreFiles = loadStoreFiles();
306+
List<HStoreFile> hStoreFiles = loadStoreFiles(warmup);
307307
// Move the storeSize calculation out of loadStoreFiles() method, because the secondary read
308308
// replica's refreshStoreFiles() will also use loadStoreFiles() to refresh its store files and
309309
// update the storeSize in the completeCompaction(..) finally (just like compaction) , so
@@ -555,12 +555,13 @@ void setDataBlockEncoderInTest(HFileDataBlockEncoder blockEncoder) {
555555
* from the given directory.
556556
* @throws IOException
557557
*/
558-
private List<HStoreFile> loadStoreFiles() throws IOException {
558+
private List<HStoreFile> loadStoreFiles(boolean warmup) throws IOException {
559559
Collection<StoreFileInfo> files = fs.getStoreFiles(getColumnFamilyName());
560-
return openStoreFiles(files);
560+
return openStoreFiles(files, warmup);
561561
}
562562

563-
private List<HStoreFile> openStoreFiles(Collection<StoreFileInfo> files) throws IOException {
563+
private List<HStoreFile> openStoreFiles(Collection<StoreFileInfo> files, boolean warmup)
564+
throws IOException {
564565
if (CollectionUtils.isEmpty(files)) {
565566
return Collections.emptyList();
566567
}
@@ -614,19 +615,22 @@ private List<HStoreFile> openStoreFiles(Collection<StoreFileInfo> files) throws
614615
throw ioe;
615616
}
616617

617-
// Remove the compacted files from result
618-
List<HStoreFile> filesToRemove = new ArrayList<>(compactedStoreFiles.size());
619-
for (HStoreFile storeFile : results) {
620-
if (compactedStoreFiles.contains(storeFile.getPath().getName())) {
621-
LOG.warn("Clearing the compacted storefile {} from this store", storeFile);
622-
storeFile.getReader().close(true);
623-
filesToRemove.add(storeFile);
618+
// Should not archive the compacted store files when region warmup. See HBASE-22163.
619+
if (!warmup) {
620+
// Remove the compacted files from result
621+
List<HStoreFile> filesToRemove = new ArrayList<>(compactedStoreFiles.size());
622+
for (HStoreFile storeFile : results) {
623+
if (compactedStoreFiles.contains(storeFile.getPath().getName())) {
624+
LOG.warn("Clearing the compacted storefile {} from this store", storeFile);
625+
storeFile.getReader().close(true);
626+
filesToRemove.add(storeFile);
627+
}
628+
}
629+
results.removeAll(filesToRemove);
630+
if (!filesToRemove.isEmpty() && this.isPrimaryReplicaStore()) {
631+
LOG.debug("Moving the files {} to archive", filesToRemove);
632+
this.fs.removeStoreFiles(this.getColumnFamilyDescriptor().getNameAsString(), filesToRemove);
624633
}
625-
}
626-
results.removeAll(filesToRemove);
627-
if (!filesToRemove.isEmpty() && this.isPrimaryReplicaStore()) {
628-
LOG.debug("Moving the files {} to archive", filesToRemove);
629-
this.fs.removeStoreFiles(this.getColumnFamilyDescriptor().getNameAsString(), filesToRemove);
630634
}
631635

632636
return results;
@@ -694,7 +698,7 @@ private void refreshStoreFilesInternal(Collection<StoreFileInfo> newFiles) throw
694698
}
695699

696700
// try to open the files
697-
List<HStoreFile> openedFiles = openStoreFiles(toBeAddedFiles);
701+
List<HStoreFile> openedFiles = openStoreFiles(toBeAddedFiles, false);
698702

699703
// propogate the file changes to the underlying store file manager
700704
replaceStoreFiles(toBeRemovedStoreFiles, openedFiles); //won't throw an exception

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,17 +2142,14 @@ public WarmupRegionResponse warmupRegion(final RpcController controller,
21422142
return response;
21432143
}
21442144

2145-
if (LOG.isDebugEnabled()) {
2146-
LOG.debug("Warming up Region " + region.getRegionNameAsString());
2147-
}
2148-
21492145
htd = regionServer.tableDescriptors.get(region.getTable());
21502146

21512147
if (regionServer.getRegionsInTransitionInRS().containsKey(encodedNameBytes)) {
21522148
LOG.info("Region is in transition. Skipping warmup " + region);
21532149
return response;
21542150
}
21552151

2152+
LOG.info("Warming up region " + region.getRegionNameAsString());
21562153
HRegion.warmupHRegion(region, htd, regionServer.getWAL(region),
21572154
regionServer.getConfiguration(), regionServer, null);
21582155

hbase-server/src/test/java/org/apache/hadoop/hbase/TestIOFencing.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,19 @@ public BlockCompactionsInCompletionRegion(Path tableDir, WAL log,
194194
TableDescriptor htd, RegionServerServices rsServices) {
195195
super(tableDir, log, fs, confParam, info, htd, rsServices);
196196
}
197+
197198
@Override
198-
protected HStore instantiateHStore(final ColumnFamilyDescriptor family) throws IOException {
199-
return new BlockCompactionsInCompletionHStore(this, family, this.conf);
199+
protected HStore instantiateHStore(final ColumnFamilyDescriptor family, boolean warmup)
200+
throws IOException {
201+
return new BlockCompactionsInCompletionHStore(this, family, this.conf, warmup);
200202
}
201203
}
202204

203205
public static class BlockCompactionsInCompletionHStore extends HStore {
204206
CompactionBlockerRegion r;
205207
protected BlockCompactionsInCompletionHStore(HRegion region, ColumnFamilyDescriptor family,
206-
Configuration confParam) throws IOException {
207-
super(region, family, confParam);
208+
Configuration confParam, boolean warmup) throws IOException {
209+
super(region, family, confParam, warmup);
208210
r = (CompactionBlockerRegion) region;
209211
}
210212

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSideScanExcpetion.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,17 @@ public MyHRegion(Path tableDir, WAL wal, FileSystem fs, Configuration confParam,
116116
}
117117

118118
@Override
119-
protected HStore instantiateHStore(ColumnFamilyDescriptor family) throws IOException {
120-
return new MyHStore(this, family, conf);
119+
protected HStore instantiateHStore(ColumnFamilyDescriptor family, boolean warmup)
120+
throws IOException {
121+
return new MyHStore(this, family, conf, warmup);
121122
}
122123
}
123124

124125
public static final class MyHStore extends HStore {
125126

126-
public MyHStore(HRegion region, ColumnFamilyDescriptor family, Configuration confParam)
127-
throws IOException {
128-
super(region, family, confParam);
127+
public MyHStore(HRegion region, ColumnFamilyDescriptor family, Configuration confParam,
128+
boolean warmup) throws IOException {
129+
super(region, family, confParam, warmup);
129130
}
130131

131132
@Override

0 commit comments

Comments
 (0)