Setting up lightweight validationQuery for MySQL
Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.
To avoid the impact of creating a new database connection for each database access request made by Application (JIRA, Confluence, Stash), a pool of pre-established database connections is maintained. As part of this we need to make sure that connection inside the pool are validated. This needs to be done in order to prevent connections in pool to be broken, which may occur after database server reboots or a network failure. There is a lightweight validation query which can be used with MySQLConnector/J.
The following appears in the tcpdump
17:36:54.292582 IP localhost.59437 > localhost.mysql: Flags [P.], seq 1272:1285, ack 846, win 522, options [nop,nop,TS val 311544791 ecr 311523797], length 13 ......y. ....select 1
- Database MySQL, JDBC Mysql Connector/J >= 5.1.3
Using connection pool without validation query may lead to broken connection and application will not be able to survive connection closures. Using usual validation query like 'select 1' will create higher load on MySQL server as it needs to parse request.
validation-query in the application database settings (please check relevant documentation for that).
To use this feature, specify a validation query in your connection pool that starts with
/* ping */. Note that the syntax must be exactly as specified.
Configuration example for JIRA:
<validation-query>/* ping */ select 1</validation-query> <pool-test-on-borrow>false</pool-test-on-borrow> <pool-test-while-idle>true</pool-test-while-idle> <validation-query-timeout>3</validation-query-timeout>