Thursday, March 27, 2014

Cassandra running out of memory heap space

I have configured Cassandra 2.0.4 in my laptop which was working fine for few weeks.  My machine configuration is below -







On a day-2-day basis, I have been truncating the database and recreating frequently.  After few weeks, when I tried to start Cassandra, I started getting the below error - 

java.lang.OutOfMemoryError: Java heap space
at org.apache.cassandra.io.compress.CompressedRandomAccessReader.<init>(CompressedRandomAccessReader.java:64)
at org.apache.cassandra.io.compress.CompressedRandomAccessReader.open(CompressedRandomAccessReader.java:44)
at org.apache.cassandra.io.sstable.SSTableReader.openDataReader(SSTableReader.java:949)
at org.apache.cassandra.io.sstable.SSTableScanner.<init>(SSTableScanner.java:72)
at org.apache.cassandra.io.sstable.SSTableReader.getScanner(SSTableReader.java:796)
at org.apache.cassandra.db.RowIteratorFactory.getIterator(RowIteratorFactory.java:88)
at org.apache.cassandra.db.ColumnFamilyStore.getRangeSlice(ColumnFamilyStore.java:1329)
at org.apache.cassandra.service.StorageProxy.getRangeSlice(StorageProxy.java:806)
at org.apache.cassandra.thrift.CassandraServer.get_range_slices(CassandraServer.java:697)
at org.apache.cassandra.thrift.Cassandra$Processor$get_range_slices.process(Cassandra.java:3202)
at org.apache.cassandra.thrift.Cassandra$Processor.process(Cassandra.java:2889)
at org.apache.cassandra.thrift.CustomTThreadPoolServer$WorkerProcess.run(CustomTThreadPoolServer.java:187)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)


I have made the below changes to Cassandra.bat and the problem got resolved.

























I have updated the two highlighted values from -Xms1G^, -Xmx1G^ to -Xms2G^, -Xmx2G^ by allocating 2GB of heap memory for Cassandra. 

3 comments:

  1. while starting the cassandra below is the error encountered as I am working ppc64 vm and using openjdk7


    ERROR 10:26:51 Exception in thread Thread[MemtableFlushWriter:1,5,main]
    java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
    at org.apache.cassandra.utils.memory.MemoryUtil.allocate(MemoryUtil.java:82) ~[main/:na]
    at org.apache.cassandra.io.util.Memory.(Memory.java:74) ~[main/:na]
    at org.apache.cassandra.io.util.SafeMemory.(SafeMemory.java:32) ~[main/:na]
    at org.apache.cassandra.io.compress.CompressionMetadata$Writer.(CompressionMetadata.java:274) ~[main/:na]
    at org.apache.cassandra.io.compress.CompressionMetadata$Writer.open(CompressionMetadata.java:288) ~[main/:na]
    at org.apache.cassandra.io.compress.CompressedSequentialWriter.(CompressedSequentialWriter.java:75) ~[main/:na]
    at org.apache.cassandra.io.util.SequentialWriter.open(SequentialWriter.java:168) ~[main/:na]
    at org.apache.cassandra.io.sstable.format.big.BigTableWriter.(BigTableWriter.java:74) ~[main/:na]
    at org.apache.cassandra.io.sstable.format.big.BigFormat$WriterFactory.open(BigFormat.java:107) ~[main/:na]
    at org.apache.cassandra.io.sstable.format.SSTableWriter.create(SSTableWriter.java:84) ~[main/:na]
    at org.apache.cassandra.db.Memtable$FlushRunnable.createFlushWriter(Memtable.java:396) ~[main/:na]
    at org.apache.cassandra.db.Memtable$FlushRunnable.writeSortedContents(Memtable.java:343) ~[main/:na]
    at org.apache.cassandra.db.Memtable$FlushRunnable.runMayThrow(Memtable.java:328) ~[main/:na]
    at org.apache.cassandra.utils.WrappedRunnable.run(WrappedRunnable.java:28) ~[main/:na]
    at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:297) ~[guava-16.0.jar:na]
    at org.apache.cassandra.db.ColumnFamilyStore$Flush.run(ColumnFamilyStore.java:1085) ~[main/:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_79]
    at java.lang.Thread.run(Thread.java:745) ~[na:1.7.0_79]

    ReplyDelete
    Replies
    1. Facing a similar error,did you get the solution for this?

      Delete
  2. Step by step instructions to Solve out of Memory Issue in Cassandra through Cassandra Technical Issue
    Rapidly settle your out of memory issue with Cognegic's Apache Cassandra Support or Cassandra Customer Service. Here we helpfully deal with the information according to customers require and give finish arrangement in regards to Cassandra database. From reinforcement to recuperation and establishment to setup we give inconceivable help. Our expert specialists offer you modified business applications for the benefit of your need. Thus, contact to Cassandra Database Support and experience the solid help which is offer by our specialists.
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete