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

insert-intention lock conflicts with waiting ORDINARY lock

Details

    Description

      We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds lock on the record. And the second's transaction lock contains "waiting" flag.

      Let's take a look 10.6 code:

      dberr_t                                                                      
      lock_rec_insert_check_and_lock(...)
      {
      ...
            const unsigned type_mode= LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION;      
       
            if (lock_t *c_lock= lock_rec_other_has_conflicting(type_mode,             
                                                               g.cell(), id,          
                                                               heap_no, trx))         
            {                                                                         
              trx->mutex_lock();                                                      
              err= lock_rec_enqueue_waiting(c_lock, type_mode, id, block->frame,      
                                            heap_no, index, thr, nullptr);            
              trx->mutex_unlock();                                                    
            }
      ...
      }
      

      Neither lock_rec_insert_check_and_lock() nor lock_rec_other_has_conflicting() doesn't check conflicting lock is in waiting state and it already waits for the requesting insert-intention lock transaction.

      The test is attached: ii-conflicts-waiting.test

      Attachments

        Issue Links

          Activity

            Transition Time In Source Status Execution Times
            Vladislav Lesin made transition -
            Open In Progress
            20d 23h 28m 1
            Vladislav Lesin made transition -
            In Progress In Testing
            34d 6h 48m 2
            Matthias Leich made transition -
            In Testing Stalled
            2d 20h 59m 2
            Vladislav Lesin made transition -
            In Progress In Review
            1m 30s 1
            Marko Mäkelä made transition -
            In Review Stalled
            9h 22m 1
            Vladislav Lesin made transition -
            Stalled Closed
            5d 2h 10m 1
            Vladislav Lesin made transition -
            Closed Stalled
            959d 21h 46m 1
            Vladislav Lesin made transition -
            Stalled In Progress
            5d 7h 59m 3
            Vladislav Lesin made transition -
            In Progress Closed
            2h 54m 1

            People

              vlad.lesin Vladislav Lesin
              vlad.lesin Vladislav Lesin
              Votes:
              1 Vote for this issue
              Watchers:
              12 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.