1
votes

I have 3 nodes(aws elasticsearch service) of 16GB running for elastic search service. I have configured my ES to have 3 shards with 2 replicas. These 3 nodes are responsible for indexing of data and querying and fetching of data.

Heap Allocation for all 3 is 7GB.

Data is split into 2 indices, index1 and index2. Index1 does not have much data and the document sizes are small. Index2 is the heavier index but the max document size in that too is 1MB.

However, many times while indexing some documents for index2, one of the ES instance throws OutOfMemoryException. I checked shards memory and there are total of 3.5 GB of document data in index2.

I am unable to figure out the cause for this and looking for some help in debugging the issue.

The structure of the document is similar to :

    {  
        "name":"ABC",
        "class":10,
        "school":"XYZ",
        "subjects":[  
               {  
                  "A":{  
                  "name":"subject a",
                  "marks":80,
                  "passed":true
                  }
               },
               {  
                 "B":{  
                   "name":"subject B",
                   "marks":76,
                   "passed":true
               }
            }
        ]
      }

The array in "subjects" key can go upto a length of 3000.

The ES version being used is 5.1.0.

Find the stack trace below :

[2017-07-28T15:44:13,912][WARN ][o.e.m.j.JvmGcMonitorService] [obLzpwI] [gc][849973] overhead, spent [26s] collecting in the last [26.1s]
[2017-07-28T15:44:13,895][WARN ][o.e.t.n.Netty4Transport  ] [obLzpwI] exception caught on transport layer [[!!!io.netty.channel.socket.nio.NioSocketChannel@650b7925=>java.lang.OutOfMemoryError:Compressed class space!!!]], closing connection
org.elasticsearch.ElasticsearchException: java.lang.OutOfMemoryError: Compressed class space
    at org.elasticsearch.transport.netty4.Netty4Transport.exceptionCaught(Netty4Transport.java:326) [transport-netty4-5.1.2.jar:5.1.2]
    at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.exceptionCaught(Netty4MessageChannelHandler.java:84) [transport-netty4-5.1.2.jar:5.1.2]
    at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:296) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.notifyHandlerException(AbstractChannelHandlerContext.java:861) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:375) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) [netty-codec-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:280) [netty-codec-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:396) [netty-codec-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) [netty-codec-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:651) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:536) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:490) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:450) [netty-transport-4.1.6.Final.jar:4.1.6.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873) [netty-common-4.1.6.Final.jar:4.1.6.Final]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
Caused by: java.lang.OutOfMemoryError: Compressed class space
1
Which ES version are you running? Can you give us the full stack trace in the logs? How are the documents indexed (if you can show a small snippet)? What are the settings of your cluster? Of your indices?Adonis
@asettouf Updated the question with stack trace and sample document. What exactly are you looking for in settings of indices? Mainly it is "settings" : { "index" : { "mapping" : { "total_fields" : { "limit" : "200000000" } }, "refresh_interval" : "1s", "number_of_shards" : "3", "max_result_window" : "200000", } } Apart from this there are custom defined analyzers and tokenizers.Aayushi

1 Answers

2
votes

You're running out of compressed class space, rather than heap memory. This can be configured using -XX: CompressedClassSpaceSize=1g (as an example value).

You can read more about that on oracle's docs here, second from the bottom.

However, this may well just be treating the symptom.

There's known problems with some older versions of elastic described on this github issue. This specific issue is caused by compiling a unique script with each request. If that sounds relevant to your problem, it might be worth updating your answer with your actual API calls that trigger the exception.