Uploaded image for project: 'Percona Server for MySQL'
  1. Percona Server for MySQL
  2. PS-296

MySQL is crashing with duplicateweedout=off and materialization=on

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 5.7.x, Not 5.5.x, Not 5.6.x
    • Fix Version/s: 5.7.21-21
    • Component/s: None

      Description

      Only PS 5.7 branch is affected. Tested against 5.7.20-19.

      When a materialized temporary table from semijoin optimization has a long key, over 1000 bytes, the server will crash.

        

      Steps to reproduce:

      1. 

      create table a (id int unsigned not null auto_increment primary key); 

       

      2. REPEAT query

      insert into a select null from a

       until it reaches that point, which will make it 256K-1 records

       

      3. 

      > CREATE TABLE `big1` (`id` varbinary(999) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB; 
      > CREATE TABLE `big2` (`id` varbinary(999) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB; 
      > insert into big1 select * from a; 
      > insert into big2 select * from a; 
      > set session optimizer_switch='duplicateweedout=off,materialization=on';
      mysql> explain select * from big1 where id in (select id from big2 ignore index (primary)) limit 10; 
      +----+--------------+-------------+------------+--------+---------------+---------+---------+----------------+--------+----------+-------------+ 
      | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | 
      +----+--------------+-------------+------------+--------+---------------+---------+---------+----------------+--------+----------+-------------+ 
      | 1 | SIMPLE | <subquery2> | NULL | ALL | NULL | NULL | NULL | NULL | NULL | 100.00 | NULL | 
      | 1 | SIMPLE | big1 | NULL | eq_ref | PRIMARY | PRIMARY | 1001 | <subquery2>.id | 1 | 100.00 | Using index | 
      | 2 | MATERIALIZED | big2 | NULL | ALL | NULL | NULL | NULL | NULL | 262604 | 100.00 | NULL | 
      +----+--------------+-------------+------------+--------+---------------+---------+---------+----------------+--------+----------+-------------+ 
      3 rows in set, 1 warning (0.00 sec)
      
      mysql> select * from big1 where id in (select id from big2 ignore index (primary)) limit 10; 
      ERROR 2013 (HY000): Lost connection to MySQL server during query
      
      11:00:10 UTC - 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.
      Attempting to collect some information that could help diagnose the problem.
      As this is a crash and something is definitely wrong, the information
      collection process might fail.
      Please help us make Percona Server better by reporting any
      bugs at http://bugs.percona.com/
      
      key_buffer_size=8388608
      read_buffer_size=131072
      max_used_connections=1
      max_threads=152
      thread_count=1
      connection_count=1
      It is possible that mysqld could use up to 
      key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68324 K bytes of memory
      Hope that's ok; if not, decrease some variables in the equation.
      
      Thread pointer: 0x4222120
      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 = 7f09f01a4d30 thread_stack 0x40000
      /usr/sbin/mysqld(my_print_stacktrace+0x3b)[0xeeed6b]
      /usr/sbin/mysqld(handle_fatal_signal+0x471)[0x7994c1]
      /lib64/libpthread.so.0(+0xf5e0)[0x7f0a100e85e0]
      /usr/sbin/mysqld(_Z16actual_key_partsPK6st_key+0xb)[0xd04b1b]
      /usr/sbin/mysqld(_Z17calculate_key_lenP5TABLEjm+0x23)[0x802433]
      /usr/sbin/mysqld(_ZN7handler14index_read_mapEPhPKhm16ha_rkey_function+0x2c)[0x805f3c]
      /usr/sbin/mysqld(_ZN7handler17ha_index_read_mapEPhPKhm16ha_rkey_function+0x248)[0x803f08]
      /usr/sbin/mysqld(_Z23check_unique_constraintP5TABLE+0x78)[0xc90578]
      /usr/sbin/mysqld[0xc90d4d]
      /usr/sbin/mysqld[0xc909e9]
      /usr/sbin/mysqld(_Z10sub_selectP4JOINP7QEP_TABb+0x18c)[0xc9600c]
      /usr/sbin/mysqld(_Z25join_materialize_semijoinP7QEP_TAB+0x7b)[0xc9660b]
      /usr/sbin/mysqld(_ZN7QEP_TAB12prepare_scanEv+0x42)[0xc8f092]
      /usr/sbin/mysqld(_Z10sub_selectP4JOINP7QEP_TABb+0x40)[0xc95ec0]
      /usr/sbin/mysqld(_ZN4JOIN4execEv+0x267)[0xc8eb77]
      /usr/sbin/mysqld(_Z12handle_queryP3THDP3LEXP12Query_resultyy+0x17d)[0xcff7ad]
      /usr/sbin/mysqld[0x7583f9]
      /usr/sbin/mysqld(_Z21mysql_execute_commandP3THDb+0x482e)[0xcc1b7e]
      /usr/sbin/mysqld(_Z11mysql_parseP3THDP12Parser_state+0x60d)[0xcc4ecd]
      /usr/sbin/mysqld(_Z16dispatch_commandP3THDPK8COM_DATA19enum_server_command+0xaca)[0xcc5a2a]
      /usr/sbin/mysqld(_Z10do_commandP3THD+0x1df)[0xcc74bf]
      /usr/sbin/mysqld(handle_connection+0x2b8)[0xd8edf8]
      /usr/sbin/mysqld(pfs_spawn_thread+0x1b4)[0xf73414]
      /lib64/libpthread.so.0(+0x7e25)[0x7f0a100e0e25]
      /lib64/libc.so.6(clone+0x6d)[0x7f0a0e2b434d]
      
      Trying to get some variables.
      Some pointers may be invalid and cause the dump to abort.
      Query (4239450): select * from big1 where id in (select id from big2 ignore index (primary)) limit 10
      Connection ID (thread ID): 7
      Status: NOT_KILLED
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              zsolt.parragi Zsolt Parragi
              Reporter:
              iwo.panowicz Iwo Panowicz
              Votes:
              2 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 6 hours, 7 minutes
                  6h 7m

                    Smart Checklist