Azure PostgreSQL Lesson Learne... Note

Azure PostgreSQL Lesson Learned #15: Troubleshooting JDBC SSL Timeouts and DNS Latency

A customer experienced intermittent connection failures between a Java application and Azure Database for PostgreSQL. These failures occurred during the SSL negotiation phase of establishing new database connections. PostgreSQL server logs showed "could not accept SSL connection: EOF detected," indicating the connection closed before SSL completed. The Java application logs revealed socket read timeouts while waiting for the server's SSL response. Network packet traces confirmed a delay in the server's SSL response, leading to the JDBC driver timing out. The root cause was identified as the enabled log_hostname server parameter. This parameter triggers reverse DNS lookups for logging, which, when slow, delays connection processing. The sequence involved an application initiating an SSL connection, a delay due to hostname resolution, the JDBC driver timing out, and the client closing the connection. PostgreSQL then logged the EOF error upon encountering the prematurely closed connection during SSL processing. Disabling log_hostname across development, testing, and production environments resolved the connection failures. This resolved issue indicated that the shared DNS server's load from hostname resolution was the primary cause. While increasing JDBC timeouts is a resiliency measure, disabling log_hostname was the direct mitigation for this specific problem.