MySQL 可以运行的计划事件的“实例”数量是否有限制?我已经设置好了:
CREATE TABLE IF NOT EXISTS t (c1 INT UNSIGNED NOT NULL) ENGINE=INNODB;
SELECT * FROM t;
DELIMITER $$
DROP EVENT IF EXISTS e_second;
CREATE EVENT e_second ON SCHEDULE EVERY 1 SECOND
DO BEGIN
INSERT INTO t (c1) VALUES (UNIX_TIMESTAMP());
SELECT SLEEP(1000);
INSERT INTO t (c1) VALUES (UNIX_TIMESTAMP());
END$$
DELIMITER ;
SELECT * FROM t;
SHOW PROCESSLIST;
SHOW VARIABLES LIKE '%connect%';
这会创建一个每秒启动的哑事件,运行时间为 1000 秒。在我的查询日志中,我确实有:
2020-02-18T15:47:00.289050Z 1016 Query INSERT INTO t (c1) VALUES (UNIX_TIMESTAMP())
2020-02-18T15:47:00.430801Z 1216 Query INSERT INTO t (c1) VALUES (UNIX_TIMESTAMP())
2020-02-18T15:47:00.430950Z 1216 Query SELECT SLEEP(200)
2020-02-18T15:47:01.290518Z 1017 Query INSERT INTO t (c1) VALUES (UNIX_TIMESTAMP())
2020-02-18T15:47:01.430943Z 1217 Query INSERT INTO t (c1) VALUES (UNIX_TIMESTAMP())
...
所以事件每秒运行一次,并挂起(故意)。现在,进程列表显示(过了一会儿):
"559" "root-heidisql" "127.0.0.1" "test_sql" "Connect" "702" "User sleep" "SELECT SLEEP(1000)"
"560" "root-heidisql" "127.0.0.1" "test_sql" "Connect" "701" "User sleep" "SELECT SLEEP(1000)"
"561" "root-heidisql" "127.0.0.1" "test_sql" "Connect" "700" "User sleep" "SELECT SLEEP(1000)"
"562" "root-heidisql" "127.0.0.1" "test_sql" "Connect" "699" "User sleep" "SELECT SLEEP(1000)"
"563" "root-heidisql" "127.0.0.1" "test_sql" "Connect" "698" "User sleep" "SELECT SLEEP(1000)"
...
所以我现在在这个进程列表中有大约 528 行。但是,我的连接限制151
如显示变量所示:
"max_connections" "151"
很明显,正在运行的事件不是连接限制的一部分。那么,极限是多少?有吗?
在我看来,在某些时候,一些 mysql 队列/列表/任何东西都会充满未决事件......这个案例是否记录在某个地方?