[MDEV-8592] aria_read_log crashes in ma_crypt_set_data_pagecache_callbacks while trying to apply log to encrypted table Created: 2015-08-09  Updated: 2015-12-24  Resolved: 2015-12-24

Status: Closed
Project: MariaDB Server
Component/s: Encryption, Scripts & Clients, Storage Engine - Aria
Affects Version/s: 10.1
Fix Version/s: 10.1.7

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
Sprint: 10.1.10

 Description   

On a clean server started with

plugin-load-add=file_key_management.so
file-key-management-filename=/10.1/mysql-test/std_data/keys.txt

MariaDB [test]> set global aria_encrypt_tables = 0;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> create table t1 (i int) engine=Aria;
Query OK, 0 rows affected (0.42 sec)
 
MariaDB [test]> insert into t1 values (1);
Query OK, 1 row affected (0.04 sec)
 
MariaDB [test]> set global aria_encrypt_tables = 1;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> create table t2 (i int) engine=Aria;
Query OK, 0 rows affected (0.48 sec)
 
MariaDB [test]> insert into t2 values (1);
Query OK, 1 row affected (0.03 sec)
 
MariaDB [test]> shutdown;

$ ../storage/maria/aria_read_log  --apply
The transaction log starts from lsn (1,0x2007)
TRACE of the last aria_read_log
Rec#1 LSN (1,0x2007) short_trid 0 checkpoint(num_type:29) len 38
CHECKPOINT found
Rec#2 LSN (1,0x2033) short_trid 0 checkpoint(num_type:29) len 38
CHECKPOINT found
Rec#3 LSN (1,0x205f) short_trid 0 checkpoint(num_type:29) len 38
CHECKPOINT found
Rec#4 LSN (1,0x208b) short_trid 0 redo_create_table(num_type:30) len 389
Table './test/t1' has create_rename_lsn (1,0x208b) more recent than record, ignoring creationRec#5 LSN (1,0x2218) short_trid 23324 long_transaction_id(num_type:36) len 6
Transaction long_trid 1 short_trid 23324 starts, undo_lsn (0,0x0) first_undo_lsn (0,0x0)
Rec#6 LSN (1,0x2221) short_trid 23324 file_id(num_type:35) len 12
Table './test/t1', id 43, opened
Rec#7 LSN (1,0x2233) short_trid 23324 redo_new_row_head(num_type:3) len 43
Rec#8 LSN (1,0x2264) short_trid 23324 undo_row_insert(num_type:18) len 15
   ends a group:
   Rec#0 LSN (1,0x2233) short_trid 23324 redo_new_row_head(num_type:3) len 43
   For table of short id 43, './test/t1', applying record
   Rec#0 LSN (1,0x2264) short_trid 23324 undo_row_insert(num_type:18) len 15
   For table of short id 43, './test/t1', applying record
   rows' count 1
Rec#9 LSN (1,0x2277) short_trid 23324 commit(num_type:27) len 0
Transaction long_trid 1 short_trid 23324 committed
Rec#10 LSN (1,0x227a) short_trid 0 redo_create_table(num_type:30) len 411
Segmentation fault (core dumped)

#0  0x0000000000000000 in ?? ()
#1  0x00007f4181e7d510 in ma_crypt_set_data_pagecache_callbacks (file=0x7ffd5cbca9d8, share=0x7f4184240570) at 10.1/storage/maria/ma_crypt.c:333
#2  0x00007f4181e877ab in _ma_set_data_pagecache_callbacks (file=0x7ffd5cbca9d8, share=0x7f4184240570) at 10.1/storage/maria/ma_open.c:1858
#3  0x00007f4181e7e76f in maria_clone_internal (share=0x7f4184240570, name=0x7f4184240350 "./test/t2", mode=0, data_file=9, internal_table=0) at 10.1/storage/maria/ma_open.c:156
#4  0x00007f4181e81b1b in maria_open (name=0x7f4184240350 "./test/t2", mode=0, open_flags=32) at 10.1/storage/maria/ma_open.c:1019
#5  0x00007f4181e73fb2 in exec_REDO_LOGREC_REDO_CREATE_TABLE (rec=0x7ffd5cbcd700) at 10.1/storage/maria/ma_recovery.c:808
#6  0x00007f4181e73828 in display_and_apply_record (log_desc=0x7f4182cc3590, rec=0x7ffd5cbcd700) at 10.1/storage/maria/ma_recovery.c:588
#7  0x00007f4181e78af4 in run_redo_phase (lsn=4294975495, lsn_end=0, apply=MARIA_LOG_APPLY) at 10.1/storage/maria/ma_recovery.c:2733
#8  0x00007f4181e7308c in maria_apply_log (from_lsn=4294975495, end_lsn=0, apply=MARIA_LOG_APPLY, trace_file=0x7f41805a87a0, should_run_undo_phase=1 '\001', skip_DDLs_arg=0 '\000', take_checkpoints=0 '\000', warnings_count=0x7ffd5cbd20dc) at 10.1/storage/maria/ma_recovery.c:350
#9  0x00007f4181e2d5ba in main (argc=0, argv=0x7f418421f598) at 10.1/storage/maria/maria_read_log.c:138



 Comments   
Comment by Sergei Golubchik [ 2015-12-18 ]

I cannot repeat this. I used this test file:

--source include/have_file_key_management_plugin.inc
set global aria_encrypt_tables = 0;
create table t1 (i int) engine=aria;
insert into t1 values (1);
set global aria_encrypt_tables = 1;
create table t2 (i int) engine=aria;
insert into t2 values (1);
shutdown;

and then manually running aria_read_log --apply in the data directory. No crash.

Comment by Elena Stepanova [ 2015-12-24 ]

Fixed in 10.1.7 by the following commit:

commit 66b9a9409c73e298d6ceb668783a7cdd5ee85a69
Author: Sergei Golubchik <serg@mariadb.org>
Date:   Fri Sep 4 10:32:52 2015 +0200
 
    New encryption API. Piece-wise encryption.
    
    Instead of encrypt(src, dst, key, iv) that encrypts all
    data in one go, now we have encrypt_init(key,iv),
    encrypt_update(src,dst), and encrypt_finish(dst).
    
    This also causes collateral changes in the internal my_crypt.cc
    encryption functions and in the encryption service.
    
    There are wrappers to provide the old all-at-once encryption
    functionality. But binlog events are often written piecewise,
    they'll need the new api.

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