mirror of https://github.com/apache/lucene.git
SOLR-9484: The modify collection API should wait for the modified properties to show up in the cluster state
This commit is contained in:
parent
5b770b56d0
commit
70fd627ca7
|
@ -126,6 +126,9 @@ Bug Fixes
|
|||
one or more sub-shards replicas do not recover due to the leader crashing or restarting between the time
|
||||
the replicas are created and before they can recover. This can cause data loss. (shalin)
|
||||
|
||||
* SOLR-9484: The modify collection API should wait for the modified properties to show up in the
|
||||
cluster state. (Cao Manh Dat, shalin)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -662,6 +662,26 @@ public class OverseerCollectionMessageHandler implements OverseerMessageHandler
|
|||
}
|
||||
|
||||
overseer.getStateUpdateQueue(zkStateReader.getZkClient()).offer(Utils.toJSON(message));
|
||||
|
||||
TimeOut timeout = new TimeOut(30, TimeUnit.SECONDS);
|
||||
boolean areChangesVisible = true;
|
||||
while (!timeout.hasTimedOut()) {
|
||||
DocCollection collection = zkStateReader.getClusterState().getCollection(collectionName);
|
||||
areChangesVisible = true;
|
||||
for (Map.Entry<String,Object> updateEntry : message.getProperties().entrySet()) {
|
||||
String updateKey = updateEntry.getKey();
|
||||
if (!updateKey.equals(ZkStateReader.COLLECTION_PROP)
|
||||
&& !updateKey.equals(Overseer.QUEUE_OPERATION)
|
||||
&& !collection.get(updateKey).equals(updateEntry.getValue())){
|
||||
areChangesVisible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (areChangesVisible) break;
|
||||
Thread.sleep(100);
|
||||
}
|
||||
if (!areChangesVisible)
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Could not modify collection " + message);
|
||||
}
|
||||
|
||||
void cleanupCollection(String collectionName, NamedList results) throws Exception {
|
||||
|
|
|
@ -234,18 +234,10 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
|
|||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
DocCollection rulesCollection = ZkStateReader.getCollectionLive(cloudClient.getZkStateReader(), rulesColl);
|
||||
log.info("version_of_coll {} ", rulesCollection.getZNodeVersion());
|
||||
List list = (List) rulesCollection.get("rule");
|
||||
assertEquals(3, list.size());
|
||||
if (!"<5".equals(((Map) list.get(0)).get("cores"))) {
|
||||
if (i < 19) {
|
||||
Thread.sleep(100);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
assertEquals("<5", ((Map) list.get(0)).get("cores"));
|
||||
assertEquals("1", ((Map) list.get(1)).get("replica"));
|
||||
assertEquals(">"+minGB2, ((Map) list.get(2)).get("freedisk"));
|
||||
|
@ -254,5 +246,4 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
|
|||
assertEquals(1, list.size());
|
||||
assertEquals("ImplicitSnitch", ((Map) list.get(0)).get("class"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue