Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -20,7 +20,6 @@

package com.apple.foundationdb.record.provider.foundationdb;

import com.apple.foundationdb.FDBError;
import com.apple.foundationdb.FDBException;
import com.apple.foundationdb.MutationType;
import com.apple.foundationdb.annotation.API;
Expand Down Expand Up @@ -59,7 +58,6 @@
import java.time.DateTimeException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -1213,22 +1211,6 @@ protected static <T> T findException(@Nullable Throwable ex, Class<T> classT) {
}
return null;
}

protected static boolean shouldLessenWork(@Nullable FDBException ex) {
// These error codes represent a list of errors that can occur if there is too much work to be done
// in a single transaction.
if (ex == null) {
return false;
}
final Set<Integer> lessenWorkCodes = new HashSet<>(Arrays.asList(
FDBError.TIMED_OUT.code(),
FDBError.TRANSACTION_TOO_OLD.code(),
FDBError.NOT_COMMITTED.code(),
FDBError.TRANSACTION_TIMED_OUT.code(),
FDBError.COMMIT_READ_INCOMPLETE.code(),
FDBError.TRANSACTION_TOO_LARGE.code()));
return lessenWorkCodes.contains(ex.getCode());
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@
// merges. Not perfect, but as long as it's rare the impact should be minimal.

mergeControl.mergeHadFailed(); // report to adjust stats
final FDBException ex = IndexingBase.findException(e, FDBException.class);
final IndexDeferredMaintenanceControl.LastStep lastStep = mergeControl.getLastStep();
if (!IndexingBase.shouldLessenWork(ex)) {
if (shouldAbort(e)) {
giveUpMerging(mergeControl, e);
}
switch (lastStep) {
Expand All @@ -175,6 +174,24 @@
return AsyncUtil.READY_TRUE; // and retry
}

private boolean shouldAbort(@Nullable Throwable e) {
if (e == null) {
return true;
}
// Expecting AsyncToSyncTimeoutException or an instance of TimeoutException. However, cannot
// refer to AsyncToSyncTimeoutException without creating a lucene dependency
// TODO: remove this kludge

Check warning on line 183 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingMerger.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingMerger.java#L183

[New] TODO: remove this kludge https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3732%2Fjjezra%2Fmerger_retry_by_default%3AHEAD&id=38228D63267E2070D6B2FF80FD8FCC8F
if (e.getClass().getCanonicalName().contains("Timeout") ) {
return false;
}
final FDBException ex = IndexingBase.findException(e, FDBException.class);
if (ex == null) {
return true;
}
// TODO: return true if the exception is clearly not retriable

Check warning on line 191 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingMerger.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingMerger.java#L191

TODO: return true if the exception is clearly not retriable https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3732%2Fjjezra%2Fmerger_retry_by_default%3AHEAD&id=8B69489D49D660B961E9007845B5895F
return false;
}

private void handleRepartitioningFailure(final IndexDeferredMaintenanceControl mergeControl, Throwable e) {
repartitionDocumentCount = mergeControl.getRepartitionDocumentCount();
if (repartitionDocumentCount == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package com.apple.foundationdb.record.provider.foundationdb;

import com.apple.foundationdb.FDBError;
import com.apple.foundationdb.FDBException;
import com.apple.foundationdb.annotation.API;
import com.apple.foundationdb.async.AsyncUtil;
Expand Down Expand Up @@ -133,7 +134,7 @@ boolean mayRetryAfterHandlingException(@Nullable FDBException fdbException,
@Nullable List<Object> additionalLogMessageKeyValues,
int currTries,
final boolean adjustLimits) {
if (currTries >= common.config.getMaxRetries() || !IndexingBase.shouldLessenWork(fdbException)) {
if (currTries >= common.config.getMaxRetries() || !shouldLessenWork(fdbException)) {
// Here: should not retry or no more retries. There is no real need to handle limits.
return false;
}
Expand All @@ -144,6 +145,22 @@ boolean mayRetryAfterHandlingException(@Nullable FDBException fdbException,
return true;
}

private static boolean shouldLessenWork(@Nullable FDBException ex) {
// These error codes represent a list of errors that can occur if there is too much work to be done
// in a single transaction.
if (ex == null) {
return false;
}
final Set<Integer> lessenWorkCodes = new HashSet<>(Arrays.asList(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This set can be declared as a static instance - no need to instantiate every time

FDBError.TIMED_OUT.code(),
FDBError.TRANSACTION_TOO_OLD.code(),
FDBError.NOT_COMMITTED.code(),
FDBError.TRANSACTION_TIMED_OUT.code(),
FDBError.COMMIT_READ_INCOMPLETE.code(),
FDBError.TRANSACTION_TOO_LARGE.code()));
return lessenWorkCodes.contains(ex.getCode());
}

void decreaseLimit(@Nonnull FDBException fdbException,
@Nullable List<Object> additionalLogMessageKeyValues) {
// TODO: decrease the limit only for certain errors
Expand Down
Loading