mirror of https://github.com/apache/lucene.git
SOLR-8804: Fix a race condition in the ClusterStatus API call
This commit is contained in:
parent
b0caca3b60
commit
343d9c6fa4
|
@ -289,6 +289,9 @@ Bug Fixes
|
||||||
* SOLR-8790: Collections API responses contain node name in the core-level responses that are
|
* SOLR-8790: Collections API responses contain node name in the core-level responses that are
|
||||||
returned. (Anshum Gupta)
|
returned. (Anshum Gupta)
|
||||||
|
|
||||||
|
* SOLR-8804: Fix a race condition in the ClusterStatus API call whereby the call would fail when a concurrent delete
|
||||||
|
collection api command was executed (Alexey Serba, Varun Thacker)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
* SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been
|
* SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class ClusterStatus {
|
||||||
byte[] bytes = Utils.toJSON(clusterState);
|
byte[] bytes = Utils.toJSON(clusterState);
|
||||||
Map<String, Object> stateMap = (Map<String,Object>) Utils.fromJSON(bytes);
|
Map<String, Object> stateMap = (Map<String,Object>) Utils.fromJSON(bytes);
|
||||||
|
|
||||||
Set<String> collections = new HashSet<>();
|
Set<String> collections;
|
||||||
String routeKey = message.getStr(ShardParams._ROUTE_);
|
String routeKey = message.getStr(ShardParams._ROUTE_);
|
||||||
String shard = message.getStr(ZkStateReader.SHARD_ID_PROP);
|
String shard = message.getStr(ZkStateReader.SHARD_ID_PROP);
|
||||||
if (collection == null) {
|
if (collection == null) {
|
||||||
|
@ -98,11 +98,19 @@ public class ClusterStatus {
|
||||||
collections = Collections.singleton(collection);
|
collections = Collections.singleton(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedList<Object> collectionProps = new SimpleOrderedMap<Object>();
|
NamedList<Object> collectionProps = new SimpleOrderedMap<>();
|
||||||
|
|
||||||
for (String name : collections) {
|
for (String name : collections) {
|
||||||
Map<String, Object> collectionStatus = null;
|
Map<String, Object> collectionStatus;
|
||||||
DocCollection clusterStateCollection = clusterState.getCollection(name);
|
DocCollection clusterStateCollection = clusterState.getCollectionOrNull(name);
|
||||||
|
if (clusterStateCollection == null) {
|
||||||
|
if (collection != null) {
|
||||||
|
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection: " + name + " not found");
|
||||||
|
} else {
|
||||||
|
//collection might have got deleted at the same time
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> requestedShards = new HashSet<>();
|
Set<String> requestedShards = new HashSet<>();
|
||||||
if (routeKey != null) {
|
if (routeKey != null) {
|
||||||
|
|
|
@ -77,6 +77,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
|
||||||
clusterStatusWithRouteKey();
|
clusterStatusWithRouteKey();
|
||||||
clusterStatusAliasTest();
|
clusterStatusAliasTest();
|
||||||
clusterStatusRolesTest();
|
clusterStatusRolesTest();
|
||||||
|
clusterStatusBadCollectionTest();
|
||||||
replicaPropTest();
|
replicaPropTest();
|
||||||
clusterStatusZNodeVersion();
|
clusterStatusZNodeVersion();
|
||||||
testClusterStateMigration();
|
testClusterStateMigration();
|
||||||
|
@ -318,6 +319,24 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clusterStatusBadCollectionTest() throws Exception {
|
||||||
|
try (CloudSolrClient client = createCloudClient(null)) {
|
||||||
|
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||||
|
params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
|
||||||
|
params.set("collection", "bad_collection_name");
|
||||||
|
SolrRequest request = new QueryRequest(params);
|
||||||
|
request.setPath("/admin/collections");
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.request(request);
|
||||||
|
fail("Collection does not exist. An exception should be thrown");
|
||||||
|
} catch (SolrException e) {
|
||||||
|
//expected
|
||||||
|
assertTrue(e.getMessage().contains("Collection: bad_collection_name not found"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void replicaPropTest() throws Exception {
|
private void replicaPropTest() throws Exception {
|
||||||
try (CloudSolrClient client = createCloudClient(null)) {
|
try (CloudSolrClient client = createCloudClient(null)) {
|
||||||
client.connect();
|
client.connect();
|
||||||
|
|
Loading…
Reference in New Issue