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

Assertion failure on ROLLBACK of SPATIAL INDEX

    XMLWordPrintable

    Details

      Description

      I tried (and failed) to create a test case for MDEV-21512. This test will hit an assertion failure in locking code:

      --source include/have_innodb.inc
      --source include/have_debug.inc
      --source include/have_sequence.inc
       
      SET @save_limit = @@innodb_limit_optimistic_insert_debug;
       
      create table t1(a serial, b geometry not null, spatial index(b)) engine=innodb;
      SET GLOBAL innodb_limit_optimistic_insert_debug = 2;
      begin;
      insert into t1 select seq, Point(1,1) from seq_1_to_5;
      rollback;
       
      check table t1;
      drop table t1;
       
      SET GLOBAL innodb_limit_optimistic_insert_debug = @save_limit;
      

      Without the MDEV-21512 fix, inserting 4 records suffices. With the fix, the test would pass with 4 records and fail with 5.
      The failure looks like this:

      10.2 c4195305b2a8431f39a4c75cc1c66ba43685f7a0

      mysqltest: At line 11: query 'rollback' failed: 2013: Lost connection to MySQL server during query
      mysqld: /mariadb/10.2o/storage/innobase/lock/lock0lock.cc:2480: void lock_rec_free_all_from_discard_page_low(ulint, ulint, hash_table_t *): Assertion `lock_rec_find_set_bit(lock) == ((ulint)(-1))' failed.
      #7  0x000055b0776a0daf in lock_rec_free_all_from_discard_page_low (space=<optimized out>, page_no=<optimized out>, lock_hash=<optimized out>) at /mariadb/10.2o/storage/innobase/lock/lock0lock.cc:2480
      #8  0x000055b0776a5b69 in lock_update_discard (heir_block=0x7f506217cde0, heir_heap_no=<optimized out>, block=0x7f506217d0f0) at /mariadb/10.2o/storage/innobase/lock/lock0lock.cc:3454
      #9  0x000055b077834752 in btr_discard_page (cursor=<optimized out>, mtr=<optimized out>) at /mariadb/10.2o/storage/innobase/include/mach0data.ic:84
      #10 0x000055b07785940d in btr_cur_pessimistic_delete (err=0x7f5061e9e394, has_reserved_extents=<optimized out>, cursor=0x7f5061e9e3f8, flags=16, rollback=<optimized out>, mtr=0x7f5061e9ea78) at /mariadb/10.2o/storage/innobase/btr/btr0cur.cc:5292
      #11 0x000055b0779709b7 in rtr_node_ptr_delete (index=<optimized out>, cursor=0x7f5061e9e3f8, block=<optimized out>, mtr=0x7f5061e9ea78) at /mariadb/10.2o/storage/innobase/gis/gis0rtree.cc:1741
      #12 0x000055b0778341f8 in btr_discard_page (cursor=<optimized out>, mtr=<optimized out>) at /mariadb/10.2o/storage/innobase/btr/btr0btr.cc:4181
      #13 0x000055b07785940d in btr_cur_pessimistic_delete (err=0x7f5061e9e7ec, has_reserved_extents=<optimized out>, cursor=0x7f5061e9e800, flags=0, rollback=<optimized out>, mtr=0x7f5061e9ea78) at /mariadb/10.2o/storage/innobase/btr/btr0cur.cc:5292
      #14 0x000055b077985ad8 in row_undo_ins_remove_sec_low (mode=196641, index=0x7f501418c2b8, entry=0x7f501407b068, thr=0x7f501418c850) at /mariadb/10.2o/storage/innobase/row/row0uins.cc:255
      #15 0x000055b07798403f in row_undo_ins_remove_sec (index=<optimized out>, entry=0x7f501407b068, thr=0x7f501418c850) at /mariadb/10.2o/storage/innobase/row/row0uins.cc:293
      #16 row_undo_ins_remove_sec_rec (node=<optimized out>, thr=0x7f501418c850) at /mariadb/10.2o/storage/innobase/row/row0uins.cc:449
      #17 row_undo_ins (node=<optimized out>, thr=0x7f501418c850) at /mariadb/10.2o/storage/innobase/row/row0uins.cc:503
      #18 0x000055b07779ffc1 in row_undo (node=<optimized out>, thr=0x7f501418c850) at /mariadb/10.2o/storage/innobase/row/row0undo.cc:298
      #19 row_undo_step (thr=0x7f501418c850) at /mariadb/10.2o/storage/innobase/row/row0undo.cc:351
      #20 0x000055b077713f78 in que_thr_step (thr=<optimized out>) at /mariadb/10.2o/storage/innobase/que/que0que.cc:1038
      #21 que_run_threads_low (thr=0x7f501418c850) at /mariadb/10.2o/storage/innobase/que/que0que.cc:1102
      #22 que_run_threads (thr=0x7f501418c850) at /mariadb/10.2o/storage/innobase/que/que0que.cc:1142
      #23 0x000055b0777f9566 in trx_rollback_to_savepoint_low (trx=0x7f5062a8b140, savept=0x0) at /mariadb/10.2o/storage/innobase/trx/trx0roll.cc:107
      #24 0x000055b0777f9ce3 in trx_rollback_for_mysql (trx=0x7f5062a8b140) at /mariadb/10.2o/storage/innobase/trx/trx0roll.cc:242
      #25 0x000055b07764a3b5 in innobase_rollback (hton=<optimized out>, thd=0x7f5014000ce8, rollback_trx=true) at /mariadb/10.2o/storage/innobase/handler/ha_innodb.cc:4834
      #26 0x000055b077479ca5 in ha_rollback_trans (thd=0x7f5014000ce8, all=true) at /mariadb/10.2o/sql/handler.cc:1707
      #27 0x000055b0773a956f in trans_rollback (thd=0x7f5014000ce8) at /mariadb/10.2o/sql/transaction.cc:415
      #28 0x000055b0772a21e2 in mysql_execute_command (thd=0x7f5014000ce8) at /mariadb/10.2o/sql/sql_parse.cc:5358
      #29 0x000055b07729e0f4 in mysql_parse (thd=0x7f5014000ce8, rawbuf=0x7f5014011920 "rollback", length=<optimized out>, parser_state=0x7f5061ea1300, is_com_multi=<optimized out>, is_next_command=false) at /mariadb/10.2o/sql/sql_parse.cc:7740
      

      Note: on MySQL 5.7, have_sequence.inc is not available, and you will have to dumb down the test case, something like this:

      begin;
      insert into t1 (b) values (Point(1,1)),(Point(1,1)),(Point(1,1)),(Point(1,1)),(Point(1,1));
      rollback;
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vlad.lesin Vladislav Lesin
              Reporter:
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: