Skip to content

Commit 1454d28

Browse files
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.
1 parent 62b2171 commit 1454d28

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# Wait max 10 min for key encryption threads to encrypt all spaces
22
# Success!
3+
SET GLOBAL innodb_encryption_threads=4;
4+
SELECT COUNT(*) AS encrypt_threads_running
5+
FROM performance_schema.threads
6+
WHERE NAME LIKE '%encrypt%';
7+
encrypt_threads_running
8+
4
39
# restart: --innodb-read-only=1 --innodb-encrypt-tables=1
10+
SET GLOBAL innodb_encryption_threads=4;
11+
SELECT COUNT(*) AS encrypt_threads_running
12+
FROM performance_schema.threads
13+
WHERE NAME LIKE '%encrypt%';
14+
encrypt_threads_running
15+
0
416
# All done

mysql-test/suite/encryption/t/innodb-read-only.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,22 @@ if (!$success)
2525
}
2626
--echo # Success!
2727

28+
# Server in normal mode
29+
SET GLOBAL innodb_encryption_threads=4;
30+
SELECT COUNT(*) AS encrypt_threads_running
31+
FROM performance_schema.threads
32+
WHERE NAME LIKE '%encrypt%';
33+
2834
#
2935
# MDEV-11835: InnoDB: Failing assertion: free_slot != NULL on
3036
# restarting server with encryption and read-only
3137
#
3238
--let $restart_parameters= --innodb-read-only=1 --innodb-encrypt-tables=1
3339
--source include/restart_mysqld.inc
40+
41+
# Server read-only mode
42+
SET GLOBAL innodb_encryption_threads=4;
43+
SELECT COUNT(*) AS encrypt_threads_running
44+
FROM performance_schema.threads
45+
WHERE NAME LIKE '%encrypt%';
3446
--echo # All done

storage/innobase/fil/fil0crypt.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,9 @@ Adjust thread count for key rotation
21082108
@param[in] enw_cnt Number of threads to be used */
21092109
void fil_crypt_set_thread_cnt(const uint new_cnt)
21102110
{
2111+
if (srv_read_only_mode)
2112+
return;
2113+
21112114
if (!fil_crypt_threads_inited) {
21122115
if (srv_shutdown_state != SRV_SHUTDOWN_NONE)
21132116
return;
@@ -2261,6 +2264,8 @@ void fil_crypt_set_encrypt_tables(ulong val)
22612264
Init threads for key rotation */
22622265
void fil_crypt_threads_init()
22632266
{
2267+
ut_ad(!srv_read_only_mode);
2268+
22642269
if (!fil_crypt_threads_inited) {
22652270
pthread_cond_init(&fil_crypt_cond, nullptr);
22662271
pthread_cond_init(&fil_crypt_threads_cond, nullptr);

0 commit comments

Comments
 (0)