mirror of https://github.com/apache/lucene.git
SOLR-13368: Tentative fix for a race condition in managed schema initialization.
This commit is contained in:
parent
ef7be67ba1
commit
0859be134d
|
@ -172,8 +172,10 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
|
|||
managedSchemaResourceName, schemaZkVersion, getSchemaUpdateLock());
|
||||
if (shouldUpgrade) {
|
||||
// Persist the managed schema if it doesn't already exist
|
||||
synchronized (schema.getSchemaUpdateLock()) {
|
||||
upgradeToManagedSchema();
|
||||
}
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public class TestManagedSchemaAPI extends SolrCloudTestCase {
|
|||
String collection = "testschemaapi";
|
||||
CollectionAdminRequest.createCollection(collection, "conf1", 1, 2)
|
||||
.process(cluster.getSolrClient());
|
||||
testModifyField(collection);
|
||||
testReloadAndAddSimple(collection);
|
||||
testAddFieldAndDocument(collection);
|
||||
}
|
||||
|
@ -99,4 +100,26 @@ public class TestManagedSchemaAPI extends SolrCloudTestCase {
|
|||
log.info("added new field="+fieldName);
|
||||
}
|
||||
|
||||
private void testModifyField(String collection) throws IOException, SolrServerException {
|
||||
CloudSolrClient cloudClient = cluster.getSolrClient();
|
||||
|
||||
SolrInputDocument doc = new SolrInputDocument("id", "3");
|
||||
cloudClient.add(collection, doc);
|
||||
cloudClient.commit(collection);
|
||||
|
||||
String fieldName = "id";
|
||||
SchemaRequest.Field getFieldRequest = new SchemaRequest.Field(fieldName);
|
||||
SchemaResponse.FieldResponse getFieldResponse = getFieldRequest.process(cloudClient, collection);
|
||||
Map<String, Object> field = getFieldResponse.getField();
|
||||
field.put("docValues", true);
|
||||
SchemaRequest.ReplaceField replaceRequest = new SchemaRequest.ReplaceField(field);
|
||||
SchemaResponse.UpdateResponse replaceResponse = replaceRequest.process(cloudClient, collection);
|
||||
assertNull(replaceResponse.getResponse().get("errors"));
|
||||
CollectionAdminRequest.Reload reloadRequest = CollectionAdminRequest.reloadCollection(collection);
|
||||
CollectionAdminResponse response = reloadRequest.process(cloudClient);
|
||||
assertEquals(0, response.getStatus());
|
||||
assertTrue(response.isSuccess());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue