Cassandra and Java 9 - ThreadPriorityPolicy = 42 is out of range

Most recently, I installed JDK 9 and Apache Cassandra from the official site. But now, when I start the cassandra in the foreground, I get this message:

apache-cassandra-3.11.1/bin$ ./cassandra -f [0.000s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/home/mmatak/monero/apache-cassandra-3.11.1/logs/gc.log instead. intx ThreadPriorityPolicy=42 is outside the allowed range [ 0 ... 1 ] Improperly specified VM option 'ThreadPriorityPolicy=42' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. 

So far, I have not found any solution for this. Is it possible that Java 9 and Cassandra are not yet compatible? A problem is also mentioned here - # CASSANDRA-13107

But I'm not sure how easy it is to “remove the flag”? Where can I override or remove this flag?

+23
source share
7 answers

I had exactly the same problem: Cannot start Cassandra (Single-Node Cluster on CentOS7)

If this is an option for you, using Java 8 instead of 9 is the easiest way to solve the problem.

+7
source

@Martin Matak Just comment out this line in conf/jvm.options :

 ######################## # GENERAL JVM SETTINGS # ######################## # allows lowering thread priority without being root on linux - probably # not necessary on Windows but doesn't harm anything. # see http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround.html **#-XX:ThreadPriorityPolicy=42** 
+7
source

Setting the following env variables solved the problem in export JAVA8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home MAC. export JAVA8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

+5
source

The solution to your question

The reason for this exception

  1. Several versions of the JDK running probably JDK9, JDK 10 throws this exception.
  2. Set only the Path to Point JDK 8 path.
  3. Currently, it is desirable that cassandra 3.1 work more than jdk 8.

Change in the Cassandra-Conf file (/opt/apache-cassandra-3.11.2/conf/cassandra-env.sh)

4. If you want to use a higher version of the JDK, update the system path variables depending on your OS.

+1
source
0
source

Following Jay's answer, answer if you are running on macOS and installed via Homebrew: the file is located in local/etc/cassandra/jvm.options .

0
source

A bit of background -XX:ThreadPriorityPolicy .

These were the values ​​as indicated in the source code.

 0 : Normal. VM chooses priorities that are appropriate for normal applications. On Solaris NORM_PRIORITY and above are mapped to normal native priority. Java priorities below NORM_PRIORITY map to lower native priority values. On Windows applications are allowed to use higher native priorities. However, with ThreadPriorityPolicy=0, VM will not use the highest possible native priority, THREAD_PRIORITY_TIME_CRITICAL, as it may interfere with system threads. On Linux thread priorities are ignored because the OS does not support static priority in SCHED_OTHER scheduling class which is the only choice for non-root, non-realtime applications. 1 : Aggressive. Java thread priorities map over to the entire range of native thread priorities. Higher Java thread priorities map to higher native thread priorities. This policy should be used with care, as sometimes it can cause performance degradation in the application and/or the entire system. On Linux this policy requires root privilege. 

In other words: The default default setting causes thread priorities to be ignored on Linux.

Now, someone has detected an error in the code that has disabled "Is root?" check the values ​​other than 1, but still try to set the priority of the stream for each value other than 0.

If it does not work as root, it will only be possible to lower the priority of the thread. Thus, although not ideal, it was a pretty significant improvement over the inability to control priorities at all.

Starting with Java 9, command-line arguments like this one started checking checked , and this hack stopped working.

By the way, in Java 11 / Linux, I can set the parameter to 1 without being root, and setting thread priorities has an effect. So something has changed during this time, and at least with recent JVMs, and this hack no longer seems necessary.

0
source

Source: https://habr.com/ru/post/1272883/


All Articles