-
Bug
-
Resolution: Done
-
Major
-
None
-
False
-
None
-
False
-
---
-
-
1. Quarkus uses `QuarkusNettyConnectionCache` for Agroal local connection cache if it finds class `FastThreadLocal`.
2. Agroal `ConnectionPool` calls `localCache.reset()` in its `ReapTask` periodically (5min in Quarkus), the `FastThreadLocal` instance is created again in `reset()` but actually the old thread local `ConnectionHandler` is still in array `FastThreadLocalThread.threadLocalMap.indexedVariables`.
3. `ConnectionHandler.closeConnection()` doesn't set its fields to null, so it still holds reference to JDBC connection such as `ConnectionImpl` in mysql-connector-j, the JDBC connection still holds some heavy Java objects, thus `localCache.reset()` leads to heavy memory leak after running for about a week.
The solution is to not create `FastThreadLocal` again, so the memory leak is limited by total count of Java threads that use JDBC to access database.
This bug is introduced since Quarkus-2.2.0 at https://github.com/quarkusio/quarkus/issues/17304 .