Skip to content

Commit fc60c07

Browse files
authored
cloud: add maximum lifetime of connections (#21895)
1 parent 7ff5264 commit fc60c07

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

develop/dev-guide-connection-parameters.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,38 @@ It is a common practice that the connection pool size is well adjusted according
3434

3535
The application needs to return the connection after finishing using it. It is recommended that the application uses the corresponding connection pool monitoring (such as **metricRegistry**) to locate connection pool issues in time.
3636

37+
### Configure the lifetime of connections
38+
39+
When a TiDB server shuts down, restarts for maintenance, or encounters unexpected issues such as hardware or network failures, your existing client connections might be reset, which can lead to application disruptions. To avoid such issues, it is recommended to close and recreate long-running database connections at least once a day.
40+
41+
Most connection pool libraries provide a parameter to control the maximum lifetime of a connection:
42+
43+
<SimpleTab>
44+
<div label="HikariCP">
45+
46+
- **`maxLifetime`**: The maximum lifetime of a connection in the pool.
47+
48+
</div>
49+
50+
<div label="tomcat-jdbc">
51+
52+
- **`maxAge`**: The maximum lifetime of a connection in the pool.
53+
54+
</div>
55+
56+
<div label="c3p0">
57+
58+
- **`maxConnectionAge`**: The maximum lifetime of a connection in the pool.
59+
60+
</div>
61+
62+
<div label="dbcp">
63+
64+
- **`maxConnLifetimeMillis`**: The maximum lifetime of a connection in the pool.
65+
66+
</div>
67+
</SimpleTab>
68+
3769
### Probe configuration
3870

3971
The connection pool maintains persistent connections from clients to TiDB as follows:
@@ -293,4 +325,4 @@ Ask the community on [Discord](https://discord.gg/DQZ2dy3cuc?utm_source=doc) or
293325

294326
Ask the community on [Discord](https://discord.gg/DQZ2dy3cuc?utm_source=doc) or [Slack](https://slack.tidb.io/invite?team=tidb-community&channel=everyone&ref=pingcap-docs), or [submit a support ticket](https://tidb.support.pingcap.com/).
295327

296-
</CustomContent>
328+
</CustomContent>

tidb-cloud/serverless-limitations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ We are constantly filling in the feature gaps between {{{ .starter }}}/Essential
2222

2323
- Only [Public Endpoint](/tidb-cloud/connect-via-standard-connection-serverless.md) and [Private Endpoint](/tidb-cloud/set-up-private-endpoint-connections-serverless.md) can be used. You cannot use [VPC Peering](/tidb-cloud/set-up-vpc-peering-connections.md) to connect to {{{ .starter }}} or {{{ .essential }}} clusters.
2424
- No [Firewall Rules](/tidb-cloud/configure-serverless-firewall-rules-for-public-endpoints.md) support for Private Endpoint.
25+
- Your database client connections might be terminated unexpectedly if they remain open for more than 30 minutes. This can occur when a TiDB server shuts down, restarts, or undergoes maintenance, potentially causing application disruptions. To avoid this issue, configure a maximum connection lifetime. It is recommended to start with 5 minutes and increase it gradually if it affects tail latency. For more information, see [Recommended settings for connection pools](/develop/dev-guide-connection-parameters.md#connection-pools-and-connection-parameters).
2526

2627
> **Note:**
2728
>

0 commit comments

Comments
 (0)