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

Bulk insert fails to apply when trigger does insert operation

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 10.9(EOL), 10.10(EOL), 10.11, 11.0(EOL), 11.1(EOL), 11.2(EOL), 11.3(EOL)
    • 10.11.8
    • None

    Description

      --source include/have_innodb.inc
      SET foreign_key_checks=0;
      SET unique_checks=OFF;
      SET autocommit=OFF;
      CREATE TABLE t (c INT) ENGINE=INNODB;
      CREATE TRIGGER t2_ai AFTER INSERT ON t FOR EACH ROW SET @a:=(SELECT * FROM t);
      INSERT INTO t VALUES (1);
      INSERT INTO t VALUES (1);
      

      Leads to:

      11.3.0 5fc19e71375fb39eb85354321bf852d998aecf81 (Optimized, UBASAN)

      /test/11.3_opt_san/storage/innobase/trx/trx0rec.cc:2004:15: runtime error: store to null pointer of type 'roll_ptr_t'
          #0 0x55f0cff82856 in trx_undo_report_row_operation(que_thr_t*, dict_index_t*, dtuple_t const*, upd_t const*, unsigned long, unsigned char const*, unsigned short const*, unsigned long*) /test/11.3_opt_san/storage/innobase/trx/trx0rec.cc:2004
          #1 0x55f0cfd2bf1d in row_ins_clust_index_entry_low(unsigned long, btr_latch_mode, dict_index_t*, unsigned long, dtuple_t*, unsigned long, que_thr_t*) /test/11.3_opt_san/storage/innobase/row/row0ins.cc:2772
          #2 0x55f0cfd40ca6 in row_ins_clust_index_entry(dict_index_t*, dtuple_t*, que_thr_t*, unsigned long) /test/11.3_opt_san/storage/innobase/row/row0ins.cc:3243
          #3 0x55f0cfd42fee in row_ins_index_entry /test/11.3_opt_san/storage/innobase/row/row0ins.cc:3375
          #4 0x55f0cfd42fee in row_ins_index_entry_step /test/11.3_opt_san/storage/innobase/row/row0ins.cc:3543
          #5 0x55f0cfd42fee in row_ins /test/11.3_opt_san/storage/innobase/row/row0ins.cc:3660
          #6 0x55f0cfd42fee in row_ins_step(que_thr_t*) /test/11.3_opt_san/storage/innobase/row/row0ins.cc:3789
          #7 0x55f0cfdaff29 in row_insert_for_mysql(unsigned char const*, row_prebuilt_t*, ins_mode_t) /test/11.3_opt_san/storage/innobase/row/row0mysql.cc:1313
          #8 0x55f0cf8da09b in ha_innobase::write_row(unsigned char const*) /test/11.3_opt_san/storage/innobase/handler/ha_innodb.cc:7832
          #9 0x55f0ce1fc282 in handler::ha_write_row(unsigned char const*) /test/11.3_opt_san/sql/handler.cc:7851
          #10 0x55f0cc965202 in write_record(THD*, TABLE*, st_copy_info*, select_result*) /test/11.3_opt_san/sql/sql_insert.cc:2212
          #11 0x55f0cc9c9985 in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /test/11.3_opt_san/sql/sql_insert.cc:1155
          #12 0x55f0ccbbfca1 in mysql_execute_command(THD*, bool) /test/11.3_opt_san/sql/sql_parse.cc:4426
          #13 0x55f0ccb4c6a0 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.3_opt_san/sql/sql_parse.cc:7743
          #14 0x55f0ccba3750 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.3_opt_san/sql/sql_parse.cc:1893
          #15 0x55f0ccbae9dd in do_command(THD*, bool) /test/11.3_opt_san/sql/sql_parse.cc:1406
          #16 0x55f0cd4f481d in do_handle_one_connection(CONNECT*, bool) /test/11.3_opt_san/sql/sql_connect.cc:1445
          #17 0x55f0cd4f6e8c in handle_one_connection /test/11.3_opt_san/sql/sql_connect.cc:1347
          #18 0x1510f4814608 in start_thread /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477
          #19 0x1510f3a89132 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f132)
      

      11.3.0 5fc19e71375fb39eb85354321bf852d998aecf81 (Optimized)

      Core was generated by `/test/MD101023-mariadb-11.3.0-linux-x86_64-opt/bin/mariadbd --no-defaults --cor'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x000055fa9f29564c in trx_undo_build_roll_ptr (offset=<optimized out>, 
          page_no=<optimized out>, rseg_id=<optimized out>, 
          is_insert=<optimized out>)
          at /test/11.3_opt/storage/innobase/include/trx0undo.inl:45
      [Current thread is 1 (Thread 0x146b4c151700 (LWP 4076533))]
      (gdb) bt
      #0  0x000055fa9f29564c in trx_undo_build_roll_ptr (offset=<optimized out>, page_no=<optimized out>, rseg_id=<optimized out>, is_insert=<optimized out>) at /test/11.3_opt/storage/innobase/include/trx0undo.inl:45
      #1  trx_undo_report_row_operation (thr=thr@entry=0x146aa401eb88, index=index@entry=0x146aa401d5d0, clust_entry=clust_entry@entry=0x146aa401cc40, update=update@entry=0x0, cmpl_info=cmpl_info@entry=0, rec=rec@entry=0x0, offsets=<optimized out>, roll_ptr=<optimized out>) at /test/11.3_opt/storage/innobase/trx/trx0rec.cc:2004
      #2  0x000055fa9f245f62 in row_ins_clust_index_entry_low (flags=<optimized out>, mode=<optimized out>, index=0x146aa401d5d0, n_uniq=<optimized out>, entry=0x146aa401cc40, n_ext=<optimized out>, thr=<optimized out>) at /test/11.3_opt/storage/innobase/row/row0ins.cc:2772
      #3  0x000055fa9f249826 in row_ins_clust_index_entry (index=0x146aa401d5d0, entry=entry@entry=0x146aa401cc40, thr=thr@entry=0x146aa401eb88, n_ext=n_ext@entry=0) at /test/11.3_opt/storage/innobase/row/row0ins.cc:3243
      #4  0x000055fa9f249f95 in row_ins_index_entry (thr=0x146aa401eb88, entry=<optimized out>, index=<optimized out>) at /test/11.3_opt/storage/innobase/row/row0ins.cc:3375
      #5  row_ins_index_entry_step (thr=0x146aa401eb88, node=<optimized out>) at /test/11.3_opt/storage/innobase/row/row0ins.cc:3543
      #6  row_ins (thr=0x146aa401eb88, node=<optimized out>) at /test/11.3_opt/storage/innobase/row/row0ins.cc:3660
      #7  row_ins_step (thr=thr@entry=0x146aa401eb88) at /test/11.3_opt/storage/innobase/row/row0ins.cc:3789
      #8  0x000055fa9f25b3e8 in row_insert_for_mysql (mysql_rec=mysql_rec@entry=0x146aa4029af8 "\375\001", prebuilt=0x146aa401e4f0, ins_mode=ROW_INS_NORMAL) at /test/11.3_opt/storage/innobase/row/row0mysql.cc:1313
      #9  0x000055fa9f1b06e0 in ha_innobase::write_row (this=0x146aa401dc50, record=0x146aa4029af8 "\375\001") at /test/11.3_opt/storage/innobase/handler/ha_innodb.cc:7832
      #10 0x000055fa9eea20b8 in handler::ha_write_row (this=0x146aa401dc50, buf=0x146aa4029af8 "\375\001") at /test/11.3_opt/sql/handler.cc:7851
      #11 0x000055fa9ebd7bed in write_record (thd=thd@entry=0x146aa4000c58, table=table@entry=0x146aa4028518, info=info@entry=0x146b4c14fa90, sink=sink@entry=0x0) at /test/11.3_opt/sql/sql_insert.cc:2212
      #12 0x000055fa9ebdea3a in mysql_insert (thd=thd@entry=0x146aa4000c58, table_list=<optimized out>, fields=@0x146aa4005ed8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55fa9ff3d010 <end_of_list>, last = 0x146aa4005ed8, elements = 0}, <No data fields>}, values_list=@0x146aa4005f20: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x146aa4011808, last = 0x146aa4011808, elements = 1}, <No data fields>}, update_fields=@0x146aa4005f08: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55fa9ff3d010 <end_of_list>, last = 0x146aa4005f08, elements = 0}, <No data fields>}, update_values=@0x146aa4005ef0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55fa9ff3d010 <end_of_list>, last = 0x146aa4005ef0, elements = 0}, <No data fields>}, duplic=<optimized out>, ignore=<optimized out>, result=<optimized out>) at /test/11.3_opt/sql/sql_insert.cc:1155
      #13 0x000055fa9ec1aa5c in mysql_execute_command (thd=0x146aa4000c58, is_called_from_prepared_stmt=<optimized out>) at /test/11.3_opt/sql/sql_parse.cc:4426
      #14 0x000055fa9ec09d46 in mysql_parse (thd=0x146aa4000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/11.3_opt/sql/sql_parse.cc:7743
      #15 0x000055fa9ec162a5 in dispatch_command (command=COM_QUERY, thd=0x146aa4000c58, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /test/11.3_opt/sql/sql_class.h:1534
      #16 0x000055fa9ec184ee in do_command (thd=0x146aa4000c58, blocking=blocking@entry=true) at /test/11.3_opt/sql/sql_parse.cc:1406
      #17 0x000055fa9ed45787 in do_handle_one_connection (connect=<optimized out>, put_in_cache=true) at /test/11.3_opt/sql/sql_connect.cc:1445
      #18 0x000055fa9ed45acd in handle_one_connection (arg=arg@entry=0x55faa1cda468) at /test/11.3_opt/sql/sql_connect.cc:1347
      #19 0x000055fa9f0ec0ac in pfs_spawn_thread (arg=0x55faa1c8f148) at /test/11.3_opt/storage/perfschema/pfs.cc:2201
      #20 0x0000146b4eff1609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #21 0x0000146b4ebdd133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.9.8 (dbg), 10.9.8 (opt), 10.10.7 (dbg), 10.10.7 (opt), 10.11.6 (dbg), 10.11.6 (opt), 11.0.4 (dbg), 11.0.4 (opt), 11.1.3 (dbg), 11.1.3 (opt), 11.2.2 (dbg), 11.2.2 (opt), 11.3.0 (dbg), 11.3.0 (opt)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.4.32 (dbg), 10.4.32 (opt), 10.5.23 (dbg), 10.5.23 (opt), 10.6.16 (dbg), 10.6.16 (opt)

      Attachments

        Issue Links

          Activity

            Based on the test case, this looks related to MDEV-24621.

            marko Marko Mäkelä added a comment - Based on the test case, this looks related to MDEV-24621 .

            Patch is in bb-10.10-MDEV-32453

            thiru Thirunarayanan Balathandayuthapani added a comment - Patch is in bb-10.10- MDEV-32453

            An unconditional call to trx_t::end_bulk_insert() at the start of every statement would traverse trx_t::mod_tables, which could cause a serious performance degradation if a multi-statement transaction is modifying a large number of tables.

            Is there any other solution to this? Which function should the SQL layer call in order to make the existing logic in InnoDB work? Could we simply disable bulk insert if there is a trigger attached to the table?

            marko Marko Mäkelä added a comment - An unconditional call to trx_t::end_bulk_insert() at the start of every statement would traverse trx_t::mod_tables , which could cause a serious performance degradation if a multi-statement transaction is modifying a large number of tables. Is there any other solution to this? Which function should the SQL layer call in order to make the existing logic in InnoDB work? Could we simply disable bulk insert if there is a trigger attached to the table?

            Looks good to me.

            marko Marko Mäkelä added a comment - Looks good to me.

            People

              thiru Thirunarayanan Balathandayuthapani
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.