diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java index fb4636582de..b2b6be584cf 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java @@ -114,6 +114,11 @@ class AsyncProcess { "hbase.client.start.log.errors.counter"; public static final int DEFAULT_START_LOG_ERRORS_AFTER_COUNT = 9; + /** + * Configuration to decide whether to log details for batch error + */ + public static final String LOG_DETAILS_FOR_BATCH_ERROR = "hbase.client.log.batcherrors.details"; + /** * The context used to wait for results from one submit call. * 1) If AsyncProcess is set to track errors globally, and not per call (for HTable puts), @@ -223,6 +228,8 @@ class AsyncProcess { protected int serverTrackerTimeout; protected int timeout; protected long primaryCallTimeoutMicroseconds; + /** Whether to log details for batch errors */ + private final boolean logBatchErrorDetails; // End configuration settings. protected static class BatchErrors { @@ -244,9 +251,12 @@ class AsyncProcess { return !throwables.isEmpty(); } - private synchronized RetriesExhaustedWithDetailsException makeException() { - return new RetriesExhaustedWithDetailsException( - new ArrayList(throwables), + private synchronized RetriesExhaustedWithDetailsException makeException(boolean logDetails) { + if (logDetails) { + LOG.error("Exception occurred! Exception details: " + throwables + ";\nActions: " + + actions); + } + return new RetriesExhaustedWithDetailsException(new ArrayList(throwables), new ArrayList(actions), new ArrayList(addresses)); } @@ -319,6 +329,7 @@ class AsyncProcess { this.rpcCallerFactory = rpcCaller; this.rpcFactory = rpcFactory; + this.logBatchErrorDetails = conf.getBoolean(LOG_DETAILS_FOR_BATCH_ERROR, false); } /** @@ -1690,7 +1701,7 @@ class AsyncProcess { @Override public RetriesExhaustedWithDetailsException getErrors() { - return errors.makeException(); + return errors.makeException(logBatchErrorDetails); } @Override @@ -1810,7 +1821,7 @@ class AsyncProcess { if (failedRows != null) { failedRows.addAll(globalErrors.actions); } - RetriesExhaustedWithDetailsException result = globalErrors.makeException(); + RetriesExhaustedWithDetailsException result = globalErrors.makeException(logBatchErrorDetails); globalErrors.clear(); return result; }