Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add exception message for error batch too large #2408

Merged
merged 1 commit into from
Oct 11, 2023
Merged
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
3 changes: 2 additions & 1 deletion intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ public enum AtlasErrorCode {
FAILED_TO_REFRESH_TYPE_DEF_CACHE(500, "ATLAS-500-00-20", "Failed to refresh type-def cache"),
CINV_UNHEALTHY(500, "ATLAS-500-00-21", "Unable to process type-definition operations"),
RUNTIME_EXCEPTION(500, "ATLAS-500-00-020", "Runtime exception {0}"),
KEYCLOAK_INIT_FAILED(500, "ATLAS-500-00-021", "Failed to initialize keycloak client: {0}"),
KEYCLOAK_INIT_FAILED(500, "ATLAS-500-00-022", "Failed to initialize keycloak client: {0}"),
BATCH_SIZE_TOO_LARGE(500, "ATLAS-500-00-023", "Batch size is too large, please use a smaller batch size"),


CLASSIFICATION_CURRENTLY_BEING_PROPAGATED(400, "ATLAS-400-00-105", "Classification {0} is currently being propagated."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.atlas;

import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException;
import com.google.common.annotations.VisibleForTesting;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
Expand All @@ -34,11 +35,7 @@
import javax.inject.Inject;
import javax.ws.rs.core.Response;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;

Expand Down Expand Up @@ -128,7 +125,11 @@ public Object invoke(MethodInvocation invocation) throws Throwable {
} else {
doRollback(logRollback, t);
}
throw t;
if (checkForBatchTooLargeError(t)) {
throw new AtlasBaseException(AtlasErrorCode.BATCH_SIZE_TOO_LARGE, t);
} else {
throw t;
}
}
} finally {
RequestContext.get().endMetricRecord(metric);
Expand Down Expand Up @@ -167,6 +168,22 @@ public Object invoke(MethodInvocation invocation) throws Throwable {
}
}

public boolean checkForBatchTooLargeError(Throwable t) {
Throwable currentCause = t;
while (currentCause != null) {
String message = currentCause.getMessage();
if (message != null &&
message.contains("Batch too large") &&
currentCause.getClass().equals(InvalidQueryException.class)) {
return true;
}
currentCause = currentCause.getCause();
}
return false;
}



private void doCommitOrRollback(final String invokingClass, final String invokedMethodName) {
if (innerFailure.get()) {
if (LOG.isDebugEnabled()) {
Expand Down
Loading