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

Server crashes in page_cur_is_after_last on altering table using a wrong encryption key

    XMLWordPrintable

Details

    Description

      Stack trace from bb-10.1-jan-encryption commit 549ed8c69b29050135bcdd045870dccd56b46d3b

      #3  <signal handler called>
      #4  0x00007f85f461d492 in page_cur_is_after_last (cur=0x7f85f3bcf978) at storage/xtradb/include/page0cur.ic:152
      #5  0x00007f85f461d57c in page_cur_move_to_next (cur=0x7f85f3bcf978) at storage/xtradb/include/page0cur.ic:196
      #6  0x00007f85f4621a6f in row_merge_read_clustered_index (trx=0x7f85db99a678, table=0x7f85db8f8070, old_table=0x7f85db981378, new_table=0x7f85db9815f8, online=true, index=0x7f85db81f070, fts_sort_idx=0x0, psort_info=0x0, files=0x7f85db860b78, key_numbers=0x7f85db81f078, n_index=1, add_cols=0x0, col_map=0x7f85db81f0c0, add_autoinc=18446744073709551615, sequence=..., block=0x7f85e98ff000 <Address 0x7f85e98ff000 out of bounds>, pct_cost=50) at storage/xtradb/row/row0merge.cc:1436
      #7  0x00007f85f4626ef7 in row_merge_build_indexes (trx=0x7f85db99a678, old_table=0x7f85db981378, new_table=0x7f85db9815f8, online=true, indexes=0x7f85db81f070, key_numbers=0x7f85db81f078, n_indexes=1, table=0x7f85db8f8070, add_cols=0x0, col_map=0x7f85db81f0c0, add_autoinc=18446744073709551615, sequence=...) at storage/xtradb/row/row0merge.cc:3772
      #8  0x00007f85f454a8be in ha_innobase::inplace_alter_table (this=0x7f85db87d088, altered_table=0x7f85db8f8070, ha_alter_info=0x7f85f3bd0630) at storage/xtradb/handler/handler0alter.cc:4076
      #9  0x00007f85f41fb981 in handler::ha_inplace_alter_table (this=0x7f85db87d088, altered_table=0x7f85db8f8070, ha_alter_info=0x7f85f3bd0630) at sql/handler.h:3671
      #10 0x00007f85f41f39eb in mysql_inplace_alter_table (thd=0x7f85e54dc070, table_list=0x7f85db8e4170, table=0x7f85db89ea70, altered_table=0x7f85db8f8070, ha_alter_info=0x7f85f3bd0630, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, target_mdl_request=0x7f85f3bd06a0, alter_ctx=0x7f85f3bd1230) at sql/sql_table.cc:7058
      #11 0x00007f85f41f83ab in mysql_alter_table (thd=0x7f85e54dc070, new_db=0x7f85db8e4750 "test", new_name=0x0, create_info=0x7f85f3bd1e20, table_list=0x7f85db8e4170, alter_info=0x7f85f3bd1d90, order_num=0, order=0x0, ignore=false) at sql/sql_table.cc:8864
      #12 0x00007f85f4268995 in Sql_cmd_alter_table::execute (this=0x7f85db8e4760, thd=0x7f85e54dc070) at sql/sql_alter.cc:325
      #13 0x00007f85f413ddcb in mysql_execute_command (thd=0x7f85e54dc070) at sql/sql_parse.cc:5607
      #14 0x00007f85f41420df in mysql_parse (thd=0x7f85e54dc070, rawbuf=0x7f85db8e4088 "alter table t1 engine=InnoDB", length=28, parser_state=0x7f85f3bd31a0) at sql/sql_parse.cc:7208
      #15 0x00007f85f4130e63 in dispatch_command (command=COM_QUERY, thd=0x7f85e54dc070, packet=0x7f85eb3f5071 "alter table t1 engine=InnoDB", packet_length=28) at sql/sql_parse.cc:1475
      #16 0x00007f85f412fb89 in do_command (thd=0x7f85e54dc070) at sql/sql_parse.cc:1097
      #17 0x00007f85f4263ed1 in do_handle_one_connection (thd_arg=0x7f85e54dc070) at sql/sql_connect.cc:1350
      #18 0x00007f85f4263c22 in handle_one_connection (arg=0x7f85e54dc070) at sql/sql_connect.cc:1262
      #19 0x00007f85f4829fe7 in pfs_spawn_thread (arg=0x7f85e54d4d70) at storage/perfschema/pfs.cc:1860
      #20 0x00007f85f3814b50 in start_thread (arg=<optimized out>) at pthread_create.c:304
      #21 0x00007f85f16a095d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

      Test flow

      - start server with encryption and valid keys 1 and 4;
      - create innodb table with key 4, insert some data;
      - restart server with the same key 1 and different key 4;
      - try to select from the table (error);
      - try to discard tablespace (error);
      - try to alter the table (ALTER TABLE .. ENGINE=InnoDB)
        => crash

      Test case

      --source include/have_innodb.inc
       
      --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      --shutdown_server
      --source include/wait_until_disconnected.inc
       
      --write_file $MYSQLTEST_VARDIR/keys1.txt
      1;770A8A65DA156D24EE2A093277530142
      4;770A8A65DA156D24EE2A093277530143
      EOF
       
      --exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      --enable_reconnect
      --source include/wait_until_connected_again.inc
       
      CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTION_KEY_ID=4;
      INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
       
      --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      --shutdown_server
      --source include/wait_until_disconnected.inc
       
      --write_file $MYSQLTEST_VARDIR/keys2.txt
      1;770A8A65DA156D24EE2A093277530142
      4;770A8A65DA156D24EE2A093277530144
      EOF
       
      --exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      --enable_reconnect
      --source include/wait_until_connected_again.inc
       
      --error 0,ER_NO_SUCH_TABLE_IN_ENGINE
      select * from t1;
      --error 0,ER_NO_SUCH_TABLE_IN_ENGINE
      alter table t1 discard tablespace;
      alter table t1 engine=InnoDB;

      Note: innodb_stats_persistent is important for the test flow, so it's reset to the default ON (normally MTR turns it off). An issue with its unexpected importance will be filed separately.

      Attachments

        Activity

          People

            jplindst Jan Lindström (Inactive)
            elenst Elena Stepanova
            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.