From c2ef91afe6e7ea03ab112cb94415ac548f08ee1a Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Tue, 17 Jan 2012 12:58:30 +0200 Subject: [PATCH] better logging when failing to load field data to memory due to OOM --- .../support/AbstractConcurrentMapFieldDataCache.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java b/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java index dc81261c5cf..1bf1850f291 100644 --- a/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java +++ b/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java @@ -118,8 +118,15 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC synchronized (fieldDataCache) { fieldData = fieldDataCache.getIfPresent(fieldName); if (fieldData == null) { - fieldData = FieldData.load(type, reader, fieldName); - fieldDataCache.put(fieldName, fieldData); + try { + fieldData = FieldData.load(type, reader, fieldName); + fieldDataCache.put(fieldName, fieldData); + } catch (OutOfMemoryError e) { + logger.warn("loading field [" + fieldName + "] caused out of memory failure", e); + final OutOfMemoryError outOfMemoryError = new OutOfMemoryError("loading field [" + fieldName + "] caused out of memory failure"); + outOfMemoryError.initCause(e); + throw outOfMemoryError; + } } } }