mariadb/mysql-test/suite/innodb_gis/r
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.result Merge 10.3 into 10.4 2022-09-13 16:36:38 +03:00
1.result Merge branch '10.5' into 10.6 2025-01-29 11:17:38 +01:00
alter_spatial_index.result Merge 10.5 into 10.6 2022-11-08 17:37:22 +02:00
bug16236208.result MDEV-14057 InnoDB GIS tests fail. 2020-03-18 13:55:21 +04:00
bug16266012.result MDEV-14057 InnoDB GIS tests fail. 2020-03-18 13:55:21 +04:00
bug17057168.result MDEV-14057 InnoDB GIS tests fail 2018-01-04 19:46:23 +02:00
check_rtree.result Remove deprication from mariadbd --debug 2023-11-28 16:33:22 +02:00
create_spatial_index.result Merge 10.5 into 10.6 2022-09-20 16:53:20 +03:00
geometry.result Merge 10.5 into 10.6 2022-09-20 16:53:20 +03:00
gis.result Merge branch '10.5' into 10.6 2024-07-18 16:25:33 +02:00
gis_split_inf.result MDEV-14057 InnoDB GIS tests fail. 2020-03-18 13:55:21 +04:00
gis_split_nan.result 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.result MDEV-31766 SIGSEGV in maria_rtree_split_page | maria_rtree_add_key. 2025-10-21 12:09:53 +04:00
kill_server.result MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
multi_pk.result MDEV-13626: Merge InnoDB test cases from MySQL 5.7 2017-10-25 06:47:08 +03:00
point_basic.result Merge branch '10.5' into 10.6 2025-01-29 11:17:38 +01:00
point_big.result MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent 2021-08-31 13:55:02 +03:00
precise.result Removing MDEV-27871 from tastcases because it is not a bug 2024-06-28 16:45:50 +07:00
repeatable_spatial.result MariaDB adjustments to innodb_gis tests. 2017-10-25 06:47:08 +03:00
rollback.result Merge 10.5 into 10.6 2025-03-26 17:09:57 +02:00
rt_precise.result Merge 10.5 into 10.6 2022-09-20 16:53:20 +03:00
rtree.result Merge branch '10.5' into 10.6 2024-10-15 16:00:44 +11:00
rtree_add_index.result MDEV-32050 fixup: Stabilize tests 2023-11-21 12:42:00 +02:00
rtree_compress.result Merge 10.5 into 10.6 2023-11-30 10:45:01 +02:00
rtree_compress2.result Updated mtr files to support different compiled in options 2019-09-01 19:17:35 +03:00
rtree_concurrent_srch.result MDEV-515 Reduce InnoDB undo logging for insert into empty table 2021-01-25 18:41:27 +02:00
rtree_create_inplace.result Remove deprication from mariadbd --debug 2023-11-28 16:33:22 +02:00
rtree_debug.result MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
rtree_drop_index.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
rtree_estimate.result Updated optimizer costs in multi_range_read_info_const() and sql_select.cc 2020-03-27 03:58:32 +02:00
rtree_multi_pk.result Merge 10.5 into 10.6 2022-09-20 16:53:20 +03:00
rtree_purge.result MDEV-32050 fixup: Stabilize tests 2023-11-21 12:42:00 +02:00
rtree_recovery.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
rtree_rollback1.result MDEV-13626: Merge InnoDB test cases from MySQL 5.7 2017-10-25 06:47:08 +03:00
rtree_rollback2.result MDEV-13626: Merge InnoDB test cases from MySQL 5.7 2017-10-25 06:47:08 +03:00
rtree_search.result MDEV-14057 InnoDB GIS tests fail. 2020-03-18 13:55:21 +04:00
rtree_split.result MDEV-27675 Incorrect r-tree split after group assignment causes page overflow 2025-10-23 07:16:26 +03:00
rtree_temporary.result MDEV-29507 InnoDB: Failing assertion: table->n_rec_locks == 0 2022-09-12 09:27:46 +03:00
rtree_undo.result MDEV-32050 fixup: Stabilize tests 2023-11-21 12:42:00 +02:00
types.result Merge 10.5 into 10.6 2022-09-20 16:53:20 +03:00
update_root.result Speed up of innodb_gis.update_root test 10x by adding BEGIN/COMMIT 2021-06-19 03:46:00 +03:00