From d7d7304d9b80614fccc70fc7a54dc2a55c8be7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 7 Oct 2025 09:59:59 +0300 Subject: [PATCH] MDEV-36556: MariaDB restart after upgrade fails with innodb_encrypt_tables ibuf_upgrade_needed(): Adjust the check for the case that the InnoDB system tablespace had been created without innodb_checksum_algorithm=full_crc32 and innodb_encrypt_tables was enabled at the time the change buffer was upgraded. --- mysql-test/suite/encryption/r/recovery_memory.result | 2 ++ .../suite/encryption/t/recovery_memory.combinations | 4 ++++ mysql-test/suite/encryption/t/recovery_memory.test | 3 +++ storage/innobase/ibuf/ibuf0ibuf.cc | 9 ++++++--- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/encryption/t/recovery_memory.combinations diff --git a/mysql-test/suite/encryption/r/recovery_memory.result b/mysql-test/suite/encryption/r/recovery_memory.result index 1b02fb6d31d..270c331e2f8 100644 --- a/mysql-test/suite/encryption/r/recovery_memory.result +++ b/mysql-test/suite/encryption/r/recovery_memory.result @@ -1,3 +1,5 @@ +SET GLOBAL innodb_encrypt_tables=ON,innodb_encryption_threads=1; +SET GLOBAL innodb_saved_page_number_debug=4,innodb_fil_make_page_dirty_debug=0; CREATE TABLE t1(f1 text, index idx(f1(20))) ENGINE INNODB; set global innodb_fast_shutdown=0; # restart: --debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0 diff --git a/mysql-test/suite/encryption/t/recovery_memory.combinations b/mysql-test/suite/encryption/t/recovery_memory.combinations new file mode 100644 index 00000000000..f985eb1f7d3 --- /dev/null +++ b/mysql-test/suite/encryption/t/recovery_memory.combinations @@ -0,0 +1,4 @@ +[full_crc32] +--innodb-checksum-algorithm=full_crc32 +[crc32] +--innodb-checksum-algorithm=crc32 diff --git a/mysql-test/suite/encryption/t/recovery_memory.test b/mysql-test/suite/encryption/t/recovery_memory.test index 64963c3e2e1..fc6f15f7ee2 100644 --- a/mysql-test/suite/encryption/t/recovery_memory.test +++ b/mysql-test/suite/encryption/t/recovery_memory.test @@ -5,6 +5,9 @@ let $basedir=$MYSQLTEST_VARDIR/tmp/backup; let MYSQLD_DATADIR=`select @@datadir`; +# Encrypt the change buffer root page +SET GLOBAL innodb_encrypt_tables=ON,innodb_encryption_threads=1; +SET GLOBAL innodb_saved_page_number_debug=4,innodb_fil_make_page_dirty_debug=0; CREATE TABLE t1(f1 text, index idx(f1(20))) ENGINE INNODB; diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 74805bdfdde..46f7f1f923e 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -1046,10 +1046,13 @@ dberr_t ibuf_upgrade_needed() if (!root) goto err_exit; + const size_t payload= fil_system.sys_space->full_crc32() || + !fil_system.sys_space->crypt_data + ? FIL_PAGE_TYPE : FIL_PAGE_SPACE_ID; + if (UNIV_LIKELY(!page_has_siblings(root->page.frame)) && - UNIV_LIKELY(!memcmp(root->page.frame + FIL_PAGE_TYPE, field_ref_zero, - srv_page_size - - (FIL_PAGE_DATA_END + FIL_PAGE_TYPE)))) + UNIV_LIKELY(!memcmp(root->page.frame + payload, field_ref_zero, + srv_page_size - (FIL_PAGE_DATA_END + payload)))) /* the change buffer was removed; no need to upgrade */; else if (page_is_comp(root->page.frame) || btr_page_get_index_id(root->page.frame) != ibuf_index_id ||