[MDEV-28860] `set @@SQL_SELECT_LIMIT=...` will case the query gets stuck forever Created: 2022-06-16  Updated: 2022-08-02  Resolved: 2022-08-02

Status: Closed
Project: MariaDB Server
Component/s: N/A
Affects Version/s: 10.6.7
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Xiaoguang Wang Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Debian



 Description   

And something more troublesome:

I have many similar tables which are generated by archiver monthly, this bug ONLY occurs on two recent tables but not the old ones, although all these tables have exactly the same structure (all created by `CREATE TABLE LIKE`) and more or less the same amount data.

-- setting the SQL_SELECT_LIMIT will cause some queries get stuck (only a few, not all)
MariaDB [the_db]> set @@SQL_SELECT_LIMIT=2000;
Query OK, 0 rows affected (0.000 sec)
 
-- BUG!! then this query gets stuck forever, SQL_SELECT_LIMIT=2000 or 20000 or 200000 makes the same result.
MariaDB [the_db]> with t as ( select * from the_table where client_ip like '183.89.%' )  select count(*) from t group by username;
^C Ctrl-C -- query killed. Continuing normally.
ERROR 1317 (70100): Query execution was interrupted
 
-- however, the simple query runs without bug
MariaDB [the_db]> select * from the_table where client_ip like '183.89.%';
+----------+
...
+----------+
80 rows in set (0.035 sec)
 
 
-- then, reset the SQL_SELECT_LIMIT, everything works fine again.
MariaDB [the_db]> set @@SQL_SELECT_LIMIT=default;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [the_db]> with t as ( select * from the_table where client_ip like '183.89.%' )  select count(*) from t group by username;
+----------+
| count(*) |
+----------+
|        2 |
......
+----------+
17 rows in set (0.026 sec)



 Comments   
Comment by Xiaoguang Wang [ 2022-06-16 ]

Surprisingly, after I do the `create table like / insert into ... select ...` to create a new table, the problem disappears ........

Comment by Elena Stepanova [ 2022-07-25 ]

Did you try to run CHECK on the tables? Are there any errors in the error log?

Comment by Xiaoguang Wang [ 2022-07-26 ]

Nothing in error log. I haven't tried CHECK. At that time, after the recreation of the table, I can not reproduce the bug.

Feel free to close the issue if there is no more clue (ps: although I still think there is something wrong .... the single SELECT works but the WITH CTE query fails)

Generated at Thu Feb 08 10:04:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.