[MDEV-8817]  Failing assertion: new_state->key_version != ENCRYPTION_KEY_VERSION_INVALID Created: 2015-09-19  Updated: 2015-09-23  Resolved: 2015-09-22

Status: Closed
Project: MariaDB Server
Component/s: Encryption, Storage Engine - InnoDB, Storage Engine - XtraDB
Affects Version/s: 10.1
Fix Version/s: 10.1.8

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Jan Lindström (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Attachments: File mdev8817.yy     File mdev8817.zz    
Issue Links:
Relates

 Description   

InnoDB: Assertion failure in thread 140535339677440 in file fil0crypt.cc line 975
InnoDB: Failing assertion: new_state->key_version != ENCRYPTION_KEY_VERSION_INVALID
InnoDB: We intentionally generate a memory trap.

Stack trace from 10.1 commit f789158ddfa90933678dc927a05719ba692d0854

#3  <signal handler called>
#4  0x00007fd11cccd165 in *__GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#5  0x00007fd11ccd03e0 in *__GI_abort () at abort.c:92
#6  0x00007fd11fc71adb in fil_crypt_get_key_state (new_state=0x7fd0eeffedb0) at 10.1/storage/xtradb/fil/fil0crypt.cc:975
#7  0x00007fd11fc72429 in fil_crypt_space_needs_rotation (state=0x7fd0eeffedc0, key_state=0x7fd0eeffedb0, recheck=0x7fd0eeffed9b) at 1
0.1/storage/xtradb/fil/fil0crypt.cc:1315
#8  0x00007fd11fc72a9c in fil_crypt_find_space_to_rotate (key_state=0x7fd0eeffedb0, state=0x7fd0eeffedc0, recheck=0x7fd0eeffed9b) at 10.1/storage/xtradb/fil/fil0crypt.cc:1561
#9  0x00007fd11fc740fe in fil_crypt_thread (arg=0x0) at 10.1/storage/xtradb/fil/fil0crypt.cc:2233
#10 0x00007fd11ece1b50 in start_thread (arg=<optimized out>) at pthread_create.c:304
#11 0x00007fd11cd7695d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

General test flow:

  • server is started with file_key_management plugin and keys, otherwise default options;
  • a few InnoDB tables are created;
  • several threads are running DML on these tables;
  • one thread is running ALTER TABLE with different values of ENCRYPTED and ENCRYPTION_KEY_ID, and also toggles innodb_encryption_threads and innodb_encrypt_tables glboal variables;
  • the server gets intentionally crashed and restarted periodically.

RQG command line

$RQG_HOME/runall-new.pl --threads=8 --duration=600 --queries=100M   --restart-timeout=30  --mysqld=--log_output=FILE --mysqld=--plugin_load_add=file_key_management.so --mysqld=--file_key_management_filename=$BASEDIR/mysql-test/std_data/keys.txt  --reporters=Backtrace,ErrorLog,CrashRestart --grammar=$HOMEDIR/mdev8817.yy --gendata=$HOMEDIR/mdev8817.zz --basedir=$BASEDIR --vardir=$HOMEDIR/var --mtr-build-thread=817

mdev8817.yy and mdev8817.zz are attached.
Use RQG from lp:~elenst/randgen/mariadb-patches.

It can also trigger MDEV-8819 and MDEV-8821.



 Comments   
Comment by Jan Lindström (Inactive) [ 2015-09-22 ]

ommit 0cf39f401c111f873fa595573a23b209d1f28534
Author: Jan Lindström <jan.lindstrom@mariadb.com>
Date: Tue Sep 22 15:03:59 2015 +0300

MDEV-8817: Failing assertion: new_state->key_version != ENCRYPTION_KEY_VERSION_INVALID

Analysis: Problem sees to be the fact that we allow creating or altering
table to use encryption_key_id that does not exists in case where
original table is not encrypted currently. Secondly we should not
do key rotation to tables that are not encrypted or tablespaces
that can't be found from tablespace cache.

Fix: Do not allow creating unencrypted table with nondefault encryption key
and do not rotate tablespaces that are not encrypted (FIL_SPACE_ENCRYPTION_OFF)
or can't be found from tablespace cache.

Generated at Thu Feb 08 07:30:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.