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

Assertion `part_share->auto_inc_initialized' failed in ha_partition::get_auto_increment on INSERT

Details

    Description

      INSTALL PLUGIN spider SONAME 'ha_spider.so';
      SET SQL_MODE='';
      CREATE TABLE t (c INT AUTO_INCREMENT, KEY(c)) ENGINE=SPIDER PARTITION BY LIST COLUMNS (c) (PARTITION p DEFAULT ENGINE=SPIDER);
      INSERT INTO t (c) VALUES (0);
      INSERT INTO t (c) VALUES (0);
      

      Leads to:

      10.7.0 1bc82aaf0a7746c0921a94034aff2d51f0d75cd0 (Debug)

      mysqld: /test/10.7_dbg/sql/ha_partition.cc:10802: virtual void ha_partition::get_auto_increment(ulonglong, ulonglong, ulonglong, ulonglong*, ulonglong*): Assertion `part_share->auto_inc_initialized' failed.
      

      10.7.0 1bc82aaf0a7746c0921a94034aff2d51f0d75cd0 (Debug)

      Core was generated by `/test/MD040921-mariadb-10.7.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      [Current thread is 1 (Thread 0x1513d8164700 (LWP 1873546))]
      (gdb) bt
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x00001513d93c7859 in __GI_abort () at abort.c:79
      #2  0x00001513d93c7729 in __assert_fail_base (fmt=0x1513d955d588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x556055939fb0 "part_share->auto_inc_initialized", file=0x556055938b80 "/test/10.7_dbg/sql/ha_partition.cc", line=10802, function=<optimized out>) at assert.c:92
      #3  0x00001513d93d8f36 in __GI___assert_fail (assertion=assertion@entry=0x556055939fb0 "part_share->auto_inc_initialized", file=file@entry=0x556055938b80 "/test/10.7_dbg/sql/ha_partition.cc", line=line@entry=10802, function=function@entry=0x556055939f10 "virtual void ha_partition::get_auto_increment(ulonglong, ulonglong, ulonglong, ulonglong*, ulonglong*)") at assert.c:101
      #4  0x0000556055062661 in ha_partition::get_auto_increment (this=0x151394055730, offset=1, increment=1, nb_desired_values=1, first_value=0x1513d8162950, nb_reserved_values=0x1513d8162958) at /test/10.7_dbg/sql/ha_partition.cc:10802
      #5  0x0000556054da5227 in handler::update_auto_increment (this=this@entry=0x151394055730) at /test/10.7_dbg/sql/handler.cc:3954
      #6  0x00005560550753de in ha_partition::write_row (this=0x151394055730, buf=0x151394030758 "\377") at /test/10.7_dbg/sql/ha_partition.cc:4432
      #7  0x0000556054dad0b5 in handler::ha_write_row (this=0x151394055730, buf=0x151394030758 "\377") at /test/10.7_dbg/sql/handler.cc:7514
      #8  0x0000556054a5133a in write_record (thd=thd@entry=0x151394000db8, table=table@entry=0x1513940326f8, info=info@entry=0x1513d8162cc0, sink=sink@entry=0x0) at /test/10.7_dbg/sql/sql_insert.cc:2135
      #9  0x0000556054a5cf6c in mysql_insert (thd=thd@entry=0x151394000db8, table_list=0x151394013d60, fields=@0x151394005fc8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x151394014568, last = 0x151394014568, elements = 1}, <No data fields>}, values_list=@0x151394006010: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x151394014a98, last = 0x151394014a98, elements = 1}, <No data fields>}, update_fields=@0x151394005ff8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x556056075c60 <end_of_list>, last = 0x151394005ff8, elements = 0}, <No data fields>}, update_values=@0x151394005fe0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x556056075c60 <end_of_list>, last = 0x151394005fe0, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/10.7_dbg/sql/sql_insert.cc:1123
      #10 0x0000556054aa309c in mysql_execute_command (thd=thd@entry=0x151394000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.7_dbg/sql/sql_parse.cc:4565
      #11 0x0000556054a8dccb in mysql_parse (thd=thd@entry=0x151394000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1513d8163400) at /test/10.7_dbg/sql/sql_parse.cc:8036
      #12 0x0000556054a9c8d0 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x151394000db8, packet=packet@entry=0x15139400b739 "INSERT INTO t (c) VALUES (0)", packet_length=packet_length@entry=28, blocking=blocking@entry=true) at /test/10.7_dbg/sql/sql_class.h:1358
      #13 0x0000556054a9fcd6 in do_command (thd=0x151394000db8, blocking=blocking@entry=true) at /test/10.7_dbg/sql/sql_parse.cc:1404
      #14 0x0000556054c160c8 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x556057caa078, put_in_cache=put_in_cache@entry=true) at /test/10.7_dbg/sql/sql_connect.cc:1418
      #15 0x0000556054c166cd in handle_one_connection (arg=arg@entry=0x556057caa078) at /test/10.7_dbg/sql/sql_connect.cc:1312
      #16 0x000055605507fade in pfs_spawn_thread (arg=0x556057ba92b8) at /test/10.7_dbg/storage/perfschema/pfs.cc:2201
      #17 0x00001513d98d6609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #18 0x00001513d94c4293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.4.22 (dbg), 10.5.13 (dbg), 10.6.5 (dbg), 10.7.0 (dbg)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.2.41 (dbg), 10.2.41 (opt), 10.3.32 (dbg), 10.3.32 (opt), 10.4.22 (opt), 10.5.13 (opt), 10.6.5 (opt), 10.7.0 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.35 (dbg), 5.7.35 (opt), 8.0.26 (dbg), 8.0.26 (opt)

      Attachments

        Activity

          Roel Roel Van de Paar created issue -
          Roel Roel Van de Paar made changes -
          Field Original Value New Value
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
          Status Open [ 1 ] Confirmed [ 10101 ]
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
          Status Confirmed [ 10101 ] In Progress [ 3 ]

          MTR test case

          --disable_query_log
          --disable_result_log
          --source ../../t/test_init.inc
          --enable_result_log
          --enable_query_log
           
          --connection master_1
          CREATE DATABASE auto_test_remote;
          USE auto_test_remote;
           
          eval CREATE TABLE `tbl_a` (
              `a` INT AUTO_INCREMENT, KEY(`a`)
          ) $MASTER_1_ENGINE $MASTER_1_CHARSET
          PARTITION BY LIST COLUMNS (`a`) (
              PARTITION `pt1` DEFAULT
          );
          --error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
          INSERT INTO tbl_a (a) VALUES (0);
          --error 2013
          INSERT INTO tbl_a (a) VALUES (0);
           
          DROP DATABASE IF EXISTS auto_test_remote;
           
          --disable_query_log
          --disable_result_log
          --source ../../t/test_deinit.inc
          --enable_result_log
          --enable_query_log
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - MTR test case --disable_query_log --disable_result_log --source ../../t/test_init.inc --enable_result_log --enable_query_log   --connection master_1 CREATE DATABASE auto_test_remote; USE auto_test_remote;   eval CREATE TABLE `tbl_a` ( `a` INT AUTO_INCREMENT, KEY (`a`) ) $MASTER_1_ENGINE $MASTER_1_CHARSET PARTITION BY LIST COLUMNS (`a`) ( PARTITION `pt1` DEFAULT ); --error ER_CONNECT_TO_FOREIGN_DATA_SOURCE INSERT INTO tbl_a (a) VALUES (0); --error 2013 INSERT INTO tbl_a (a) VALUES (0);   DROP DATABASE IF EXISTS auto_test_remote;   --disable_query_log --disable_result_log --source ../../t/test_deinit.inc --enable_result_log --enable_query_log
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
          Affects Version/s 10.3 [ 22126 ]
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
          Fix Version/s 10.3 [ 22126 ]

          The bug is reproducible even on 10.3 HEAD, but not 10.2.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The bug is reproducible even on 10.3 HEAD, but not 10.2.
          Roel Roel Van de Paar made changes -
          Labels regression not-10.2 regression

          The bug reproduces at least on mariadb-10.3.3.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The bug reproduces at least on mariadb-10.3.3.

          The following assertion fails:

           DBUG_ASSERT(part_share->auto_inc_initialized);
          

          The variable auto_inc_initialized is asusmed to be set TRUE by ha_partition::write_row(). However, the vlue is not set because ha_spider::can_use_for_auto_inc_init() returns FALSE.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The following assertion fails: DBUG_ASSERT(part_share->auto_inc_initialized); The variable auto_inc_initialized is asusmed to be set TRUE by ha_partition::write_row() . However, the vlue is not set because ha_spider::can_use_for_auto_inc_init() returns FALSE .

          bool ha_partition::can_use_for_auto_inc_init()
          {
            handler **file= m_file;
            DBUG_ENTER("ha_partition::can_use_for_auto_inc_init");
           
            do
            {
              if (!(*file)->can_use_for_auto_inc_init())
                DBUG_RETURN(FALSE);
            } while (*(++file));
            DBUG_RETURN(TRUE);
          }
          

          (*file)->can_use_for_auto_inc_init() returns FALSE so the whole function returns FALSE.

          The instance pointed by *file seems not to be initialized.

          p ((ha_spider*) *file)->auto_inc_temporary
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - - edited bool ha_partition::can_use_for_auto_inc_init() { handler **file= m_file; DBUG_ENTER( "ha_partition::can_use_for_auto_inc_init" );   do { if (!(*file)->can_use_for_auto_inc_init()) DBUG_RETURN(FALSE); } while (*(++file)); DBUG_RETURN(TRUE); } (*file)->can_use_for_auto_inc_init() returns FALSE so the whole function returns FALSE . The instance pointed by *file seems not to be initialized. p ((ha_spider*) *file)->auto_inc_temporary

          file is allocated by get_new_handler() in spd_table.cc.

          What I should do next is to compare the buggy execution trace and one that is generated by another test case in which the connection strings are properly defined.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - file is allocated by get_new_handler() in spd_table.cc . What I should do next is to compare the buggy execution trace and one that is generated by another test case in which the connection strings are properly defined.

          MTR test case with proper connection string:

          --disable_query_log
          --disable_result_log
          --source ../../t/test_init.inc
          --enable_result_log
          --enable_query_log
           
          --connection child2_1
          CREATE DATABASE auto_test_remote;
          USE auto_test_remote;
           
          eval CREATE TABLE `tbl_a` (
              `a` INT AUTO_INCREMENT, KEY(`a`)
          ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
           
          --connection master_1
          CREATE DATABASE auto_test_remote;
          USE auto_test_remote;
           
          eval CREATE TABLE `tbl_a` (
              `a` INT AUTO_INCREMENT, KEY(`a`)
          ) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a"'
          PARTITION BY LIST COLUMNS (`a`) (
              PARTITION `pt1` DEFAULT COMMENT='srv "s_2_1"'
          );
          INSERT INTO tbl_a (a) VALUES (0);
          INSERT INTO tbl_a (a) VALUES (0);
           
          DROP DATABASE IF EXISTS auto_test_remote;
           
          --connection child2_1
          DROP DATABASE auto_test_remote;
           
          --disable_query_log
          --disable_result_log
          --source ../../t/test_deinit.inc
          --enable_result_log
          --enable_query_log
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - MTR test case with proper connection string: --disable_query_log --disable_result_log --source ../../t/test_init.inc --enable_result_log --enable_query_log   --connection child2_1 CREATE DATABASE auto_test_remote; USE auto_test_remote;   eval CREATE TABLE `tbl_a` ( `a` INT AUTO_INCREMENT, KEY (`a`) ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;   --connection master_1 CREATE DATABASE auto_test_remote; USE auto_test_remote;   eval CREATE TABLE `tbl_a` ( `a` INT AUTO_INCREMENT, KEY (`a`) ) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT= 'table "tbl_a"' PARTITION BY LIST COLUMNS (`a`) ( PARTITION `pt1` DEFAULT COMMENT= 'srv "s_2_1"' ); INSERT INTO tbl_a (a) VALUES (0); INSERT INTO tbl_a (a) VALUES (0);   DROP DATABASE IF EXISTS auto_test_remote;   --connection child2_1 DROP DATABASE auto_test_remote;   --disable_query_log --disable_result_log --source ../../t/test_deinit.inc --enable_result_log --enable_query_log

          In the execution of the above test case, ha_spider::auto_inc_temporary is set to TRUE and thus (*file)->can_use_for_auto_inc_init() returns TRUE.

          The variable ha_spider::auto_inc_temporary is set by ha_spider::info.

          Thread 151 hit Hardware watchpoint 3: -location auto_inc_temporary                                                                                                                                                                                
          Old value = false                                                                                                        New value = 165                                                                                                          
          0x00007f7eef42fdb4 in ha_spider::info (this=0x7f7f140d5b98, flag=16)                                                         at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/ha_spider.cc:8646                                         
          8646      auto_inc_temporary = FALSE;   
           
          (rr) bt
          #0  0x00007f7eef42fdb4 in ha_spider::info (this=0x7f7f140d5b98, flag=16) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/ha_spider.cc:8646
          #1  0x00005609d79c4305 in ha_partition::info (this=0x7f7f140d5348, flag=280) at /home/nayuta_mariadb/repo/mariadb-server/sql/ha_partition.cc:8332
          #2  0x00005609d79b6a8c in ha_partition::open (this=0x7f7f140d5348, name=0x7f7f140ade18 "./auto_test_remote/tbl_a", mode=2, test_if_locked=18) at /home/nayuta_mariadb/repo/mariadb-server/sql/ha_partition.cc:3639
          #3  0x00005609d7177cdf in handler::ha_open (this=0x7f7f140d5348, table_arg=0x7f7f140d4700, name=0x7f7f140ade18 "./auto_test_remote/tbl_a", mode=2, test_if_locked=18, mem_root=0x0, partitions_to_open=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/handler.cc:2769
          #4  0x00005609d6f6cb3f in open_table_from_share (thd=0x7f7f1400ae70, share=0x7f7f140ad8c8, alias=0x7f7f1401ba38, db_stat=33, prgflag=8, ha_open_flags=18, outparam=0x7f7f140d4700, is_create_table=false, partitions_to_open=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/table.cc:3592
          #5  0x00005609d6daa966 in open_table (thd=0x7f7f1400ae70, table_list=0x7f7f1401b9f0, ot_ctx=0x7f7f0805d880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1992
          #6  0x00005609d6dae2cd in open_and_process_table (thd=0x7f7f1400ae70, tables=0x7f7f1401b9f0, counter=0x7f7f0805d914, flags=0, prelocking_strategy=0x7f7f0805d998, has_prelocking_list=false, ot_ctx=0x7f7f0805d880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:3715
          #7  0x00005609d6daf33e in open_tables (thd=0x7f7f1400ae70, options=..., start=0x7f7f0805d8f8, counter=0x7f7f0805d914, flags=0, prelocking_strategy=0x7f7f0805d998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:4190
          #8  0x00005609d6db1283 in open_and_lock_tables (thd=0x7f7f1400ae70, options=..., tables=0x7f7f1401b9f0, derived=true, flags=0, prelocking_strategy=0x7f7f0805d998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:5129
          #9  0x00005609d6d6cde3 in open_and_lock_tables (thd=0x7f7f1400ae70, tables=0x7f7f1401b9f0, derived=true, flags=0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.h:503
          #10 0x00005609d6e01087 in mysql_insert (thd=0x7f7f1400ae70, table_list=0x7f7f1401b9f0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_insert.cc:760
          #11 0x00005609d6e47985 in mysql_execute_command (thd=0x7f7f1400ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:4504
          #12 0x00005609d6e53310 in mysql_parse (thd=0x7f7f1400ae70, rawbuf=0x7f7f1401b8f8 "INSERT INTO tbl_a (a) VALUES (0)", length=32, parser_state=0x7f7f0805e4e0, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:7870
          #13 0x00005609d6e3f9ce in dispatch_command (command=COM_QUERY, thd=0x7f7f1400ae70, packet=0x7f7f14013111 "INSERT INTO tbl_a (a) VALUES (0)", packet_length=32, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1852
          #14 0x00005609d6e3e373 in do_command (thd=0x7f7f1400ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1398
          #15 0x00005609d6fbf03c in do_handle_one_connection (connect=0x5609da39a720) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1403
          #16 0x00005609d6fbed9b in handle_one_connection (arg=0x5609da39a720) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1308
          #17 0x00007f7f222e0450 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
          #18 0x00007f7f22202d53 in clone () from /lib/x86_64-linux-gnu/libc.so.6
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - In the execution of the above test case, ha_spider::auto_inc_temporary is set to TRUE and thus (*file)->can_use_for_auto_inc_init() returns TRUE . The variable ha_spider::auto_inc_temporary is set by ha_spider::info . Thread 151 hit Hardware watchpoint 3: -location auto_inc_temporary Old value = false New value = 165 0x00007f7eef42fdb4 in ha_spider::info (this=0x7f7f140d5b98, flag=16) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/ha_spider.cc:8646 8646 auto_inc_temporary = FALSE ;   (rr) bt #0 0x00007f7eef42fdb4 in ha_spider::info (this=0x7f7f140d5b98, flag=16) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/ha_spider.cc:8646 #1 0x00005609d79c4305 in ha_partition::info (this=0x7f7f140d5348, flag=280) at /home/nayuta_mariadb/repo/mariadb-server/sql/ha_partition.cc:8332 #2 0x00005609d79b6a8c in ha_partition:: open (this=0x7f7f140d5348, name =0x7f7f140ade18 "./auto_test_remote/tbl_a" , mode=2, test_if_locked=18) at /home/nayuta_mariadb/repo/mariadb-server/sql/ha_partition.cc:3639 #3 0x00005609d7177cdf in handler::ha_open (this=0x7f7f140d5348, table_arg=0x7f7f140d4700, name =0x7f7f140ade18 "./auto_test_remote/tbl_a" , mode=2, test_if_locked=18, mem_root=0x0, partitions_to_open=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/handler.cc:2769 #4 0x00005609d6f6cb3f in open_table_from_share (thd=0x7f7f1400ae70, share=0x7f7f140ad8c8, alias=0x7f7f1401ba38, db_stat=33, prgflag=8, ha_open_flags=18, outparam=0x7f7f140d4700, is_create_table= false , partitions_to_open=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/ table .cc:3592 #5 0x00005609d6daa966 in open_table (thd=0x7f7f1400ae70, table_list=0x7f7f1401b9f0, ot_ctx=0x7f7f0805d880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1992 #6 0x00005609d6dae2cd in open_and_process_table (thd=0x7f7f1400ae70, tables=0x7f7f1401b9f0, counter=0x7f7f0805d914, flags=0, prelocking_strategy=0x7f7f0805d998, has_prelocking_list= false , ot_ctx=0x7f7f0805d880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:3715 #7 0x00005609d6daf33e in open_tables (thd=0x7f7f1400ae70, options=..., start=0x7f7f0805d8f8, counter=0x7f7f0805d914, flags=0, prelocking_strategy=0x7f7f0805d998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:4190 #8 0x00005609d6db1283 in open_and_lock_tables (thd=0x7f7f1400ae70, options=..., tables=0x7f7f1401b9f0, derived= true , flags=0, prelocking_strategy=0x7f7f0805d998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:5129 #9 0x00005609d6d6cde3 in open_and_lock_tables (thd=0x7f7f1400ae70, tables=0x7f7f1401b9f0, derived= true , flags=0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.h:503 #10 0x00005609d6e01087 in mysql_insert (thd=0x7f7f1400ae70, table_list=0x7f7f1401b9f0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore = false ) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_insert.cc:760 #11 0x00005609d6e47985 in mysql_execute_command (thd=0x7f7f1400ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:4504 #12 0x00005609d6e53310 in mysql_parse (thd=0x7f7f1400ae70, rawbuf=0x7f7f1401b8f8 "INSERT INTO tbl_a (a) VALUES (0)" , length=32, parser_state=0x7f7f0805e4e0, is_com_multi= false , is_next_command= false ) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:7870 #13 0x00005609d6e3f9ce in dispatch_command (command=COM_QUERY, thd=0x7f7f1400ae70, packet=0x7f7f14013111 "INSERT INTO tbl_a (a) VALUES (0)" , packet_length=32, is_com_multi= false , is_next_command= false ) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1852 #14 0x00005609d6e3e373 in do_command (thd=0x7f7f1400ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1398 #15 0x00005609d6fbf03c in do_handle_one_connection ( connect =0x5609da39a720) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1403 #16 0x00005609d6fbed9b in handle_one_connection (arg=0x5609da39a720) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1308 #17 0x00007f7f222e0450 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 #18 0x00007f7f22202d53 in clone () from /lib/x86_64-linux-gnu/libc.so.6

          In the above test case with the proper query string, ha_spider::info() is called four times. On the other hand, in the test case without the query string, the function is only called three times.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - In the above test case with the proper query string, ha_spider::info() is called four times. On the other hand, in the test case without the query string, the function is only called three times.

          The first INSERT seems not to reach ha_partition::get_auto_increment(). This seems to be a valid behavior because there is no need to get the auto-increment value if the backend server is not accessible.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The first INSERT seems not to reach ha_partition::get_auto_increment() . This seems to be a valid behavior because there is no need to get the auto-increment value if the backend server is not accessible.

          The first INSERT abort early at mysql_prepare_insert(). This is because mysql_prepare_insert() returns TRUE. And, that is further because open_tables() makes thd->is_error() TRUE.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The first INSERT abort early at mysql_prepare_insert() . This is because mysql_prepare_insert() returns TRUE . And, that is further because open_tables() makes thd->is_error() TRUE .

          The error is set here:

          (rr) bt
          #0  0x000055b24719d391 in Diagnostics_area::set_error_status (this=0x7f3b1c010310, sql_errno=1429, message=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost", sqlstate=0x55b247e64d5d "HY000", ucid=..., error_condition=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_error.cc:468
          #1  0x000055b247178fea in THD::raise_condition (this=0x7f3b1c00ad60, sql_errno=1429, sqlstate=0x55b247e64d5d "HY000", level=Sql_state_errno_level::WARN_LEVEL_ERROR, ucid=..., msg=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost") at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_class.cc:1065
          #2  0x000055b2470c03b8 in THD::raise_condition (this=0x7f3b1c00ad60, sql_errno=1429, sqlstate=0x0, level=Sql_state_errno_level::WARN_LEVEL_ERROR, msg=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost") at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_class.h:4373
          #3  0x000055b2470b2667 in my_message_sql (error=1429, str=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost", MyFlags=0) at /home/nayuta_mariadb/repo/mariadb-server/sql/mysqld.cc:3717
          #4  0x000055b247d9ac43 in my_message (error=1429, str=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost", MyFlags=139891849626384) at /home/nayuta_mariadb/repo/mariadb-server/mysys/my_error.c:196
          #5  0x00007f3af9972e96 in spider_db_connect (share=0x7f3b1c0d83a0, conn=0x7f3b1c0e4f60, link_idx=0) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:113
          #6  0x00007f3af9973d65 in spider_db_conn_queue_action (conn=0x7f3b1c0e4f60) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:292
          #7  0x00007f3af997582d in spider_db_before_query (conn=0x7f3b1c0e4f60, need_mon=0x7f3b1c0e3340) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:561
          #8  0x00007f3af997758c in spider_db_set_names_internal (trx=0x7f3b1c0b1bd0, share=0x7f3b1c0d83a0, conn=0x7f3b1c0e4f60, all_link_idx=0, need_mon=0x7f3b1c0e3340) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:863
          #9  0x00007f3af997795d in spider_db_set_names (spider=0x7f3b1c0d5e78, conn=0x7f3b1c0e4f60, link_idx=0) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:908
          #10 0x00007f3af9a7ea1c in spider_mbase_handler::show_table_status (this=0x7f3b1c0e34a0, link_idx=0, sts_mode=1, flag=80) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_mysql.cc:12523
          #11 0x00007f3af998bb1b in spider_db_show_table_status (spider=0x7f3b1c0d5e78, link_idx=0, sts_mode=1, flag=80) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:5713
          #12 0x00007f3af99e0894 in spider_get_sts (share=0x7f3b1c0d83a0, link_idx=0, tmp_time=1634140622, spider=0x7f3b1c0d5e78, sts_interval=0, sts_mode=1, sts_sync=0, sts_sync_level=1, flag=80) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_table.cc:7693
          #13 0x00007f3af9a2e655 in ha_spider::info (this=0x7f3b1c0d5e78, flag=16) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/ha_spider.cc:8795
          #14 0x000055b247d68305 in ha_partition::info (this=0x7f3b1c0d5628, flag=280) at /home/nayuta_mariadb/repo/mariadb-server/sql/ha_partition.cc:8332
          #15 0x000055b247d5aa8c in ha_partition::open (this=0x7f3b1c0d5628, name=0x7f3b1c0ae6c8 "./auto_test_remote/tbl_a", mode=2, test_if_locked=18) at /home/nayuta_mariadb/repo/mariadb-server/sql/ha_partition.cc:3639
          #16 0x000055b24751bcdf in handler::ha_open (this=0x7f3b1c0d5628, table_arg=0x7f3b1c0d49e0, name=0x7f3b1c0ae6c8 "./auto_test_remote/tbl_a", mode=2, test_if_locked=18, mem_root=0x0, partitions_to_open=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/handler.cc:2769
          #17 0x000055b247310b3f in open_table_from_share (thd=0x7f3b1c00ad60, share=0x7f3b1c0ae178, alias=0x7f3b1c01b928, db_stat=33, prgflag=8, ha_open_flags=18, outparam=0x7f3b1c0d49e0, is_create_table=false, partitions_to_open=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/table.cc:3592
          #18 0x000055b24714e966 in open_table (thd=0x7f3b1c00ad60, table_list=0x7f3b1c01b8e0, ot_ctx=0x7f3b180a7880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1992
          #19 0x000055b2471522cd in open_and_process_table (thd=0x7f3b1c00ad60, tables=0x7f3b1c01b8e0, counter=0x7f3b180a7914, flags=0, prelocking_strategy=0x7f3b180a7998, has_prelocking_list=false, ot_ctx=0x7f3b180a7880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:3715
          #20 0x000055b24715333e in open_tables (thd=0x7f3b1c00ad60, options=..., start=0x7f3b180a78f8, counter=0x7f3b180a7914, flags=0, prelocking_strategy=0x7f3b180a7998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:4190
          #21 0x000055b247155283 in open_and_lock_tables (thd=0x7f3b1c00ad60, options=..., tables=0x7f3b1c01b8e0, derived=true, flags=0, prelocking_strategy=0x7f3b180a7998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:5129
          #22 0x000055b247110de3 in open_and_lock_tables (thd=0x7f3b1c00ad60, tables=0x7f3b1c01b8e0, derived=true, flags=0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.h:503
          #23 0x000055b2471a5087 in mysql_insert (thd=0x7f3b1c00ad60, table_list=0x7f3b1c01b8e0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_insert.cc:760
          #24 0x000055b2471eb985 in mysql_execute_command (thd=0x7f3b1c00ad60) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:4504
          #25 0x000055b2471f7310 in mysql_parse (thd=0x7f3b1c00ad60, rawbuf=0x7f3b1c01b7e8 "INSERT INTO tbl_a (a) VALUES (0)", length=32, parser_state=0x7f3b180a84e0, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:7870
          #26 0x000055b2471e39ce in dispatch_command (command=COM_QUERY, thd=0x7f3b1c00ad60, packet=0x7f3b1c013001 "INSERT INTO tbl_a (a) VALUES (0)", packet_length=32, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1852
          #27 0x000055b2471e2373 in do_command (thd=0x7f3b1c00ad60) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1398
          #28 0x000055b24736303c in do_handle_one_connection (connect=0x55b24aaa28d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1403
          #29 0x000055b247362d9b in handle_one_connection (arg=0x55b24aaa28d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1308
          #30 0x00007f3b2c911450 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
          #31 0x00007f3b2c833d53 in clone () from /lib/x86_64-linux-gnu/libc.so.6
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The error is set here: (rr) bt #0 0x000055b24719d391 in Diagnostics_area::set_error_status (this=0x7f3b1c010310, sql_errno=1429, message=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost", sqlstate=0x55b247e64d5d "HY000", ucid=..., error_condition=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_error.cc:468 #1 0x000055b247178fea in THD::raise_condition (this=0x7f3b1c00ad60, sql_errno=1429, sqlstate=0x55b247e64d5d "HY000", level=Sql_state_errno_level::WARN_LEVEL_ERROR, ucid=..., msg=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost") at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_class.cc:1065 #2 0x000055b2470c03b8 in THD::raise_condition (this=0x7f3b1c00ad60, sql_errno=1429, sqlstate=0x0, level=Sql_state_errno_level::WARN_LEVEL_ERROR, msg=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost") at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_class.h:4373 #3 0x000055b2470b2667 in my_message_sql (error=1429, str=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost", MyFlags=0) at /home/nayuta_mariadb/repo/mariadb-server/sql/mysqld.cc:3717 #4 0x000055b247d9ac43 in my_message (error=1429, str=0x7f3b1c0e5652 "Unable to connect to foreign data source: localhost", MyFlags=139891849626384) at /home/nayuta_mariadb/repo/mariadb-server/mysys/my_error.c:196 #5 0x00007f3af9972e96 in spider_db_connect (share=0x7f3b1c0d83a0, conn=0x7f3b1c0e4f60, link_idx=0) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:113 #6 0x00007f3af9973d65 in spider_db_conn_queue_action (conn=0x7f3b1c0e4f60) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:292 #7 0x00007f3af997582d in spider_db_before_query (conn=0x7f3b1c0e4f60, need_mon=0x7f3b1c0e3340) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:561 #8 0x00007f3af997758c in spider_db_set_names_internal (trx=0x7f3b1c0b1bd0, share=0x7f3b1c0d83a0, conn=0x7f3b1c0e4f60, all_link_idx=0, need_mon=0x7f3b1c0e3340) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:863 #9 0x00007f3af997795d in spider_db_set_names (spider=0x7f3b1c0d5e78, conn=0x7f3b1c0e4f60, link_idx=0) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:908 #10 0x00007f3af9a7ea1c in spider_mbase_handler::show_table_status (this=0x7f3b1c0e34a0, link_idx=0, sts_mode=1, flag=80) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_mysql.cc:12523 #11 0x00007f3af998bb1b in spider_db_show_table_status (spider=0x7f3b1c0d5e78, link_idx=0, sts_mode=1, flag=80) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_db_conn.cc:5713 #12 0x00007f3af99e0894 in spider_get_sts (share=0x7f3b1c0d83a0, link_idx=0, tmp_time=1634140622, spider=0x7f3b1c0d5e78, sts_interval=0, sts_mode=1, sts_sync=0, sts_sync_level=1, flag=80) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/spd_table.cc:7693 #13 0x00007f3af9a2e655 in ha_spider::info (this=0x7f3b1c0d5e78, flag=16) at /home/nayuta_mariadb/repo/mariadb-server/storage/spider/ha_spider.cc:8795 #14 0x000055b247d68305 in ha_partition::info (this=0x7f3b1c0d5628, flag=280) at /home/nayuta_mariadb/repo/mariadb-server/sql/ha_partition.cc:8332 #15 0x000055b247d5aa8c in ha_partition::open (this=0x7f3b1c0d5628, name=0x7f3b1c0ae6c8 "./auto_test_remote/tbl_a", mode=2, test_if_locked=18) at /home/nayuta_mariadb/repo/mariadb-server/sql/ha_partition.cc:3639 #16 0x000055b24751bcdf in handler::ha_open (this=0x7f3b1c0d5628, table_arg=0x7f3b1c0d49e0, name=0x7f3b1c0ae6c8 "./auto_test_remote/tbl_a", mode=2, test_if_locked=18, mem_root=0x0, partitions_to_open=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/handler.cc:2769 #17 0x000055b247310b3f in open_table_from_share (thd=0x7f3b1c00ad60, share=0x7f3b1c0ae178, alias=0x7f3b1c01b928, db_stat=33, prgflag=8, ha_open_flags=18, outparam=0x7f3b1c0d49e0, is_create_table=false, partitions_to_open=0x0) at /home/nayuta_mariadb/repo/mariadb-server/sql/table.cc:3592 #18 0x000055b24714e966 in open_table (thd=0x7f3b1c00ad60, table_list=0x7f3b1c01b8e0, ot_ctx=0x7f3b180a7880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1992 #19 0x000055b2471522cd in open_and_process_table (thd=0x7f3b1c00ad60, tables=0x7f3b1c01b8e0, counter=0x7f3b180a7914, flags=0, prelocking_strategy=0x7f3b180a7998, has_prelocking_list=false, ot_ctx=0x7f3b180a7880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:3715 #20 0x000055b24715333e in open_tables (thd=0x7f3b1c00ad60, options=..., start=0x7f3b180a78f8, counter=0x7f3b180a7914, flags=0, prelocking_strategy=0x7f3b180a7998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:4190 #21 0x000055b247155283 in open_and_lock_tables (thd=0x7f3b1c00ad60, options=..., tables=0x7f3b1c01b8e0, derived=true, flags=0, prelocking_strategy=0x7f3b180a7998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:5129 #22 0x000055b247110de3 in open_and_lock_tables (thd=0x7f3b1c00ad60, tables=0x7f3b1c01b8e0, derived=true, flags=0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.h:503 #23 0x000055b2471a5087 in mysql_insert (thd=0x7f3b1c00ad60, table_list=0x7f3b1c01b8e0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_insert.cc:760 #24 0x000055b2471eb985 in mysql_execute_command (thd=0x7f3b1c00ad60) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:4504 #25 0x000055b2471f7310 in mysql_parse (thd=0x7f3b1c00ad60, rawbuf=0x7f3b1c01b7e8 "INSERT INTO tbl_a (a) VALUES (0)", length=32, parser_state=0x7f3b180a84e0, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:7870 #26 0x000055b2471e39ce in dispatch_command (command=COM_QUERY, thd=0x7f3b1c00ad60, packet=0x7f3b1c013001 "INSERT INTO tbl_a (a) VALUES (0)", packet_length=32, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1852 #27 0x000055b2471e2373 in do_command (thd=0x7f3b1c00ad60) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1398 #28 0x000055b24736303c in do_handle_one_connection (connect=0x55b24aaa28d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1403 #29 0x000055b247362d9b in handle_one_connection (arg=0x55b24aaa28d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1308 #30 0x00007f3b2c911450 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 #31 0x00007f3b2c833d53 in clone () from /lib/x86_64-linux-gnu/libc.so.6

          For the second INSERT, the table is fetched from the table open cache. Thus, the server does not access the storage engine and cannot know that it can not connect to the backend data node through the table. IMHO, the table should not be cached at the first INSERT because it is cannot be a valid one.

          Thread 2 hit Hardware watchpoint 5: -location table
           
          Old value = (TABLE *) 0x15180
          New value = (TABLE *) 0x7f9f0c0d4af0
          tdc_acquire_share (thd=0x7f9f0c00ae70, tl=0x7f9f0c01b9e8, flags=3, out_table=0x7f9f100554c8) at /home/nayuta_mariadb/repo/mariadb-server/sql/table_cache.cc:872
          872         if ((*out_table= tc_acquire_table(thd, element)))
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - - edited For the second INSERT, the table is fetched from the table open cache. Thus, the server does not access the storage engine and cannot know that it can not connect to the backend data node through the table. IMHO, the table should not be cached at the first INSERT because it is cannot be a valid one. Thread 2 hit Hardware watchpoint 5: -location table   Old value = (TABLE *) 0x15180 New value = (TABLE *) 0x7f9f0c0d4af0 tdc_acquire_share (thd=0x7f9f0c00ae70, tl=0x7f9f0c01b9e8, flags=3, out_table=0x7f9f100554c8) at /home/nayuta_mariadb/repo/mariadb-server/sql/table_cache.cc:872 872 if ((*out_table= tc_acquire_table(thd, element)))

          The first INSERT:

          (rr) info b
          Num     Type           Disp Enb Address            What
          13      breakpoint     keep y   0x00005604a660980c in open_table(THD*, TABLE_LIST*, Open_table_context*) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976
                  breakpoint already hit 61 times
          (rr) c
          Continuing.
           
          Thread 2 hit Breakpoint 13, open_table (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9f0, ot_ctx=0x7f9f10055880)
              at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976
          1976      if (table)
          (rr) p table
          $17 = (TABLE *) 0x0
          (rr) bt
          #0  open_table (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9f0, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976
          #1  0x00005604a660d2cd in open_and_process_table (thd=0x7f9f0c00ae70, tables=0x7f9f0c01b9f0, counter=0x7f9f10055914, flags=0, prelocking_strategy=0x7f9f10055998, 
              has_prelocking_list=false, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:3715
          #2  0x00005604a660e33e in open_tables (thd=0x7f9f0c00ae70, options=..., start=0x7f9f100558f8, counter=0x7f9f10055914, flags=0, prelocking_strategy=0x7f9f10055998)
              at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:4190
          #3  0x00005604a6610283 in open_and_lock_tables (thd=0x7f9f0c00ae70, options=..., tables=0x7f9f0c01b9f0, derived=true, flags=0, prelocking_strategy=0x7f9f10055998)
              at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:5129
          #4  0x00005604a65cbde3 in open_and_lock_tables (thd=0x7f9f0c00ae70, tables=0x7f9f0c01b9f0, derived=true, flags=0)
              at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.h:503
          #5  0x00005604a6660087 in mysql_insert (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9f0, fields=..., values_list=..., update_fields=..., update_values=..., 
              duplic=DUP_ERROR, ignore=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_insert.cc:760
          #6  0x00005604a66a6985 in mysql_execute_command (thd=0x7f9f0c00ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:4504
          #7  0x00005604a66b2310 in mysql_parse (thd=0x7f9f0c00ae70, rawbuf=0x7f9f0c01b8f8 "INSERT INTO tbl_a (a) VALUES (0)", length=32, parser_state=0x7f9f100564e0, 
              is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:7870
          #8  0x00005604a669e9ce in dispatch_command (command=COM_QUERY, thd=0x7f9f0c00ae70, packet=0x7f9f0c013111 "INSERT INTO tbl_a (a) VALUES (0)", packet_length=32, 
              is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1852
          #9  0x00005604a669d373 in do_command (thd=0x7f9f0c00ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1398
          #10 0x00005604a681e03c in do_handle_one_connection (connect=0x5604a96ec8d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1403
          #11 0x00005604a681dd9b in handle_one_connection (arg=0x5604a96ec8d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1308
          #12 0x00007f9f1a7b5450 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
          #13 0x00007f9f1a6d7d53 in clone () from /lib/x86_64-linux-gnu/libc.so.6
          

          The second INSERT:

          (rr) info b
          Num     Type           Disp Enb Address            What
          13      breakpoint     keep y   0x00005604a660980c in open_table(THD*, TABLE_LIST*, Open_table_context*) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976
                  breakpoint already hit 67 times
          (rr) c
          Continuing.
           
          Thread 2 hit Breakpoint 13, open_table (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9e8, ot_ctx=0x7f9f10055880)
              at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976
          1976      if (table)
          (rr) p table
          $18 = (TABLE *) 0x7f9f0c0d4af0
          (rr) bt
          #0  open_table (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9e8, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976
          #1  0x00005604a660d2cd in open_and_process_table (thd=0x7f9f0c00ae70, tables=0x7f9f0c01b9e8, counter=0x7f9f10055914, flags=0, prelocking_strategy=0x7f9f10055998, 
              has_prelocking_list=false, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:3715
          #2  0x00005604a660e33e in open_tables (thd=0x7f9f0c00ae70, options=..., start=0x7f9f100558f8, counter=0x7f9f10055914, flags=0, prelocking_strategy=0x7f9f10055998)
              at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:4190
          #3  0x00005604a6610283 in open_and_lock_tables (thd=0x7f9f0c00ae70, options=..., tables=0x7f9f0c01b9e8, derived=true, flags=0, prelocking_strategy=0x7f9f10055998)
              at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:5129
          #4  0x00005604a65cbde3 in open_and_lock_tables (thd=0x7f9f0c00ae70, tables=0x7f9f0c01b9e8, derived=true, flags=0)
              at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.h:503
          #5  0x00005604a6660087 in mysql_insert (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9e8, fields=..., values_list=..., update_fields=..., update_values=..., 
              duplic=DUP_ERROR, ignore=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_insert.cc:760
          #6  0x00005604a66a6985 in mysql_execute_command (thd=0x7f9f0c00ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:4504
          #7  0x00005604a66b2310 in mysql_parse (thd=0x7f9f0c00ae70, rawbuf=0x7f9f0c01b8f8 "INSERT INTO tbl_a () VALUES ()", length=30, parser_state=0x7f9f100564e0, 
              is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:7870
          #8  0x00005604a669e9ce in dispatch_command (command=COM_QUERY, thd=0x7f9f0c00ae70, packet=0x7f9f0c013111 "INSERT INTO tbl_a () VALUES ()", packet_length=30, 
              is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1852
          #9  0x00005604a669d373 in do_command (thd=0x7f9f0c00ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1398
          #10 0x00005604a681e03c in do_handle_one_connection (connect=0x5604a96ec8d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1403
          #11 0x00005604a681dd9b in handle_one_connection (arg=0x5604a96ec8d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1308
          #12 0x00007f9f1a7b5450 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
          #13 0x00007f9f1a6d7d53 in clone () from /lib/x86_64-linux-gnu/libc.so.6
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The first INSERT: (rr) info b Num Type Disp Enb Address What 13 breakpoint keep y 0x00005604a660980c in open_table(THD*, TABLE_LIST*, Open_table_context*) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976 breakpoint already hit 61 times (rr) c Continuing.   Thread 2 hit Breakpoint 13, open_table (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9f0, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976 1976 if (table) (rr) p table $17 = (TABLE *) 0x0 (rr) bt #0 open_table (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9f0, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976 #1 0x00005604a660d2cd in open_and_process_table (thd=0x7f9f0c00ae70, tables=0x7f9f0c01b9f0, counter=0x7f9f10055914, flags=0, prelocking_strategy=0x7f9f10055998, has_prelocking_list=false, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:3715 #2 0x00005604a660e33e in open_tables (thd=0x7f9f0c00ae70, options=..., start=0x7f9f100558f8, counter=0x7f9f10055914, flags=0, prelocking_strategy=0x7f9f10055998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:4190 #3 0x00005604a6610283 in open_and_lock_tables (thd=0x7f9f0c00ae70, options=..., tables=0x7f9f0c01b9f0, derived=true, flags=0, prelocking_strategy=0x7f9f10055998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:5129 #4 0x00005604a65cbde3 in open_and_lock_tables (thd=0x7f9f0c00ae70, tables=0x7f9f0c01b9f0, derived=true, flags=0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.h:503 #5 0x00005604a6660087 in mysql_insert (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9f0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_insert.cc:760 #6 0x00005604a66a6985 in mysql_execute_command (thd=0x7f9f0c00ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:4504 #7 0x00005604a66b2310 in mysql_parse (thd=0x7f9f0c00ae70, rawbuf=0x7f9f0c01b8f8 "INSERT INTO tbl_a (a) VALUES (0)", length=32, parser_state=0x7f9f100564e0, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:7870 #8 0x00005604a669e9ce in dispatch_command (command=COM_QUERY, thd=0x7f9f0c00ae70, packet=0x7f9f0c013111 "INSERT INTO tbl_a (a) VALUES (0)", packet_length=32, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1852 #9 0x00005604a669d373 in do_command (thd=0x7f9f0c00ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1398 #10 0x00005604a681e03c in do_handle_one_connection (connect=0x5604a96ec8d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1403 #11 0x00005604a681dd9b in handle_one_connection (arg=0x5604a96ec8d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1308 #12 0x00007f9f1a7b5450 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 #13 0x00007f9f1a6d7d53 in clone () from /lib/x86_64-linux-gnu/libc.so.6 The second INSERT: (rr) info b Num Type Disp Enb Address What 13 breakpoint keep y 0x00005604a660980c in open_table(THD*, TABLE_LIST*, Open_table_context*) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976 breakpoint already hit 67 times (rr) c Continuing.   Thread 2 hit Breakpoint 13, open_table (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9e8, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976 1976 if (table) (rr) p table $18 = (TABLE *) 0x7f9f0c0d4af0 (rr) bt #0 open_table (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9e8, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:1976 #1 0x00005604a660d2cd in open_and_process_table (thd=0x7f9f0c00ae70, tables=0x7f9f0c01b9e8, counter=0x7f9f10055914, flags=0, prelocking_strategy=0x7f9f10055998, has_prelocking_list=false, ot_ctx=0x7f9f10055880) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:3715 #2 0x00005604a660e33e in open_tables (thd=0x7f9f0c00ae70, options=..., start=0x7f9f100558f8, counter=0x7f9f10055914, flags=0, prelocking_strategy=0x7f9f10055998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:4190 #3 0x00005604a6610283 in open_and_lock_tables (thd=0x7f9f0c00ae70, options=..., tables=0x7f9f0c01b9e8, derived=true, flags=0, prelocking_strategy=0x7f9f10055998) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.cc:5129 #4 0x00005604a65cbde3 in open_and_lock_tables (thd=0x7f9f0c00ae70, tables=0x7f9f0c01b9e8, derived=true, flags=0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_base.h:503 #5 0x00005604a6660087 in mysql_insert (thd=0x7f9f0c00ae70, table_list=0x7f9f0c01b9e8, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_insert.cc:760 #6 0x00005604a66a6985 in mysql_execute_command (thd=0x7f9f0c00ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:4504 #7 0x00005604a66b2310 in mysql_parse (thd=0x7f9f0c00ae70, rawbuf=0x7f9f0c01b8f8 "INSERT INTO tbl_a () VALUES ()", length=30, parser_state=0x7f9f100564e0, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:7870 #8 0x00005604a669e9ce in dispatch_command (command=COM_QUERY, thd=0x7f9f0c00ae70, packet=0x7f9f0c013111 "INSERT INTO tbl_a () VALUES ()", packet_length=30, is_com_multi=false, is_next_command=false) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1852 #9 0x00005604a669d373 in do_command (thd=0x7f9f0c00ae70) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_parse.cc:1398 #10 0x00005604a681e03c in do_handle_one_connection (connect=0x5604a96ec8d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1403 #11 0x00005604a681dd9b in handle_one_connection (arg=0x5604a96ec8d0) at /home/nayuta_mariadb/repo/mariadb-server/sql/sql_connect.cc:1308 #12 0x00007f9f1a7b5450 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 #13 0x00007f9f1a6d7d53 in clone () from /lib/x86_64-linux-gnu/libc.so.6

          > IMHO, the table should not be cached at the first INSERT because it is cannot be a valid one.

          We can possibly do this by setting TABLE_SHARE::error because tdc_aquire_share() checks the error:

          ...
              if (checked_unlikely(share->error))
              {
                free_table_share(share);
                lf_hash_delete(&tdc_hash, thd->tdc_hash_pins, key, key_length);
                DBUG_RETURN(0);
              }
          ...
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - - edited > IMHO, the table should not be cached at the first INSERT because it is cannot be a valid one. We can possibly do this by setting TABLE_SHARE::error because tdc_aquire_share() checks the error: ... if (checked_unlikely(share->error)) { free_table_share(share); lf_hash_delete(&tdc_hash, thd->tdc_hash_pins, key, key_length); DBUG_RETURN(0); } ...

          > We can possibly do this by setting TABLE_SHARE::error because tdc_aquire_share() checks the error:

          I noticed that, during the table share creation, the server seems not to access the Spider storage engine, so the above is impossible. I think, instead, we can stop caching TABLE.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - > We can possibly do this by setting TABLE_SHARE::error because tdc_aquire_share() checks the error: I noticed that, during the table share creation, the server seems not to access the Spider storage engine, so the above is impossible. I think, instead, we can stop caching TABLE.

          The fix below is incomplete (it causes memory leaks), but I am thinking of making a fix in this direction.

          diff --git a/sql/sql_base.cc b/sql/sql_base.cc
          index a1f3f6116b9..bc938ae4c96 100644
          --- a/sql/sql_base.cc
          +++ b/sql/sql_base.cc
          @@ -3715,13 +3715,15 @@ open_and_process_table(THD *thd, TABLE_LIST *tables, uint *counter, uint flags,
                 error= open_table(thd, tables, ot_ctx);
             }
           
          -  if (unlikely(error))
          +  if (unlikely(error || thd->is_error()))
             {
               if (! ot_ctx->can_recover_from_failed_open() && safe_to_ignore_table)
               {
                 DBUG_PRINT("info", ("open_table: ignoring table '%s'.'%s'",
                                     tables->db.str, tables->alias.str));
                 error= FALSE;
          +    } else {
          +      close_cached_tables(thd, tables, FALSE, LONG_TIMEOUT);
               }
               goto end;
             }
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The fix below is incomplete (it causes memory leaks), but I am thinking of making a fix in this direction. diff --git a/sql/sql_base.cc b/sql/sql_base.cc index a1f3f6116b9..bc938ae4c96 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3715,13 +3715,15 @@ open_and_process_table(THD *thd, TABLE_LIST *tables, uint *counter, uint flags, error= open_table(thd, tables, ot_ctx); } - if (unlikely(error)) + if (unlikely(error || thd->is_error())) { if (! ot_ctx->can_recover_from_failed_open() && safe_to_ignore_table) { DBUG_PRINT( "info" , ( "open_table: ignoring table '%s'.'%s'" , tables->db.str, tables->alias.str)); error= FALSE; + } else { + close_cached_tables(thd, tables, FALSE, LONG_TIMEOUT); } goto end; }

          I think the basic direction is right, but it still leaks memory. I will dig it further tomorrow.

          diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
          index ca3b7fa08ed..c1292b16f5d 100644
          --- a/storage/spider/spd_table.cc
          +++ b/storage/spider/spd_table.cc
          @@ -5162,14 +5162,17 @@ SPIDER_SHARE *spider_get_share(
                     !same_server_link ||
                     load_sts_at_startup
                   ) &&
          -        spider_get_sts(share, spider->search_link_idx, tmp_time,
          +        (*error_num = spider_get_sts(share, spider->search_link_idx, tmp_time,
                     spider, sts_interval, sts_mode,
           #ifdef WITH_PARTITION_STORAGE_ENGINE
                     sts_sync,
           #endif
          -          1, HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_AUTO)
          +          1, HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_AUTO))
                 ) {
          -        thd->clear_error();
          +        pthread_mutex_unlock(&share->crd_mutex);
          +        pthread_mutex_unlock(&share->sts_mutex);
          +        spider_free_share(share);
          +        goto error_but_no_delete;
                 }
                 if (
                   (
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - - edited I think the basic direction is right, but it still leaks memory. I will dig it further tomorrow. diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index ca3b7fa08ed..c1292b16f5d 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -5162,14 +5162,17 @@ SPIDER_SHARE *spider_get_share( !same_server_link || load_sts_at_startup ) && - spider_get_sts(share, spider->search_link_idx, tmp_time, + (*error_num = spider_get_sts(share, spider->search_link_idx, tmp_time, spider, sts_interval, sts_mode, #ifdef WITH_PARTITION_STORAGE_ENGINE sts_sync, #endif - 1, HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_AUTO) + 1, HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_AUTO)) ) { - thd->clear_error(); + pthread_mutex_unlock(&share->crd_mutex); + pthread_mutex_unlock(&share->sts_mutex); + spider_free_share(share); + goto error_but_no_delete; } if ( (

          Another possible fix (with no leak) is the following:

          diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
          index fc1f0ebcb4e..7616b3ee364 100644
          --- a/sql/ha_partition.cc
          +++ b/sql/ha_partition.cc
          @@ -4273,8 +4273,10 @@ int ha_partition::write_row(uchar * buf)
             if (have_auto_increment)
             {
               if (!table_share->next_number_keypart)
          -      update_next_auto_inc_val();
          -    error= update_auto_increment();
          +      error= update_next_auto_inc_val();
          +
          +    if (!error)
          +      error= update_auto_increment();
           
               /*
                 If we have failed to set the auto-increment value for this row,
          @@ -8221,6 +8223,7 @@ int ha_partition::compare_number_of_records(ha_partition *me,
           
           int ha_partition::info(uint flag)
           {
          +  int error;
             uint no_lock_flag= flag & HA_STATUS_NO_LOCK;
             uint extra_var_flag= flag & HA_STATUS_VARIABLE_EXTRA;
             DBUG_ENTER("ha_partition::info");
          @@ -8273,7 +8276,11 @@ int ha_partition::info(uint flag)
                       break;
                     }
                     file= *file_array;
          -          file->info(HA_STATUS_AUTO | no_lock_flag);
          +          if ((error= file->info(HA_STATUS_AUTO | no_lock_flag)))
          +          {
          +            unlock_auto_increment();
          +            DBUG_RETURN(error);
          +          }
                     set_if_bigger(auto_increment_value,
                                   file->stats.auto_increment_value);
                   } while (*(++file_array));
          @@ -10443,11 +10450,11 @@ int ha_partition::cmp_ref(const uchar *ref1, const uchar *ref2)
              the underlying partitions require that the value should be re-calculated
           */
           
          -void ha_partition::update_next_auto_inc_val()
          +int ha_partition::update_next_auto_inc_val()
           {
          -  if (!part_share->auto_inc_initialized ||
          -      need_info_for_auto_inc())
          -    info(HA_STATUS_AUTO);
          +  if (!part_share->auto_inc_initialized || need_info_for_auto_inc())
          +    return info(HA_STATUS_AUTO);
          +  return 0;
           }
           
           
          diff --git a/sql/ha_partition.h b/sql/ha_partition.h
          index 48552301f55..63af91c6dd7 100644
          --- a/sql/ha_partition.h
          +++ b/sql/ha_partition.h
          @@ -1364,7 +1364,7 @@ class ha_partition :public handler
             virtual void release_auto_increment();
           private:
             virtual int reset_auto_increment(ulonglong value);
          -  void update_next_auto_inc_val();
          +  int update_next_auto_inc_val();
             virtual void lock_auto_increment()
             {
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - Another possible fix (with no leak) is the following: diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index fc1f0ebcb4e..7616b3ee364 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4273,8 +4273,10 @@ int ha_partition::write_row(uchar * buf) if (have_auto_increment) { if (!table_share->next_number_keypart) - update_next_auto_inc_val(); - error= update_auto_increment(); + error= update_next_auto_inc_val(); + + if (!error) + error= update_auto_increment(); /* If we have failed to set the auto-increment value for this row, @@ -8221,6 +8223,7 @@ int ha_partition::compare_number_of_records(ha_partition *me, int ha_partition::info(uint flag) { + int error; uint no_lock_flag= flag & HA_STATUS_NO_LOCK; uint extra_var_flag= flag & HA_STATUS_VARIABLE_EXTRA; DBUG_ENTER("ha_partition::info"); @@ -8273,7 +8276,11 @@ int ha_partition::info(uint flag) break; } file= *file_array; - file->info(HA_STATUS_AUTO | no_lock_flag); + if ((error= file->info(HA_STATUS_AUTO | no_lock_flag))) + { + unlock_auto_increment(); + DBUG_RETURN(error); + } set_if_bigger(auto_increment_value, file->stats.auto_increment_value); } while (*(++file_array)); @@ -10443,11 +10450,11 @@ int ha_partition::cmp_ref(const uchar *ref1, const uchar *ref2) the underlying partitions require that the value should be re-calculated */ - void ha_partition::update_next_auto_inc_val() + int ha_partition::update_next_auto_inc_val() { - if (!part_share->auto_inc_initialized || - need_info_for_auto_inc()) - info(HA_STATUS_AUTO); + if (!part_share->auto_inc_initialized || need_info_for_auto_inc()) + return info(HA_STATUS_AUTO); + return 0; } diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 48552301f55..63af91c6dd7 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1364,7 +1364,7 @@ class ha_partition : public handler virtual void release_auto_increment(); private : virtual int reset_auto_increment(ulonglong value); - void update_next_auto_inc_val(); + int update_next_auto_inc_val(); virtual void lock_auto_increment() {

          The above breaks so many test, at least the followings:

          Failing test(s): parts.partition_auto_increment_blackhole main.partition parts.partition_auto_increment_maria parts.partition_auto_increment_myisam
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The above breaks so many test, at least the followings: Failing test(s): parts.partition_auto_increment_blackhole main.partition parts.partition_auto_increment_maria parts.partition_auto_increment_myisam
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - holyfoot Please review https://github.com/MariaDB/server/commit/a56a56a35440b3b3a9dde335d85ced2003aa25c2
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
          Assignee Nayuta Yanagisawa [ JIRAUSER47117 ] Alexey Botchkov [ holyfoot ]
          Status In Progress [ 3 ] In Review [ 10002 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 124830 ] MariaDB v4 [ 143802 ]
          Roel Roel Van de Paar made changes -
          Fix Version/s 10.7 [ 24805 ]

          In case it helps, at times, this failed stack may be seen in connection with this bug:

          10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

          mysqld: /test/10.9_dbg/sql/ha_partition.cc:10808: virtual void ha_partition::get_auto_increment(ulonglong, ulonglong, ulonglong, ulonglong*, ulonglong*): Assertion `part_share->auto_inc_initialized' failed.
          

          10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

          Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --max_a'.
          Program terminated with signal SIGABRT, Aborted.
          #0  0x000014a299f0418b in ?? ()
          [Current thread is 1 (LWP 3879947)]
          (gdb) bt
          #0  0x000014a299f0418b in ?? ()
          Backtrace stopped: Cannot access memory at address 0x14a2980d6610
          

          Roel Roel Van de Paar added a comment - In case it helps, at times, this failed stack may be seen in connection with this bug: 10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug) mysqld: /test/10.9_dbg/sql/ha_partition.cc:10808: virtual void ha_partition::get_auto_increment(ulonglong, ulonglong, ulonglong, ulonglong*, ulonglong*): Assertion `part_share->auto_inc_initialized' failed. 10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug) Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --max_a'. Program terminated with signal SIGABRT, Aborted. #0 0x000014a299f0418b in ?? () [Current thread is 1 (LWP 3879947)] (gdb) bt #0 0x000014a299f0418b in ?? () Backtrace stopped: Cannot access memory at address 0x14a2980d6610
          Roel Roel Van de Paar added a comment - - edited

          Additional testcase

          INSTALL PLUGIN spider SONAME 'ha_spider.so';
          SET sql_mode='';
          CREATE TABLE t (c INT UNSIGNED AUTO_INCREMENT,c2 INT UNSIGNED,KEY(c)) COMMENT='' PARTITION BY LIST COLUMNS (c) (PARTITION p DEFAULT COMMENT='' ENGINE=SPIDER);
          SELECT * FROM t LIMIT 100;
          INSERT INTO t VALUES ('',1);
          

          Leads to:

          10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

          mysqld: /test/10.9_dbg/sql/ha_partition.cc:10808: virtual void ha_partition::get_auto_increment(ulonglong, ulonglong, ulonglong, ulonglong*, ulonglong*): Assertion `part_share->auto_inc_initialized' failed.
          

          10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

          Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
          Program terminated with signal SIGABRT, Aborted.
          #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
          [Current thread is 1 (Thread 0x14d7fc0b3700 (LWP 983))]
          (gdb) bt
          #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
          #1  0x000014d81b338859 in __GI_abort () at abort.c:79
          #2  0x000014d81b338729 in __assert_fail_base (fmt=0x14d81b4ce588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5573758da120 "part_share->auto_inc_initialized", file=0x5573758d8cf0 "/test/10.9_dbg/sql/ha_partition.cc", line=10808, function=<optimized out>) at assert.c:92
          #3  0x000014d81b349f36 in __GI___assert_fail (assertion=assertion@entry=0x5573758da120 "part_share->auto_inc_initialized", file=file@entry=0x5573758d8cf0 "/test/10.9_dbg/sql/ha_partition.cc", line=line@entry=10808, function=function@entry=0x5573758da080 "virtual void ha_partition::get_auto_increment(ulonglong, ulonglong, ulonglong, ulonglong*, ulonglong*)") at assert.c:101
          #4  0x0000557374fdff65 in ha_partition::get_auto_increment (this=0x14d75c056620, offset=1, increment=1, nb_desired_values=1, first_value=0x14d7fc0b1970, nb_reserved_values=0x14d7fc0b1978) at /test/10.9_dbg/sql/ha_partition.cc:10808
          #5  0x0000557374d0a4a9 in handler::update_auto_increment (this=this@entry=0x14d75c056620) at /test/10.9_dbg/sql/handler.cc:3951
          #6  0x0000557374ff2d0a in ha_partition::write_row (this=0x14d75c056620, buf=0x14d75c032188 <incomplete sequence \375>) at /test/10.9_dbg/sql/ha_partition.cc:4438
          #7  0x0000557374d12369 in handler::ha_write_row (this=0x14d75c056620, buf=0x14d75c032188 <incomplete sequence \375>) at /test/10.9_dbg/sql/handler.cc:7522
          #8  0x00005573749a8372 in write_record (thd=thd@entry=0x14d75c000db8, table=table@entry=0x14d75c0313e8, info=info@entry=0x14d7fc0b1cd0, sink=sink@entry=0x0) at /test/10.9_dbg/sql/sql_insert.cc:2156
          #9  0x00005573749b40c8 in mysql_insert (thd=thd@entry=0x14d75c000db8, table_list=0x14d75c013ec0, fields=@0x14d75c006080: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5573760439e0 <end_of_list>, last = 0x14d75c006080, elements = 0}, <No data fields>}, values_list=@0x14d75c0060c8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14d75c014b50, last = 0x14d75c014b50, elements = 1}, <No data fields>}, update_fields=@0x14d75c0060b0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5573760439e0 <end_of_list>, last = 0x14d75c0060b0, elements = 0}, <No data fields>}, update_values=@0x14d75c006098: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5573760439e0 <end_of_list>, last = 0x14d75c006098, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/10.9_dbg/sql/sql_insert.cc:1127
          #10 0x00005573749fa92a in mysql_execute_command (thd=thd@entry=0x14d75c000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:4562
          #11 0x00005573749e5315 in mysql_parse (thd=thd@entry=0x14d75c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14d7fc0b2400) at /test/10.9_dbg/sql/sql_parse.cc:8027
          #12 0x00005573749f3fb1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14d75c000db8, packet=packet@entry=0x14d75c00b889 "INSERT INTO t VALUES ('',1)", packet_length=packet_length@entry=27, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362
          #13 0x00005573749f73f8 in do_command (thd=0x14d75c000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1402
          #14 0x0000557374b71fc4 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x557377c21718, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
          #15 0x0000557374b725c9 in handle_one_connection (arg=arg@entry=0x557377c21718) at /test/10.9_dbg/sql/sql_connect.cc:1312
          #16 0x0000557374ff8d67 in pfs_spawn_thread (arg=0x557377b34878) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201
          #17 0x000014d81b847609 in start_thread (arg=<optimized out>) at pthread_create.c:477
          #18 0x000014d81b435293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
          

          Bug confirmed present in:
          MariaDB: 10.4.23 (dbg), 10.5.14 (dbg), 10.6.6 (dbg), 10.7.2 (dbg), 10.8.1 (dbg), 10.9.0 (dbg)

          Bug (or feature/syntax) confirmed not present in:
          MariaDB: 10.4.23 (opt), 10.5.14 (opt), 10.6.6 (opt), 10.7.2 (opt), 10.8.1 (opt), 10.9.0 (opt)
          MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

          May exist in 10.3 also.

          Roel Roel Van de Paar added a comment - - edited Additional testcase INSTALL PLUGIN spider SONAME 'ha_spider.so' ; SET sql_mode= '' ; CREATE TABLE t (c INT UNSIGNED AUTO_INCREMENT,c2 INT UNSIGNED, KEY (c)) COMMENT= '' PARTITION BY LIST COLUMNS (c) (PARTITION p DEFAULT COMMENT= '' ENGINE=SPIDER); SELECT * FROM t LIMIT 100; INSERT INTO t VALUES ( '' ,1); Leads to: 10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug) mysqld: /test/10.9_dbg/sql/ha_partition.cc:10808: virtual void ha_partition::get_auto_increment(ulonglong, ulonglong, ulonglong, ulonglong*, ulonglong*): Assertion `part_share->auto_inc_initialized' failed. 10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug) Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'. Program terminated with signal SIGABRT, Aborted. #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 [Current thread is 1 (Thread 0x14d7fc0b3700 (LWP 983))] (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x000014d81b338859 in __GI_abort () at abort.c:79 #2 0x000014d81b338729 in __assert_fail_base (fmt=0x14d81b4ce588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5573758da120 "part_share->auto_inc_initialized", file=0x5573758d8cf0 "/test/10.9_dbg/sql/ha_partition.cc", line=10808, function=<optimized out>) at assert.c:92 #3 0x000014d81b349f36 in __GI___assert_fail (assertion=assertion@entry=0x5573758da120 "part_share->auto_inc_initialized", file=file@entry=0x5573758d8cf0 "/test/10.9_dbg/sql/ha_partition.cc", line=line@entry=10808, function=function@entry=0x5573758da080 "virtual void ha_partition::get_auto_increment(ulonglong, ulonglong, ulonglong, ulonglong*, ulonglong*)") at assert.c:101 #4 0x0000557374fdff65 in ha_partition::get_auto_increment (this=0x14d75c056620, offset=1, increment=1, nb_desired_values=1, first_value=0x14d7fc0b1970, nb_reserved_values=0x14d7fc0b1978) at /test/10.9_dbg/sql/ha_partition.cc:10808 #5 0x0000557374d0a4a9 in handler::update_auto_increment (this=this@entry=0x14d75c056620) at /test/10.9_dbg/sql/handler.cc:3951 #6 0x0000557374ff2d0a in ha_partition::write_row (this=0x14d75c056620, buf=0x14d75c032188 <incomplete sequence \375>) at /test/10.9_dbg/sql/ha_partition.cc:4438 #7 0x0000557374d12369 in handler::ha_write_row (this=0x14d75c056620, buf=0x14d75c032188 <incomplete sequence \375>) at /test/10.9_dbg/sql/handler.cc:7522 #8 0x00005573749a8372 in write_record (thd=thd@entry=0x14d75c000db8, table=table@entry=0x14d75c0313e8, info=info@entry=0x14d7fc0b1cd0, sink=sink@entry=0x0) at /test/10.9_dbg/sql/sql_insert.cc:2156 #9 0x00005573749b40c8 in mysql_insert (thd=thd@entry=0x14d75c000db8, table_list=0x14d75c013ec0, fields=@0x14d75c006080: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5573760439e0 <end_of_list>, last = 0x14d75c006080, elements = 0}, <No data fields>}, values_list=@0x14d75c0060c8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14d75c014b50, last = 0x14d75c014b50, elements = 1}, <No data fields>}, update_fields=@0x14d75c0060b0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5573760439e0 <end_of_list>, last = 0x14d75c0060b0, elements = 0}, <No data fields>}, update_values=@0x14d75c006098: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5573760439e0 <end_of_list>, last = 0x14d75c006098, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/10.9_dbg/sql/sql_insert.cc:1127 #10 0x00005573749fa92a in mysql_execute_command (thd=thd@entry=0x14d75c000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:4562 #11 0x00005573749e5315 in mysql_parse (thd=thd@entry=0x14d75c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14d7fc0b2400) at /test/10.9_dbg/sql/sql_parse.cc:8027 #12 0x00005573749f3fb1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14d75c000db8, packet=packet@entry=0x14d75c00b889 "INSERT INTO t VALUES ('',1)", packet_length=packet_length@entry=27, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362 #13 0x00005573749f73f8 in do_command (thd=0x14d75c000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1402 #14 0x0000557374b71fc4 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x557377c21718, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418 #15 0x0000557374b725c9 in handle_one_connection (arg=arg@entry=0x557377c21718) at /test/10.9_dbg/sql/sql_connect.cc:1312 #16 0x0000557374ff8d67 in pfs_spawn_thread (arg=0x557377b34878) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201 #17 0x000014d81b847609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #18 0x000014d81b435293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Bug confirmed present in: MariaDB: 10.4.23 (dbg), 10.5.14 (dbg), 10.6.6 (dbg), 10.7.2 (dbg), 10.8.1 (dbg), 10.9.0 (dbg) Bug (or feature/syntax) confirmed not present in: MariaDB: 10.4.23 (opt), 10.5.14 (opt), 10.6.6 (opt), 10.7.2 (opt), 10.8.1 (opt), 10.9.0 (opt) MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt) May exist in 10.3 also.

          holyfoot The fix has been proposed months ago. Please review.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - holyfoot The fix has been proposed months ago. Please review.

          Two comments added to the patch.

          holyfoot Alexey Botchkov added a comment - Two comments added to the patch.
          holyfoot Alexey Botchkov made changes -
          Assignee Alexey Botchkov [ holyfoot ] Nayuta Yanagisawa [ JIRAUSER47117 ]
          Status In Review [ 10002 ] Stalled [ 10000 ]
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - holyfoot Thank you for your review. Fixed following your comments: https://github.com/MariaDB/server/commit/0bc343ad201431923615b2dbf8fc1f6fcf887299#
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
          Assignee Nayuta Yanagisawa [ JIRAUSER47117 ] Alexey Botchkov [ holyfoot ]
          Status Stalled [ 10000 ] In Review [ 10002 ]

          > int error= 0;
          No need to assign here.
          Otherwise ok to push.

          holyfoot Alexey Botchkov added a comment - > int error= 0; No need to assign here. Otherwise ok to push.
          holyfoot Alexey Botchkov made changes -
          Assignee Alexey Botchkov [ holyfoot ] Nayuta Yanagisawa [ JIRAUSER47117 ]
          Status In Review [ 10002 ] Stalled [ 10000 ]

          Thank you for your review. Remove the assignment and pushed.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - Thank you for your review. Remove the assignment and pushed.
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
          Fix Version/s 10.3.36 [ 27513 ]
          Fix Version/s 10.4.26 [ 27511 ]
          Fix Version/s 10.5.17 [ 27509 ]
          Fix Version/s 10.6.9 [ 27507 ]
          Fix Version/s 10.7.5 [ 27505 ]
          Fix Version/s 10.8.4 [ 27503 ]
          Fix Version/s 10.9.2 [ 27115 ]
          Fix Version/s 10.3 [ 22126 ]
          Fix Version/s 10.4 [ 22408 ]
          Fix Version/s 10.5 [ 23123 ]
          Fix Version/s 10.6 [ 24028 ]
          Fix Version/s 10.7 [ 24805 ]
          Resolution Fixed [ 1 ]
          Status Stalled [ 10000 ] Closed [ 6 ]
          Roel Roel Van de Paar added a comment - - edited

          I ran into this bug again in an older feature branch (not in trunk). For completeness, here is a minimal testcase:

          INSTALL PLUGIN Spider SONAME 'ha_spider.so';
          CREATE TABLE t (i INT AUTO_INCREMENT KEY) ENGINE=Spider PARTITION BY HASH (i) PARTITIONS 2;
          INSERT INTO t VALUES (0);
          INSERT INTO t VALUES (0);
          

          Roel Roel Van de Paar added a comment - - edited I ran into this bug again in an older feature branch (not in trunk). For completeness, here is a minimal testcase: INSTALL PLUGIN Spider SONAME 'ha_spider.so' ; CREATE TABLE t (i INT AUTO_INCREMENT KEY ) ENGINE=Spider PARTITION BY HASH (i) PARTITIONS 2; INSERT INTO t VALUES (0); INSERT INTO t VALUES (0);

          People

            nayuta-yanagisawa Nayuta Yanagisawa (Inactive)
            Roel Roel Van de Paar
            Votes:
            0 Vote for this issue
            Watchers:
            5 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.