mendix / database-connector

https://appstore.home.mendix.com/link/app/2888/Mendix/Database-Connector
Apache License 2.0
9 stars 25 forks source link

Connection Pool returns Old connection when password is changed #24

Open pavansolapure opened 4 years ago

pavansolapure commented 4 years ago

I need to store database details like url, user, password in mendix schema so I can change the password or point to new external database. In this scenario, even if I change the password and try to execute query, I get old connection based on the computed pool key. This Pool Key is calculated based on url + user.

So when I change password, there is no impact on pool key at all and I get old connection with old password.

I think if we calculate pool key as url + user + password then I believe this caching of old connection in case of password change wont arise.

https://github.com/mendix/database-connector/blob/0509eb41a4af953ae543dbd51a361b68dd3bab28/javasource/databaseconnector/impl/JdbcConnectionManager.java#L69

https://github.com/mendix/database-connector/blob/0509eb41a4af953ae543dbd51a361b68dd3bab28/javasource/databaseconnector/impl/JdbcConnectionManager.java#L70

This is just a thought, may be you might have more elegant solution.

Please see if we can do any thing here

Appreciate.

basi01 commented 3 years ago

Idea: let me try -Dhikaricp.configurationFile= and connectionTestQuery= Upd: the setting above is honored, but in case of a wrong password it doesn't even reach the point where the test query is run, but throws again: MicroflowException: com.mendix.systemwideinterfaces.MendixRuntimeException: org.postgresql.util.PSQLException: FATAL: password authentication failed for user

Looks like there are two layers of pooling and the outer layer is buggy.