LuckPerms

LuckPerms

41.4k Downloads

Can't connect to postgresql database if another mod is using the same driver

daniromome opened this issue ยท 3 comments

commented

Description

I have a proprietary mod that connects to a postgresql database and whenever I try to start the server with both luckperms and my mod luckperms refuses to connect to the database

Reproduction Steps

Have any other mod that uses org.postgresql:postgresql:42.6.0 to connect to a database installed
Config luckperms to use postgresql as a database

Expected Behaviour

Luckperms should be able to connect to the database

Server Details

Fabric 0.14.21 for Minecraft 1.20.1

LuckPerms Version

v5.4.98

Logs and Configs

https://gist.github.com/daniromome/2730a6c0b66209e3e7e1015df22de88f

Extra Details

On my mod the only thing that I do is on initialization sync database tables (create or update with specified schema) and sync the json statistics of each player to those tables every 5 minutes

commented

I have a suspicion that this is due to the postgresql driver using DriverManager.getConnection instead of using its own driver class directly (this is in BaseDataSource.getConnection), and the DriverManager might pick a registered postgresql driver that is different from the one in "this" driver, although the DriverManager does have some classloader safeguards in place but that would only really be useful when each mod/plugin has its own isolated ClassLoader (or when the CL prioritises its own classpath before requesting the parent CL), I don't know how Fabric sets up mod class loading but, for example, this should not happen on Spigot servers.

A solution I can think off the top of my head is to ship a patched version of the driver that does not use the DriverManager to get a connection, but uses the own Driver class directly.

This should probably be reported to pgjdbc/pgjdbc if it hasn't already, but honestly I can't blame them for doing that, as this kind of configuration of "i need to shade/bundle + relocate because someone else might be doing it without relocating but the classloaders are mixed" is far from standard but very brittle.

commented

Please try using v5.4.101 or newer

https://luckperms.net/download

commented

After updating the issue has been resolved! Thank you :)