Node Client with bulk request indefinitely blocked thread when ClusterBlockException is being thrown

(Cosmin Vasii) #1

I am using the dataless NodeClient to connect to my cluster (version is 1.1.1). Everything is working ok, except when failures occur. The scenario is the following:
-I have an application java based which connects to ES Cluster (application is started and the cluster is up and running)
-I shutdown the cluster
-I try to send a bulk request
-The following exception is displayed in the logs, which is normal. But my call never catches the exception:

Exception in thread "elasticsearch[Lasher][generic][T#6]"
org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];[SERVICE_UNAVAILA
BLE/2/no master];
at org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedException(
at org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedRaiseException(
at org.elasticsearch.action.bulk.TransportBulkAction.executeBulk(
at org.elasticsearch.action.bulk.TransportBulkAction.access$000(
at org.elasticsearch.action.bulk.TransportBulkAction$1.onFailure(
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

My code is something like this

    BulkResponse response;
    try {
        response = requestBuilder.execute().actionGet();
    catch(NoNodeAvailableException ex){
        LOGGER.error("Cannot connect to ES Cluster:  " + ex.getMessage());
        throw ex;
    catch (ClusterBlockException ex){
        LOGGER.error("Cannot connect to ES Cluster:  " + ex.getMessage());
        throw ex;
    catch (Exception ex) {

        LOGGER.error("Exception in processing indexing request by ES server. " + ex.getMessage());

When I use a single request everything is ok. I also noticed a TODO in the ES code in the

private void executeBulk(final BulkRequest bulkRequest, final long startTime, final ActionListener listener, final AtomicArray responses ) {
ClusterState clusterState = clusterService.state();
// TODO use timeout to wait here if its blocked...


Is this a known situation or a known bug?

(system) #2