public class

ConnectionPoolHealthSqlInterceptor

extends Object
implements SQLConnectionInterceptor
java.lang.Object
   ↳ com.atlassian.jira.ofbiz.ConnectionPoolHealthSqlInterceptor

Class Overview

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 becomes 2 if in STRICT_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.

Summary

Constants
String DANGER_ZONE The minimum number of connections that must still be available for it to be considered safe to request a second connection.
String QUIET Forces all logging to be at the debug level instead of the warning level.
String STRICT_MODE Lowers the threshold of what constitutes "too many connections" from 3 to 2 so that we can be even more aggressive in tracking down code that consumes multiple connections.
Public Constructors
ConnectionPoolHealthSqlInterceptor()
Public Methods
void afterSuccessfulExecution(String sqlString, List<String> parameterValues, Statement statement, ResultSet resultSet, int rowsUpdated)
void beforeExecution(String sqlString, List<String> parameterValues, Statement statement)
void onConnectionReplaced(Connection connection, ConnectionPoolState connectionPoolState)
void onConnectionTaken(Connection connection, ConnectionPoolState connectionPoolState)
void onException(String sqlString, List<String> parameterValues, Statement statement, SQLException sqlException)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.ofbiz.core.entity.jdbc.interceptors.SQLInterceptor
From interface org.ofbiz.core.entity.jdbc.interceptors.connection.SQLConnectionInterceptor

Constants

public static final String DANGER_ZONE

The minimum number of connections that must still be available for it to be considered safe to request a second connection. Outside of STRICT_MODE, we would normally only log when 3 or more connections are requested at once; however, if the pool is within the "danger zone" of being exhausted, then even requesting just 2 connections is considered as a deadlock risk.

Default: 2

Constant Value: "jira.db.counter.danger.zone"

public static final String QUIET

Forces all logging to be at the debug level instead of the warning level.

Constant Value: "jira.db.counter.quiet"

public static final String STRICT_MODE

Lowers the threshold of what constitutes "too many connections" from 3 to 2 so 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

Constant Value: "jira.db.counter.strict.mode"

Public Constructors

public ConnectionPoolHealthSqlInterceptor ()

Public Methods

public void afterSuccessfulExecution (String sqlString, List<String> parameterValues, Statement statement, ResultSet resultSet, int rowsUpdated)

public void beforeExecution (String sqlString, List<String> parameterValues, Statement statement)

public void onConnectionReplaced (Connection connection, ConnectionPoolState connectionPoolState)

public void onConnectionTaken (Connection connection, ConnectionPoolState connectionPoolState)

public void onException (String sqlString, List<String> parameterValues, Statement statement, SQLException sqlException)