Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meaning of "Value was returned to the bag that was not borrowed"? #69

Closed
jaredstehler opened this issue Apr 29, 2014 · 5 comments
Closed

Comments

@jaredstehler
Copy link
Contributor

I'm occasionally seeing the following error from my app:

! java.lang.IllegalStateException: Value was returned to the bag that was not borrowed
! at com.zaxxer.hikari.util.ConcurrentBag.requite(ConcurrentBag.java:177) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.zaxxer.hikari.HikariPool.releaseConnection(HikariPool.java:199) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.zaxxer.hikari.proxy.ConnectionProxy.close(ConnectionProxy.java:330) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at com.mchange.v2.sql.filter.FilterConnection.close(FilterConnection.java:327) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.BasicHandle.close(BasicHandle.java:116) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$CloseHandler.invoke(CloseInternalDoNotUseThisClass.java:36) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.SqlObject.invoke(SqlObject.java:171) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.SqlObject$1.intercept(SqlObject.java:75) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$e389b236.___jdbi_close___(<generated>) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.SqlObject.close(SqlObject.java:184) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.sqlobject.SqlObjectBuilder.close(SqlObjectBuilder.java:76) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
! at org.skife.jdbi.v2.DBI.close(DBI.java:353) ~[ContentRendering-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]

What could cause this error to occur? Is this indicative of a connection leak?

@brettwooldridge
Copy link
Owner

Wow, what is going on? I see com.mchange.v2.sql.filter.FilterConnection.close() in the stacktrace. That class is from the C3P0 connection pool. It is generally a bad idea to wrap one connection pool (HikariCP) inside of another (C3P0). Is it possible to remove C3P0 from the configuration?

@brettwooldridge
Copy link
Owner

Looking at the exception itself, it appears that someone is calling getConnection(), using the connection, calling close() on the Connection, then continuing to use the connection before calling close() again on the Connection. This may, or may not, be a side-effect of wrapping HikariCP inside of C3P0.

@jaredstehler
Copy link
Contributor Author

We aren't actually using two pools; we've written a wrapper around jdbc which uses hystrix to fail over to another datasource if one is having issues. The mchange class is a simple delegating wrapper so we didn't have to implement the 50-odd methods of the JDBC connection interface.

@brettwooldridge
Copy link
Owner

I see. The core cause of the exception seems to be as stated. Some code path is closing a Connection but continuing to use it. The stacktrace provided may point to the cause or it may point to the victim.

@jaredstehler
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants