SOLR-6591: Overseer can use stale cluster state and lose updates for collections with stateFormat > 1

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1634243 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-10-25 19:20:28 +00:00
parent 23eb9cbfcc
commit 08c6f54346
4 changed files with 89 additions and 12 deletions

View File

@ -267,6 +267,9 @@ Bug Fixes
* SOLR-6647: Bad error message when missing resource from ZK when parsing Schema (janhoy)
* SOLR-6591: Overseer can use stale cluster state and lose updates for collections
with stateFormat > 1. (shalin)
Optimizations
----------------------

View File

@ -1039,18 +1039,9 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
"conf1");
// remove collection
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionAction.DELETE.toString());
params.set("name", collectionName);
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
if (client == null) {
client = createCloudClient(null);
}
client.request(request);
CollectionAdminRequest.Delete delete = new CollectionAdminRequest.Delete();
delete.setCollectionName(collectionName);
client.request(delete);
} catch (SolrServerException e) {
e.printStackTrace();
throw new RuntimeException(e);

View File

@ -0,0 +1,82 @@
package org.apache.solr.cloud;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestBase {
public SimpleCollectionCreateDeleteTest() {
fixShardCount = true;
sliceCount = 1;
shardCount = 1;
}
@Override
public void doTest() throws Exception {
String overseerNode = OverseerCollectionProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient());
String notOverseerNode = null;
for (CloudJettyRunner cloudJetty : cloudJettys) {
if (!overseerNode.equals(cloudJetty.nodeName)) {
notOverseerNode = cloudJetty.nodeName;
break;
}
}
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
String collectionName = "SimpleCollectionCreateDeleteTest";
create.setCollectionName(collectionName);
create.setNumShards(1);
create.setReplicationFactor(1);
create.setCreateNodeSet(overseerNode);
ModifiableSolrParams params = new ModifiableSolrParams(create.getParams());
params.set("stateFormat", "2");
QueryRequest req = new QueryRequest(params);
req.setPath("/admin/collections");
NamedList<Object> request = cloudClient.request(req);
if (request.get("success") != null) {
assertTrue(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, false));
CollectionAdminRequest.Delete delete = new CollectionAdminRequest.Delete();
delete.setCollectionName(collectionName);
cloudClient.request(delete);
assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, false));
// create collection again on a node other than the overseer leader
create = new CollectionAdminRequest.Create();
create.setCollectionName(collectionName);
create.setNumShards(1);
create.setReplicationFactor(1);
create.setCreateNodeSet(notOverseerNode);
params = new ModifiableSolrParams(create.getParams());
params.set("stateFormat", "2");
req = new QueryRequest(params);
req.setPath("/admin/collections");
request = cloudClient.request(req);
assertTrue("Collection creation should not have failed", request.get("success") != null);
}
}
}

View File

@ -876,6 +876,7 @@ public class ZkStateReader implements Closeable {
public void removeZKWatch(final String coll) {
synchronized (this) {
watchedCollections.remove(coll);
watchedCollectionStates.remove(coll);
try {
updateClusterState(true);
} catch (KeeperException e) {