Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
package org.apache.accumulo.tserver.tablet;

import org.apache.accumulo.core.clientImpl.AcceptableThriftTableOperationException;
import org.apache.accumulo.core.clientImpl.thrift.TableOperation;
import org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.file.FilePrefix;
import org.apache.accumulo.core.metadata.ReferencedTabletFile;
import org.apache.accumulo.core.metadata.schema.DataFileValue;
Expand All @@ -41,6 +45,8 @@ class MinorCompactionTask implements Runnable {
private final long flushId;
private final MinorCompactionReason mincReason;

private final long pauseLimit;

MinorCompactionTask(Tablet tablet, CommitSession commitSession, long flushId,
MinorCompactionReason mincReason) {
this.tablet = tablet;
Expand All @@ -49,13 +55,32 @@ class MinorCompactionTask implements Runnable {
this.commitSession = commitSession;
this.flushId = flushId;
this.mincReason = mincReason;
this.pauseLimit = tablet.getContext().getTableConfiguration(tablet.extent.tableId())
.getCount(Property.TABLE_FILE_PAUSE);
}

private static void checkMinorCompactionFiles(String tableId, long pauseLimit,
long currentFileCount) throws AcceptableThriftTableOperationException {
if (pauseLimit > 0 && currentFileCount > pauseLimit) {
throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.COMPACT,
TableOperationExceptionType.OTHER, "Attempted to perform minor compaction with "
+ currentFileCount + " files, exceeding the configured limit of " + pauseLimit);
}
}

@Override
public void run() {
tablet.minorCompactionStarted();
try {
Span span = TraceUtil.startSpan(this.getClass(), "minorCompaction");
try {
long currentFileCount = tablet.getTabletMemory().getNumEntries();
checkMinorCompactionFiles(tablet.extent.tableId().canonical(), pauseLimit,
currentFileCount); // Add pause check here
} catch (AcceptableThriftTableOperationException e) {
log.warn("Minor compaction paused due to file count for tablet {}", tablet.extent);
return;
}
try (Scope scope = span.makeCurrent()) {
Span span2 = TraceUtil.startSpan(this.getClass(), "waitForCommits");
try (Scope scope2 = span2.makeCurrent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ DataFileValue minorCompact(InMemoryMap memTable, ReferencedTabletFile tmpDatafil
boolean failed = false;
long start = System.currentTimeMillis();
timer.incrementStatusMinor();

long pauseLimit =
getContext().getTableConfiguration(extent.tableId()).getCount(Property.TABLE_FILE_PAUSE);
long count = 0;

String oldName = Thread.currentThread().getName();
Expand All @@ -392,7 +393,13 @@ DataFileValue minorCompact(InMemoryMap memTable, ReferencedTabletFile tmpDatafil
Span span = TraceUtil.startSpan(this.getClass(), "minorCompact::write");
try (Scope scope = span.makeCurrent()) {
count = memTable.getNumEntries();

if (count > pauseLimit && pauseLimit > 0) {
log.debug(
"tablet {} has {} entries, which exceeds the pause limit of {}, pausing minor compaction.",
this.extent, count, pauseLimit);
failed = true; // Set the failed flag
return null;
}
MinorCompactor compactor = new MinorCompactor(tabletServer, this, memTable, tmpDatafile,
mincReason, tableConfiguration);
stats = compactor.call();
Expand Down