Bug #87303 innodb_redo_log_encrypt-setting testcases are unstable
Submitted: 3 Aug 2017 13:01 Modified: 9 Aug 2017 13:59
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Tests Severity:S3 (Non-critical)
Version:8.0.2 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution, innodb, mtr

[3 Aug 2017 13:01] Laurynas Biveinis
Description:
I saw only a single instance of this and was not able to repeat it, but the cause seems clear from the testcase.

sys_vars.innodb_redo_log_encrypt_basic   w4 [ fail ]
        Test ended at 2017-08-02 18:16:12

CURRENT_TEST: sys_vars.innodb_redo_log_encrypt_basic
--- /mnt/workspace/mysql-5.7-param/BUILD_TYPE/release/Host/ubuntu-xenial-64bit/mysql-test/suite/sys_vars/r/innodb_redo_log_encrypt_basic.result	2017-08-02 18:21:30.204890246 +0300
+++ /mnt/workspace/mysql-5.7-param/BUILD_TYPE/release/Host/ubuntu-xenial-64bit/build/mysql-test/var/4/log/innodb_redo_log_encrypt_basic.reject	2017-08-02 21:16:12.355291397 +0300
@@ -25,7 +25,7 @@
 set global innodb_redo_log_encrypt=1;
 select @@global.innodb_redo_log_encrypt;
 @@global.innodb_redo_log_encrypt
-0
+1
 select * from performance_schema.global_variables where variable_name='innodb_redo_log_encrypt';
 VARIABLE_NAME	VARIABLE_VALUE
 innodb_redo_log_encrypt	OFF

mysqltest: Result content mismatch

How to repeat:
Was not able to repeat. But see below

Suggested fix:
The testcase bit in question is

set global innodb_redo_log_encrypt=1;
--sleep 2
select @@global.innodb_redo_log_encrypt;

where the select returns zero.

It is the InnoDB master thread which reset the variable from one to zero by calling log_enable_encryption_if_set. The testcase uses sleep instead of proper sync to give the master thread a chance to run, but this is not guaranteed to happen on a loaded system. The sleep and select should be replaced by a wait until the variable value becomes zero.
[4 Aug 2017 2:45] Laurynas Biveinis
Exact same issue on innodb.log_encrypt_3:

@@ -6,7 +6,7 @@
 Level	Code	Message
 SELECT @@global.innodb_redo_log_encrypt ;
 @@global.innodb_redo_log_encrypt
-0
+1
 CREATE TABLE tde_db.t4 (a BIGINT PRIMARY KEY, b LONGBLOB) ENGINE=InnoDB;
 INSERT INTO t4 (a, b) VALUES (1, REPEAT('a', 6*512*512));
 SELECT a,LEFT(b,10) FROM tde_db.t4;

mysqltest: Result content mismatch

Caused by exact same antipattern:

SET GLOBAL innodb_redo_log_encrypt = 1;
--sleep 1

SHOW WARNINGS;
SELECT @@global.innodb_redo_log_encrypt ;
[4 Aug 2017 2:58] Laurynas Biveinis
By code review innodb.log_encrypt_kill may fail to find an error message in the error log because of the same:

SELECT @@global.innodb_redo_log_encrypt ;
SET GLOBAL innodb_redo_log_encrypt = 1;
SET GLOBAL innodb_undo_log_encrypt = 1;
--sleep 1

# sleep to get message recorded in error log
--sleep 1
[5 Aug 2017 7:34] Laurynas Biveinis
Bug 87303 fix for 8.0.2

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: bug87303-8.0.2.patch (application/octet-stream, text), 4.42 KiB.

[7 Aug 2017 7:38] MySQL Verification Team
Hello Laurynas,

Thank you for the report and contribution.

Thanks,
Umesh
[9 Aug 2017 13:59] Paul DuBois
Posted by developer:
 
Fixed in 8.0.3.

The sys_vars.innodb_redo_log_encrypt_basic test case output was
unstable. Thanks to Laurynas Biveinis for the patch.