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

Server crashes while executing ALTER TABLE in sql_mode=oracle

    XMLWordPrintable

Details

    Description

      MariaDB server version 10.2.14 (build 22257 and build from current source) from bb-10.2-compatibility branch crashes while executing ALTER TABLE that changes TIMESTAMP column and sets '' as default value for it.

      Consider the following table:

      CREATE TABLE tbug (
        id int(11) NOT NULL AUTO_INCREMENT,
        fn varchar(50) NOT NULL DEFAULT '0',
        data longtext NOT NULL DEFAULT '0',
        more_data longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '0',
        even_more_data longtext DEFAULT '0',
        udate timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
        uby varchar(50) NOT NULL,
        PRIMARY KEY (fn),
        KEY `id` (id)
      ) ENGINE=InnoDB;
      

      with 21 rows of data inserted as follows:

      ...
      MariaDB [test]> insert into tbug(fn, data, more_data, even_more_data, uby) values(rand()*10000, repeat('a', 10000), repeat('b', 2000), repeat('c', 3000), rand()*100);
      Query OK, 1 row affected (0.03 sec)
       
      MariaDB [test]> insert into tbug(fn, data, more_data, even_more_data, uby) values(rand()*10000, repeat('a', 10000), repeat('b', 2000), repeat('c', 3000), rand()*100);
      Query OK, 1 row affected (0.03 sec)
       
      MariaDB [test]> insert into tbug(fn, data, more_data, even_more_data, uby) values(rand()*10000, repeat('a', 10000), repeat('b', 2000), repeat('c', 3000), rand()*100);
      Query OK, 1 row affected (0.04 sec)
       
      MariaDB [test]> show create table tbug\G
      *************************** 1. row ***************************
             Table: tbug
      Create Table: CREATE TABLE `tbug` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `fn` varchar(50) NOT NULL DEFAULT '0',
        `data` longtext NOT NULL DEFAULT '0',
        `more_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '0',
        `even_more_data` longtext DEFAULT '0',
        `udate` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
        `uby` varchar(50) NOT NULL,
        PRIMARY KEY (`fn`),
        KEY `id` (`id`)
      ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1
      1 row in set (0.00 sec)
      

      Now, if we try to run this ALTER in default sql_mode:

      MariaDB [test]> ALTER TABLE tbug CHANGE COLUMN udate udate TIMESTAMP NULL DEFAULT '' ON UPDATE CURRENT_TIMESTAMP AFTER even_more_data;
      ERROR 1292 (22007): Incorrect datetime value: '' for column 'udate' at row 1
      MariaDB [test]> select @@sql_mode;
      +-------------------------------------------------------------------------------------------+
      | @@sql_mode                                                                                |
      +-------------------------------------------------------------------------------------------+
      | STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
      +-------------------------------------------------------------------------------------------+
      1 row in set (0.00 sec)
      

      it is not accepted, but when we try to set sql_mode to oracle it crashes:

      MariaDB [test]> set sql_mode=oracle;
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> select @@sql_mode;
      +----------------------------------------------------------------------------------------------------------------------+
      | @@sql_mode                                                                                                           |
      +----------------------------------------------------------------------------------------------------------------------+
      | PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER |
      +----------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> ALTER TABLE tbug CHANGE COLUMN udate udate TIMESTAMP NULL DEFAULT '' ON UPDATE CURRENT_TIMESTAMP AFTER even_more_data;
      ERROR 2013 (HY000): Lost connection to MySQL server during query
      MariaDB [test]> exit
      Bye
      [openxs@fc29 maria10.2]$ tail -80 data/fc29.err
      or one of the libraries it was linked against is corrupt, improperly built,
      or misconfigured. This error can also be caused by malfunctioning hardware.
       
      To report this bug, see https://mariadb.com/kb/en/reporting-bugs
       
      We will try our best to scrape up some info that will hopefully help
      diagnose the problem, but since we have already crashed,
      something is definitely wrong and this may fail.
       
      Server version: 10.2.14-MariaDB
      key_buffer_size=134217728
      read_buffer_size=131072
      max_used_connections=1
      max_threads=153
      thread_count=7
      It is possible that mysqld could use up to
      key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467310 K  bytes of memory
      Hope that's ok; if not, decrease some variables in the equation.
       
      Thread pointer: 0x7fc010000c08
      Attempting backtrace. You can use the following information to find out
      where mysqld died. If you see no messages after this, something went
      terribly wrong...
      stack_bottom = 0x7fc070a3dcb8 thread_stack 0x49000
      /home/openxs/dbs/maria10.2/bin/mysqld(my_print_stacktrace+0x29)[0x55a7ee149699]
      mysys/stacktrace.c:268(my_print_stacktrace)[0x55a7edcd7cab]
      sigaction.c:0(__restore_rt)[0x7fc086fb9070]
      /home/openxs/dbs/maria10.2/bin/mysqld(_ZN17Column_definition22has_default_expressionEv+0x19)[0x55a7edcc8e59]
      sql/field.cc:10686(Column_definition::has_default_expression())[0x55a7edbdcf15]
      sql/unireg.cc:578(pack_vcols)[0x55a7edbaafe5]
      sql/sql_table.cc:4527(mysql_create_frm_image(THD*, char const*, char const*, HA_CREATE_INFO*, Alter_info*, int, st_key**, unsigned int*, st_mysql_const_unsigned_lex_string*))[0x55a7edbb0455]
      sql/sql_table.cc:4768(create_table_impl(THD*, char const*, char const*, char const*, char const*, char const*, DDL_options_st, HA_CREATE_INFO*, Alter_info*, int, bool*, st_key**, unsigned int*, st_mysql_const_unsigned_lex_string*))[0x55a7edbb23ac]
      sql/sql_table.cc:9100(mysql_alter_table(THD*, char const*, char const*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool))[0x55a7edbfa1f4]
      sql/sql_alter.cc:324(Sql_cmd_alter_table::execute(THD*))[0x55a7edb2c8a0]
      sql/sql_parse.cc:6257(mysql_execute_command(THD*))[0x55a7edb33cf6]
      sql/sql_parse.cc:7983(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55a7edb36929]
      sql/sql_parse.cc:1837(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55a7edb3739e]
      sql/sql_parse.cc:1388(do_command(THD*))[0x55a7edbf7674]
      sql/sql_connect.cc:1335(do_handle_one_connection(CONNECT*))[0x55a7edbf7814]
      pthread_create.c:0(start_thread)[0x7fc086fae58e]
      :0(__GI___clone)[0x7fc086684683]
       
      Trying to get some variables.
      Some pointers may be invalid and cause the dump to abort.
      Query (0x7fc01000f520): ALTER TABLE tbug CHANGE COLUMN udate udate TIMESTAMP NULL DEFAULT '' ON UPDATE CURRENT_TIMESTAMP AFTER even_more_data
      Connection ID (thread ID): 8
      Status: NOT_KILLED
      ...
      

      Other, a bit different stack trace, was noted on build 22257 with a simuilat table and ALTER (that can not be shared in public) by a user:

      190421  6:00:47 [ERROR] mysqld got signal 11 ;
      This could be because you hit a bug. It is also possible that this binary
      or one of the libraries it was linked against is corrupt, improperly built,
      or misconfigured. This error can also be caused by malfunctioning hardware.
       
      To report this bug, see https://mariadb.com/kb/en/reporting-bugs
       
      We will try our best to scrape up some info that will hopefully help
      diagnose the problem, but since we have already crashed, 
      something is definitely wrong and this may fail.
       
      Server version: 10.2.14-MariaDB-log
      key_buffer_size=67108864
      read_buffer_size=131072
      max_used_connections=116
      max_threads=3002
      thread_count=77
      It is possible that mysqld could use up to 
      key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 6663253 K  bytes of memory
      Hope that's ok; if not, decrease some variables in the equation.
       
      Thread pointer: 0x7f2478054598
      Attempting backtrace. You can use the following information to find out
      where mysqld died. If you see no messages after this, something went
      terribly wrong...
      stack_bottom = 0x7f24b828dd30 thread_stack 0x40000
      /usr/sbin/mysqld(my_print_stacktrace+0x2e)[0x559efc54a58e]
      /usr/sbin/mysqld(handle_fatal_signal+0x355)[0x559efbfdecc5]
      sigaction.c:0(__restore_rt)[0x7f2aa1f63680]
      sql/item.h:812(Item::field_type() const)[0x559efbe48b56]
      sql/sql_table.cc:3176(Column_definition::prepare_stage1_string(THD*, st_mem_root*, handler*, unsigned long long))[0x559efbea0864]
      sql/sql_table.cc:3360(mysql_prepare_create_table)[0x559efbe9e573]
      sql/sql_table.cc:4519(mysql_create_frm_image(THD*, char const*, char const*, HA_CREATE_INFO*, Alter_info*, int, st_key**, unsigned int*, st_mysql_const_unsigned_lex_string*))[0x559efbea0aeb]
      sql/sql_table.cc:4768(create_table_impl)[0x559efbea4ecf]
      sql/sql_table.cc:9102(mysql_alter_table(THD*, char const*, char const*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool))[0x559efbea7ec7]
      sql/sql_alter.cc:330(Sql_cmd_alter_table::execute(THD*))[0x559efbef3afa]
      sql/sql_parse.cc:6257(mysql_execute_command(THD*))[0x559efbe1d1fb]
      sql/sql_parse.cc:7982(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x559efbe255f2]
      sql/sql_parse.cc:1838(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x559efbe290e5]
      sql/sql_parse.cc:1388(do_command(THD*))[0x559efbe29e29]
      sql/sql_connect.cc:1335(do_handle_one_connection(CONNECT*))[0x559efbef0cca]
      sql/sql_connect.cc:1243(handle_one_connection)[0x559efbef0ded]
      pthread_create.c:0(start_thread)[0x7f2aa1f5bdd5]
      /lib64/libc.so.6(clone+0x6d)[0x7f2aa02ffb3d]
      ...
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              valerii Valerii Kravchuk
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.