Skip to content

Commit 450a54b

Browse files
committed
HBASE-26938 Compaction failures after StoreFileTracker integration (#4350)
Introduce a StoreFileWriterCreationTracker to track the store files being written Signed-off-by: Josh Elser <[email protected]> Signed-off-by: Andrew Purtell <[email protected]> (cherry picked from commit 48c4a46)
1 parent 0753172 commit 450a54b

26 files changed

+395
-245
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/mob/DefaultMobStoreCompactor.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
import java.util.ArrayList;
2323
import java.util.Date;
2424
import java.util.List;
25+
import java.util.function.Consumer;
2526
import org.apache.hadoop.conf.Configuration;
2627
import org.apache.hadoop.fs.Path;
2728
import org.apache.hadoop.hbase.Cell;
2829
import org.apache.hadoop.hbase.CellUtil;
2930
import org.apache.hadoop.hbase.PrivateCellUtil;
3031
import org.apache.hadoop.hbase.KeyValue;
32+
import org.apache.hadoop.hbase.regionserver.CellSink;
3133
import org.apache.hadoop.hbase.regionserver.HMobStore;
3234
import org.apache.hadoop.hbase.regionserver.HStore;
3335
import org.apache.hadoop.hbase.regionserver.InternalScanner;
@@ -40,6 +42,7 @@
4042
import org.apache.hadoop.hbase.regionserver.StoreFileWriter;
4143
import org.apache.hadoop.hbase.regionserver.StoreScanner;
4244
import org.apache.hadoop.hbase.regionserver.compactions.CloseChecker;
45+
import org.apache.hadoop.hbase.regionserver.compactions.CompactionProgress;
4346
import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequestImpl;
4447
import org.apache.hadoop.hbase.regionserver.compactions.DefaultCompactor;
4548
import org.apache.hadoop.hbase.regionserver.throttle.ThroughputControlUtil;
@@ -84,10 +87,14 @@ public InternalScanner createScanner(ScanInfo scanInfo, List<StoreFileScanner> s
8487
@Override
8588
public StoreFileWriter createWriter(InternalScanner scanner,
8689
org.apache.hadoop.hbase.regionserver.compactions.Compactor.FileDetails fd,
87-
boolean shouldDropBehind, boolean major) throws IOException {
90+
boolean shouldDropBehind, boolean major, Consumer<Path> writerCreationTracker)
91+
throws IOException {
8892
// make this writer with tags always because of possible new cells with tags.
89-
return store.getStoreEngine().createWriter(
90-
createParams(fd, shouldDropBehind, major).includeMVCCReadpoint(true).includesTag(true));
93+
return store.getStoreEngine()
94+
.createWriter(
95+
createParams(fd, shouldDropBehind, major, writerCreationTracker)
96+
.includeMVCCReadpoint(true)
97+
.includesTag(true));
9198
}
9299
};
93100

@@ -155,17 +162,19 @@ public List<Path> compact(CompactionRequestImpl request, ThroughputController th
155162
* the scanner to filter the deleted cells.
156163
* @param fd File details
157164
* @param scanner Where to read from.
165+
* @param writer Where to write to.
158166
* @param smallestReadPoint Smallest read point.
159167
* @param cleanSeqId When true, remove seqId(used to be mvcc) value which is <= smallestReadPoint
160168
* @param throughputController The compaction throughput controller.
161169
* @param major Is a major compaction.
162170
* @param numofFilesToCompact the number of files to compact
171+
* @param progress Progress reporter.
163172
* @return Whether compaction ended; false if it was interrupted for any reason.
164173
*/
165174
@Override
166-
protected boolean performCompaction(FileDetails fd, InternalScanner scanner,
175+
protected boolean performCompaction(FileDetails fd, InternalScanner scanner, CellSink writer,
167176
long smallestReadPoint, boolean cleanSeqId, ThroughputController throughputController,
168-
boolean major, int numofFilesToCompact) throws IOException {
177+
boolean major, int numofFilesToCompact, CompactionProgress progress) throws IOException {
169178
long bytesWrittenProgressForLog = 0;
170179
long bytesWrittenProgressForShippedCall = 0;
171180
// Since scanner.next() can return 'false' but still be delivering data,
@@ -369,9 +378,8 @@ protected boolean performCompaction(FileDetails fd, InternalScanner scanner,
369378
return true;
370379
}
371380

372-
373381
@Override
374-
protected List<Path> commitWriter(FileDetails fd,
382+
protected List<Path> commitWriter(StoreFileWriter writer, FileDetails fd,
375383
CompactionRequestImpl request) throws IOException {
376384
List<Path> newFiles = Lists.newArrayList(writer.getPath());
377385
writer.appendMetadata(fd.maxSeqId, request.isAllFiles(), request.getFiles());

hbase-server/src/main/java/org/apache/hadoop/hbase/mob/DefaultMobStoreFlusher.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.ArrayList;
2424
import java.util.Date;
2525
import java.util.List;
26+
import java.util.function.Consumer;
2627
import org.apache.hadoop.conf.Configuration;
2728
import org.apache.hadoop.fs.Path;
2829
import org.apache.hadoop.hbase.Cell;
@@ -100,7 +101,7 @@ public DefaultMobStoreFlusher(Configuration conf, HStore store) throws IOExcepti
100101
@Override
101102
public List<Path> flushSnapshot(MemStoreSnapshot snapshot, long cacheFlushId,
102103
MonitoredTask status, ThroughputController throughputController,
103-
FlushLifeCycleTracker tracker) throws IOException {
104+
FlushLifeCycleTracker tracker, Consumer<Path> writerCreationTracker) throws IOException {
104105
ArrayList<Path> result = new ArrayList<>();
105106
long cellsCount = snapshot.getCellsCount();
106107
if (cellsCount == 0) return result; // don't flush if there are no entries
@@ -114,7 +115,7 @@ public List<Path> flushSnapshot(MemStoreSnapshot snapshot, long cacheFlushId,
114115
synchronized (flushLock) {
115116
status.setStatus("Flushing " + store + ": creating writer");
116117
// Write the map out to the disk
117-
writer = createWriter(snapshot, true);
118+
writer = createWriter(snapshot, true, writerCreationTracker);
118119
IOException e = null;
119120
try {
120121
// It's a mob store, flush the cells in a mob way. This is the difference of flushing

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void init(StoreScanner sourceScanner, WriterFactory factory) {
6767
* comments in HBASE-15400 for more details.
6868
*/
6969
public List<Path> commitWriters(long maxSeqId, boolean majorCompaction) throws IOException {
70-
return commitWriters(maxSeqId, majorCompaction, Collections.EMPTY_SET);
70+
return commitWriters(maxSeqId, majorCompaction, Collections.emptyList());
7171
}
7272

7373
public List<Path> commitWriters(long maxSeqId, boolean majorCompaction,
@@ -110,11 +110,7 @@ public List<Path> abortWriters() {
110110
return paths;
111111
}
112112

113-
/**
114-
* Returns all writers. This is used to prevent deleting currently writen storefiles
115-
* during cleanup.
116-
*/
117-
public abstract Collection<StoreFileWriter> writers();
113+
protected abstract Collection<StoreFileWriter> writers();
118114

119115
/**
120116
* Subclasses override this method to be called at the end of a successful sequence of append; all

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private void cleanFileIfNeeded(FileStatus file, HStore store,
152152
}
153153

154154
private boolean isCompactionResultFile(FileStatus file, HStore store) {
155-
return store.getStoreEngine().getCompactor().getCompactionTargets().contains(file.getPath());
155+
return store.getStoreFilesBeingWritten().contains(file.getPath());
156156
}
157157

158158
// Compacted files can still have readers and are cleaned by a separate chore, so they have to

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package org.apache.hadoop.hbase.regionserver;
1919

20+
import java.util.function.Consumer;
21+
import org.apache.hadoop.fs.Path;
2022
import org.apache.hadoop.hbase.HConstants;
2123
import org.apache.hadoop.hbase.io.compress.Compression;
2224
import org.apache.yetus.audience.InterfaceAudience;
@@ -40,6 +42,8 @@ public final class CreateStoreFileWriterParams {
4042

4143
private String fileStoragePolicy = HConstants.EMPTY_STRING;
4244

45+
private Consumer<Path> writerCreationTracker;
46+
4347
private CreateStoreFileWriterParams() {
4448
}
4549

@@ -127,8 +131,16 @@ public CreateStoreFileWriterParams fileStoragePolicy(String fileStoragePolicy) {
127131
return this;
128132
}
129133

134+
public Consumer<Path> writerCreationTracker() {
135+
return writerCreationTracker;
136+
}
137+
138+
public CreateStoreFileWriterParams writerCreationTracker(Consumer<Path> writerCreationTracker) {
139+
this.writerCreationTracker = writerCreationTracker;
140+
return this;
141+
}
142+
130143
public static CreateStoreFileWriterParams create() {
131144
return new CreateStoreFileWriterParams();
132145
}
133-
134146
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void append(Cell cell) throws IOException {
7171
}
7272

7373
@Override
74-
public Collection<StoreFileWriter> writers() {
74+
protected Collection<StoreFileWriter> writers() {
7575
return lowerBoundary2Writer.values();
7676
}
7777

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.IOException;
2222
import java.util.ArrayList;
2323
import java.util.List;
24+
import java.util.function.Consumer;
2425
import org.apache.hadoop.conf.Configuration;
2526
import org.apache.hadoop.fs.Path;
2627
import org.apache.hadoop.hbase.monitoring.MonitoredTask;
@@ -44,8 +45,8 @@ public DefaultStoreFlusher(Configuration conf, HStore store) {
4445

4546
@Override
4647
public List<Path> flushSnapshot(MemStoreSnapshot snapshot, long cacheFlushId,
47-
MonitoredTask status, ThroughputController throughputController,
48-
FlushLifeCycleTracker tracker) throws IOException {
48+
MonitoredTask status, ThroughputController throughputController, FlushLifeCycleTracker tracker,
49+
Consumer<Path> writerCreationTracker) throws IOException {
4950
ArrayList<Path> result = new ArrayList<>();
5051
int cellsCount = snapshot.getCellsCount();
5152
if (cellsCount == 0) return result; // don't flush if there are no entries
@@ -59,7 +60,7 @@ public List<Path> flushSnapshot(MemStoreSnapshot snapshot, long cacheFlushId,
5960
synchronized (flushLock) {
6061
status.setStatus("Flushing " + store + ": creating writer");
6162
// Write the map out to the disk
62-
writer = createWriter(snapshot, false);
63+
writer = createWriter(snapshot, false, writerCreationTracker);
6364
IOException e = null;
6465
try {
6566
performFlush(scanner, writer, throughputController);

0 commit comments

Comments
 (0)