[MDEV-16867] Recursive query leads to endless execution or server crash Created: 2018-07-31  Updated: 2018-08-13  Resolved: 2018-08-03

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

Type: Bug Priority: Blocker
Reporter: Radek Wikturna Assignee: Alice Sherepa
Resolution: Duplicate Votes: 0
Labels: None
Environment:

Java 8, Windows 10, 16GB RAM, SSD disk, JDBC driver mariadb-java-client-2.1.0


Attachments: File TEST.sql     PNG File task manager.png    
Issue Links:
Duplicate
duplicates MDEV-15840 Recursive query using temp table rand... Closed
Relates
relates to MDEV-12556 Possible performance problem with rec... Closed

 Description   

Execution of the recursive query below leads to one of the possible outcomes:
a) query execution seems to be endless (I waited no more than 20 minutes) while CPU, memory and disk usage is high (see attached screenshot)
...and sometimes the exectiuon leads to the crash of the server!!! The mysqld service was stopped and I had to start it up.
b) the following exception occurs almost immediatelly :
java.sql.SQLException: (conn:1608) (conn:1608) Out of memory (Needed 2327021592 bytes)
c) the following exception occurs after several seconds:
error code 1815, java.sql.SQLException: (conn:1626) (conn:1626) Internal error: Using too big key for internal temp tables

The query is:
with recursive query(ID, PARENT_ID, `TEXT`, DESCRIPTION) as (
select CD0T0.ID, CD0T0.PARENT_ID, CD0T0.TEXT, CD0T0.DESCRIPTION
FROM TEST CD0T0 where CD0T0.TEXT = 'vehicle' and CD0T0.PARENT_ID IS NULL
union all
select CD0T0.ID, CD0T0.PARENT_ID, CD0T0.TEXT, CD0T0.DESCRIPTION
from TEST CD0T0, query
where CD0T0.PARENT_ID = query.ID)
select *
from query

The column TEXT is varchar(100), the column DESCRIPTION is longtext.
The complete table defintion and data is an an attached file.

The problem does not occur when the DESCRIPTION column is ommittted from the query - it returns the 8 rows almost instantly.

The problem depends on the data somehow. Without the mass data (I had 22000+ records), the problem doesn't occur.

I thought it could be the same problem as MDEV-12556, but that one should be solved in 10.2.



 Comments   
Comment by Radek Wikturna [ 2018-07-31 ]

Note to MDEV-12556:
When I created the test table and executed both queries (with or without the c2 column), both executed in a few miliseconds. This means that that bug has been shomehow fixed.
However something in my table structure and data still leads to a massive perfomance problem.

Comment by Alice Sherepa [ 2018-08-03 ]

Thanks for the report! It is the same problem as MDEV-15840 ( MDEV-15556), that was fixed in 10.2.15
I will close as a duplicate, but please reopen if you get similar problem after version 10.2.15

Comment by Radek Wikturna [ 2018-08-10 ]

I've retested with 10.2.16 and its seems to be OK.
Does the problem affect the 10.3 line? If so, which exact version and which version contains the fix?
In MDEV-15556 it says that 10.3 is affected too, but it's not listed as fixed.

Comment by Alice Sherepa [ 2018-08-13 ]

I added the fix version (10.3.7) for MDEV-15556, thanks!

Generated at Thu Feb 08 08:32:09 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.