Bug #99459 | SQL run with GROUP_MIN_MAX may infinite loop and never return | ||
---|---|---|---|
Submitted: | 6 May 2020 8:17 | Modified: | 8 May 2020 13:21 |
Reporter: | Ze Yang (OCA) | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.6,5.7,8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[6 May 2020 8:17]
Ze Yang
[6 May 2020 13:51]
MySQL Verification Team
Hi Mr. Yang, Thank you for your bug report. However, we do have additional questions and requests. First of all, have you been able to repeat this behaviour without DEBUG_SYNC. If you are able to, we would like to see a simple test case where that GROUP BY query takes a very, very long time to execute. If it would require to run the tests 10 times, or with some other query in parallel, please let us know. Simply, our users do not add DEBUG_SYNC, so we need a repeatable test case without it. Second, have you tried latest 8.0 release, 8.0.20 ??? We are eagerly awaiting your answers.
[7 May 2020 6:05]
Ze Yang
This is the testcase without add DEBUG_SYNC ``` create table t(c1 int, c2 int, c3 int, c4 int, key(c1, c2, c3)); delimiter //; CREATE PROCEDURE BatchInsert(IN begin INT, IN end INT, IN name VARCHAR(10)) BEGIN SET @insert_stmt = concat('INSERT INTO ', name, ' VALUES(?, ?, ?, ?);'); PREPARE stmt from @insert_stmt; WHILE begin <= end DO SET @ID1 = begin; EXECUTE stmt using @ID1, @ID1, @ID1, @ID1; SET begin = begin + 1; END WHILE; END; // delimiter ;// CALL BatchInsert(1, 20000, 't'); analyze table t; set transaction_isolation='read-uncommitted'; set debug = '+d,force_lis_for_group_by'; explain select c1, max(c3) from t where c2 = 6 group by c1; --send select c1, max(c3) from t where c2 = 6 group by c1; connect(con1,localhost,root,,test,,); connection con1; --echo # Switch to connection con1 select sleep(0.03); delete from t where c1 = 20000; connection default; --reap ```
[7 May 2020 6:06]
Ze Yang
And the latest 8.0 release(8.0.20) version still have this problem.
[7 May 2020 13:41]
MySQL Verification Team
Hi Mr. Yang, I have ran your test and it ran beautifully. The only change I did is to comment out the debug line. Again, we need a test case without such intervention, since we can not verify a bug where we need to raise some control flags, which does not happen in the near world. This does not look like a bug to me.
[8 May 2020 8:17]
Ze Yang
This is the test case without DEBUG line. And you can run it with release version. ``` create table t(c1 int, c2 int, c3 int, c4 int, key(c1, c2, c3)); delimiter //; CREATE PROCEDURE BatchInsert(IN begin INT, IN end INT, IN name VARCHAR(10)) BEGIN SET @insert_stmt = concat('INSERT INTO ', name, ' VALUES(?/20, ?, ?, ?);'); PREPARE stmt from @insert_stmt; WHILE begin <= end DO SET @ID1 = begin; EXECUTE stmt using @ID1, @ID1, @ID1, @ID1; SET begin = begin + 1; END WHILE; END; // delimiter ;// CALL BatchInsert(1, 100000, 't'); insert into t select * from t; insert into t select * from t; analyze table t; set transaction_isolation='read-uncommitted'; explain select c1, max(c3) from t where c2 = 600000 group by c1; --send select c1, max(c3) from t where c2 = 600000 group by c1; connect(con1,localhost,root,,test,,); connection con1; --echo # Switch to connection con1 select sleep(0.01); delete from t where c1 = 100000/20; connection default; --reap ``` By the way, in your opinion what's the meaning of debug code in MySQL source code and DEBUG line in MySQL mtr cases.
[8 May 2020 13:21]
MySQL Verification Team
Hi Mr. Yang, I have run your test case. I have changed debug sync timeout to 3600 seconds and I ran your test case. After one hour, timeout has expired. Hence, I conclude that there is definitely a problem in the code, so I am verifying this report, alas, with lower severity. Debug code is there for testing only, or for debugging with debug binaries. This is not a pice of code that is utilised in any manner in the production. Verified as an optimiser bug.