mariadb/mysql-test/suite/innodb_gis/t
Thirunarayanan Balathandayuthapani 413c59db32 MDEV-27675 Incorrect r-tree split after group assignment causes page overflow
Problem:
========
- When an R-tree root page becomes full and requires splitting,
InnoDB follows a specific root-raising procedure to maintain
tree integrity. The process involves allocating a new page
(Page X) to hold the current root's content, preserving the
original root page number as the tree's entry point, and
migrating all existing records to Page X.

The root page is then cleared and reconstructed as an
internal node containing a single node pointer with an
MBR that encompasses all spatial objects on Page X.
Subsequently, InnoDB should split the records on Page X
into two spatially optimized groups using the
pick_seeds() and pick_next() algorithms,
creating a second page (Page Y) for Group B records
while retaining Group A records on Page X.

After records are redistributed between Page X and Page Y,
the recalculated MBR for Page X must remain within
or be smaller than the original MBR stored in the
root page's node pointer.

Bug scenario:
============
- When root page 4 becomes full, it triggers a split operation
where the content is copied to page 7 and root page 4 is cleared
to become an internal node.
- During the first split attempt on page 7, Group 1 overflows
and remaining entries are reassigned to Group 2.
- A new page 8 is created and the remaining entry record
is inserted, but the combined size of the remaining entry
record and new record exceeds the page size limit.
- This triggers a second split operation on page 7, where
Group 2 overflows again and entries are moved back to Group 1.
- When the new record is finally inserted into page 7,
it causes the MBR (Minimum Bounding Rectangle) for page 7
to expand beyond its original boundaries.
- Subsequently, when InnoDB attempts to update the parent
page 4 with the new MBR information, it fails to locate
the corresponding internal node, leading to spatial
index corruption and the reported failure.

Problem:
========
- Second split operation should happen on page 8, not on page 7.
- split_rtree_node() considers key_size to estimate
record sizes during the splitting algorithm, which fails to
account for variable-length fields in spatial records.
- In rtr_page_split_and_insert(), when reorganization
succeeds, InnoDB doesn't attempt the insert the entry

Solution:
========
rtr_page_split_and_insert(): InnoDB should do insert the
tuple when btr_page_reorganize() is successful.

rtr_page_split_and_insert(): Use the overflow page
for consecutive split operation.

split_rtree_node(): Store the record length for each
record in r-tree node. This should give proper
estimation while determining the group entries and
also helpful in overflow validation
2025-10-23 07:16:26 +03:00
..
0.test MDEV-31003: Second execution for ps-protocol 2023-07-26 17:15:00 +07:00
1.test Merge branch '10.5' into 10.6 2025-01-29 11:17:38 +01:00
alter_spatial_index.test Merge 10.5 into 10.6 2022-11-08 17:37:22 +02:00
bug16236208.test MDEV-13467: Feature request: Support for ST_Distance_Sphere() 2021-03-27 10:42:39 +01:00
bug16266012.test MDEV-14057 InnoDB GIS tests fail. 2020-03-18 13:55:21 +04:00
bug17057168.test MariaDB adjustments to innodb_gis tests. 2017-10-25 06:47:08 +03:00
check_rtree.test
create_spatial_index.test Merge 10.5 into 10.6 2021-03-31 12:04:50 +03:00
geometry.test Merge branch '10.5' into 10.6 2024-07-18 16:25:33 +02:00
gis.test Merge 10.5 into 10.6 2024-10-03 09:31:39 +03:00
gis_split_inf.test MDEV-14057 InnoDB GIS tests fail. 2020-03-18 13:55:21 +04:00
gis_split_nan.test MDEV-21678 innodb_gis.gis_split_nan fails with ER_CANT_CREATE_GEOMETRY_OBJECT 2023-09-11 08:12:58 +03:00
innodb_gis_rtree.test Create 'main' test directory and move 't' and 'r' there 2018-03-29 13:59:44 +03:00
kill_server.test Adjust tests after commit b5615eff0d 2019-04-02 11:03:28 +03:00
multi_pk.test MSAN: Disable some slow tests 2022-06-30 13:00:58 +03:00
point_basic.test MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent 2021-08-31 13:55:02 +03:00
point_big.test MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent 2021-08-31 13:55:02 +03:00
precise.test Merge 10.2 into 10.3 2021-03-31 08:01:03 +03:00
repeatable_spatial.test MDEV-13626: Merge InnoDB test cases from MySQL 5.7 2017-10-25 06:47:08 +03:00
rollback.test MDEV-35420 Server aborts while deleting the record in spatial index 2025-03-21 15:26:21 +01:00
rt_precise.test MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent 2021-08-31 13:55:02 +03:00
rtree.test MDEV-35116 InnoDB fails to set error index for HA_ERR_NULL_IN_SPATIAL 2024-10-14 14:28:24 +05:30
rtree_add_index.test MDEV-32050 fixup: Stabilize tests 2023-11-21 12:42:00 +02:00
rtree_compress.test MDEV-32050 fixup: Stabilize tests 2023-11-21 12:42:00 +02:00
rtree_compress2.test Merge branch '10.3' into 10.4 2019-09-06 11:53:10 +02:00
rtree_concurrent_srch.test MDEV-515 Reduce InnoDB undo logging for insert into empty table 2021-01-25 18:41:27 +02:00
rtree_create_inplace.opt MDEV-13626 Merge InnoDB test cases from MySQL 5.7 2023-11-08 12:17:14 +02:00
rtree_create_inplace.test MDEV-13626 Merge InnoDB test cases from MySQL 5.7 2023-11-08 12:17:14 +02:00
rtree_debug.test MDEV-21360 global debug_dbug pre-test value restoration issues 2020-01-15 18:06:24 +01:00
rtree_drop_index.test MariaDB adjustments to innodb_gis tests. 2017-10-25 06:47:08 +03:00
rtree_estimate.test MDEV-16188 Post-merge corrections and adjustments 2019-02-04 22:44:33 -08:00
rtree_multi_pk.test MDEV-14057 InnoDB GIS tests fail. 2020-03-18 13:55:21 +04:00
rtree_purge.test MDEV-36848: identify tests with various MSAN suitability 2025-05-28 16:33:49 +10:00
rtree_recovery.test Re-remove the file kill_and_restart_mysqld.inc 2017-12-14 08:40:09 +02:00
rtree_rollback1.test Enable tests for --embedded 2020-01-20 08:41:13 +02:00
rtree_rollback2.test Enable tests for --embedded 2020-01-20 08:41:13 +02:00
rtree_search.test MDEV-14209 innodb_gis.rtree_debug produces huge server error logs 2018-01-29 23:02:12 +02:00
rtree_split.test MDEV-27675 Incorrect r-tree split after group assignment causes page overflow 2025-10-23 07:16:26 +03:00
rtree_temporary.test MDEV-29507 InnoDB: Failing assertion: table->n_rec_locks == 0 2022-09-12 09:27:46 +03:00
rtree_undo.test MDEV-32050 fixup: Stabilize tests 2023-11-21 12:42:00 +02:00
types.test MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent 2021-08-31 13:55:02 +03:00
update_root.test Speed up of innodb_gis.update_root test 10x by adding BEGIN/COMMIT 2021-06-19 03:46:00 +03:00