graphfoundation / ongdb

ONgDB is an independent fork of Neo4j® Enterprise Edition version 3.4.0.rc02 licensed under AGPLv3 and/or Community Edition licensed under GPLv3
https://www.graphfoundation.org/projects/ongdb/
380 stars 57 forks source link

Fix the JDK checks on startup please, and Windows won't start at all #95

Open duhmojo opened 1 year ago

duhmojo commented 1 year ago

Guidelines

ongdb 1.0.4 Windows Server 2002 AlmaLinux 8.5

Hi all.

This:

https://github.com/graphfoundation/ongdb/blob/0b53efa5d1b1bfdf87abfd2c5c2fe5123be744b5/packaging/standalone/src/main/distribution/shell-scripts/bin/ONgDB-Management/Get-JavaVersion.ps1#L110

And this:

https://github.com/graphfoundation/ongdb/blob/182c2312bca5c722a7880cc9a7ba101d9f1dcf4b/packaging/standalone/src/main/distribution/shell-scripts/bin/ongdb-shell#L99

Is not how you do a version check. You can't simply compare if a string is less than another and it'll magically understand the periods and the difference between "1.10" and "1.8" or "1.1". What it does mean is ongdb has most likely not been tested, as released, with an different JDK than 1.8.

I know you expect to support all the common JDKs:

https://github.com/graphfoundation/ongdb/blob/182c2312bca5c722a7880cc9a7ba101d9f1dcf4b/packaging/standalone/src/main/distribution/shell-scripts/bin/ongdb-shell#L105

You have no ongdb documentation and the project site (https://www.graphfoundation.org/ongdb/) doesn't provide documentation, installation or requirement guidance.

I've been using ongdb on Linux for a year now and I had to comment out the JDK check, but recently had to set it up on Windows and it has been a real pain.

JDK 1.17 would fail (obviously because it's not "1.8") and the service would not launch. The only way to know what the problem is (the JDK version issue) you have to manually run the ongdb batch with Verbose to get a clue: C:\Program Files\ongdb\bin>ongdb.bat start -Verbose

So say I jumped back and installed OpenJDK 1.8. Still no luck. I dug in and tried manually running: "C:\Program Files\ongdb\bin\tools\prunsrv-amd64.exe" "//RS//ongdb" and it would silently fail.

C:\Program Files\ongdb\bin>"C:\Program Files\ongdb\bin\tools\prunsrv-amd64.exe" "//ES//ongdb"

Nothing. I retried it with all the logs deleted:

[2023-02-14 23:26:36] [info]  [ 7428] Commons Daemon procrun (1.0.15.0 64-bit) started
[2023-02-14 23:26:36] [info]  [ 7428] Running 'ongdb' Service...
[2023-02-14 23:26:36] [error] [ 7428] StartServiceCtrlDispatcher for 'ongdb' failed
[2023-02-14 23:26:36] [error] [ 7428] The service process could not connect to the service controller.
[2023-02-14 23:26:36] [error] [ 7428] Commons Daemon procrun failed with exit value: 4 (Failed to run service)
[2023-02-14 23:26:36] [error] [ 7428] The service process could not connect to the service controller.

Odd enough, the first hit for "Commons Daemon procrun failed with exit value: 4 (Failed to run service)" was against a Neo4j issue, that was related to but not conclusive, that the problem with JAVA path related.

I took a look at the Neo4j Github and it seems to have cleaned up the service scripts, and their install guidance cites JDK 1.17 so I assume it can be used.

The problem seems to be that I had to re-install the Windows service AFTER downgrading to the 1.8 JDK because it's embedded into the service call.

Seems like a problem waiting to happen if the admin upgrades to a newer version of Java, the old one will keep being used, not the new patched one. If I uninstalled the old version it would mean the ongdb service wouldn't run.

Expected behavior

I expect to know what the ongdb installation requirements are for Linux and Windows. I expect to be able to install and use the product as a service on Linux and Windows.

This isn't too vague. Simply try installing with a JDK version newer than 1.8 and it will fail. Trying to track down ongdb installation requirements is impossible. Resorting to using old graphdb or neo4j docs is no longer safe for an administrator because the shell scrips are different now.

Actual behavior

cmhull42 commented 1 year ago

Hi, can you share what java build (openjdk, zulu, adoptium) you have installed that is returning 1.17 for version? I understand the version check is flawed but can't seem to reproduce this.

11, 17 on temurin and openjdk start just fine with the 1.0.4 release as java -version returns java version "17.0.1" 2021-10-19 LTS for example.

As for the second issue, I'll look into how we can make this easier, we should be able to at least surface the error better.

duhmojo commented 1 year ago

Hey.

$ java --version
openjdk 11.0.16.1 2022-08-12 LTS

C:\Users\Administrator>java -version
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_362-b09)
OpenJDK 64-Bit Server VM (Temurin)(build 25.362-b09, mixed mode)

The JRE 1.17 I was running on Windows was reinstalled to 1.8, so I can't get you a sample output right now. You can play with the existing logic in Bash like this:

[[ "11.0.16.1" < "1.8" ]] && echo "less than 1.8" || echo "totally fine version"

Because Sun/Oracle switched up how versions are reported you'll have to do special checks for post 1.8 reported versions. A regex could handle doing the pattern detection and extracting the comparable value. Same in PowerShell. Probably the easiest approach.

I point out how the Windows service is registered with the JRE path embedded because it'll be a future point of mysterious failure. I completely recognize that Windows services are a PITA. If you fix the version detection, people will upgrade their JRE versions and may not keep the old one around.

Thanks for responding.

noncom commented 1 year ago

Having the same problem: on Windows it just doesn't start. Not sure if the reason is the same, but here's all I get:

D:\some-path\ongdb-community-1.0.4-windows\ongdb-community-1.0.4\bin>ongdb start -Verbose
 ONgDB Root is 'D:\some-path\ongdb-community-1.0.4-windows\ongdb-community-1.0.4'
 ONgDB Server Type is 'Community'
 ONgDB Version is '1.0.4'
 ONgDB Database Mode is ''
 Start command specified
 ONgDB Windows Service Name is ongdb
 Java detected at 'C:\Users\user\.jdks\corretto-18.0.2\bin\java.exe'
 Invoking C:\Users\user\.jdks\corretto-18.0.2\bin\java.exe -version 2>&1
 Command returned with exit code 0
 Java version response: openjdk version "18.0.2" 2022-07-19
OpenJDK Runtime Environment Corretto-18.0.2.9.1 (build 18.0.2+9-FR)
OpenJDK 64-Bit Server VM Corretto-18.0.2.9.1 (build 18.0.2+9-FR, mixed mode, sharing)
 Java Version detected as 18.0.2
 ONgDB Windows Service Name is ongdb
 Starting ONgDB as a service
 Invoking D:\some-path\ongdb-community-1.0.4-windows\ongdb-community-1.0.4\bin\tools\prunsrv-amd64.exe "//ES//ongdb" 2>&1
 Command returned with exit code 5
ONgDB service did not start
duhmojo commented 9 months ago

Yes it would. The point of the issue is that anything newer than JDK8 will work fine except for the start script's JDK version detection. Still no update to 1.0.4.