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

Assertion failure in Protocol::end_statement or lack of warning upon query with INTERSECT and LIMIT ROWS EXAMINED

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.6, 10.11, 11.4, 11.8, 12.3
    • 10.11, 11.4, 11.8, 12.3
    • Server
    • None

    Description

      --source include/have_innodb.inc
      --source include/have_sequence.inc
       
      CREATE TABLE t (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
      INSERT INTO t SELECT seq, seq FROM seq_1_to_30;
      (SELECT a FROM t LIMIT ROWS EXAMINED 100) EXCEPT ALL (SELECT a FROM t);
       
      DROP TABLE t;
      

      main 6660d0bdd7c8bdca9ec4e4e7e0f11df4e22c30f1

      mariadbd: /data/bld/main-asan-ubsan/sql/protocol.cc:639: void Protocol::end_statement(): Assertion `0' failed.
      260404 16:58:17 [ERROR] /share8t/bld/main-asan-ubsan/sql/mariadbd got signal 6 ;
       
      #9  0x00007f0165445395 in __assert_fail_base (fmt=0x7f01655b9a90 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x561a63a20480 "0", file=file@entry=0x561a63a1e3e0 "/data/bld/main-asan-ubsan/sql/protocol.cc", line=line@entry=639, function=function@entry=0x561a63a203a0 "void Protocol::end_statement()") at ./assert/assert.c:92
      #10 0x00007f0165453eb2 in __GI___assert_fail (assertion=0x561a63a20480 "0", file=0x561a63a1e3e0 "/data/bld/main-asan-ubsan/sql/protocol.cc", line=639, function=0x561a63a203a0 "void Protocol::end_statement()") at ./assert/assert.c:101
      #11 0x0000561a5ede9363 in Protocol::end_statement (this=this@entry=0x62c0001e08f0) at /data/bld/main-asan-ubsan/sql/protocol.cc:639
      #12 0x0000561a5f561ed2 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x62c0001e0218, packet=<optimized out>, packet@entry=0x6290002d0219 "(SELECT a FROM t LIMIT ROWS EXAMINED 100) EXCEPT ALL (SELECT a FROM t)", packet_length=packet_length@entry=70, blocking=blocking@entry=true) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:2448
      #13 0x0000561a5f5668e5 in do_command (thd=thd@entry=0x62c0001e0218, blocking=blocking@entry=true) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:1432
      #14 0x0000561a5ff1e2e2 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x6080000079b8, put_in_cache=put_in_cache@entry=true) at /data/bld/main-asan-ubsan/sql/sql_connect.cc:1503
      #15 0x0000561a5ff1f44b in handle_one_connection (arg=0x6080000079b8) at /data/bld/main-asan-ubsan/sql/sql_connect.cc:1415
      #16 0x0000561a61e519cf in pfs_spawn_thread (arg=0x61700000a898) at /data/bld/main-asan-ubsan/storage/perfschema/pfs.cc:2198
      #17 0x00007f01654a81c4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #18 0x00007f016552885c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      On a non-debug build, the query ends without errors/warnings and returns an empty result which is expected in this case, but check the original test case below – it was only affecting 10.6 and 10.11 at the time of filing, but its importance is that it was exhibiting wrong behavior on a non-debug build as well, maybe there are other ones which would affect other versions, too.


      Below is the original test case which was only failing on 10.6 and 10.11, I recommend checking it as well.

      --source include/have_sequence.inc
       
      CREATE TABLE t (id INT PRIMARY KEY, f VARCHAR(16)) ENGINE=MyISAM;
      INSERT INTO t SELECT seq, '' FROM seq_1_to_8650;
      (SELECT f FROM t WHERE id BETWEEN 7000 AND 9000 LIMIT ROWS EXAMINED 8000)
      INTERSECT
      (SELECT f FROM t WHERE id BETWEEN 7000 AND 9000 LIMIT ROWS EXAMINED 8000);
       
      DROP TABLE t;
      

      10.11 14f96a2e08073e7fa4aee5b182ca0111380089ad

      mariadbd: /data/bld/10.11-asan-ubsan/sql/protocol.cc:618: void Protocol::end_statement(): Assertion `0' failed.
      260305 23:22:01 [ERROR] /share8t/bld/10.11-asan-ubsan/sql/mariadbd got signal 6 ;
       
      #9  0x00007f4063445395 in __assert_fail_base (fmt=0x7f40635b9a90 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x564b72a17c80 "0", file=file@entry=0x564b72a179a0 "/data/bld/10.11-asan-ubsan/sql/protocol.cc", line=line@entry=618, function=function@entry=0x564b72a19b40 "void Protocol::end_statement()") at ./assert/assert.c:92
      #10 0x00007f4063453eb2 in __GI___assert_fail (assertion=0x564b72a17c80 "0", file=0x564b72a179a0 "/data/bld/10.11-asan-ubsan/sql/protocol.cc", line=618, function=0x564b72a19b40 "void Protocol::end_statement()") at ./assert/assert.c:101
      #11 0x0000564b6eb3ff0f in Protocol::end_statement (this=this@entry=0x62c0000b0838) at /data/bld/10.11-asan-ubsan/sql/protocol.cc:618
      #12 0x0000564b6f175c18 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x62c0000b0218, packet=<optimized out>, packet@entry=0x62900024e219 "(SELECT f FROM t WHERE id BETWEEN 7000 AND 9000 LIMIT ROWS EXAMINED 8000)\nINTERSECT\n(SELECT f FROM t WHERE id BETWEEN 7000 AND 9000 LIMIT ROWS EXAMINED 8000)", packet_length=packet_length@entry=157, blocking=blocking@entry=true) at /data/bld/10.11-asan-ubsan/sql/sql_parse.cc:2471
      #13 0x0000564b6f17a41e in do_command (thd=thd@entry=0x62c0000b0218, blocking=blocking@entry=true) at /data/bld/10.11-asan-ubsan/sql/sql_parse.cc:1434
      #14 0x0000564b6f976db8 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x6080000039b8, put_in_cache=put_in_cache@entry=true) at /data/bld/10.11-asan-ubsan/sql/sql_connect.cc:1475
      #15 0x0000564b6f977f15 in handle_one_connection (arg=0x6080000039b8) at /data/bld/10.11-asan-ubsan/sql/sql_connect.cc:1387
      #16 0x0000564b712fd327 in pfs_spawn_thread (arg=0x617000005b98) at /data/bld/10.11-asan-ubsan/storage/perfschema/pfs.cc:2201
      #17 0x00007f40634a81c4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #18 0x00007f406352885c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      On a non-debug build, the query ends quietly without a warning, but doesn't return the result (so there should really be a warning).

      INSERT INTO t SELECT seq, '' FROM seq_1_to_8650;
      (SELECT f FROM t WHERE id BETWEEN 7000 AND 9000 LIMIT ROWS EXAMINED 8000)
      INTERSECT
      (SELECT f FROM t WHERE id BETWEEN 7000 AND 9000 LIMIT ROWS EXAMINED 8000);
      DROP TABLE t;
      

      Reproducible on 10.6 and 10.11. Not reproducible on 11.4+ – no debug assertion failure, and non-debug build returns a result and a warning.

      May be somehow related to MDEV-29289.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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