diff --git a/develop/dev-guide-connection-parameters.md b/develop/dev-guide-connection-parameters.md index b4ef34c17399f..38a92ad92b190 100644 --- a/develop/dev-guide-connection-parameters.md +++ b/develop/dev-guide-connection-parameters.md @@ -34,6 +34,38 @@ It is a common practice that the connection pool size is well adjusted according 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. +### Configure the lifetime of connections + +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. + +Most connection pool libraries provide a parameter to control the maximum lifetime of a connection: + + +
+ +- **`maxLifetime`**: The maximum lifetime of a connection in the pool. + +
+ +
+ +- **`maxAge`**: The maximum lifetime of a connection in the pool. + +
+ +
+ +- **`maxConnectionAge`**: The maximum lifetime of a connection in the pool. + +
+ +
+ +- **`maxConnLifetimeMillis`**: The maximum lifetime of a connection in the pool. + +
+
+ ### Probe configuration 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 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/). - \ No newline at end of file + diff --git a/tidb-cloud/serverless-limitations.md b/tidb-cloud/serverless-limitations.md index b8a31b5838202..82493cf39f02e 100644 --- a/tidb-cloud/serverless-limitations.md +++ b/tidb-cloud/serverless-limitations.md @@ -22,6 +22,7 @@ We are constantly filling in the feature gaps between {{{ .starter }}}/Essential - 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. - No [Firewall Rules](/tidb-cloud/configure-serverless-firewall-rules-for-public-endpoints.md) support for Private Endpoint. +- 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). > **Note:** >