Skip to content

Commit 32a58c8

Browse files
MDEV-35420 Server aborts while deleting the record in spatial index
- InnoDB spatial index keep track of all active r-tree search cursor. While deleting a record from the index, spatial index discards the page present in the active r-tree search cursor. rtr_check_discard_page() have the assumption that all active r-tree cursor should point to shadow block for the matched records. If the cursor was opened when the table is empty then there won't be any shadow block.
1 parent 652f33e commit 32a58c8

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

mysql-test/suite/innodb_gis/r/rollback.result

+21
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,24 @@ update t1 set a=point(5,5), b=point(5,5), c=5 where i < 3;
412412
ERROR HY000: Lost connection to server during query
413413
insert into t1 values(5, point(5,5), point(5,5), 5);
414414
drop table t1;
415+
#
416+
# MDEV-35420 Server aborts while deleting the record
417+
# in spatial index
418+
#
419+
CREATE TABLE t1 (c POINT NOT NULL, SPATIAL(c)) engine=InnoDB;
420+
CHECK TABLE t1;
421+
Table Op Msg_type Msg_text
422+
test.t1 check status OK
423+
INSERT INTO t1 VALUES(ST_GeomFromText('POINT(114368751 656950466)'));
424+
BEGIN;
425+
INSERT INTO t1 SELECT * FROM t1;
426+
INSERT INTO t1 SELECT * FROM t1;
427+
INSERT INTO t1 SELECT * FROM t1;
428+
INSERT INTO t1 SELECT * FROM t1;
429+
INSERT INTO t1 SELECT * FROM t1;
430+
INSERT INTO t1 SELECT * FROM t1;
431+
INSERT INTO t1 SELECT * FROM t1;
432+
INSERT INTO t1 SELECT * FROM t1;
433+
INSERT INTO t1 SELECT * FROM t1;
434+
ROLLBACK;
435+
DROP TABLE t1;

mysql-test/suite/innodb_gis/t/rollback.test

+20
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,23 @@ update t1 set a=point(5,5), b=point(5,5), c=5 where i < 3;
475475
insert into t1 values(5, point(5,5), point(5,5), 5);
476476

477477
drop table t1;
478+
479+
--echo #
480+
--echo # MDEV-35420 Server aborts while deleting the record
481+
--echo # in spatial index
482+
--echo #
483+
CREATE TABLE t1 (c POINT NOT NULL, SPATIAL(c)) engine=InnoDB;
484+
CHECK TABLE t1;
485+
INSERT INTO t1 VALUES(ST_GeomFromText('POINT(114368751 656950466)'));
486+
BEGIN;
487+
INSERT INTO t1 SELECT * FROM t1;
488+
INSERT INTO t1 SELECT * FROM t1;
489+
INSERT INTO t1 SELECT * FROM t1;
490+
INSERT INTO t1 SELECT * FROM t1;
491+
INSERT INTO t1 SELECT * FROM t1;
492+
INSERT INTO t1 SELECT * FROM t1;
493+
INSERT INTO t1 SELECT * FROM t1;
494+
INSERT INTO t1 SELECT * FROM t1;
495+
INSERT INTO t1 SELECT * FROM t1;
496+
ROLLBACK;
497+
DROP TABLE t1;

storage/innobase/gis/gis0sea.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,8 @@ rtr_check_discard_page(
15651565
if (auto matches = rtr_info->matches) {
15661566
mysql_mutex_lock(&matches->rtr_match_mutex);
15671567

1568-
if (matches->block->page.id() == id) {
1568+
if (matches->block &&
1569+
matches->block->page.id() == id) {
15691570
matches->matched_recs->clear();
15701571
matches->valid = false;
15711572
}

0 commit comments

Comments
 (0)