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

Assertion `*str != '\0'' failed in my_message_sql after a Spider error

Details

    Description

      INSTALL SONAME 'ha_spider';
      SET spider_same_server_link=ON, spider_net_read_timeout=1;
       
      --eval create server s foreign data wrapper mysql options (host "127.0.0.1", database "test", user "root", port $MASTER_MYPORT)
       
      CREATE TABLE t_remote (a INT);
      CREATE TABLE t (a INT) ENGINE=SPIDER COMMENT = 'wrapper "mysql", srv "s", table "t_remote"';
      --error ER_NET_READ_INTERRUPTED
      CREATE OR REPLACE TABLE t_remote LIKE t;
      SHOW WARNINGS;
      

      10.5 b8b77177c27412777fe1763f28b344a3a260741a

      mariadbd: /data/bld/10.5-asan/sql/mysqld.cc:3080: void my_message_sql(uint, const char*, myf): Assertion `*str != '\0'' failed.
      250128 11:59:21 [ERROR] /share8t/bld/10.5-asan/sql/mariadbd got signal 6 ;
       
      #9  0x00007f4575253eb2 in __GI___assert_fail (assertion=0x56492682b440 "*str != '\\0'", file=0x564926829040 "/data/bld/10.5-asan/sql/mysqld.cc", line=3080, function=0x56492682b3a0 "void my_message_sql(uint, const char*, myf)") at ./assert/assert.c:101
      #10 0x0000564924444823 in my_message_sql (error=1159, str=0x61a000045d2f "", MyFlags=0) at /data/bld/10.5-asan/sql/mysqld.cc:3080
      #11 0x00005649265b6476 in my_message (error=1159, str=0x61a000045d2f "", MyFlags=0) at /data/bld/10.5-asan/mysys/my_error.c:195
      #12 0x00007f456a96550b in spider_db_errorno (conn=0x61f00009f4a8) at /data/bld/10.5-asan/storage/spider/spd_db_conn.cc:727
      #13 0x00007f456abdccaf in spider_mbase_handler::show_table_status (this=0x619000176180, link_idx=0, sts_mode=1, flag=88) at /data/bld/10.5-asan/storage/spider/spd_db_mysql.cc:12818
      #14 0x00007f456a99d94a in spider_db_show_table_status (spider=0x61f00009e6b8, link_idx=0, sts_mode=1, flag=88) at /data/bld/10.5-asan/storage/spider/spd_db_conn.cc:5678
      #15 0x00007f456aa57473 in spider_get_sts (share=0x6210000d0d28, link_idx=0, tmp_time=1738058360, spider=0x61f00009e6b8, sts_interval=10, sts_mode=1, sts_sync=0, sts_sync_level=1, flag=88) at /data/bld/10.5-asan/storage/spider/spd_table.cc:6802
      #16 0x00007f456aa45dd1 in spider_get_share (table_name=0x61b000078b60 "./test/t", table=0x619000172098, thd=0x62b000069218, spider=0x61f00009e6b8, error_num=0x7f456bce7250) at /data/bld/10.5-asan/storage/spider/spd_table.cc:4736
      #17 0x00007f456aad6c71 in ha_spider::open (this=0x61f00009e6b8, name=0x61b000078b60 "./test/t", mode=2, test_if_locked=18) at /data/bld/10.5-asan/storage/spider/ha_spider.cc:309
      #18 0x0000564924fd1685 in handler::ha_open (this=0x61f00009e6b8, table_arg=0x619000172098, name=0x61b000078b60 "./test/t", mode=2, test_if_locked=18, mem_root=0x0, partitions_to_open=0x0) at /data/bld/10.5-asan/sql/handler.cc:3106
      #19 0x0000564924ad8353 in open_table_from_share (thd=0x62b000069218, share=0x61b0000785b8, alias=0x62b000038b38, db_stat=33, prgflag=8, ha_open_flags=18, outparam=0x619000172098, is_create_table=false, partitions_to_open=0x0) at /data/bld/10.5-asan/sql/table.cc:4351
      #20 0x00005649245c8266 in open_table (thd=0x62b000069218, table_list=0x62b000038af0, ot_ctx=0x7f456bce7e00) at /data/bld/10.5-asan/sql/sql_base.cc:2042
      #21 0x00005649245d1c5d in open_and_process_table (thd=0x62b000069218, tables=0x62b000038af0, counter=0x7f456bce7ff0, flags=0, prelocking_strategy=0x7f456bce7ef0, has_prelocking_list=false, ot_ctx=0x7f456bce7e00) at /data/bld/10.5-asan/sql/sql_base.cc:3837
      #22 0x00005649245d478a in open_tables (thd=0x62b000069218, options=..., start=0x62b00006d318, counter=0x7f456bce7ff0, flags=0, prelocking_strategy=0x7f456bce7ef0) at /data/bld/10.5-asan/sql/sql_base.cc:4321
      #23 0x0000564924a4063b in open_tables (thd=0x62b000069218, options=..., tables=0x62b00006d318, counter=0x7f456bce7ff0, flags=0) at /data/bld/10.5-asan/sql/sql_base.h:471
      #24 0x0000564924a0b791 in mysql_create_like_table (thd=0x62b000069218, table=0x62b000038388, src_table=0x62b000038af0, create_info=0x7f456bce9b40) at /data/bld/10.5-asan/sql/sql_table.cc:6247
      #25 0x0000564924a3c74c in Sql_cmd_create_table_like::execute (this=0x62b0000382f0, thd=0x62b000069218) at /data/bld/10.5-asan/sql/sql_table.cc:12759
      #26 0x000056492477e4b5 in mysql_execute_command (thd=0x62b000069218) at /data/bld/10.5-asan/sql/sql_parse.cc:6194
      #27 0x000056492478b8c1 in mysql_parse (thd=0x62b000069218, rawbuf=0x62b000038238 "CREATE OR REPLACE TABLE t_remote LIKE t", length=39, parser_state=0x7f456bceac70, is_com_multi=false, is_next_command=false) at /data/bld/10.5-asan/sql/sql_parse.cc:8252
      #28 0x0000564924760a83 in dispatch_command (command=COM_QUERY, thd=0x62b000069218, packet=0x629000235219 "CREATE OR REPLACE TABLE t_remote LIKE t", packet_length=39, is_com_multi=false, is_next_command=false) at /data/bld/10.5-asan/sql/sql_parse.cc:1891
      #29 0x000056492475d416 in do_command (thd=0x62b000069218) at /data/bld/10.5-asan/sql/sql_parse.cc:1375
      #30 0x0000564924bba5b3 in do_handle_one_connection (connect=0x608000002f38, put_in_cache=true) at /data/bld/10.5-asan/sql/sql_connect.cc:1386
      #31 0x0000564924bba119 in handle_one_connection (arg=0x608000002eb8) at /data/bld/10.5-asan/sql/sql_connect.cc:1298
      #32 0x0000564925819c5c in pfs_spawn_thread (arg=0x615000006c18) at /data/bld/10.5-asan/storage/perfschema/pfs.cc:2201
      #33 0x00007f45752a81c4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #34 0x00007f457532885c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      The failure started happening after this commit in 10.5, but I guess it was the point of the commit as it added the assertion.

      commit 82fd202fa4c417a0be4f09028dfdc88f8d902130
      Author: Sergei Golubchik <serg@mariadb.org>
      Date:   Wed Jan 8 18:42:37 2025 +0100
       
          fix "enforce no trailing \n in Diagnostic_area messages"
      

      Attachments

        Issue Links

          Activity

            ycp Yuchen Pei added a comment -

            After initial debugging I don't see spider doing anything wrong here - it simply calls my_message with mysql->net.last_error through mysql_error(mysql) which happens to be an empty string. The commit message of the patch that added the assertion does not seem to address a bug corresponding to spider is doing here. serg do you think this is a spider bug?

            ycp Yuchen Pei added a comment - After initial debugging I don't see spider doing anything wrong here - it simply calls my_message with mysql->net.last_error through mysql_error(mysql) which happens to be an empty string. The commit message of the patch that added the assertion does not seem to address a bug corresponding to spider is doing here. serg do you think this is a spider bug?

            I was maybe over-optimistically assuming that if it were generic, it would be failing in MTR, so it must be in the way Spider handles/uses the error. Please reassign as needed.

            elenst Elena Stepanova added a comment - I was maybe over-optimistically assuming that if it were generic, it would be failing in MTR, so it must be in the way Spider handles/uses the error. Please reassign as needed.

            Not a spider bug. But it's a spider test case, so would you mind committing the fix together with a proper spider test case?

            This fixes the bug for me, although, admittedly, I didn't run the complete test suite:

            --- a/sql/net_serv.cc
            +++ b/sql/net_serv.cc
            @@ -1097,6 +1097,7 @@ my_real_read(NET *net, size_t *complen,
                                         ER_NET_READ_INTERRUPTED :
                                         ER_NET_READ_ERROR);
             #ifdef MYSQL_SERVER
            +          strmake_buf(net->last_error, ER(net->last_errno));
                       if (global_system_variables.log_warnings > 3)
                       {
                         /* Log things as a warning */
            

            serg Sergei Golubchik added a comment - Not a spider bug. But it's a spider test case, so would you mind committing the fix together with a proper spider test case? This fixes the bug for me, although, admittedly, I didn't run the complete test suite: --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -1097,6 +1097,7 @@ my_real_read(NET *net, size_t *complen, ER_NET_READ_INTERRUPTED : ER_NET_READ_ERROR); #ifdef MYSQL_SERVER + strmake_buf(net->last_error, ER(net->last_errno)); if (global_system_variables.log_warnings > 3) { /* Log things as a warning */
            ycp Yuchen Pei added a comment - - edited

            Thanks serg, ptal thanks

            9abb3bee8f1 bb-10.5-mdev-35959 MDEV-35959 Store the error message at the net layer when reading a packet from the server
            

            ycp Yuchen Pei added a comment - - edited Thanks serg , ptal thanks 9abb3bee8f1 bb-10.5-mdev-35959 MDEV-35959 Store the error message at the net layer when reading a packet from the server

            ok to push, thanks

            serg Sergei Golubchik added a comment - ok to push, thanks
            ycp Yuchen Pei added a comment -

            Thanks for the review. Pushed 0ca98e834dbeb00a2dae5cb1406d0efc31ba6655 to 10.5

            ycp Yuchen Pei added a comment - Thanks for the review. Pushed 0ca98e834dbeb00a2dae5cb1406d0efc31ba6655 to 10.5

            People

              ycp Yuchen Pei
              elenst Elena Stepanova
              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.