[QFJ-20] Database statement leak in JDBCStore Created: 03/Jun/06  Updated: 02/Sep/06  Resolved: 04/Jun/06

Status: Closed
Project: QuickFIX/J
Component/s: None
Affects Version/s: 1.0.0 Final
Fix Version/s: 1.0.1

Type: Bug Priority: Major
Reporter: Steve Bate Assignee: Steve Bate
Resolution: Fixed Votes: 0
Labels: None


 Description   

We moved a FIX gateway server built on quickfixj into production a few
days ago, and it quickly became quite clear that the java program
leaked menory somehow, and so did the mysql server. Both servers grew
to about 2GB each in a few hours. After that, we had to restart the
processes because of performance problems.

Anyway, I traced the problem to the JdbcStore class, which allocates a
new statement for each call. The statement is never closed.
Depending on the Jdbc driver, these statements might or might not be
garbage collected, but in our case they were at least not.

After patching the code everything seems to run really well and fast.

Anyway, I'm a bit reluctant to post a patch since the one I made is so
ugly... It seems that someone started work on caching prepared
statements in the JdbcStore class (using the statementCache member),
but since it is not finished, it results in the leak. The JdbcLog
class does not have this problem.

At first glance it seems very easy to make the cache work (the only
missing statement is one that actually adds the statement to the
cache). It seems to me that thread safety needs to be taken into
account, which might not be trivial. Maybe that's why the cache
mechanism was never finished?

Btw, my current patch just adds a close() call to a number of places.

Staffan



 Comments   
Comment by Steve Bate [ 04/Jun/06 ]

Added database connection (and statement) pooling and support for JDBC data sources. This should address the memory leak and the threading issues.

Generated at Sat Nov 23 07:48:10 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.