imbajin commented on code in PR #704:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/pull/704#discussion_r2704456982
##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/executor/LoadOptions.java:
##########
@@ -406,9 +425,31 @@ public static LoadOptions parseOptions(String[] args) {
options.maxParseErrors = Constants.NO_LIMIT;
options.maxInsertErrors = Constants.NO_LIMIT;
}
Review Comment:
⚠️ **Important - 连接池自动调整逻辑不完整**
`adjustConnectionPoolIfDefault` 只在 `batchInsertThreads != CPUS` 时触发,但存在以下问题:
**场景分析:**
1. 用户未设置 `batch-insert-threads`,使用默认值 CPUS
2. 用户设置了 `max-conn=100`,期望使用自定义值
3. 由于 `batchInsertThreads == CPUS`,调整逻辑不执行
4. 即使 `maxConnections(100) < batchThreads(CPUS) * 4`,也不会调整
**根本问题:**
当前逻辑假设:"如果用户改了 batch-insert-threads,就可能需要调整连接池"
实际应该:"如果连接池是默认值且不足以支撑 batch-insert-threads,就调整"
**建议修复:**
```suggestion
private static void adjustConnectionPoolIfDefault(LoadOptions options) {
int batchThreads = options.batchInsertThreads;
int maxConn = options.maxConnections;
int maxConnPerRoute = options.maxConnectionsPerRoute;
// 只有当连接池配置是默认值,且小于推荐值时才调整
if (maxConn == DEFAULT_MAX_CONNECTIONS && maxConn < batchThreads *
4) {
options.maxConnections = batchThreads * 4;
LOG.info("Auto adjusted max-conn to {} based on " +
"batch-insert-threads({})",
options.maxConnections, batchThreads);
}
if (maxConnPerRoute == DEFAULT_MAX_CONNECTIONS_PER_ROUTE &&
maxConnPerRoute < batchThreads * 2) {
options.maxConnectionsPerRoute = batchThreads * 2;
LOG.info("Auto adjusted max-conn-per-route to {} based on " +
"batch-insert-threads({})",
options.maxConnectionsPerRoute, batchThreads);
}
}
```
并修改调用处:
```java
// 始终检查是否需要调整连接池
adjustConnectionPoolIfDefault(options);
```
**需要测试:**
1. 默认 batch-insert-threads(=CPUS),验证连接池是否正确调整
2. 自定义 max-conn,验证不会被覆盖
3. 自定义 batch-insert-threads,验证连接池按新值调整
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]