You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2018/10/10 11:43:37 UTC

lucene-solr:branch_7x: SOLR-12739: Release the policy session as soon as we're done with the computation.

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 859559a38 -> a4cc66bd5


SOLR-12739: Release the policy session as soon as we're done with the computation.

This fixes the CollectionsAPIDistributedZkTest.testCoresAreDistributedAcrossNodes test failures. Due to the various tests for exceptional conditions, there were times where the session was not released causing stale data to remain in the policy session cache.

(cherry picked from commit 50d1c7b4816baefe4b47fd59271001d5d590cd3f)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a4cc66bd
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a4cc66bd
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a4cc66bd

Branch: refs/heads/branch_7x
Commit: a4cc66bd50e28cb01aea2179c5cfa36e5fbade36
Parents: 859559a
Author: Shalin Shekhar Mangar <sh...@apache.org>
Authored: Wed Oct 10 17:12:50 2018 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Wed Oct 10 17:13:28 2018 +0530

----------------------------------------------------------------------
 .../cloud/api/collections/AddReplicaCmd.java     | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a4cc66bd/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java
index 6e851db..8b72cdf 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java
@@ -141,10 +141,17 @@ public class AddReplicaCmd implements OverseerCollectionMessageHandler.Cmd {
     }
 
     AtomicReference<PolicyHelper.SessionWrapper> sessionWrapper = new AtomicReference<>();
-    List<CreateReplica> createReplicas = buildReplicaPositions(ocmh.cloudManager, clusterState, collectionName, message, replicaTypesVsCount, sessionWrapper)
-        .stream()
-        .map(replicaPosition -> assignReplicaDetails(ocmh.cloudManager, clusterState, message, replicaPosition))
-        .collect(Collectors.toList());
+    List<CreateReplica> createReplicas;
+    try {
+      createReplicas = buildReplicaPositions(ocmh.cloudManager, clusterState, collectionName, message, replicaTypesVsCount, sessionWrapper)
+          .stream()
+          .map(replicaPosition -> assignReplicaDetails(ocmh.cloudManager, clusterState, message, replicaPosition))
+          .collect(Collectors.toList());
+    } finally {
+      if (sessionWrapper.get() != null) {
+        sessionWrapper.get().release();
+      }
+    }
 
     ShardHandler shardHandler = ocmh.shardHandlerFactory.getShardHandler();
     ZkStateReader zkStateReader = ocmh.zkStateReader;
@@ -162,10 +169,6 @@ public class AddReplicaCmd implements OverseerCollectionMessageHandler.Cmd {
       for (CreateReplica replica : createReplicas) {
         ocmh.waitForCoreNodeName(collectionName, replica.node, replica.coreName);
       }
-
-      if (sessionWrapper.get() != null) {
-        sessionWrapper.get().release();
-      }
       if (onComplete != null) onComplete.run();
     };