[MDEV-27557] InnoDB unnecessarily commits mtr during secondary index search to preserve clustered index latching order Created: 2022-01-20  Updated: 2022-09-07  Resolved: 2022-03-25

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.9.0, 10.5.16, 10.6.8, 10.7.4, 10.8.3

Type: Bug Priority: Major
Reporter: Vladislav Lesin Assignee: Vladislav Lesin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-20605 Awaken transaction can miss inserted ... Closed

 Description   

There is no need to commit mtr in the following code:

dberr_t                                                                         
row_search_mvcc(...)                                                            
{                                                                               
...                                                                             
        } else if (mtr_has_extra_clust_latch) {                                 
                /* If we have extra cluster latch, we must commit               
 
                mtr if we are moving to the next non-clustered                  
                index record, because we could break the latching               
                order if we would access a different clustered                  
                index page right away without releasing the previous. */        
                                                                                
                btr_pcur_store_position(pcur, &mtr);                            
                mtr.commit();                                                   
                mtr_has_extra_clust_latch = FALSE;                              
                                                                                
                mtr.start();                                                    
                                                                                
                if (sel_restore_position_for_mysql(&same_user_rec,              
                                                   BTR_SEARCH_LEAF,             
                                                   pcur, moves_up, &mtr)) {     
                        goto rec_loop;                                          
                }                                                               
        }                                                                       
                                                                                
...                                                                             
}

We could create mtr savepoint before requesting clustered index record(mtr_t::get_savepoint()), then release only clustered index page latches(mtr_t::release_s_latch_at_savepoint()) instead of mtr committing.



 Comments   
Comment by Matthias Leich [ 2022-03-22 ]

origin/bb-10.6-MDEV-27557-clust-mtr-savepoint 9543c70a07687941787dfe79accce649182315a8 2022-03-21T15:51:39+03:00
performed well in RQG testing.

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