[MDEV-24240] Pessimistic operations on SPATIAL INDEX wrongly release page latches Created: 2020-11-18  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: GIS, Storage Engine - InnoDB
Affects Version/s: 10.2.2, 10.3.0, 10.4.0, 10.5.0
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Unresolved Votes: 0
Labels: performance

Issue Links:
Blocks
blocks MDEV-24142 rw_lock_t has unnecessarily complex w... Closed

 Description   

The function btr_cur_search_to_nth_level_func() may be invoked during rollback with the flag BTR_RTREE_UNDO_INS applied on top of BTR_MODIFY_TREE. In the BTR_MODIFY_TREE mode, we are not supposed to release any upper-level page latches. But we are doing that. The following would avoid that:

diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index 29ece955702..4563da31cd2 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -160,6 +160,8 @@ record is in spatial index */
 					 | BTR_ALREADY_S_LATCHED	\
 					 | BTR_LATCH_FOR_INSERT		\
 					 | BTR_LATCH_FOR_DELETE		\
+					 | BTR_RTREE_UNDO_INS		\
+					 | BTR_RTREE_DELETE_MARK	\
 					 | BTR_MODIFY_EXTERNAL)))
 

Also, some function parameters or local variables could be optimized. For example, the function rtr_pcur_open_low() is always being invoked with level=0.

Note: This does not fix the race condition that could explain MDEV-15284, MDEV-16269. Those failures are still repeatable after this cleanup.


Generated at Thu Feb 08 09:28:29 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.