You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2019/06/17 22:54:59 UTC

[lucene-solr] branch master updated: eliminate CPU hogging spin-loops in OverseerTest

This is an automated email from the ASF dual-hosted git repository.

hossman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new 3030ea9  eliminate CPU hogging spin-loops in OverseerTest
3030ea9 is described below

commit 3030ea9d9418626ffb3c3bbd174aee344a778b25
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Mon Jun 17 15:42:07 2019 -0700

    eliminate CPU hogging spin-loops in OverseerTest
    
    this test already uses waitForState (frequently via verifyReplicaStatus) so there is no reason to include CPU/network/ZK intensive infinite loop checks looking for udpated cluster state
---
 .../test/org/apache/solr/cloud/OverseerTest.java   | 36 +++++-----------------
 1 file changed, 7 insertions(+), 29 deletions(-)

diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
index 692284b..175806d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
@@ -670,42 +670,33 @@ public class OverseerTest extends SolrTestCaseJ4 {
       waitForCollections(reader, COLLECTION);
       verifyReplicaStatus(reader, COLLECTION, "shard1", "core_node1", Replica.State.RECOVERING);
 
-      int version = getClusterStateVersion(zkClient);
-
       mockController.publishState(COLLECTION, core, core_node, "shard1", Replica.State.ACTIVE,
           numShards, true, overseers.get(0));
 
-      while (version == getClusterStateVersion(zkClient));
-
       verifyReplicaStatus(reader, COLLECTION, "shard1", "core_node1", Replica.State.ACTIVE);
-      version = getClusterStateVersion(zkClient);
 
       mockController.publishState(COLLECTION, core, core_node, "shard1",
           Replica.State.RECOVERING, numShards, true, overseers.get(0));
 
       overseerClient.close();
-
-      version = getClusterStateVersion(zkClient);
-
+      
       overseerClient = electNewOverseer(server.getZkAddress());
 
-      while (version == getClusterStateVersion(zkClient));
-
       verifyReplicaStatus(reader, COLLECTION, "shard1", "core_node1", Replica.State.RECOVERING);
 
       assertEquals("Live nodes count does not match", 1, reader
           .getClusterState().getLiveNodes().size());
       assertEquals(shard+" replica count does not match", 1, reader.getClusterState()
           .getCollection(COLLECTION).getSlice(shard).getReplicasMap().size());
-      version = getClusterStateVersion(zkClient);
       mockController.publishState(COLLECTION, core, core_node, "shard1", null, numShards, true, overseers.get(1));
-      while (version == getClusterStateVersion(zkClient));
-
-      assertTrue(COLLECTION +" should remain after removal of the last core", // as of SOLR-5209 core removal does not cascade to remove the slice and collection
-          reader.getClusterState().hasCollection(COLLECTION));
 
       reader.waitForState(COLLECTION, 5000,
             TimeUnit.MILLISECONDS, (liveNodes, collectionState) -> collectionState != null && collectionState.getReplica(core_node) == null);
+
+      reader.forceUpdateCollection(COLLECTION);
+      // as of SOLR-5209 core removal does not cascade to remove the slice and collection
+      assertTrue(COLLECTION +" should remain after removal of the last core", 
+          reader.getClusterState().hasCollection(COLLECTION));
       assertTrue(core_node+" should be gone after publishing the null state",
           null == reader.getClusterState().getCollection(COLLECTION).getReplica(core_node));
     } finally {
@@ -1055,18 +1046,11 @@ public class OverseerTest extends SolrTestCaseJ4 {
 
       mockController.close();
 
-      int version = getClusterStateVersion(zkClient);
-
       mockController = new MockZKController(server.getZkAddress(), "node1", overseers);
 
       mockController.publishState(COLLECTION, "core1", "core_node1","shard1", Replica.State.RECOVERING, 1, true, overseers.get(0));
 
-      try {
-        reader.waitForState(COLLECTION, 5, TimeUnit.SECONDS, (liveNodes, collectionState) -> version == zkController
-            .getZkStateReader().getClusterState().getZkClusterStateVersion());
-      } catch (TimeoutException e) {
-        // okay
-      }
+      reader.forceUpdateCollection(COLLECTION);
       ClusterState state = reader.getClusterState();
 
       int numFound = 0;
@@ -1397,12 +1381,6 @@ public class OverseerTest extends SolrTestCaseJ4 {
     }
   }
 
-  private int getClusterStateVersion(SolrZkClient controllerClient)
-      throws KeeperException, InterruptedException {
-    return controllerClient.exists(ZkStateReader.CLUSTER_STATE, null, false).getVersion();
-  }
-
-
   private SolrZkClient electNewOverseer(String address)
       throws InterruptedException, TimeoutException, IOException,
       KeeperException, ParserConfigurationException, SAXException, NoSuchFieldException, SecurityException {