[JDBC-56] Problem with find-connection when using agents with c3p0 connection pool Created: 16/May/13 Updated: 01/Jun/16 Resolved: 15/Sep/13
|Reporter:||Ed O'Loughlin||Assignee:||Sean Corfield|
OS X 10.8.3
I use an agent to offload email processing and update a db on completion. If I use a c3p0 connection pool, I get an exception and a complaint that the connection isn't open (see stacktrace). The code works if I wrap the agent fn in a clojure.java.jdbc/with-connection and get a connection from the pool in the agent thread.
The in jdbc.clj, the find-connection (db-find-connection in HEAD) checks for an existing connection and tries to use it without checking if it's open. This causes an exception with a c3p0 connection that was acquired in another thread.
Here's the stacktrace I'm seeing (note the "You can't operate on a closed Connection!!!"):
|Comment by Ed O'Loughlin [ 16/May/13 4:50 AM ]|
Apologies: this is a crappy bug report. I'm under a bit of pressure at the moment so I can't make a test case.
|Comment by Sean Corfield [ 21/May/13 12:36 PM ]|
If you use the new API, you pass the db-spec into the functions and it will take care of getting the connection, using it, and closing it - and that will all happen on the same (agent) thread. I would not expect you to be able to get a connection in one thread and use it from another thread.
When you get a chance, please post an example of both the working and non-working code, but my initial thinking is this isn't a bug, just an inherent limitation of working with connections across threads....?
|Comment by Sean Corfield [ 15/Jun/13 9:04 PM ]|
Ed, are you going to get a chance to post an example of working / non-working code per my request a month ago?
I'll leave this open until the end of June but without further information, I'm going to assert it works if used as designed and close this as not a bug.
|Comment by Sean Corfield [ 15/Sep/13 4:17 PM ]|
In the absence of better information, I'm closing this "works as designed" and caution that people need to be more careful when using connections across multiple threads.