Skip to content

Commit

Permalink
handle EsRejectedExecutionException on blob upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed May 7, 2015
1 parent 326e843 commit 4d25e87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions blob/src/main/java/io/crate/blob/BlobTransferTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private void removeTransferAfterRecovery(UUID transferId) {
}
}
if (toSchedule) {
logger.info("finished transfer {}, removing state", transferId);
logger.debug("finished transfer {}, removing state", transferId);

/**
* there might be a race condition that the recoveryActive flag is still false although a
Expand Down Expand Up @@ -340,7 +340,7 @@ public void stopRecovery() {
synchronized (lock) {
recoveryActive = false;
for (UUID finishedUpload : finishedUploads) {
logger.info("finished transfer and recovery for {}, removing state", finishedUpload);
logger.debug("finished transfer and recovery for {}, removing state", finishedUpload);
activeTransfers.remove(finishedUpload);
}
}
Expand Down
12 changes: 11 additions & 1 deletion blob/src/main/java/io/crate/http/netty/HttpBlobHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.crate.blob.v2.BlobsDisabledException;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.indices.IndexMissingException;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
Expand All @@ -52,6 +53,7 @@
import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.*;
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK;
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.PARTIAL_CONTENT;
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.TOO_MANY_REQUESTS;
import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;

public class HttpBlobHandler extends SimpleChannelUpstreamHandler implements
Expand Down Expand Up @@ -215,7 +217,12 @@ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
logger.trace("channel closed: {}", ex.toString());
return;
} else if (ex instanceof IOException) {
logger.warn(ex.getMessage());
String message = ex.getMessage();
if (message != null && message.contains("Connection reset by peer")) {
logger.debug(message);
} else {
logger.warn(message, e);
}
return;
}

Expand All @@ -229,6 +236,9 @@ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
} else if (ex instanceof BlobsDisabledException || ex instanceof IndexMissingException) {
status = HttpResponseStatus.BAD_REQUEST;
body = ex.getMessage();
} else if (ex instanceof EsRejectedExecutionException) {
status = TOO_MANY_REQUESTS;
body = ex.getMessage();
} else {
status = HttpResponseStatus.INTERNAL_SERVER_ERROR;
logger.error("unhandled exception:", ex);
Expand Down

0 comments on commit 4d25e87

Please sign in to comment.