From 1454d28cf8fea55eee8a9fc970f53ad64affaf17 Mon Sep 17 00:00:00 2001 From: mariadb-satishkumar Date: Wed, 17 Sep 2025 10:26:58 +0000 Subject: [PATCH] MDEV-37299: Fix crash when server read-only and encrption ON Modified srv_start to call fil_crypt_threads_init() only when srv_read_only_mode is not set. Modified encryption.innodb-read-only to capture number of encryption threads created for both scenarios when server is not read only as well as when server is read only. --- .../suite/encryption/r/innodb-read-only.result | 12 ++++++++++++ mysql-test/suite/encryption/t/innodb-read-only.test | 12 ++++++++++++ storage/innobase/fil/fil0crypt.cc | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/mysql-test/suite/encryption/r/innodb-read-only.result b/mysql-test/suite/encryption/r/innodb-read-only.result index 35ba28dbe1e..3d23d3142f4 100644 --- a/mysql-test/suite/encryption/r/innodb-read-only.result +++ b/mysql-test/suite/encryption/r/innodb-read-only.result @@ -1,4 +1,16 @@ # Wait max 10 min for key encryption threads to encrypt all spaces # Success! +SET GLOBAL innodb_encryption_threads=4; +SELECT COUNT(*) AS encrypt_threads_running +FROM performance_schema.threads +WHERE NAME LIKE '%encrypt%'; +encrypt_threads_running +4 # restart: --innodb-read-only=1 --innodb-encrypt-tables=1 +SET GLOBAL innodb_encryption_threads=4; +SELECT COUNT(*) AS encrypt_threads_running +FROM performance_schema.threads +WHERE NAME LIKE '%encrypt%'; +encrypt_threads_running +0 # All done diff --git a/mysql-test/suite/encryption/t/innodb-read-only.test b/mysql-test/suite/encryption/t/innodb-read-only.test index 10ec87467b6..d51825e1da5 100644 --- a/mysql-test/suite/encryption/t/innodb-read-only.test +++ b/mysql-test/suite/encryption/t/innodb-read-only.test @@ -25,10 +25,22 @@ if (!$success) } --echo # Success! +# Server in normal mode +SET GLOBAL innodb_encryption_threads=4; +SELECT COUNT(*) AS encrypt_threads_running +FROM performance_schema.threads +WHERE NAME LIKE '%encrypt%'; + # # MDEV-11835: InnoDB: Failing assertion: free_slot != NULL on # restarting server with encryption and read-only # --let $restart_parameters= --innodb-read-only=1 --innodb-encrypt-tables=1 --source include/restart_mysqld.inc + +# Server read-only mode +SET GLOBAL innodb_encryption_threads=4; +SELECT COUNT(*) AS encrypt_threads_running +FROM performance_schema.threads +WHERE NAME LIKE '%encrypt%'; --echo # All done diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 4626ef85918..af5a6cb0f8a 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -2108,6 +2108,9 @@ Adjust thread count for key rotation @param[in] enw_cnt Number of threads to be used */ void fil_crypt_set_thread_cnt(const uint new_cnt) { + if (srv_read_only_mode) + return; + if (!fil_crypt_threads_inited) { if (srv_shutdown_state != SRV_SHUTDOWN_NONE) return; @@ -2261,6 +2264,8 @@ void fil_crypt_set_encrypt_tables(ulong val) Init threads for key rotation */ void fil_crypt_threads_init() { + ut_ad(!srv_read_only_mode); + if (!fil_crypt_threads_inited) { pthread_cond_init(&fil_crypt_cond, nullptr); pthread_cond_init(&fil_crypt_threads_cond, nullptr);