Disallow dynamic mapping updated in follow shards

I forgot to configure a mapping in the follow shard shard, which caused
a dynamic update (due to type auto creation), but this was ignored.

Subsequent searches in follow index then failed due to a mapping missing.
(The _id couldn't be fetched during fetch phase, because the mapping was missing)

We should at a later stage investigate how to best solve this, but for
know to avoid confusion just fail if a dynamic update happens in a
follow shard.
This commit is contained in:
Martijn van Groningen 2017-11-30 11:14:55 +01:00
parent be5f83a6bd
commit 2e382bf7f3
1 changed files with 5 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.mapper.MapperException;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.translog.Translog;
import org.elasticsearch.indices.IndicesService;
@ -67,7 +68,10 @@ public class TransportBulkShardOperationsAction
final BulkShardOperationsRequest request, final IndexShard shard, final Engine.Operation.Origin origin) throws IOException {
Translog.Location location = null;
for (final Translog.Operation operation : request.getOperations()) {
final Engine.Result result = shard.applyTranslogOperation(operation, origin, m -> {});
final Engine.Result result = shard.applyTranslogOperation(operation, origin, m -> {
// TODO: Figure out how to deal best with dynamic mapping updates from the leader side:
throw new MapperException("dynamic mapping updates are not allowed in follow shards [" + operation + "]");
});
assert result.getSeqNo() == operation.seqNo();
assert result.hasFailure() == false;
location = locationToSync(location, result.getTranslogLocation());