MDEV-38271 Server hangs during concurrent set innodb_encryption_threads

Problem:
=======
 - Multiple user threads waits for all encryption threads to start
before returing the control to user. But in fil_crypt_thread(),
InnoDB signals that thread is started after incrementing
srv_n_fil_crypt_threads_started variable. For multiple waiters,
pthread_cond_broadcast() would be more appropriate as
it wakes all waiting threads.

Solution:
========
fil_crypt_thread(): Use pthread_cond_broadcast instead of
pthread_cond_signal(fil_crypt_cond) to wake multiple waiter
threads
This commit is contained in:
Thirunarayanan Balathandayuthapani 2025-12-22 11:57:34 +05:30
commit 6892722577

View file

@ -2021,7 +2021,7 @@ static void fil_crypt_thread()
#endif /* UNIV_PFS_THREAD */
mysql_mutex_lock(&fil_crypt_threads_mutex);
rotate_thread_t thr(srv_n_fil_crypt_threads_started++);
pthread_cond_signal(&fil_crypt_cond); /* signal that we started */
pthread_cond_broadcast(&fil_crypt_cond);
if (!thr.should_shutdown()) {
/* if we find a tablespace that is starting, skip over it
@ -2093,7 +2093,7 @@ wait_for_work:
fil_crypt_return_iops(&thr);
srv_n_fil_crypt_threads_started--;
pthread_cond_signal(&fil_crypt_cond); /* signal that we stopped */
pthread_cond_broadcast(&fil_crypt_cond);
mysql_mutex_unlock(&fil_crypt_threads_mutex);
my_thread_end();