k8s-manifests/ops/druid-validation
2026-11-03 14:14:18 +08:00
..
IdleDisconnectCheck.java test(druid): reproduce expired connection during active polling 2026-11-03 14:12:13 +08:00
README.md test(ops): verify Nacos metadata and document JDBC failure coverage 2026-11-03 14:14:18 +08:00

Expired JDBC connection validation

MES-37 / MES-42 / MES-119 / MES-124 use Druid 1.2.9 and MySQL Connector/J 8.0.30. testWhileIdle=true with the default 60-second interval permits a connection closed during a shorter idle interval to reach business SQL. The default testOnBorrow=false leaves that interval unchecked. The original failure is reproduced against a disposable MySQL 8.0.32 with wait_timeout=2 seconds: after 3.5 seconds idle, borrowing succeeds but the business query fails.

The same test succeeds with these native Druid system properties:

-Ddruid.testOnBorrow=true
-Ddruid.mysql.usePingMethod=false
-Ddruid.validationQueryTimeout=3
-Ddruid.phyTimeoutMillis=1800000

The first property validates every borrow. The second makes the MySQL checker execute its default SELECT 1 instead of relying on protocol pings through a proxy. The validation has a three-second query timeout. Physical connections are recycled after 30 minutes when returned or borrowed; active business transactions are not forcibly interrupted. Do not retry business SQL or hide connection-pool error logs.

Druid reads these properties in its constructor, including datasources wrapped by the Seata JDK proxy and pools created outside Spring configuration binding. For Spring-managed primary pools, equivalent datasource properties are supplied in the workload environment to prevent a later binder overriding the setting.

This closes a demonstrated stale-connection validation gap. It does not prove that every historical EOF was caused by an idle connection. Keep each incident open until its production recurrence interval has passed and business calls remain healthy. Do not alter ProxySQL or MySQL global timeout settings.