opensingular / singular-keycloak-database-federation

Keycloak User Storage SPI for Relational Databases (Keycloak User Federation, supports postgresql, mysql, oracle and mysql)
Apache License 2.0
120 stars 57 forks source link

fix DB connections leak #14

Closed dla-c-box closed 2 years ago

dla-c-box commented 2 years ago

Every time the plugin is re-deployed, it is leaking the previous DB connections, up to the point where it depletes the available DB connections (especially in a Development mode with a limited number of DB Connections available, but the same would be true for Production), and the DB log would show something like this: image

And Keycloak would show the error "We are sorry... An internal server error has occurred": image

e.g. Checking the number of connections on a Postgresql DB, running SELECT sum(numbackends) FROM pg_stat_database; would show that 10 connections are leaked on each re-deploy.

viniciusuriel commented 2 years ago

Did it actually solved the problem? I think it might have yet some other issue regarding connection cleanup. I will further review the code for connection management issues. Thank you.

dla-c-box commented 2 years ago

Yes, it did solve this specific issue. I was able to confirm the exact number of connections that were added on each re-deploy without the fix, and to confirm that it (the number of connections increasing) was no longer the case with the fix. This doesn't mean there aren't other connection cleanup problems to be found, but it fixed this specific one. Thanks.