Commit 65f30050 authored by Varun Gupta's avatar Varun Gupta

MDEV-18335: Assertion `!error || error == 137' failed in subselect_rowid_merge_engine::init

When duplicates are removed from a table using a hash, if the record is a duplicate it is marked
as deleted. The handler API check if the record is deleted and send an error flag HA_ERR_RECORD_DELETED.
When we scan over the table if the thread is not killed then we skip the
records marked as HA_ERR_RECORD_DELETED.

The issue here is when a query is aborted by a user (this is happening when the LIMIT for ROWS EXAMINED
is exceeded), the scan over the table does not skip the records for which HA_ERR_RECORD_DELETED is sent.
It just returns an error flag HA_ERR_ABORTED_BY_USER.
This error flag is not checked at the upper level and hence we hit the assert.
If the query is aborted by the user we should just skip reading rows and return
control to the upper levels of execution.
parent 95831888
...@@ -2686,4 +2686,35 @@ SELECT * FROM t2; ...@@ -2686,4 +2686,35 @@ SELECT * FROM t2;
f f
bar bar
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# MDEV-18335: Assertion `!error || error == 137' failed in subselect_rowid_merge_engine::init
#
CREATE TABLE t1 (i1 int,v1 varchar(1),KEY (v1,i1));
INSERT INTO t1 VALUES
(9,'y'),(4,'q'),(0,null),(0,'p'),(null,'j');
CREATE TABLE t2 (pk int);
INSERT INTO t2 VALUES (1),(2);
CREATE TABLE t3 (v2 varchar(1));
INSERT INTO t3 VALUES
('p'),('j'),('y'),('q');
CREATE TABLE t4 (v2 varchar(1));
INSERT INTO t4 VALUES
('a'),('a'),('b'),('b'),('c'),('c'),
('d'),('d'),('e'),('e'),('f'),('f'),
('g'),('g'),('h'),('h'),('i'),('i'),
('j'),('j'),('k'),('k'),('l'),('l'),
('m'),('m'),('n'),('n'),('o'),('o'),
('p'),('p'),('q'),('q'),('r'),('r'),
('s'),('s'),('t'),('t'),('u'),('u'),('v'),('v'),
('w'),('w'),('x'),('x'), (NULL),(NULL);
SET @save_join_cache_level=@@join_cache_level;
SET join_cache_level=0;
select 1
from t2 join t1 on
('i','w') not in (select t1.v1,t4.v2 from t4,t1,t3 where t3.v2 = t1.v1) LIMIT ROWS EXAMINED 500;
1
Warnings:
Warning 1931 Query execution was interrupted. The query examined at least 3020 rows, which exceeds LIMIT ROWS EXAMINED (500). The query result may be incomplete
SET join_cache_level= @save_join_cache_level;
DROP TABLE t1,t2,t3,t4;
# End of 10.2 tests # End of 10.2 tests
...@@ -2201,4 +2201,40 @@ SELECT * FROM t2; ...@@ -2201,4 +2201,40 @@ SELECT * FROM t2;
DROP TABLE t1, t2; DROP TABLE t1, t2;
--echo #
--echo # MDEV-18335: Assertion `!error || error == 137' failed in subselect_rowid_merge_engine::init
--echo #
CREATE TABLE t1 (i1 int,v1 varchar(1),KEY (v1,i1));
INSERT INTO t1 VALUES
(9,'y'),(4,'q'),(0,null),(0,'p'),(null,'j');
CREATE TABLE t2 (pk int);
INSERT INTO t2 VALUES (1),(2);
CREATE TABLE t3 (v2 varchar(1));
INSERT INTO t3 VALUES
('p'),('j'),('y'),('q');
CREATE TABLE t4 (v2 varchar(1));
INSERT INTO t4 VALUES
('a'),('a'),('b'),('b'),('c'),('c'),
('d'),('d'),('e'),('e'),('f'),('f'),
('g'),('g'),('h'),('h'),('i'),('i'),
('j'),('j'),('k'),('k'),('l'),('l'),
('m'),('m'),('n'),('n'),('o'),('o'),
('p'),('p'),('q'),('q'),('r'),('r'),
('s'),('s'),('t'),('t'),('u'),('u'),('v'),('v'),
('w'),('w'),('x'),('x'), (NULL),(NULL);
SET @save_join_cache_level=@@join_cache_level;
SET join_cache_level=0;
select 1
from t2 join t1 on
('i','w') not in (select t1.v1,t4.v2 from t4,t1,t3 where t3.v2 = t1.v1) LIMIT ROWS EXAMINED 500;
SET join_cache_level= @save_join_cache_level;
DROP TABLE t1,t2,t3,t4;
--echo # End of 10.2 tests --echo # End of 10.2 tests
...@@ -6281,6 +6281,9 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts, ...@@ -6281,6 +6281,9 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts,
while (TRUE) while (TRUE)
{ {
error= tmp_table->file->ha_rnd_next(tmp_table->record[0]); error= tmp_table->file->ha_rnd_next(tmp_table->record[0]);
if (error == HA_ERR_ABORTED_BY_USER)
break;
/* /*
This is a temp table that we fully own, there should be no other This is a temp table that we fully own, there should be no other
cause to stop the iteration than EOF. cause to stop the iteration than EOF.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment