From 99c4749d1aab4cc1768855549bda785f7694b3ea Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Sun, 11 Nov 2012 21:54:04 +0000 Subject: [PATCH] SOLR-4055: Fix a thread safety issue with the Collections API that could cause actions to be targeted at the wrong SolrCores. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1408125 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 4 +++ .../cloud/OverseerCollectionProcessor.java | 33 ++++++++++--------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 0191775f613..7598ccf3e35 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -159,6 +159,10 @@ Bug Fixes after shutdown has already occurred, leaving an IndexWriter that is not closed. (Mark Miller) +* SOLR-4055: Fix a thread safety issue with the Collections API that could + cause actions to be targeted at the wrong SolrCores. + (Raintung Li via Mark Miller) + Other Changes ---------------------- 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 c8033d4446d..0988e383eca 100644 --- a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java +++ b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java @@ -262,21 +262,24 @@ public class OverseerCollectionProcessor implements Runnable { for (Map.Entry shardEntry : shardEntries) { final ZkNodeProps node = shardEntry.getValue(); if (clusterState.liveNodesContain(node.getStr(ZkStateReader.NODE_NAME_PROP))) { - params.set(CoreAdminParams.CORE, node.getStr(ZkStateReader.CORE_NAME_PROP)); - - String replica = node.getStr(ZkStateReader.BASE_URL_PROP); - ShardRequest sreq = new ShardRequest(); - // yes, they must use same admin handler path everywhere... - params.set("qt", adminPath); - - sreq.purpose = 1; - // TODO: this sucks - if (replica.startsWith("http://")) replica = replica.substring(7); - sreq.shards = new String[] {replica}; - sreq.actualShards = sreq.shards; - sreq.params = params; - log.info("Collection Admin sending CoreAdmin cmd to " + replica); - shardHandler.submit(sreq, replica, sreq.params); + //For thread safety, only simple clone the ModifiableSolrParams + ModifiableSolrParams cloneParams = new ModifiableSolrParams(); + cloneParams.add(params); + cloneParams.set(CoreAdminParams.CORE, node.getStr(ZkStateReader.CORE_NAME_PROP)); + + String replica = node.getStr(ZkStateReader.BASE_URL_PROP); + ShardRequest sreq = new ShardRequest(); + + // yes, they must use same admin handler path everywhere... + cloneParams.set("qt", adminPath); + sreq.purpose = 1; + // TODO: this sucks + if (replica.startsWith("http://")) replica = replica.substring(7); + sreq.shards = new String[] {replica}; + sreq.actualShards = sreq.shards; + sreq.params = cloneParams; + log.info("Collection Admin sending CoreAdmin cmd to " + replica + " params:" + sreq.params); + shardHandler.submit(sreq, replica, sreq.params); } } }