[MDEV-11782] Redefine the innodb_encrypt_log format Created: 2017-01-12 Updated: 2018-01-05 Resolved: 2017-02-15 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Fix Version/s: | 10.2.4 |
| Type: | Task | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | 10.2-ga, compat57, crash, recovery | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sprint: | 10.2.4-1, 10.2.4-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
WL#8845 introduced a redo log format identifier in MySQL 5.7.9. The MariaDB extension innodb_encrypt_log should distinguish encrypted redo logs from cleartext ones by the redo log format tag. In this way, an attempt to start up MySQL 5.7 after a crash of MariaDB with innodb_encrypt_log=1 will result in a clear error message rather than some strange-looking crash. |
| Comments |
| Comment by Marko Mäkelä [ 2017-01-24 ] | ||||||||||
|
As part of this task, we must test if MariaDB can be upgraded from 10.1 to 10.2 when log encryption is in use. Here is my test on Debian GNU/Linux Sid:
After shutting down the 10.1 server (for me, it would should shut down because another mysqld instance was already started on port 3306), start 10.2 in gdb on the same files:
Observe that the following message is displayed:
I think that the message should be revised to refer to MariaDB 10.2.2, and that we should attempt to decrypt the data. Upgrade with a clean encrypted redo log from 10.1 should definitely be allowed. | ||||||||||
| Comment by Marko Mäkelä [ 2017-02-01 ] | ||||||||||
|
I think that as part of this effort, in 10.2 we must rebuild the redo log files on startup if the requested innodb_encrypt_log setting differs from the redo log header, just like we would rebuild the redo log files when upgrading from 10.1 or MySQL 5.6 or earlier. | ||||||||||
| Comment by Marko Mäkelä [ 2017-02-01 ] | ||||||||||
|
In the new encrypted redo log format for MySQL 10.2, the function log_block_checksum_is_ok() should be used so that we always know beforehand (based on the redo log header block) whether subsequent blocks are supposed to be encrypted. I would forcibly enable the redo log checksum when redo log encryption is used. | ||||||||||
| Comment by Marko Mäkelä [ 2017-02-06 ] | ||||||||||
|
To support an upgrade from an encrypted 10.1 redo log, the function recv_log_format_0_recover() needs to call log_decrypt_after_read() after reading the redo log block. | ||||||||||
| Comment by Marko Mäkelä [ 2017-02-06 ] | ||||||||||
|
The code so far is available in 10.2. The test encryption.innodb_encrypt_log_corruption demonstrates that we can upgrade from an encrypted 10.1 redo log file. | ||||||||||
| Comment by Marko Mäkelä [ 2017-02-10 ] | ||||||||||
|
I committed two preparatory patches to bb-10.2-marko for review: | ||||||||||
| Comment by Jan Lindström (Inactive) [ 2017-02-12 ] | ||||||||||
|
ok to push above preparatory patches to 10.2. | ||||||||||
| Comment by Marko Mäkelä [ 2017-02-13 ] | ||||||||||
| Comment by Marko Mäkelä [ 2017-02-13 ] | ||||||||||
|
Revised patch with less memcpy() and consistently using a 4-byte cleartext log block header: bb-10.2-mdev-11782 | ||||||||||
| Comment by Jan Lindström (Inactive) [ 2017-02-14 ] | ||||||||||
|
ok to push after addressing review comments that are open. | ||||||||||
| Comment by Marko Mäkelä [ 2017-02-14 ] | ||||||||||
|
Revised patch, addressing the review comments and test failures, and also with some changes to the startup logic: We must not generate redo log before rebuilding the redo logs. | ||||||||||
| Comment by Marko Mäkelä [ 2017-02-15 ] | ||||||||||
|
commit 2af28a363c0ac55c9b91aa9eb26949fc9ecf043a Write only one encryption key to the checkpoint page. Issue notes, not warning messages for rewriting the redo log files. recv_recovery_from_checkpoint_finish(): Do not generate any redo log, Issue a firm "Missing MLOG_CHECKPOINT" error message. Remove some LOG_HEADER_FORMAT_ENCRYPTED: A flag for identifying an encrypted redo log_group_t::is_encrypted(), log_t::is_encrypted(): Determine recv_find_max_checkpoint(): Interpret LOG_HEADER_FORMAT_ENCRYPTED. srv_prepare_to_delete_redo_log_files(): Display NOTE messages about innobase_start_or_create_for_mysql(): Rebuild the redo logs also when innodb_log_checksums_func_update(): Always use the CRC-32C checksum log_group_write_buf(): Compute the checksum on the encrypted Rewrite most of the redo log encryption code. Only remember one |