Solr
  1. Solr
  2. SOLR-8255

MiniSolrCloudCluster doesn't use a thread-safe list for its jetties

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.4
    • Component/s: None
    • Labels:
      None

      Description

      MiniSolrCloudCluster uses a LinkedList<> to hold its jetties. However, multi-threaded startup can break this because the list isn't thread safe. We should use CopyOnWriteArrayList instead.

      See for example http://jenkins.thetaphi.de/job/Lucene-Solr-trunk-Linux/14819/, which starts up 5 nodes but then only has 4 entries in its jetty list, causing assertion errors and thread leaks.

        Activity

        Hide
        Alan Woodward added a comment -

        Simple patch:

        diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
        index 7f0c548..205ce81 100644
        --- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
        +++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
        @@ -26,11 +26,11 @@ import java.nio.file.Path;
         import java.util.ArrayList;
         import java.util.Collection;
         import java.util.Collections;
        -import java.util.LinkedList;
         import java.util.List;
         import java.util.Map;
         import java.util.SortedMap;
         import java.util.concurrent.Callable;
        +import java.util.concurrent.CopyOnWriteArrayList;
         import java.util.concurrent.ExecutionException;
         import java.util.concurrent.ExecutorService;
         import java.util.concurrent.Future;
        @@ -89,7 +89,7 @@ public class MiniSolrCloudCluster {
        
           private final ZkTestServer zkServer;
           private final boolean externalZkServer;
        -  private final List<JettySolrRunner> jettys = new LinkedList<>();
        +  private final List<JettySolrRunner> jettys = new CopyOnWriteArrayList<>();
           private final Path baseDir;
           private final CloudSolrClient solrClient;
           private final JettyConfig jettyConfig;
        
        Show
        Alan Woodward added a comment - Simple patch: diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java index 7f0c548..205ce81 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java @@ -26,11 +26,11 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; - import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.SortedMap; import java.util.concurrent.Callable; + import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; @@ -89,7 +89,7 @@ public class MiniSolrCloudCluster { private final ZkTestServer zkServer; private final boolean externalZkServer; - private final List<JettySolrRunner> jettys = new LinkedList<>(); + private final List<JettySolrRunner> jettys = new CopyOnWriteArrayList<>(); private final Path baseDir; private final CloudSolrClient solrClient; private final JettyConfig jettyConfig;
        Hide
        ASF subversion and git services added a comment -

        Commit 1713457 from Alan Woodward in branch 'dev/trunk'
        [ https://svn.apache.org/r1713457 ]

        SOLR-8255: MiniSolrCloudCluster should use a thread-safe list to hold its child nodes

        Show
        ASF subversion and git services added a comment - Commit 1713457 from Alan Woodward in branch 'dev/trunk' [ https://svn.apache.org/r1713457 ] SOLR-8255 : MiniSolrCloudCluster should use a thread-safe list to hold its child nodes
        Hide
        ASF subversion and git services added a comment -

        Commit 1713458 from Alan Woodward in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1713458 ]

        SOLR-8255: MiniSolrCloudCluster should use a thread-safe list to hold its child nodes

        Show
        ASF subversion and git services added a comment - Commit 1713458 from Alan Woodward in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1713458 ] SOLR-8255 : MiniSolrCloudCluster should use a thread-safe list to hold its child nodes

          People

          • Assignee:
            Alan Woodward
            Reporter:
            Alan Woodward
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development