Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 提问一个问题tidb如何处理
[TiDB Usage Environment] Production Environment / Testing / Poc
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
I set max-execution-time=2000
Now DDL reports an error. How can I prevent DDL from being affected?
[Encountered Issue: Issue Symptoms and Impact]
[Resource Configuration]
[Attachments: Screenshots / Logs / Monitoring]
Modify it at the session level and then execute the DDL?
This parameter also affects DDL, which feels a bit unreasonable. It should only target DML. It would be better if there were parameters to control whether it takes effect for DDL. You can provide feedback or raise an issue. Temporarily increase it during DDL operations.
opened 08:39AM - 26 Nov 21 UTC
type/enhancement
type/compatibility
sig/sql-infra
## Bug Report
Please answer these questions before submitting your issue. Tha… nks!
### 1. Minimal reproduce step (Required)
The first point:Does not take effect for ddl statements
# run long time, it > max_execution_time
```
mysql> alter table sbtest1 add index idx_aa(id,c,pad);
^@ERROR 1317 (70100): Query execution was interrupted
mysql> select @@max_execution_time;
+----------------------+
| @@max_execution_time |
+----------------------+
| 1000 |
+----------------------+
1 row in set (0.03 sec)
mysql> admin show ddl jobs;
+--------+---------+---------------------+---------------+--------------+-----------+----------+-----------+---------------------+---------------------+--------+
| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | START_TIME | END_TIME | STATE |
+--------+---------+---------------------+---------------+--------------+-----------+----------+-----------+---------------------+---------------------+--------+
| 123 | test | sbtest1 | add index | public | 1 | 71 | 1600007 | 2021-11-24 02:35:08 | 2021-11-24 02:37:27 | synced |
+--------+---------+---------------------+---------------+--------------+-----------+----------+-----------+---------------------+---------------------+--------+
10 rows in set (0.05 sec)
mysql> show create table sbtest1;
+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| sbtest1 | CREATE TABLE `sbtest1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`k` int(11) NOT NULL DEFAULT '0',
`c` char(120) NOT NULL DEFAULT '',
`pad` char(60) NOT NULL DEFAULT '',
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
KEY `k_1` (`k`),
KEY `idx_aa` (`id`,`c`,`pad`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=8691384 |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.03 sec)
mysql>
```
secondy point:
This may affect the normal execution of other sql, it is recommended to only leave the select, consistent with mysql
```
mysql> set max_execute_time = 2;
ERROR 1193 (HY000): Unknown system variable 'max_execute_time'
mysql> set max_execution_time = 2;
Query OK, 0 rows affected (0.00 sec)
mysql> analyze table test.sbtest1;
ERROR 1317 (70100): Query execution was interrupted
mysql>
```
If you want to restrict the application, it is recommended to configure variable set in JDBC.
Check the official website, the unit is milliseconds. If the DDL time exceeds 2 seconds, an error will be reported.
MAX_EXECUTION_TIME(N)
limits the execution time of the statement to within N
milliseconds. If it times out, the server will terminate the execution of the statement.
The following Hint sets a timeout of 1000 milliseconds (i.e., 1 second):
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.