[MDEV-28404] JSON functions don't respect KILL QUERY / max_statement_time limit #2 Created: 2022-04-24  Updated: 2023-03-03

Status: Open
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8
Fix Version/s: 10.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-24909 JSON functions don't respect KILL QUE... Closed

 Description   

The fix for MDEV-24909 is in the main branches now, however same problem still affects various JSON-related queries/functions.

For example,

--source include/have_sequence.inc
 
--connect (con1,localhost,root,,)
 
set max_statement_time= 5;
select concat('{',group_concat(concat('"seq',seq,'":',seq)),'}') into @json from seq_1_to_50000;
--let $conid= `select connection_id()`
 
send
SELECT JSON_CONTAINS(@json, @json);
 
--connection default
sleep 2;
show processlist;
sleep 5;
show processlist;
sleep 5;
show processlist;
 
--connection con1
--reap

Shows this

10.6 fae0ccad non-debug

show processlist;
Id	User	Host	db	Command	Time	State	Info	Progress
4	root	localhost	test	Query	0	starting	show processlist	0.000
5	root	localhost	test	Query	2	Executing	SELECT JSON_CONTAINS(@json, @json)	0.000
show processlist;
Id	User	Host	db	Command	Time	State	Info	Progress
4	root	localhost	test	Query	0	starting	show processlist	0.000
5	root	localhost	test	Killed	7	Executing	SELECT JSON_CONTAINS(@json, @json)	0.000
show processlist;
Id	User	Host	db	Command	Time	State	Info	Progress
4	root	localhost	test	Query	0	starting	show processlist	0.000
5	root	localhost	test	Killed	12	Executing	SELECT JSON_CONTAINS(@json, @json)	0.000

Same with explicit KILL instead of max_statement_time.

It doesn't hang, the server keeps processing the query at 100% CPU and eventually responds, but it takes the same time as it does if the query is executed without interruption (on my machine, it's ~1.5 min on a non-debug 10.6 build and ~3.5 min on debug).

It's scalable, depending on the size of the JSON documents involved. Increase the number of rows selected from the sequence table if it's too fast on your machine. Watch for group_concat_max_len, you may need to set it to a non-default value if the number of rows is increased.

Set fix version to 10.6 because MDEV-24909 was fixed in 10.6.


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