From 739e977aa737dd254c37b0f50f5a6b3ebd7a9863 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Thu, 31 Jul 2014 16:57:49 +0200 Subject: [PATCH] cluster block with auto create index bulk action can cause bulk execution to not return when there is a cluster block (like no master yet discovered), the bulk action doesn't properly catch the exception of inner execute to notify the listener, causing the bulk operation to hang closes #7086 --- .../action/bulk/TransportBulkAction.java | 10 ++-- .../cluster/NoMasterNodeTests.java | 49 ++++++++++++++----- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index d764311dbd9..1289fa352e5 100644 --- a/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -96,7 +96,7 @@ public class TransportBulkAction extends HandledTransportAction listener) { final long startTime = System.currentTimeMillis(); - final AtomicArray responses = new AtomicArray(bulkRequest.requests.size()); + final AtomicArray responses = new AtomicArray<>(bulkRequest.requests.size()); if (autoCreateIndex.needToCheck()) { final Set indices = Sets.newHashSet(); @@ -125,7 +125,7 @@ public class TransportBulkAction extends HandledTransportAction() { + createIndexAction.execute(new CreateIndexRequest(index).cause("auto(bulk api)").masterNodeTimeout(bulkRequest.timeout()), new ActionListener() { @Override public void onResponse(CreateIndexResponse result) { if (counter.decrementAndGet() == 0) { @@ -145,7 +145,11 @@ public class TransportBulkAction extends HandledTransportAction