mirror of https://github.com/apache/lucene.git
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:
parent
23eb9cbfcc
commit
08c6f54346
|
@ -267,6 +267,9 @@ Bug Fixes
|
||||||
|
|
||||||
* SOLR-6647: Bad error message when missing resource from ZK when parsing Schema (janhoy)
|
* 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
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -1039,18 +1039,9 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
||||||
"conf1");
|
"conf1");
|
||||||
|
|
||||||
// remove collection
|
// remove collection
|
||||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
CollectionAdminRequest.Delete delete = new CollectionAdminRequest.Delete();
|
||||||
params.set("action", CollectionAction.DELETE.toString());
|
delete.setCollectionName(collectionName);
|
||||||
params.set("name", collectionName);
|
client.request(delete);
|
||||||
QueryRequest request = new QueryRequest(params);
|
|
||||||
request.setPath("/admin/collections");
|
|
||||||
|
|
||||||
if (client == null) {
|
|
||||||
client = createCloudClient(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
client.request(request);
|
|
||||||
|
|
||||||
} catch (SolrServerException e) {
|
} catch (SolrServerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -876,6 +876,7 @@ public class ZkStateReader implements Closeable {
|
||||||
public void removeZKWatch(final String coll) {
|
public void removeZKWatch(final String coll) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
watchedCollections.remove(coll);
|
watchedCollections.remove(coll);
|
||||||
|
watchedCollectionStates.remove(coll);
|
||||||
try {
|
try {
|
||||||
updateClusterState(true);
|
updateClusterState(true);
|
||||||
} catch (KeeperException e) {
|
} catch (KeeperException e) {
|
||||||
|
|
Loading…
Reference in New Issue