Skip to content

Commit 0598e36

Browse files
committed
new: make default max query timeout configurable
1 parent 102b419 commit 0598e36

File tree

7 files changed

+20
-8
lines changed

7 files changed

+20
-8
lines changed

deploy/docker/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Image can be configured by setting environment variables.
3737
| `ENCRYPTION_SALT` | Salt used for encrypting password | `lowcoder.org` |
3838
| `CORS_ALLOWED_DOMAINS` | CORS allowed domains | `*` |
3939
| `LOWCODER_MAX_REQUEST_SIZE` | Lowcoder max request size | `20m` |
40+
| `LOWCODER_MAX_QUERY_TIMEOUT` | Lowcoder max query timeout (in seconds) | `120` |
4041
| `LOWCODER_API_SERVICE_URL` | Lowcoder API service URL | `http://localhost:8080` |
4142
| `LOWCODER_NODE_SERVICE_URL` | Lowcoder Node service (js executor) URL | `http://localhost:6060` |
4243
| `DEFAULT_ORGS_PER_USER` | Default maximum organizations per user | `100` |
@@ -77,6 +78,8 @@ Image can be configured by setting environment variables.
7778
| `DEFAULT_ORG_GROUP_COUNT` | Default maximum groups per organization | `100` |
7879
| `DEFAULT_ORG_APP_COUNT` | Default maximum applications per organization | `1000` |
7980
| `DEFAULT_DEVELOPER_COUNT` | Default maximum developers | `100` |
81+
| `LOWCODER_MAX_QUERY_TIMEOUT` | Lowcoder max query timeout (in seconds) | `120` |
82+
| `LOWCODER_MAX_REQUEST_SIZE` | Lowcoder max request size | `20m` |
8083

8184

8285

@@ -122,6 +125,7 @@ Image can be configured by setting environment variables.
122125
| --------------------------------| --------------------------------------------------------------------| ------------------------------------------------------- |
123126
| `PUID` | ID of user running services. It will own all created logs and data. | `9001` |
124127
| `PGID` | ID of group of the user running services. | `9001` |
128+
| `LOWCODER_MAX_QUERY_TIMEOUT` | Lowcoder max query timeout (in seconds) | `120` |
125129
| `LOWCODER_MAX_REQUEST_SIZE` | Lowcoder max request size | `20m` |
126130
| `LOWCODER_API_SERVICE_URL` | Lowcoder API service URL | `http://localhost:8080` |
127131
| `LOWCODER_NODE_SERVICE_URL` | Lowcoder Node service (js executor) URL | `http://localhost:6060` |

deploy/docker/docker-compose-multi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ services:
3636
MONGODB_URL: "mongodb://lowcoder:secret123@mongodb/lowcoder?authSource=admin"
3737
REDIS_URL: "redis://redis:6379"
3838
LOWCODER_NODE_SERVICE_URL: "http://lowcoder-node-service:6060"
39+
LOWCODER_MAX_QUERY_TIMEOUT: 120
3940
ENABLE_USER_SIGN_UP: "true"
4041
ENCRYPTION_PASSWORD: "lowcoder.org"
4142
ENCRYPTION_SALT: "lowcoder.org"
@@ -76,6 +77,7 @@ services:
7677
PUID: "9001"
7778
PGID: "9001"
7879
LOWCODER_MAX_REQUEST_SIZE: 20m
80+
LOWCODER_MAX_QUERY_TIMEOUT: 120
7981
LOWCODER_API_SERVICE_URL: "http://lowcoder-api-service:8080"
8082
LOWCODER_NODE_SERVICE_URL: "http://lowcoder-node-service:6060"
8183
restart: unless-stopped

deploy/docker/docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ services:
3838
LOWCODER_NODE_SERVICE_URL: "http://localhost:6060"
3939
# frontend parameters
4040
LOWCODER_MAX_REQUEST_SIZE: 20m
41+
LOWCODER_MAX_QUERY_TIMEOUT: 120
4142
volumes:
4243
- ./lowcoder-stacks:/lowcoder-stacks
4344
restart: unless-stopped

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/query/service/QueryExecutionService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.lowcoder.domain.plugin.client.DatasourcePluginClient;
1717
import org.lowcoder.domain.plugin.service.DatasourceMetaInfoService;
1818
import org.lowcoder.domain.query.util.QueryTimeoutUtils;
19+
import org.lowcoder.sdk.config.CommonConfig;
1920
import org.lowcoder.sdk.exception.BizException;
2021
import org.lowcoder.sdk.exception.PluginException;
2122
import org.lowcoder.sdk.models.QueryExecutionResult;
@@ -40,10 +41,13 @@ public class QueryExecutionService {
4041
@Autowired
4142
private DatasourcePluginClient datasourcePluginClient;
4243

44+
@Autowired
45+
private CommonConfig common;
46+
4347
public Mono<QueryExecutionResult> executeQuery(Datasource datasource, Map<String, Object> queryConfig, Map<String, Object> requestParams,
4448
String timeoutStr, QueryVisitorContext queryVisitorContext) {
4549

46-
int timeoutMs = QueryTimeoutUtils.parseQueryTimeoutMs(timeoutStr, requestParams);
50+
int timeoutMs = QueryTimeoutUtils.parseQueryTimeoutMs(timeoutStr, requestParams, common.getMaxQueryTimeout());
4751
queryConfig.putIfAbsent("timeoutMs", timeoutMs);
4852

4953
return Mono.defer(() -> {

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/query/util/QueryTimeoutUtils.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
public final class QueryTimeoutUtils {
1818

1919
private static final int DEFAULT_QUERY_TIMEOUT_MILLIS = 10000;
20-
private static final int MAX_QUERY_TIMEOUT_SECONDS = 120;
2120

22-
public static int parseQueryTimeoutMs(String timeoutStr, Map<String, Object> paramMap) {
23-
return parseQueryTimeoutMs(renderMustacheString(timeoutStr, paramMap));
21+
public static int parseQueryTimeoutMs(String timeoutStr, Map<String, Object> paramMap, int maxQueryTimeout) {
22+
return parseQueryTimeoutMs(renderMustacheString(timeoutStr, paramMap), maxQueryTimeout);
2423
}
2524

2625
@VisibleForTesting
27-
public static int parseQueryTimeoutMs(String timeoutStr) {
26+
public static int parseQueryTimeoutMs(String timeoutStr, int maxQueryTimeout) {
2827
if (StringUtils.isBlank(timeoutStr)) {
2928
return DEFAULT_QUERY_TIMEOUT_MILLIS;
3029
}
@@ -44,10 +43,10 @@ public static int parseQueryTimeoutMs(String timeoutStr) {
4443
if (value < 0) {
4544
throw new PluginException(QUERY_ARGUMENT_ERROR, "INVALID_TIMEOUT_SETTING", timeoutStr);
4645
}
47-
46+
4847
int millis = convertToMs(value, unit);
49-
if (millis > Duration.ofSeconds(MAX_QUERY_TIMEOUT_SECONDS).toMillis()) {
50-
throw new PluginException(EXCEED_MAX_QUERY_TIMEOUT, "EXCEED_MAX_QUERY_TIMEOUT", MAX_QUERY_TIMEOUT_SECONDS);
48+
if (millis > Duration.ofSeconds(maxQueryTimeout).toMillis()) {
49+
throw new PluginException(EXCEED_MAX_QUERY_TIMEOUT, "EXCEED_MAX_QUERY_TIMEOUT", maxQueryTimeout);
5150
}
5251

5352
return millis;

server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/config/CommonConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class CommonConfig {
3535
private String version;
3636
private boolean blockHoundEnable;
3737
private String cookieName;
38+
private int maxQueryTimeout = 300;
3839
private String maxUploadSize = "20MB";
3940
private String maxQueryRequestSize = "20MB";
4041
private String maxQueryResponseSize = "20MB";

server/api-service/lowcoder-server/src/main/resources/selfhost/ce/application.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ common:
4444
max-query-request-size: ${LOWCODER_MAX_REQUEST_SIZE:20m}
4545
max-query-response-size: ${LOWCODER_MAX_REQUEST_SIZE:20m}
4646
max-upload-size: ${LOWCODER_MAX_REQUEST_SIZE:20m}
47+
max-query-timeout: ${LOWCODER_MAX_QUERY_TIMEOUT:120}
4748

4849
material:
4950
mongodb-grid-fs:

0 commit comments

Comments
 (0)