Are there parameters in TiDB to limit the number of connections for a specific user?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb有没有参数限制某个用户的连接数

| username: ablewang_xiaobo

[TiDB Usage Environment] Production Environment
[TiDB Version] v4.0.9
[Encountered Problem] Our developer mentioned that when using a common account to initiate 20 connections, an error occurs. However, using another user to initiate 20 connections does not cause any issues. The error message is as follows:

Currently, the connection configuration information for the TiDB database is as follows:
image

| username: wuxiangdong | Original post link

First, check the maximum number of connections configured in the connection pool by the developers.

| username: OnTheRoad | Original post link

Currently, it seems that it is not possible to limit the number of connections by user.

| username: ablewang_xiaobo | Original post link

Setting the connection pool to 500 doesn’t work either, the initial value is 50.

| username: ablewang_xiaobo | Original post link

I checked, TiDB does not support limiting the number of connections per user.

| username: wuxiangdong | Original post link

It is most likely an issue with the connection pool. Check how many connections this program has initiated with the database.

| username: ablewang_xiaobo | Original post link

I checked, the user currently has 342 connections. The developer said that changing the connection pool to 500 still cannot create 20 more connections.

| username: wuxiangdong | Original post link

Increase the minimum connections in the connection pool and increase the connect timeout.

| username: ablewang_xiaobo | Original post link

There is no parameter for minimum connections

Type: com.zaxxer.hikari.HikariDataSource
# Minimum number of idle connections
minimum-idle: 5
# Maximum number of connections in the connection pool, default is 10
maximum-pool-size: 500
# This property controls the default auto-commit behavior of connections returned from the pool, default value: true
auto-commit: true
# Maximum lifetime of idle connections, default 600000 (10 minutes)
idle-timeout: 30000
# Database connection timeout, default 30 seconds, i.e., 30000
connection-timeout: 30000
connection-test-query: SELECT 1

| username: wuxiangdong | Original post link

minimum-idle: 30 Try using 30
connection-timeout: 90000 Try using 90s

| username: xiaohetao | Original post link

Where can I find the max-server-connections parameter?

| username: ShawnYan | Original post link

Indeed

TiDB does not support WITH MAX_USER_CONNECTIONS and other CREATE options.

| username: alfred | Original post link

It does not support setting profiles similar to Oracle user profiles, right?

| username: ablewang_xiaobo | Original post link

The developer replied that indeed it can connect after increasing the settings, but the speed is a bit slow.

| username: ablewang_xiaobo | Original post link

TiDB does not support a profile-like format.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.