Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max_execution_time compatibility issues #30175

Open
glkappe opened this issue Nov 26, 2021 · 4 comments
Open

max_execution_time compatibility issues #30175

glkappe opened this issue Nov 26, 2021 · 4 comments

Comments

@glkappe
Copy link

glkappe commented Nov 26, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

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>
@glkappe glkappe added the type/bug This issue is a bug. label Nov 26, 2021
@bb7133
Copy link
Member

bb7133 commented Nov 26, 2021

The current behavior of max_execution_time is by design(not a bug), I will treat it as an enhancement.

@shellderp
Copy link

To me it is a feature that max_execution_time applies to update and delete, not only select. It is a dangerous implementation in MySQL. That said, maybe perfect compatibility is more important.

@morgo
Copy link
Contributor

morgo commented Nov 30, 2021

To me it is a feature that max_execution_time applies to update and delete, not only select. It is a dangerous implementation in MySQL. That said, maybe perfect compatibility is more important.

MySQL implements MVCC differently, so rolling back a statement can be something like 30x more expensive than the corresponding apply. If the limit applied to all statements, there is a high risk that under some loads DMLs could hit the threshold and effectively DoS the server.

Since TiDB does not have this issue, I think it is quite a reasonable feature extension. But we can perhaps leave this open as a feature request and if there is a lot of user feedback, we can change it.

@mjonss
Copy link
Contributor

mjonss commented Dec 1, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants