Skip to content

Commit

Permalink
fix(RelationalStorage): modify HikariCP config (#422)
Browse files Browse the repository at this point in the history
增加RelationalStorage中HikariCP的最大连接数至20
将RelationalStorage中的HikariDataSource连接池的配置设置为可选参数,可在add storageengine时配置
connection_timeout:连接超时时间,默认为30000,单位毫秒
idle_timeout:空闲连接超时时间,默认为10000,单位毫秒
maximum_pool_size:连接池中的最大连接数,默认为20
minimum_idle:连接池中的最小空闲连接数,默认为1
leak_detection_threshold:检测连接泄漏的阈值,默认为2500,单位毫秒
prep_stmt_cache_size:SQL预编译对象缓存个数,默认为250
prep_stmt_cache_sql_limit:SQL预编译对象缓存个数上限,默认为2048
  • Loading branch information
jzl18thu authored Aug 17, 2024
1 parent f8011b2 commit 62076d1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,21 @@ private Connection getConnection(String databaseName) {
config.setJdbcUrl(getUrl(databaseName, meta));
config.setUsername(meta.getExtraParams().get(USERNAME));
config.setPassword(meta.getExtraParams().get(PASSWORD));
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.setLeakDetectionThreshold(2500);
config.setConnectionTimeout(30000);
config.setIdleTimeout(10000);
config.setMaximumPoolSize(10);
config.setMinimumIdle(1);
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.addDataSourceProperty(
"prepStmtCacheSize", meta.getExtraParams().getOrDefault("prep_stmt_cache_size", "250"));
config.setLeakDetectionThreshold(
Long.parseLong(meta.getExtraParams().getOrDefault("leak_detection_threshold", "2500")));
config.setConnectionTimeout(
Long.parseLong(meta.getExtraParams().getOrDefault("connection_timeout", "30000")));
config.setIdleTimeout(
Long.parseLong(meta.getExtraParams().getOrDefault("idle_timeout", "10000")));
config.setMaximumPoolSize(
Integer.parseInt(meta.getExtraParams().getOrDefault("maximum_pool_size", "20")));
config.setMinimumIdle(
Integer.parseInt(meta.getExtraParams().getOrDefault("minimum_idle", "1")));
config.addDataSourceProperty(
"prepStmtCacheSqlLimit",
meta.getExtraParams().getOrDefault("prep_stmt_cache_sql_limit", "2048"));

HikariDataSource newDataSource = new HikariDataSource(config);
connectionPoolMap.put(databaseName, newDataSource);
Expand Down
12 changes: 12 additions & 0 deletions docs/quickStarts/IGinXManual-EnglishVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,18 @@ In order to facilitate installation and management of IGinX, IGinX provides user
| statisticsCollectorClassName | Statistics collection class | cn.edu.tsinghua.iginx.statistics.StatisticsCollector |
| statisticsLogInterval | Statistics print interval, in milliseconds | 1000 |

When connecting to relational databases such as PostgreSQL and MySQL, you can configure the parameters of the HikariDataSource at `storageEngineList`

| Configuration Item | Description | Defalt |
|---------------------------|-----------------------------------------------------------------|--------|
| connection_timeout | Connection timeout (ms) | 30000 |
| idle_timeout | Idle connection timeout (ms) | 10000 |
| maximum_pool_size | The maximum number of connections in the connection pool | 20 |
| minimum_idle | Minimum number of idle connections in the connection pool | 1 |
| leak_detection_threshold | Threshold for detecting connection leaks (ms) | 2500 |
| prep_stmt_cache_size | Number of SQL precompiled objects cached | 250 |
| prep_stmt_cache_sql_limit | The upper limit of the number of SQL precompiled objects cached | 2048 |

#### Rest Configuration

| Configuration item | Description | Default value |
Expand Down
12 changes: 12 additions & 0 deletions docs/quickStarts/IGinXManual.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,18 @@ IGinX、Rest、元数据管理三方面配置。
| statisticsCollectorClassName | 统计信息收集类 | cn.edu.tsinghua.iginx.statistics.StatisticsCollector |
| statisticsLogInterval | 统计信息打印间隔,单位毫秒 | 1000 |

连接PostgreSQL、MySQL等关系数据库时,可在storageEngineList处配置HikariDataSource连接池的参数

| 配置项 | 描述 | 默认值 |
|---------------------------|------------------|-------|
| connection_timeout | 连接超时时间(单位:毫秒) | 30000 |
| idle_timeout | 空闲连接超时时间(单位:毫秒) | 10000 |
| maximum_pool_size | 连接池中的最大连接数 | 20 |
| minimum_idle | 连接池中的最小空闲连接数 | 1 |
| leak_detection_threshold | 检测连接泄漏的阈值(单位:毫秒) | 2500 |
| prep_stmt_cache_size | SQL预编译对象缓存个数 | 250 |
| prep_stmt_cache_sql_limit | SQL预编译对象缓存个数上限 | 2048 |

#### Rest 配置

| 配置项 | 描述 | 默认值 |
Expand Down

0 comments on commit 62076d1

Please sign in to comment.