server icon indicating copy to clipboard operation
server copied to clipboard

MDEV-32397, MDEV-32403 Crashes during join processing.

Open DaveGosselin-MariaDB opened this issue 10 months ago • 2 comments

Queries having the following form may cause a crash SELECT t1.a FROM ( SELECT a AS a1 FROM t1 ) dt JOIN t1 ON a1 LIKE EXISTS ( SELECT a + RAND () FROM t1 UNION SELECT a FROM t1); because the table t1 has some JOIN cleanup operations performed prematurely during the subselect.

In this particular case, the presence of RAND() makes the subquery uncacheable, necessitating the need to execute the subquery multiple times during join record evaluation. Each time the subquery runs, it creates its own JOIN structure which has references to the table t1. When the subquery completes, JOIN::cleanup and functions called by it result in ha_end_keyread() being called on table t1. However, we are not done with table t1 because the upper level select t1.a from... query requires table t1 to be open. To solve this, we make the executor aware of when we're in subqueries like this and delay JOIN cleanup until the end of the query.

DaveGosselin-MariaDB avatar Apr 03 '24 20:04 DaveGosselin-MariaDB

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Apr 03 '24 20:04 CLAassistant

... see the suggestion in : https://jira.mariadb.org/browse/MDEV-32403?focusedCommentId=284537&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-284537

spetrunia avatar May 06 '24 12:05 spetrunia