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

Assertion `!node->table->skip_alter_undo' failed in row_upd_clust_rec on CREATE

Details

    Description

      CREATE TABLE IF NOT EXISTS t1 (a INT UNIQUE, b INT) REPLACE SELECT 1 AS a, 1 AS b UNION SELECT 1 AS a, 2 AS b;
      

      Leads to:

      10.6.0 3f871b339429441ad907ecf7dfabdc414797e664 (Debug)

      mysqld: /data/builds/10.6_dbg/storage/innobase/row/row0upd.cc:2530: dberr_t row_upd_clust_rec(ulint, upd_node_t*, dict_index_t*, rec_offs*, mem_heap_t**, que_thr_t*, mtr_t*): Assertion `!node->table->skip_alter_undo' failed.
      

      10.6.0 3f871b339429441ad907ecf7dfabdc414797e664 (Debug)

      Core was generated by `/test/MD260121-mariadb-10.6.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
          at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
      [Current thread is 1 (Thread 0x150c30b9e700 (LWP 2950885))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
      #1  0x0000556ec64dd210 in my_write_core (sig=sig@entry=6) at /data/builds/10.6_dbg/mysys/stacktrace.c:424
      #2  0x0000556ec5c722d0 in handle_fatal_signal (sig=6) at /data/builds/10.6_dbg/sql/signal_handler.cc:330
      #3  <signal handler called>
      #4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #5  0x0000150c3a003859 in __GI_abort () at abort.c:79
      #6  0x0000150c3a003729 in __assert_fail_base (fmt=0x150c3a199588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x556ec68df273 "!node->table->skip_alter_undo", file=0x556ec68e4280 "/data/builds/10.6_dbg/storage/innobase/row/row0upd.cc", line=2530, function=<optimized out>) at assert.c:92
      #7  0x0000150c3a014f36 in __GI___assert_fail (assertion=assertion@entry=0x556ec68df273 "!node->table->skip_alter_undo", file=file@entry=0x556ec68e4280 "/data/builds/10.6_dbg/storage/innobase/row/row0upd.cc", line=line@entry=2530, function=function@entry=0x556ec68e4ee8 "dberr_t row_upd_clust_rec(ulint, upd_node_t*, dict_index_t*, rec_offs*, mem_heap_t**, que_thr_t*, mtr_t*)") at assert.c:101
      #8  0x0000556ec62505a6 in row_upd_clust_rec (flags=flags@entry=0, node=node@entry=0x150be4048d38, index=index@entry=0x150be4042948, offsets=<optimized out>, offsets@entry=0x150c30b9b570, offsets_heap=offsets_heap@entry=0x150c30b9b558, thr=thr@entry=0x150be4049040, mtr=0x150c30b9bbb0) at /data/builds/10.6_dbg/storage/innobase/row/row0upd.cc:2530
      #9  0x0000556ec62526f1 in row_upd_clust_step (node=node@entry=0x150be4048d38, thr=thr@entry=0x150be4049040) at /data/builds/10.6_dbg/storage/innobase/row/row0upd.cc:2888
      #10 0x0000556ec6254ceb in row_upd (thr=0x150be4049040, node=0x150be4048d38) at /data/builds/10.6_dbg/storage/innobase/row/row0upd.cc:2992
      #11 row_upd_step (thr=thr@entry=0x150be4049040) at /data/builds/10.6_dbg/storage/innobase/row/row0upd.cc:3136
      #12 0x0000556ec61f5ac1 in row_update_for_mysql (prebuilt=0x150be40482b8) at /data/builds/10.6_dbg/storage/innobase/row/row0mysql.cc:1854
      #13 0x0000556ec607a257 in ha_innobase::update_row (this=0x150be4045b60, old_row=0x150be4045708 "\241\001", new_row=0x150be40456f8 "\371\001") at /data/builds/10.6_dbg/storage/innobase/handler/ha_innodb.cc:8130
      #14 0x0000556ec5c86c37 in handler::ha_update_row (this=0x150be4045b60, old_data=0x150be4045708 "\241\001", new_data=0x150be40456f8 "\371\001") at /data/builds/10.6_dbg/sql/handler.cc:7204
      #15 0x0000556ec595c7cd in write_record (thd=0x150be4000db8, table=0x150be4045268, info=info@entry=0x150be40150f0, sink=0x0) at /data/builds/10.6_dbg/sql/sql_insert.cc:2023
      #16 0x0000556ec595c905 in select_insert::send_data (this=0x150be40150a0, values=<optimized out>) at /data/builds/10.6_dbg/sql/sql_insert.cc:4076
      #17 0x0000556ec5a11ba8 in select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=@0x150be40056d0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x150be4016360, last = 0x150be40164b0, elements = 2}, <No data fields>}, this=<optimized out>) at /data/builds/10.6_dbg/sql/sql_class.h:5376
      #18 end_send (join=0x150be4016aa8, join_tab=0x150be404a5a8, end_of_records=<optimized out>) at /data/builds/10.6_dbg/sql/sql_select.cc:21802
      #19 0x0000556ec59e087e in evaluate_join_record (join=join@entry=0x150be4016aa8, join_tab=join_tab@entry=0x150be404a1f8, error=error@entry=0) at /data/builds/10.6_dbg/sql/sql_select.cc:20825
      #20 0x0000556ec59f7017 in sub_select (join=0x150be4016aa8, join_tab=0x150be404a1f8, end_of_records=<optimized out>) at /data/builds/10.6_dbg/sql/sql_select.cc:20641
      #21 0x0000556ec5a2fa22 in do_select (procedure=0x0, join=0x150be4016aa8) at /data/builds/10.6_dbg/sql/sql_select.cc:20149
      #22 JOIN::exec_inner (this=this@entry=0x150be4016aa8) at /data/builds/10.6_dbg/sql/sql_select.cc:4476
      #23 0x0000556ec5a2fe92 in JOIN::exec (this=this@entry=0x150be4016aa8) at /data/builds/10.6_dbg/sql/sql_select.cc:4256
      #24 0x0000556ec5a2e0f2 in mysql_select (thd=0x150be4000db8, tables=tables@entry=0x150be4004fc8, fields=@0x150be40056d0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x150be4016360, last = 0x150be40164b0, elements = 2}, <No data fields>}, conds=conds@entry=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2199023255552, result=0x150be40150a0, unit=0x150be4004f80, select_lex=0x150be4014760) at /data/builds/10.6_dbg/sql/sql_select.cc:4672
      #25 0x0000556ec5a9ccdb in st_select_lex_unit::exec (this=this@entry=0x150be4004f80) at /data/builds/10.6_dbg/sql/sql_lex.h:925
      #26 0x0000556ec5aa0ef2 in mysql_union (thd=thd@entry=0x150be4000db8, lex=lex@entry=0x150be4004eb8, result=result@entry=0x150be40150a0, unit=unit@entry=0x150be4004f80, setup_tables_done_option=<optimized out>, setup_tables_done_option@entry=0) at /data/builds/10.6_dbg/sql/sql_union.cc:41
      #27 0x0000556ec5a2e2f6 in handle_select (thd=thd@entry=0x150be4000db8, lex=lex@entry=0x150be4004eb8, result=result@entry=0x150be40150a0, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/builds/10.6_dbg/sql/sql_select.cc:407
      #28 0x0000556ec5a854c4 in Sql_cmd_create_table_like::execute (this=<optimized out>, thd=0x150be4000db8) at /data/builds/10.6_dbg/sql/sql_table.cc:12110
      #29 0x0000556ec59b3556 in mysql_execute_command (thd=thd@entry=0x150be4000db8) at /data/builds/10.6_dbg/sql/sql_parse.cc:5875
      #30 0x0000556ec599a15e in mysql_parse (thd=thd@entry=0x150be4000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x150c30b9d3d0) at /data/builds/10.6_dbg/sql/sql_parse.cc:7901
      #31 0x0000556ec59a824f in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x150be4000db8, packet=packet@entry=0x150be401aac9 "CREATE TABLE IF NOT EXISTS t1 (a INT UNIQUE, b INT) REPLACE SELECT 1 AS a, 1 AS b UNION SELECT 1 AS a, 2 AS b", packet_length=packet_length@entry=109) at /data/builds/10.6_dbg/sql/sql_class.h:1294
      #32 0x0000556ec59ab581 in do_command (thd=0x150be4000db8) at /data/builds/10.6_dbg/sql/sql_parse.cc:1365
      #33 0x0000556ec5b07079 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x556ec9803688, put_in_cache=put_in_cache@entry=true) at /data/builds/10.6_dbg/sql/sql_connect.cc:1410
      #34 0x0000556ec5b0777d in handle_one_connection (arg=arg@entry=0x556ec9803688) at /data/builds/10.6_dbg/sql/sql_connect.cc:1312
      #35 0x0000556ec5fba43f in pfs_spawn_thread (arg=0x556ec96e8bd8) at /data/builds/10.6_dbg/storage/perfschema/pfs.cc:2201
      #36 0x0000150c3a511609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #37 0x0000150c3a100293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.6.0 (dbg)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.2.37 (dbg), 10.2.37 (opt), 10.3.28 (dbg), 10.3.28 (opt), 10.4.18 (dbg), 10.4.18 (opt), 10.5.9 (dbg), 10.5.9 (opt), 10.6.0 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.33 (dbg), 5.7.33 (opt), 8.0.23 (dbg), 8.0.23 (opt)

      Attachments

        Issue Links

          Activity

            Roel Roel Van de Paar added a comment - - edited

            Slightly simplified & clarified testcase

            CREATE TABLE t (a INT UNIQUE) REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
            

            Roel Roel Van de Paar added a comment - - edited Slightly simplified & clarified testcase CREATE TABLE t (a INT UNIQUE) REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
            Roel Roel Van de Paar added a comment - - edited

            Please also see MDEV-22255 and MDEV-22257.

            Roel Roel Van de Paar added a comment - - edited Please also see MDEV-22255 and MDEV-22257 .

            The cause appears to be this call that was added in MDEV-515:

            diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
            --- a/sql/sql_insert.cc
            +++ b/sql/sql_insert.cc
            @@ -4740,7 +4744,10 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
               if (info.handle_duplicates == DUP_UPDATE)
                 table->file->extra(HA_EXTRA_INSERT_WITH_UPDATE);
               if (thd->locked_tables_mode <= LTM_LOCK_TABLES)
            +  {
                 table->file->ha_start_bulk_insert((ha_rows) 0);
            +    table->file->extra(HA_EXTRA_BEGIN_ALTER_COPY);
            +  }
               thd->abort_on_warning= !info.ignore && thd->is_strict_mode();
               if (check_that_all_fields_are_given_values(thd, table, table_list))
                 DBUG_RETURN(1);
            

            The intention of this call was to disable the MDEV-515 bulk insert during CREATE…SELECT. This definitely must not be invoked for CREATE…REPLACE SELECT, because executing that will depend on the ability to roll back individual rows.

            marko Marko Mäkelä added a comment - The cause appears to be this call that was added in MDEV-515 : diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4740,7 +4744,10 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u) if (info.handle_duplicates == DUP_UPDATE) table->file->extra(HA_EXTRA_INSERT_WITH_UPDATE); if (thd->locked_tables_mode <= LTM_LOCK_TABLES) + { table->file->ha_start_bulk_insert((ha_rows) 0); + table->file->extra(HA_EXTRA_BEGIN_ALTER_COPY); + } thd->abort_on_warning= !info.ignore && thd->is_strict_mode(); if (check_that_all_fields_are_given_values(thd, table, table_list)) DBUG_RETURN(1); The intention of this call was to disable the MDEV-515 bulk insert during CREATE…SELECT . This definitely must not be invoked for CREATE…REPLACE SELECT , because executing that will depend on the ability to roll back individual rows.

            People

              marko Marko Mäkelä
              Roel Roel Van de Paar
              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.