better error handling when processing refresh/update mapping

don't fail the whole bulk of updates, just the specific ones, and warn log it
This commit is contained in:
Shay Banon 2013-12-05 00:58:19 +01:00
parent dd86db3347
commit df4ffbe723
1 changed files with 71 additions and 64 deletions

View File

@ -160,6 +160,7 @@ public class MetaDataMappingService extends AbstractComponent {
if (task instanceof RefreshTask) { if (task instanceof RefreshTask) {
RefreshTask refreshTask = (RefreshTask) task; RefreshTask refreshTask = (RefreshTask) task;
try {
IndexService indexService = indicesService.indexService(index); IndexService indexService = indicesService.indexService(index);
if (indexService == null) { if (indexService == null) {
// we need to create the index here, and add the current mapping to it, so we can merge // we need to create the index here, and add the current mapping to it, so we can merge
@ -194,9 +195,12 @@ public class MetaDataMappingService extends AbstractComponent {
logger.warn("[{}] re-syncing mappings with cluster state for types [{}]", index, updatedTypes); logger.warn("[{}] re-syncing mappings with cluster state for types [{}]", index, updatedTypes);
mdBuilder.put(indexMetaDataBuilder); mdBuilder.put(indexMetaDataBuilder);
dirty = true; dirty = true;
} catch (Throwable t) {
logger.warn("[{}] failed to refresh-mapping in cluster state, types [{}]", index, refreshTask.types);
}
} else if (task instanceof UpdateTask) { } else if (task instanceof UpdateTask) {
UpdateTask updateTask = (UpdateTask) task; UpdateTask updateTask = (UpdateTask) task;
try {
String type = updateTask.type; String type = updateTask.type;
CompressedString mappingSource = updateTask.mappingSource; CompressedString mappingSource = updateTask.mappingSource;
@ -234,6 +238,9 @@ public class MetaDataMappingService extends AbstractComponent {
mdBuilder.put(IndexMetaData.builder(indexMetaData).putMapping(new MappingMetaData(updatedMapper))); mdBuilder.put(IndexMetaData.builder(indexMetaData).putMapping(new MappingMetaData(updatedMapper)));
dirty = true; dirty = true;
} catch (Throwable t) {
logger.warn("[{}] failed to update-mapping in cluster state, type [{}]", index, updateTask.type);
}
} else { } else {
logger.warn("illegal state, got wrong mapping task type [{}]", task); logger.warn("illegal state, got wrong mapping task type [{}]", task);
} }