Skip to content

Commit e1e1ef3

Browse files
committed
Add connection lifetime config samples
Signed-off-by: Xiaoguang Sun <[email protected]>
1 parent 40ba06b commit e1e1ef3

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

develop/dev-guide-connection-parameters.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,35 @@ 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 is shut down or restarted for maintenance or due to hardware failure, client connections may be reset, leading to application disruptions. It is recommended to close and reconnect long-running database connections at least once a day.
40+
41+
<SimpleTab>
42+
<div label="HikariCP">
43+
44+
- **maxLifetime**: The maximum lifetime of a connection in the pool.
45+
46+
</div>
47+
48+
<div label="tomcat-jdbc">
49+
50+
- **maxAge**: The maximum lifetime of a connection in the pool.
51+
52+
</div>
53+
54+
<div label="c3p0">
55+
56+
- **maxConnectionAge**: The maximum lifetime of a connection in the pool.
57+
58+
</div>
59+
60+
<div label="dbcp">
61+
- **maxConnLifetimeMillis**: The maximum lifetime of a connection in the pool.
62+
63+
</div>
64+
</SimpleTab>
65+
3766
### Probe configuration
3867

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

294323
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/).
295324

296-
</CustomContent>
325+
</CustomContent>

tidb-cloud/serverless-limitations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ We are constantly filling in the feature gaps between {{{ .starter }}}/Essential
2020

2121
### Connection
2222

23-
- Database client connections that are held open longer than 30 minutes may be terminated unexpectedly. To avoid this, start with a 5-minute maximum connection lifetime and increase it if you observe a negative impact on tail latency.
23+
- Database client connections that remain open for more than 30 minutes may be terminated unexpectedly. When a server is shut down or restarted, client connections can be reset after this duration, resulting in application disruptions. It is recommended to start with a maximum connection lifetime of 15 minutes and extend it if you notice a negative impact on tail latency. Refer to the [recommended settings for connection pools](/develop/dev-guide-connection-parameters.md#connection-pools-and-connection-parameters) for additional information.
2424
- 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. 
2525
- No [IP Access list](/tidb-cloud/configure-ip-access-list.md) support.
2626

0 commit comments

Comments
 (0)