0

I'm trying to enable the usage of Java Flight Recorder to collect thread dumps for every 10 seconds while running Cypher queries using Neo4j Desktop. But in the 'settings' tab (configuration file) in Neo4j desktop, the recommended flight recorder options are unrecognized and throw an error during startup.

I'm using Oracle JDK 11.

These are the commands I entered in the file -

# flight recorder settings
dbms.jvm.additional=-XX:+UnlockCommercialFeatures
dbms.jvm.additional=-XX:+FlightRecorder
dbms.jvm.additional=-XX:FlightRecorderOptions=stackdepth=500
dbms.jvm.additional=-XX:+UnlockDiagnosticVMOptions
dbms.jvm.additional=-XX:+DebugNonSafepoints

and these throw an error when I startup the DB -

Active database: graph.db
Directories in use:
  home:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3
  config:       /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/conf
  logs:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/logs
  plugins:      /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/plugins
  import:       /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/import
  data:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/data
  certificates: /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/certificates
  run:          /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/run
Starting Neo4j.
Unrecognized VM option 'UnlockCommercialFeatures'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Active database: graph.db
Directories in use:
  home:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3
  config:       /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/conf
  logs:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/logs
  plugins:      /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/plugins
  import:       /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/import
  data:         /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/data
  certificates: /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/certificates
  run:          /Users/manishgiri/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-4efa4b3e-50bc-46fa-90b2-ee6df8205205/installation-3.5.3/run
Starting Neo4j.
Unrecognized VM option 'FlightRecorder'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

I've verified that Flight Recorder does work on my machine by testing it on another simple program -

java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=duration=120s,filename=myrecording.jfr OOMEGenerator

This command works fine and generates the recording successfully.

Is there some other way to enable flight recorder settings in the config file?

Manish Giri
  • 3,562
  • 8
  • 45
  • 81

1 Answers1

0

Neo4j Desktop includes a Java Virtual Machine from Azul, which is based on OpenJDK that doesn't recognize the -XX:+UnlockCommercialFeatures flag.

The flag is no longer needed as Flight Recorder has been open sourced (JDK 11). The Oracle JDK will ignore the flag.

Easiest is just to remove -XX:+UnlockCommercialFeatures flag.

If that doesn't work, i.e. it complains about -XX:+FlightRecorder or -XX:StartFlightRecording, it could be because because Neo4j Desktop is shipped with an earlier release of Azul, which doesn't support Flight Recorder.

If that is the case, you have to switch JDK.

(You can also remove -XX:+FlightRecorder as this flag has not been needed since releases prior to Oracle JDK 8u40)

Kire Haglin
  • 6,569
  • 22
  • 27
  • Thanks for helping! I'm pretty sure the machine is running Oracle JDK 11 because that's what the version shows when I run `java -version`. I've also never installed any OpenJDK builds before. I tried deleting the first entry - `dbms.jvm.additional=-XX:+UnlockCommercialFeatures`, when I got the error `Unrecognized VM option 'UnlockCommercialFeatures'`, but then I got the same error with the `-XX:+FlightRecorder` command, which means none of these flags are supported in Oracle JDK11.. In that case, how do I run flight recorder without using these flags when I run Neo4j Desktop? – Manish Giri May 09 '19 at 03:33
  • but desktop ships with it's own copy of a JDK you can find it in the desktop directories (you can justt relink the directory which is what I did to use desktop with GraalVM) – Michael Hunger Aug 28 '19 at 15:15
  • `/Users/manishgiri/Library/Application Support/Neo4j Desktop` – Michael Hunger Aug 28 '19 at 15:15