#84 c3p0 seem to be deadlocked when calling BasicResourcePool.aw

closed
nobody
None
5
2010-09-25
2010-07-15
Shachar Zehavi
No

Hello All.

We are using c3p0 on a multi threaded database batch upload application. From time to time the application hangs.

Using jstack we got the attached thread stack trace dump that indicates all working threads are stuck on BasicResourcePool.awaitAvailable.

Any idea why this is happening?

Thanks,
Shachar

Discussion

  • Shachar Zehavi
    Shachar Zehavi
    2010-07-15

    jstack

     
    Attachments
  • Steve Waldman
    Steve Waldman
    2010-07-15

    It sounds like you have a leak, like Connections are occasionally being checked out, but not rechecked in (closed).

    Try temporarily setting an unreturnedConnectionTimeout and using debugUnreturnedConnectionStackTraces to track down the leak.

    http://www.mchange.com/projects/c3p0/index.html#unreturnedConnectionTimeout
    http://www.mchange.com/projects/c3p0/index.html#debugUnreturnedConnectionStackTraces

    Are you carefully using the robust resource clean-up idiom?

    Connection c = null;
    OtherResource or = null;

    try
    {
    c = cpds.getConnection();
    or = getOtherResource()

    // do stuff
    // ...
    }
    finally
    {
    try { if (or != null) or.close(); }
    catch (Exception e) { e.printStackTrace(); }

    try { if (c != null) c.close(); }
    catch (Exception e) { e.printStackTrace(); }
    }

    Note that the finally clause will definitely be executed if the Connection is acquired, and there is a best-attempt close() of each resource: If or fails to close(), that Exception won't prevent the attempt to close() the Connection.

     
  • Steve Waldman
    Steve Waldman
    2010-07-15

    • status: open --> pending
     
  • This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
    • status: pending --> closed