Timeouts and leak detection
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
configure timeouts that fail fast, and find leaks.
Planned topics
connectionTimeout: how long a thread waits for a connection (a few seconds, not 30 s default for APIs; verify default).- Database side:
statement_timeout,lock_timeout,idle_in_transaction_session_timeout. - A leak is a borrowed connection never returned;
leakDetectionThresholdlogs a stack trace when one is held too long. - Pool exhaustion signs: threads blocked in
HikariPool.getConnectionin thread dumps,pendingthreads metric above zero. - Do not hold a connection across remote calls;
spring.jpa.open-in-viewcan hold one for a whole request (consider turning it off).
Draft outline details
Demonstration
a thread dump excerpt with many threads waiting in HikariPool.getConnection.
Check your understanding
What does leakDetectionThreshold report?
Show answer
A stack trace for connections held longer than the threshold.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.