Package com.atlassian.jira.ofbiz
Class ConnectionPoolHealthSqlInterceptor
java.lang.Object
com.atlassian.jira.ofbiz.ConnectionPoolHealthSqlInterceptor
- All Implemented Interfaces:
org.ofbiz.core.entity.jdbc.interceptors.connection.SQLConnectionInterceptor,org.ofbiz.core.entity.jdbc.interceptors.SQLInterceptor
public class ConnectionPoolHealthSqlInterceptor
extends Object
implements org.ofbiz.core.entity.jdbc.interceptors.connection.SQLConnectionInterceptor
An interceptor for SQL connection use that will keep track of how many connections each thread uses
and report warnings for various things that could cause trouble, like a single thread requesting multiple
connections from the pool.
We log a warning or error message when:
- A thread requests LIMIT connections at once for the first time since it was last reset, where LIMIT is
normally
3, but becomes2if inSTRICT_MODE. - A thread requests multiple connections while the connection pool is in the
DANGER_ZONE. - One of the preceding events has occurred and the thread is releasing one of the connections that had been obtained before one of the above log messages had been triggered. The idea is that these did not get logged on the way in, but it may be important to see where the outer connections came from, and hopefully the code that releases the connection is located near whatever allocated it. This is a workaround for the fact that creating a stack trace for everything just-in-case is too expensive.
- Since:
- v7.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe minimum number of connections that must still be available for it to be considered safe to request a second connection.static final StringForces all logging to be at the debug level instead of the warning level.static final StringLowers the threshold of what constitutes "too many connections" from3to2so that we can be even more aggressive in tracking down code that consumes multiple connections. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterSuccessfulExecution(String sqlString, List<String> parameterValues, Statement statement, ResultSet resultSet, int rowsUpdated) voidbeforeExecution(String sqlString, List<String> parameterValues, Statement statement) voidonConnectionReplaced(Connection connection, org.ofbiz.core.entity.jdbc.interceptors.connection.ConnectionPoolState connectionPoolState) voidonConnectionTaken(Connection connection, org.ofbiz.core.entity.jdbc.interceptors.connection.ConnectionPoolState connectionPoolState) voidonException(String sqlString, List<String> parameterValues, Statement statement, SQLException sqlException) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ofbiz.core.entity.jdbc.interceptors.SQLInterceptor
afterSuccessfulExecution, beforeExecution, onException
-
Field Details
-
DANGER_ZONE
The minimum number of connections that must still be available for it to be considered safe to request a second connection. Outside ofSTRICT_MODE, we would normally only log when3or more connections are requested at once; however, if the pool is within the "danger zone" of being exhausted, then even requesting just2connections is considered as a deadlock risk.Default:
2- See Also:
-
QUIET
Forces all logging to be at the debug level instead of the warning level.- See Also:
-
STRICT_MODE
Lowers the threshold of what constitutes "too many connections" from3to2so that we can be even more aggressive in tracking down code that consumes multiple connections. Be forewarned that there are known places where multiple connections are deliberately used at times, such as when indexing issues, creating an issue, or populating an ID bank for OfBiz, so the signal-to-noise ratio may be disappointing.Default:
false- See Also:
-
-
Constructor Details
-
ConnectionPoolHealthSqlInterceptor
public ConnectionPoolHealthSqlInterceptor()
-
-
Method Details
-
onConnectionTaken
public void onConnectionTaken(Connection connection, org.ofbiz.core.entity.jdbc.interceptors.connection.ConnectionPoolState connectionPoolState) - Specified by:
onConnectionTakenin interfaceorg.ofbiz.core.entity.jdbc.interceptors.connection.SQLConnectionInterceptor
-
onConnectionReplaced
public void onConnectionReplaced(Connection connection, org.ofbiz.core.entity.jdbc.interceptors.connection.ConnectionPoolState connectionPoolState) - Specified by:
onConnectionReplacedin interfaceorg.ofbiz.core.entity.jdbc.interceptors.connection.SQLConnectionInterceptor
-
beforeExecution
- Specified by:
beforeExecutionin interfaceorg.ofbiz.core.entity.jdbc.interceptors.SQLInterceptor
-
afterSuccessfulExecution
public void afterSuccessfulExecution(String sqlString, List<String> parameterValues, Statement statement, ResultSet resultSet, int rowsUpdated) - Specified by:
afterSuccessfulExecutionin interfaceorg.ofbiz.core.entity.jdbc.interceptors.SQLInterceptor
-
onException
public void onException(String sqlString, List<String> parameterValues, Statement statement, SQLException sqlException) - Specified by:
onExceptionin interfaceorg.ofbiz.core.entity.jdbc.interceptors.SQLInterceptor
-