[MDEV-16086] Recursive CTE Hangs Created: 2018-05-03 Updated: 2018-05-09 Resolved: 2018-05-09 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer - CTE |
| Affects Version/s: | 10.2.14 |
| Fix Version/s: | 10.2.15 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Bryce Lowe | Assignee: | Igor Babaev |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Environment: |
CentOS VMware virtual machine running MariaDB 10.2.14 |
||
| Description |
|
I am attempting to use the recursive common table expressions to explode a bill of materials, however I am running into a problem where the MariaDB server hangs and eventually fills up the disk if left unchecked, even though there are not any circular references in this expression. See the following example: 1. Table to hold the bom
2. Add some dummy entries that represent a part/child product structure
3. Attempt to run a recursive common table expression with a path using cast to avoid data truncation. In this query the Path column is created as TEXT because of the CAST to CHAR(513), it never seems to complete and eventually fills the disk.
4. Attempt to run a recursive common table expression with a path using cast to avoid data truncation. This query the Path column is created as VARCHAR(512) because of the CAST to CHAR(512) and DOES complete.
In this particular example the query just continues executing, even though there aren't any circular references. As I mention in the reproduction steps, I believe I have narrowed down part of the issue to the datatype that the Path column eventually becomes. When you CAST the path to anything over CHAR(512) the column type switches from VARCHAR to TEXT, once that happens the never completes. However if you cast to CHAR(512) and below you get the expected result and the Path column is VARCHAR. In my particular use case, the column must be text as the path gets very long and is key to not only detecting circular references, but also drawing the indented version of the bill of materials. |
| Comments |
| Comment by Alice Sherepa [ 2018-05-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the report, reproducible as described on 10.2-10.3 1) datatype CHAR(M), the range of M is 0 to 255. (https://mariadb.com/kb/en/library/char/), then why CHAR(512) works 2) casting to CHAR(513), result type is text, while for CHAR(512) it is varchar(512) (MariaDB 5.5 - 10.3)
3) Query with recursive CTE hangs due to truncating of types.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-05-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This bug cannot be reproduced on the current 10.2 development tree because it was actually fixed by the patch for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-05-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This bug was fixed by the patch for |