Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-4201 LevelDB Storage Engine MS2
  3. MDEV-4300

LevelDB: Server crashes in inline_mysql_mutex_lock on SELECT .. FOR UPDATE

Details

    • Technical task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=LevelDB;
      CREATE TABLE t2 (pk INT PRIMARY KEY, i INT, KEY (i)) ENGINE=LevelDB;
      INSERT INTO t1 VALUES (1),(2);
      INSERT INTO t2 VALUES (1,4),(2,5);
      SELECT ( SELECT 1 FROM t1 ) FROM t2 WHERE i < 0 FOR UPDATE;

      #3  <signal handler called>
      #4  0x0000000000b0b7a6 in inline_mysql_mutex_lock (that=0xb5, src_file=0x102cb40 "mysql-5.6-leveldb/storage/leveldb/ldb_locks.cc", src_line=277) at mysql-5.6-leveldb/include/mysql/psi/mysql_thread.h:659
      #5  0x0000000000b0c27c in LockTable::release_lock (this=0x17817a0, pins=0x7f969c038a40, own_lock=0x95) at mysql-5.6-leveldb/storage/leveldb/ldb_locks.cc:277
      #6  0x0000000000b09303 in Ldb_transaction::release_last_lock (this=0x7f969c013fa0) at mysql-5.6-leveldb/storage/leveldb/ha_leveldb.cc:236
      #7  0x0000000000b06937 in ha_leveldb::unlock_row (this=0x7f969c03e7a0) at mysql-5.6-leveldb/storage/leveldb/ha_leveldb.cc:1649
      #8  0x0000000000621cd9 in handler::read_range_first (this=0x7f969c03e7a0, start_key=0x7f969c03e880, end_key=0x7f969c03e8a0, eq_range_arg=false, sorted=false) at mysql-5.6-leveldb/sql/handler.cc:6577
      #9  0x0000000000620079 in handler::multi_range_read_next (this=0x7f969c03e7a0, range_info=0x7f96c065f5f0) at mysql-5.6-leveldb/sql/handler.cc:5732
      #10 0x0000000000922d32 in QUICK_RANGE_SELECT::get_next (this=0x7f969c05ada0) at mysql-5.6-leveldb/sql/opt_range.cc:10407
      #11 0x000000000093a952 in rr_quick (info=0x7f969c0403b0) at mysql-5.6-leveldb/sql/records.cc:367
      #12 0x0000000000775c07 in join_init_read_record (tab=0x7f969c040320) at mysql-5.6-leveldb/sql/sql_executor.cc:2388
      #13 0x0000000000773477 in sub_select (join=0x7f969c03f2a0, join_tab=0x7f969c040320, end_of_records=false) at mysql-5.6-leveldb/sql/sql_executor.cc:1249
      #14 0x0000000000772f11 in do_select (join=0x7f969c03f2a0) at mysql-5.6-leveldb/sql/sql_executor.cc:936
      #15 0x0000000000770f5e in JOIN::exec (this=0x7f969c03f2a0) at mysql-5.6-leveldb/sql/sql_executor.cc:191
      #16 0x00000000007cbb85 in mysql_execute_select (thd=0x2545740, select_lex=0x2547f20, free_join=true) at mysql-5.6-leveldb/sql/sql_select.cc:1100
      #17 0x00000000007cbe6a in mysql_select (thd=0x2545740, tables=0x7f969c006238, wild_num=0, fields=..., conds=0x7f969c006960, order=0x25480e8, group=0x2548020, having=0x0, select_options=2147748608, result=0x7f969c006b98, unit=0x25478e0, select_lex=0x2547f20) at mysql-5.6-leveldb/sql/sql_select.cc:1221
      #18 0x00000000007c9fba in handle_select (thd=0x2545740, result=0x7f969c006b98, setup_tables_done_option=0) at mysql-5.6-leveldb/sql/sql_select.cc:110
      #19 0x00000000007a6782 in execute_sqlcom_select (thd=0x2545740, all_tables=0x7f969c006238) at mysql-5.6-leveldb/sql/sql_parse.cc:4987
      #20 0x000000000079f5f4 in mysql_execute_command (thd=0x2545740) at mysql-5.6-leveldb/sql/sql_parse.cc:2557
      #21 0x00000000007a8be7 in mysql_parse (thd=0x2545740, rawbuf=0x7f969c004fd0 "SELECT ( SELECT 1 FROM t1 ) FROM t2 WHERE i < 0 FOR UPDATE", length=58, parser_state=0x7f96c0661110) at mysql-5.6-leveldb/sql/sql_parse.cc:6117
      #22 0x000000000079c9a3 in dispatch_command (command=COM_QUERY, thd=0x2545740, packet=0x2618ca1 "", packet_length=58) at mysql-5.6-leveldb/sql/sql_parse.cc:1312
      #23 0x000000000079bb66 in do_command (thd=0x2545740) at mysql-5.6-leveldb/sql/sql_parse.cc:1036
      #24 0x0000000000766e09 in do_handle_one_connection (thd_arg=0x2545740) at mysql-5.6-leveldb/sql/sql_connect.cc:969
      #25 0x000000000076682e in handle_one_connection (arg=0x2545740) at mysql-5.6-leveldb/sql/sql_connect.cc:885
      #26 0x0000000000af6924 in pfs_spawn_thread (arg=0x249a920) at mysql-5.6-leveldb/storage/perfschema/pfs.cc:1853
      #27 0x00007f96c1a7de9a in start_thread (arg=0x7f96c0662700) at pthread_create.c:308
      #28 0x00007f96c0f98cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

      revision-id: psergey@askmonty.org-20130319094846-yze9xy3qeb5g6hrc
      revno: 4610
      branch-nick: mysql-5.6-leveldb

      Attachments

        Activity

          A simpler testcase is possible: instead of

          SELECT ( SELECT 1 FROM t1 ) FROM t2 WHERE i < 0 FOR UPDATE;

          one can use

          SELECT 1 FROM t2 WHERE i < 0 FOR UPDATE;

          psergei Sergei Petrunia added a comment - A simpler testcase is possible: instead of SELECT ( SELECT 1 FROM t1 ) FROM t2 WHERE i < 0 FOR UPDATE; one can use SELECT 1 FROM t2 WHERE i < 0 FOR UPDATE;

          The cause of the bug seems to be that

          • SQL layer tells us to run index_only scan, which we do. index-only scans cannot do any locking.
          • SQL layer calls handler->unlock_row(), which tries to release the last row lock.. when the transaction doesn't have any locks. Crash.

          IIRC, InnoDB had the same problem. SELECT .. FOR UPDATE ran index-only scans. InnoDB made them non-index-only under the hood. I'll investigate whether that is still true.

          psergei Sergei Petrunia added a comment - The cause of the bug seems to be that SQL layer tells us to run index_only scan, which we do. index-only scans cannot do any locking. SQL layer calls handler->unlock_row(), which tries to release the last row lock.. when the transaction doesn't have any locks. Crash. IIRC, InnoDB had the same problem. SELECT .. FOR UPDATE ran index-only scans. InnoDB made them non-index-only under the hood. I'll investigate whether that is still true.

          ... No, they seem to lock index records, now.

          psergei Sergei Petrunia added a comment - ... No, they seem to lock index records, now.

          #0 row_get_rec_trx_id (rec=0xabe1c5cb "\200", index=0x994d588, offsets=0xa6505ccc) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/include/row0row.ic:79
          #1 0x087c6704 in lock_clust_rec_some_has_impl (rec=0xabe1c5cb "\200", index=0x994d588, offsets=0xa6505ccc) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/include/lock0priv.ic:64
          #2 0x087d15d9 in lock_rec_convert_impl_to_expl (block=0xab7e3c80, rec=0xabe1c5cb "\200", index=0x994d588, offsets=0xa6505ccc) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/lock/lock0lock.cc:6024
          #3 0x087d191a in lock_clust_rec_read_check_and_lock (flags=0, block=0xab7e3c80, rec=0xabe1c5cb "\200", index=0x994d588, offsets=0xa6505ccc, mode=LOCK_X, gap_mode=1024, thr=0x9945390) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/lock/lock0lock.cc:6349
          #4 0x0889dd85 in row_sel_get_clust_rec_for_mysql (prebuilt=0x9944d90, sec_index=0x994dba0, rec=0xabdf81c0 "\200", thr=0x9945390, out_rec=0xa6505e9c, offsets=0xa6505e74, offset_heap=0xa6505e78, mtr=0xa6505ec4) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/row/row0sel.cc:3111
          #5 0x0889ffad in row_search_for_mysql (buf=0x9931158 "\377", mode=2, prebuilt=0x9944d90, match_mode=0, direction=0) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/row/row0sel.cc:4682
          #6 0x08789887 in ha_innobase::index_read (this=0x992f740, buf=0x9931158 "\377", key_ptr=0x98b8cb0 "", key_len=5, find_flag=HA_READ_KEY_OR_NEXT) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/handler/ha_innodb.cc:7398
          #7 0x0823fed8 in handler::index_read_map (this=0x992f740, buf=0x9931158 "\377", key=0x98b8cb0 "", keypart_map=1, find_flag=HA_READ_KEY_OR_NEXT) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.h:2203
          #8 0x08230420 in handler::ha_index_read_map (this=0x992f740, buf=0x9931158 "\377", key=0x98b8cb0 "", keypart_map=1, find_flag=HA_READ_KEY_OR_NEXT) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.cc:2668
          #9 0x08234179 in handler::read_range_first (this=0x992f740, start_key=0x992f7e4, end_key=0x992f7f4, eq_range_arg=false, sorted=false) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.cc:6576
          #10 0x0822f9c2 in handler::multi_range_read_next (this=0x992f740, range_info=0xa65065b0) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.cc:5747
          #11 0x0823536b in DsMrr_impl::dsmrr_next (this=0x9931124, range_info=0xa65065b0) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.cc:6106
          #12 0x087728bc in ha_innobase::multi_range_read_next (this=0x992f740, range_info=0xa65065b0) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/handler/ha_innodb.cc:16427
          #13 0x0857aaab in QUICK_RANGE_SELECT::get_next (this=0x98b8b78) at /home/psergey/dev2/mysql-5.6-leveldb/sql/opt_range.cc:10409
          #14 0x085aaa57 in rr_quick (info=0x995ba4c) at /home/psergey/dev2/mysql-5.6-leveldb/sql/records.cc:367
          #15 0x083ba89c in join_init_read_record (tab=0x995b9fc) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_executor.cc:2395
          #16 0x083bc92a in sub_select (join=0x98b8d78, join_tab=0x995b9fc, end_of_records=false) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_executor.cc:1256
          #17 0x083bd174 in do_select (join=0x98b8d78) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_executor.cc:941
          #18 0x083beec9 in JOIN::exec (this=0x98b8d78) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_executor.cc:191
          #19 0x0842100d in mysql_execute_select (thd=0x989f328, select_lex=0x98a0fc8, free_join=true) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_select.cc:1100
          #20 0x08421a75 in mysql_select (thd=0x989f328, tables=0x98ba8c8, wild_num=0, fields=..., conds=0x994c838, order=0x98a10dc, group=0x98a1060, having=0x0, select_options=2148797184, result=0x994a708, unit=0x98a0b64, select_lex=0x98a0fc8) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_select.cc:1221
          #21 0x084230b8 in handle_select (thd=0x989f328, result=0x994a708, setup_tables_done_option=0) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_select.cc:110
          #22 0x083e872c in execute_sqlcom_select (thd=0x989f328, all_tables=0x98ba8c8) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_parse.cc:5019
          #23 0x083ea89d in mysql_execute_command (thd=0x989f328) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_parse.cc:2589
          #24 0x083f2b91 in mysql_parse (thd=0x989f328, rawbuf=0x98bad88 "select 1 from t10 where a between 23 and 33 for update", length=54,

          psergei Sergei Petrunia added a comment - #0 row_get_rec_trx_id (rec=0xabe1c5cb "\200", index=0x994d588, offsets=0xa6505ccc) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/include/row0row.ic:79 #1 0x087c6704 in lock_clust_rec_some_has_impl (rec=0xabe1c5cb "\200", index=0x994d588, offsets=0xa6505ccc) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/include/lock0priv.ic:64 #2 0x087d15d9 in lock_rec_convert_impl_to_expl (block=0xab7e3c80, rec=0xabe1c5cb "\200", index=0x994d588, offsets=0xa6505ccc) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/lock/lock0lock.cc:6024 #3 0x087d191a in lock_clust_rec_read_check_and_lock (flags=0, block=0xab7e3c80, rec=0xabe1c5cb "\200", index=0x994d588, offsets=0xa6505ccc, mode=LOCK_X, gap_mode=1024, thr=0x9945390) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/lock/lock0lock.cc:6349 #4 0x0889dd85 in row_sel_get_clust_rec_for_mysql (prebuilt=0x9944d90, sec_index=0x994dba0, rec=0xabdf81c0 "\200", thr=0x9945390, out_rec=0xa6505e9c, offsets=0xa6505e74, offset_heap=0xa6505e78, mtr=0xa6505ec4) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/row/row0sel.cc:3111 #5 0x0889ffad in row_search_for_mysql (buf=0x9931158 "\377", mode=2, prebuilt=0x9944d90, match_mode=0, direction=0) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/row/row0sel.cc:4682 #6 0x08789887 in ha_innobase::index_read (this=0x992f740, buf=0x9931158 "\377", key_ptr=0x98b8cb0 "", key_len=5, find_flag=HA_READ_KEY_OR_NEXT) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/handler/ha_innodb.cc:7398 #7 0x0823fed8 in handler::index_read_map (this=0x992f740, buf=0x9931158 "\377", key=0x98b8cb0 "", keypart_map=1, find_flag=HA_READ_KEY_OR_NEXT) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.h:2203 #8 0x08230420 in handler::ha_index_read_map (this=0x992f740, buf=0x9931158 "\377", key=0x98b8cb0 "", keypart_map=1, find_flag=HA_READ_KEY_OR_NEXT) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.cc:2668 #9 0x08234179 in handler::read_range_first (this=0x992f740, start_key=0x992f7e4, end_key=0x992f7f4, eq_range_arg=false, sorted=false) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.cc:6576 #10 0x0822f9c2 in handler::multi_range_read_next (this=0x992f740, range_info=0xa65065b0) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.cc:5747 #11 0x0823536b in DsMrr_impl::dsmrr_next (this=0x9931124, range_info=0xa65065b0) at /home/psergey/dev2/mysql-5.6-leveldb/sql/handler.cc:6106 #12 0x087728bc in ha_innobase::multi_range_read_next (this=0x992f740, range_info=0xa65065b0) at /home/psergey/dev2/mysql-5.6-leveldb/storage/innobase/handler/ha_innodb.cc:16427 #13 0x0857aaab in QUICK_RANGE_SELECT::get_next (this=0x98b8b78) at /home/psergey/dev2/mysql-5.6-leveldb/sql/opt_range.cc:10409 #14 0x085aaa57 in rr_quick (info=0x995ba4c) at /home/psergey/dev2/mysql-5.6-leveldb/sql/records.cc:367 #15 0x083ba89c in join_init_read_record (tab=0x995b9fc) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_executor.cc:2395 #16 0x083bc92a in sub_select (join=0x98b8d78, join_tab=0x995b9fc, end_of_records=false) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_executor.cc:1256 #17 0x083bd174 in do_select (join=0x98b8d78) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_executor.cc:941 #18 0x083beec9 in JOIN::exec (this=0x98b8d78) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_executor.cc:191 #19 0x0842100d in mysql_execute_select (thd=0x989f328, select_lex=0x98a0fc8, free_join=true) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_select.cc:1100 #20 0x08421a75 in mysql_select (thd=0x989f328, tables=0x98ba8c8, wild_num=0, fields=..., conds=0x994c838, order=0x98a10dc, group=0x98a1060, having=0x0, select_options=2148797184, result=0x994a708, unit=0x98a0b64, select_lex=0x98a0fc8) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_select.cc:1221 #21 0x084230b8 in handle_select (thd=0x989f328, result=0x994a708, setup_tables_done_option=0) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_select.cc:110 #22 0x083e872c in execute_sqlcom_select (thd=0x989f328, all_tables=0x98ba8c8) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_parse.cc:5019 #23 0x083ea89d in mysql_execute_command (thd=0x989f328) at /home/psergey/dev2/mysql-5.6-leveldb/sql/sql_parse.cc:2589 #24 0x083f2b91 in mysql_parse (thd=0x989f328, rawbuf=0x98bad88 "select 1 from t10 where a between 23 and 33 for update", length=54,

          People

            psergei Sergei Petrunia
            elenst Elena Stepanova
            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.