sonatype / nexus-public

Sonatype Nexus Repository Open-source codebase mirror
https://www.sonatype.com/products/repository-oss-download
Eclipse Public License 1.0
1.9k stars 564 forks source link

Performance issues 3.71.0 #467

Open nesc58 opened 2 weeks ago

nesc58 commented 2 weeks ago

Hi, i have noticed performance issues using the new 3.71.0 after database migration to h2. Using the 3.70.1 restoring nuget packages took ~20 seconds Using the 3.71.0 restoring took ~50 seconds

We are using a nuget group with 7 members.

Is it known that the performance of h2 is worse than the old orient db?

Nexus is running as docker container, the parameters of JAVA_OPTS are updated because the options like MaxDirectMemorySize no longer relevant when using the h2 database.

My expected behaviour is an equivalent performance (or slightly better) using h2 instead of orient db but definitely not 2.5 times slower

mrprescott commented 1 week ago

It's entirely possible that H2 is slower for some use cases. OrientDB is fast but not especially safe—it regularly allows duplicate keys in unique indexes and/or corrupts itself under concurrent usage.

nesc58 commented 1 day ago

Thank you for the answer. I have tried a lot of things to improve the performance (more RAM, more cpu cores, switch to a SSD) but it keeps 2.5 times slower than the orientdb. The point which has triggered me is that the performance decreased so much. A few percents slower were fine but this is a lot. When using h2 database the jdbc url parameter will be ignored correct? I have seen a lot of tweaks and optimizations like SET CACHE_SIZE or SET WRITE_DELAY Is there any special nexus is using? E.g. connection pooling, opening/reopening the connections? Is there anything I can check using the logs or traces which part consumes a lot of time?

onnos commented 21 hours ago

I also saw major performance problems when switching to H2. In my case, some digging revealed the database churning a lot on optimize due to this bug in the embedded H2 version 2.2.24. Presumably this will be fixed when Sonatype updates the embedded H2 version to something newer like 2.3.230 or 2.3.232.

If your problem is the same, a workaround is to make a backup of the database, unzipping the resulting backup and dumping the database to a file and importing it again (note: your directories will likely be different so don't blindly copy/paste):

java -cp /opt/nexus/system/com/h2database/h2/*/h2-*.jar org.h2.tools.Shell -url jdbc:h2://var/nexus/backup/nexus -sql "SCRIPT TO 'dump.sql';"
java -cp /opt/nexus/system/com/h2database/h2/*/h2-*.jar org.h2.tools.Shell -url jdbc:h2:/var/nexus/backup/newdb -sql "RUNSCRIPT FROM 'dump.sql'"

Then stop nexus, move the newdb.mv.db into place to overwrite the old nexus.mv.db and it will run happily again for a little while. The problem will come back though, the only solution is Nexus itself being updated.