Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-27557

InnoDB unnecessarily commits mtr during secondary index search to preserve clustered index latching order

    XMLWordPrintable

    Details

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vlad.lesin Vladislav Lesin
              Reporter:
              vlad.lesin Vladislav Lesin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.