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

server hang with conflciting insert/update load on tables with foreign key costraint

    XMLWordPrintable

Details

    Description

      development debug build of MariaDB 10.11 hangs when 4 sessions issue updates and inserts into two tables with foreign key constraint.

      A simple mtr was developed to reproduce the issue, will be attached here.

      MariaDB [test]> show processlist;
      +----+------+-----------------+------+---------+------+----------+------------------------------------------------------------------------------------------------------+----------+
      | Id | User | Host            | db   | Command | Time | State    | Info                                                                                                 | Progress |
      +----+------+-----------------+------+---------+------+----------+------------------------------------------------------------------------------------------------------+----------+
      | 13 | root | localhost       | test | Sleep   |  160 |          | NULL                                                                                                 |    0.000 |
      | 14 | root | localhost       | test | Query   |  160 | Update   | INSERT INTO child VALUES ( NAME_CONST('pk',13), NAME_CONST('pk',13),0)                               |    0.000 |
      | 15 | root | localhost       | test | Sleep   |   89 |          | NULL                                                                                                 |    0.000 |
      | 16 | root | localhost       | test | Query   |  159 | Updating | UPDATE child SET j= NAME_CONST('current_num',2454) WHERE id> (floor(rand() *  NAME_CONST('row_count' |    0.000 |
      | 17 | root | localhost       | test | Query   |  159 | Updating | UPDATE child SET j= NAME_CONST('current_num',2452) WHERE id> (floor(rand() *  NAME_CONST('row_count' |    0.000 |
      | 18 | root | localhost       | test | Sleep   |  160 |          | NULL                                                                                                 |    0.000 |
      | 19 | root | localhost:38396 | test | Query   |    0 | starting | show processlist                                                                                     |    0.000 |
      +----+------+-----------------+------+---------+------+----------+------------------------------------------------------------------------------------------------------+-------
      

      ------------
      TRANSACTIONS
      ------------
      Trx id counter 78279
      Purge done for trx's n:o < 78276 undo n:o < 0 state: running
      History list length 10483
      Total number of lock structs in row lock hash table 6134
      LIST OF TRANSACTIONS FOR EACH SESSION:
      ---TRANSACTION (0x7fdc6a360280), not started
      0 lock struct(s), heap size 1152, 0 row lock(s)
      ---TRANSACTION 78278, ACTIVE 0 sec starting index read
      mysql tables in use 1, locked 1
      LOCK WAIT 2 lock struct(s), heap size 1152, 1 row lock(s)
      MariaDB thread id 17, OS thread handle 140584615913216, query id 114369 localhost root Updating
      UPDATE child SET j= NAME_CONST('current_num',3459) WHERE id> (floor(rand() *  NAME_CONST('row_count',10000))) limit 10
      ------- TRX HAS BEEN WAITING 75173 ns FOR THIS LOCK TO BE GRANTED:
      RECORD LOCKS space id 8 page no 5 n bits 520 index PRIMARY of table `test`.`child` trx id 78278 lock_mode X waiting
      Record lock, heap no 2 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
       0: len 4; hex 8000001e; asc     ;;
       1: len 6; hex 000000000000; asc       ;;
       2: len 7; hex 80000000000000; asc        ;;
       3: len 4; hex 8000001e; asc     ;;
       4: len 4; hex 80000ccf; asc     ;;
       
      ------------------
      ---TRANSACTION 78276, ACTIVE 0 sec fetching rows
      mysql tables in use 1, locked 1
      2 lock struct(s), heap size 1152, 144 row lock(s), undo log entries 9
      MariaDB thread id 16, OS thread handle 140584615606016, query id 114366 localhost root Updating
      UPDATE child SET j= NAME_CONST('current_num',3460) WHERE id> (floor(rand() *  NAME_CONST('row_count',10000))) limit 10
      ---TRANSACTION (0x7fdc6a35e180), not started
      0 lock struct(s), heap size 1152, 0 row lock(s)
      ---TRANSACTION 57309, ACTIVE 322 sec inserting
      mysql tables in use 1, locked 1
      LOCK WAIT 6133 lock struct(s), heap size 1008000, 6132 row lock(s)
      MariaDB thread id 14, OS thread handle 140584617142016, query id 82909 localhost root Update
      INSERT INTO child VALUES ( NAME_CONST('pk',13), NAME_CONST('pk',13),0)
      ------- TRX HAS BEEN WAITING 80695 ns FOR THIS LOCK TO BE GRANTED:
      RECORD LOCKS space id 8 page no 5 n bits 520 index PRIMARY of table `test`.`child` trx id 57309 lock_mode X locks gap before rec insert intention waiting
      Record lock, heap no 2 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
       0: len 4; hex 8000001e; asc     ;;
       1: len 6; hex 000000000000; asc       ;;
       2: len 7; hex 80000000000000; asc        ;;
       3: len 4; hex 8000001e; asc     ;;
       4: len 4; hex 80000ccf; asc     ;;
       
      ------------------
      ---TRANSACTION (0x7fdc6a35cb80), not started
      0 lock struct(s), heap size 1152, 0 row lock(s)
      
      

      Attachments

        Activity

          People

            marko Marko Mäkelä
            seppo Seppo Jaakola
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.