Skip to content

Commit f2e8800

Browse files
authored
best-practices: fix incorrect default value of wait_timeout (#21592)
1 parent 3108927 commit f2e8800

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

best-practices/java-app-best-practices.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ After it is configured, you can check the monitoring to see a decreased number o
210210
211211
#### Timeout-related parameters
212212

213-
TiDB provides two MySQL-compatible parameters that controls the timeout: `wait_timeout` and `max_execution_time`. These two parameters respectively control the connection idle timeout with the Java application and the timeout of the SQL execution in the connection; that is to say, these parameters control the longest idle time and the longest busy time for the connection between TiDB and the Java application. The default value of both parameters is `0`, which by default allows the connection to be infinitely idle and infinitely busy (an infinite duration for one SQL statement to execute).
213+
TiDB provides the following MySQL-compatible timeout control parameters.
214+
215+
- `wait_timeout`: controls the non-interactive idle timeout for the connection to Java applications. Starting from TiDB v5.4, the default value of `wait_timeout` is `28800` seconds, which is 8 hours. For TiDB versions earlier than v5.4, the default value is `0`, which means the timeout is unlimited.
216+
- `interactive_timeout`: controls the interactive idle timeout for the connection to Java applications. The value is 8 hours by default.
217+
- `max_execution_time`: controls the timeout for SQL execution in the connection, only effective for read-only SQL statements. The value is `0` by default, which allows the connection to be infinitely busy, that is, an SQL statement is executed for an infinitely long time.
214218

215219
However, in an actual production environment, idle connections and SQL statements with excessively long execution time negatively affect databases and applications. To avoid idle connections and SQL statements that are executed for too long, you can configure these two parameters in your application's connection string. For example, set `sessionVariables=wait_timeout=3600` (1 hour) and `sessionVariables=max_execution_time=300000` (5 minutes).
216220

0 commit comments

Comments
 (0)