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

Server crash in print_keydup_error / key_unpack or unexpected ER_DUP_KEY

    XMLWordPrintable

    Details

      Description

      Note: the test case fails for me all the time right now, but it's still non-deterministic. Try several times if it doesn't fail for you.

      INSTALL SONAME 'ha_rocksdb';
       
      CREATE TABLE t1 (a INT, KEY(a)) ENGINE=RocksDB;
      INSERT INTO t1 VALUES (1),(2);
      	
      CREATE TABLE t2 (b INT) ENGINE=RocksDB;
      CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2;
       
      CREATE OR REPLACE TABLE t3 (c INT) ENGINE=RocksDB;
      BEGIN;
       
      --connect (con1,localhost,root,,test)
      SET lock_wait_timeout= 2;
      --delimiter $
      CREATE TRIGGER tr BEFORE UPDATE ON t3 FOR EACH ROW 
      BEGIN
        DELETE FROM t1; 
        DELETE FROM non_existing_table; 
      END $
      --delimiter ;
      --send
      	ALTER TABLE t1 FORCE;
       
      --connection default
      DELETE FROM v2 WHERE b < 1;
      --error ER_BAD_FIELD_ERROR
      UPDATE t3 SET unknown_column = NULL;
       
      --connection con1
      --reap
      INSERT INTO t1 VALUES (3);
       
      # Cleanup
      --disconnect con1
      --connection default
      COMMIT;
      DROP VIEW v2;
      DROP TABLE t1, t2, t3;
      UNINSTALL SONAME 'ha_rocksdb';
      

      Till recently (I suppose till changes Monty made in scope of MDEV-14970 / MDEV-14141, although I didn't bisect), the test case above caused the crash:

      10.2.12

      #3  <signal handler called>
      #4  0x000055d7081bc333 in key_unpack (to=0x7fa5e017e7a0, table=0x7fa5d0371c70, key=0x7fa5d03765d0) at /data/src/10.2-bug/sql/key.cc:432
      #5  0x000055d7080caf56 in print_keydup_error (table=0x7fa5d0371c70, key=0x7fa5d03765d0, msg=0x55d70abcf1f4 "Duplicate entry '%-.64s' for key '%-.192s'", errflag=0) at /data/src/10.2-bug/sql/handler.cc:3334
      #6  0x000055d7080cb094 in print_keydup_error (table=0x7fa5d0371c70, key=0x7fa5d03765d0, errflag=0) at /data/src/10.2-bug/sql/handler.cc:3356
      #7  0x000055d7080cb2e8 in handler::print_error (this=0x7fa5d0372878, error=121, errflag=0) at /data/src/10.2-bug/sql/handler.cc:3433
      #8  0x000055d707e2fc00 in write_record (thd=0x7fa5ac000b00, table=0x7fa5d0371c70, info=0x7fa5e01804a0) at /data/src/10.2-bug/sql/sql_insert.cc:1958
      #9  0x000055d707e2d471 in mysql_insert (thd=0x7fa5ac000b00, table_list=0x7fa5ac011208, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /data/src/10.2-bug/sql/sql_insert.cc:1057
      #10 0x000055d707e54af7 in mysql_execute_command (thd=0x7fa5ac000b00) at /data/src/10.2-bug/sql/sql_parse.cc:4415
      #11 0x000055d707e5fa6e in mysql_parse (thd=0x7fa5ac000b00, rawbuf=0x7fa5ac011128 "INSERT INTO t1 VALUES (3)", length=25, parser_state=0x7fa5e0181200, is_com_multi=false, is_next_command=false) at /data/src/10.2-bug/sql/sql_parse.cc:7900
      #12 0x000055d707e4d97c in dispatch_command (command=COM_QUERY, thd=0x7fa5ac000b00, packet=0x7fa5ac008941 "INSERT INTO t1 VALUES (3)", packet_length=25, is_com_multi=false, is_next_command=false) at /data/src/10.2-bug/sql/sql_parse.cc:1805
      #13 0x000055d707e4c2da in do_command (thd=0x7fa5ac000b00) at /data/src/10.2-bug/sql/sql_parse.cc:1360
      #14 0x000055d707f9a225 in do_handle_one_connection (connect=0x55d70adddcc0) at /data/src/10.2-bug/sql/sql_connect.cc:1335
      #15 0x000055d707f99fb2 in handle_one_connection (arg=0x55d70adddcc0) at /data/src/10.2-bug/sql/sql_connect.cc:1241
      #16 0x000055d7083b936e in pfs_spawn_thread (arg=0x55d70ac0d730) at /data/src/10.2-bug/storage/perfschema/pfs.cc:1863
      #17 0x00007fa5e7bc6494 in start_thread (arg=0x7fa5e0182700) at pthread_create.c:333
      #18 0x00007fa5e5fac93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      Now it causes ER_DUP_KEY on a table which has no unique keys:

      mysqltest: At line 31: query 'INSERT INTO t1 VALUES (3)' failed: 1022: Can't write; duplicate key in table 't1'
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergey Sergei Petrunia
              Reporter:
              elenst Elena Stepanova
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: