Send the update-mapping events before actually indexing into the shard, because the latter may generate exceptions (like when the shard is not yet ready to accept new docs).
Also improved the SimpleDeleteMappingTest, as it make take a while until the update-mapping event is processed. Closes #3782
This commit is contained in:
parent
c63869b0be
commit
b66f3c6834
|
@ -202,6 +202,9 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi
|
||||||
.version(request.version())
|
.version(request.version())
|
||||||
.versionType(request.versionType())
|
.versionType(request.versionType())
|
||||||
.origin(Engine.Operation.Origin.PRIMARY);
|
.origin(Engine.Operation.Origin.PRIMARY);
|
||||||
|
if (index.parsedDoc().mappingsModified()) {
|
||||||
|
updateMappingOnMaster(request);
|
||||||
|
}
|
||||||
indexShard.index(index);
|
indexShard.index(index);
|
||||||
version = index.version();
|
version = index.version();
|
||||||
op = index;
|
op = index;
|
||||||
|
@ -211,6 +214,9 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi
|
||||||
.version(request.version())
|
.version(request.version())
|
||||||
.versionType(request.versionType())
|
.versionType(request.versionType())
|
||||||
.origin(Engine.Operation.Origin.PRIMARY);
|
.origin(Engine.Operation.Origin.PRIMARY);
|
||||||
|
if (create.parsedDoc().mappingsModified()) {
|
||||||
|
updateMappingOnMaster(request);
|
||||||
|
}
|
||||||
indexShard.create(create);
|
indexShard.create(create);
|
||||||
version = create.version();
|
version = create.version();
|
||||||
op = create;
|
op = create;
|
||||||
|
@ -223,9 +229,7 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (op.parsedDoc().mappingsModified()) {
|
|
||||||
updateMappingOnMaster(request);
|
|
||||||
}
|
|
||||||
// update the version on the request, so it will be used for the replicas
|
// update the version on the request, so it will be used for the replicas
|
||||||
request.version(version);
|
request.version(version);
|
||||||
|
|
||||||
|
|
|
@ -51,12 +51,10 @@ public class SimpleDeleteMappingTests extends AbstractIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState();
|
ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState();
|
||||||
if (!clusterState.metaData().index("test").mappings().containsKey("type1")) {
|
for (int i = 0; i < 10 && !clusterState.metaData().index("test").mappings().containsKey("type1"); i++, Thread.sleep(100)) ;
|
||||||
logger.info("mapping of type [{}] is not in the clusterstate version: [{}] localNode: [{}] nodes: [{}]", "type1",
|
|
||||||
clusterState.version(), clusterState.nodes().localNode(), clusterState.nodes().dataNodes().values());
|
assertThat(clusterState.metaData().index("test").mappings(), hasKey("type1"));
|
||||||
logger.info("Current mappings in clusterstate: [{}]", clusterState.metaData().index("test").mappings().keySet());
|
|
||||||
}
|
|
||||||
assertThat(clusterState.metaData().index("test").mappings().containsKey("type1"), equalTo(true));
|
|
||||||
GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings("test").setTypes("type1").execute().actionGet();
|
GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings("test").setTypes("type1").execute().actionGet();
|
||||||
assertThat(mappingsResponse.getMappings().get("test").get("type1"), notNullValue());
|
assertThat(mappingsResponse.getMappings().get("test").get("type1"), notNullValue());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue