How to fix the below Cassandara error in docker container

942 views Asked by At

enter image description here

Picked up _JAVA_OPTIONS: -Xms128m -Xmx256m

[0.013s][warning][gc,ergo] NewSize was set larger than initial heap size, will use initial heap size.

[0.013s][warning][gc,ergo] MaxNewSize (409600k) is equal to or greater than the entire heap (262144k).  A new max generation size of 262080k will be used.

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.

CMSRescanMultiple (32) must be less than or equal to ergonomic maximum (2) which is based on the maximum size of the old generation of the Java heap

CMSConcMarkMultiple (32) must be less than or equal to ergonomic maximum (2) which is based on the maximum size of the old generation of the Java heap

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

Picked up _JAVA_OPTIONS: -Xms128m -Xmx256m

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.

[0.008s][warning][gc,ergo] NewSize was set larger than initial heap size, will use initial heap size.

[0.009s][warning][gc,ergo] MaxNewSize (409600k) is equal to or greater than the entire heap (262144k).  A new max generation size of 262080k will be used.

CMSRescanMultiple (32) must be less than or equal to ergonomic maximum (2) which is based on the maximum size of the old generation of the Java heap

CMSConcMarkMultiple (32) must be less than or equal to ergonomic maximum (2) which is based on the maximum size of the old generation of the Java heap

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.
2

There are 2 answers

0
Erick Ramirez On

It looks like you're using a custom image of Cassandra. If you're new to Cassandra, we recommend that you follow the steps in the Quick Start guide on the Apache Cassandra website which will pull the image from Docker hub.

It doesn't make sense to have a NewGen size of 400MB (409600k) when there is only 256MB allocated to the heap. We recommend setting min (-Xms) and max (-Xmx) heap to the same size so that the maximum is pre-allocated on startup. Also set NewGen to 50% of max heap.

Additionally, Java 9 is not supported. Only Java 8 is supported in Cassandra 3.11 and earlier releases. Experimental support for Java 11 was added in Cassandra 4.0 although we are hoping to drop the "experimental" tag soon and make it official for 4.x. The intention is to support Java 11 + 17 LTS for future Cassandra releases. Cheers!

2
Aaron On

Agree with Erick! The quick fix here, is to use the latest patch of OpenJDK 8, and set Xmx & Xms to 1GB or 2GB, and then maybe keep Xmn @ 400MB.

Edit 20210929

Just to clarify my statement above, current guidance on setting Xmn (heap new gen size) w/ CMS GC for Cassandra is to go between 25%-40% of Xmx (heap max size). So with a 2GB heap, Xmn should be between 500MB and 800MB; for a 1GB heap the 400MB setting should be fine.

The above solutions do not work

Ok, then there must be something else besides the heap settings causing an issue here. Based on the error message reported above, you're running into this section of bin/cassandra.in.sh, where Cassandra 4.0 parses the output of java -version to determine which JDK you're running on.

I've seen this happen with JDKs that don't format their version output the same way that OpenJDK or Oracle do. Are you maybe using AdoptOpenJDK?

Edit your post with the output from java -version, and we'll see where to go from there.