diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java index b94fb370bc3..8023e083f90 100644 --- a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java +++ b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java @@ -321,7 +321,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { } try { - markTaskAsRunning(head, collectionName, asyncId); + markTaskAsRunning(head, collectionName, asyncId, message); log.debug("Marked task [{}] as running", head.getId()); } catch (KeeperException.NodeExistsException e) { // This should never happen @@ -366,6 +366,10 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { if(collectionName == null) return true; + // CLUSTERSTATUS is always mutually exclusive + if(CLUSTERSTATUS.isEqual(message.getStr(Overseer.QUEUE_OPERATION))) + return true; + if(collectionWip.contains(collectionName)) return false; @@ -2560,7 +2564,8 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { } while(true); } - private void markTaskAsRunning(QueueEvent head, String collectionName,String asyncId) + private void markTaskAsRunning(QueueEvent head, String collectionName, + String asyncId, ZkNodeProps message) throws KeeperException, InterruptedException { synchronized (runningZKTasks) { runningZKTasks.add(head.getId()); @@ -2569,7 +2574,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { synchronized (runningTasks) { runningTasks.add(head.getId()); } - if(collectionName != null) { + if(!CLUSTERSTATUS.isEqual(message.getStr(Overseer.QUEUE_OPERATION)) && collectionName != null) { synchronized (collectionWip) { collectionWip.add(collectionName); } @@ -2662,7 +2667,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { if(asyncId != null) runningMap.remove(asyncId); - if(collectionName != null) { + if(!CLUSTERSTATUS.isEqual(operation) && collectionName != null) { synchronized (collectionWip) { collectionWip.remove(collectionName); } @@ -2679,7 +2684,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { runningTasks.remove(id); } - if (collectionName != null) { + if (!CLUSTERSTATUS.isEqual(operation) && collectionName != null) { synchronized (collectionWip) { collectionWip.remove(collectionName); } diff --git a/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java b/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java index 309e91dbb71..79418b9b5bc 100644 --- a/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java @@ -17,12 +17,15 @@ package org.apache.solr.cloud; * limitations under the License. */ +import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServer; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.request.CollectionAdminRequest; +import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.common.params.CollectionParams; +import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.update.DirectUpdateHandler2; import org.junit.Before; @@ -191,6 +194,16 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase { invokeCollectionApi("action", CollectionParams.CollectionAction.OVERSEERSTATUS.toLower()); + // CLUSTERSTATE is always mutually exclusive, it should return with a response before the split completes + + ModifiableSolrParams params = new ModifiableSolrParams(); + params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString()); + params.set("collection", "collection1"); + SolrRequest request = new QueryRequest(params); + request.setPath("/admin/collections"); + + server.request(request); + state = getRequestState("2000", server); assertTrue("After invoking OVERSEERSTATUS, SplitShard task [2000] was still supposed to be in [running] but isn't." +