Skip to content

Commit 39dd13c

Browse files
committed
Bug#35145188: innodb.log_file_resize_1 is failing sporadically in pb2
innodb_redo_log_capacity_update changes log capacity, and waits for the next governor thread iteration to finish, but the governor thread might not actually be aware of the change, as it might have been running in paralell already. The routine log_files_wait_until_next_governor_iteration in this case just waits for the current iteration to finish. This patch alters log_files_wait_until_next_governor_iteration, to make sure it waits for a full iteration to complete. Change-Id: Ia359ea371405df3eab1ec5234a86f29d50552250
1 parent 29608ef commit 39dd13c

File tree

8 files changed

+20
-0
lines changed

8 files changed

+20
-0
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ static PSI_mutex_info all_innodb_mutexes[] = {
731731
PSI_MUTEX_KEY(log_flusher_mutex, 0, 0, PSI_DOCUMENT_ME),
732732
PSI_MUTEX_KEY(log_write_notifier_mutex, 0, 0, PSI_DOCUMENT_ME),
733733
PSI_MUTEX_KEY(log_flush_notifier_mutex, 0, 0, PSI_DOCUMENT_ME),
734+
PSI_MUTEX_KEY(log_governor_mutex, 0, 0, PSI_DOCUMENT_ME),
734735
PSI_MUTEX_KEY(log_sys_arch_mutex, 0, 0, PSI_DOCUMENT_ME),
735736
PSI_MUTEX_KEY(log_cmdq_mutex, 0, 0, PSI_DOCUMENT_ME),
736737
PSI_MUTEX_KEY(log_sn_mutex, 0, 0, PSI_DOCUMENT_ME),

storage/innobase/include/log0sys.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ struct alignas(ut::INNODB_CACHE_LINE_SIZE) log_t {
440440
/** Event used by log files governor thread to wait. */
441441
os_event_t m_files_governor_event;
442442

443+
/** Mutex which can be used to pause log governor thread. */
444+
alignas(ut::INNODB_CACHE_LINE_SIZE) mutable ib_mutex_t
445+
governor_iteration_mutex;
446+
443447
/** Event used by other threads to wait until log files governor finished
444448
its next iteration. This is useful when some sys_var gets changed to wait
445449
until log files governor re-computed everything and then check if the

storage/innobase/include/sync0sync.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ extern mysql_pfs_key_t log_write_notifier_mutex_key;
120120
extern mysql_pfs_key_t log_flush_notifier_mutex_key;
121121
extern mysql_pfs_key_t log_limits_mutex_key;
122122
extern mysql_pfs_key_t log_files_mutex_key;
123+
extern mysql_pfs_key_t log_governor_mutex_key;
123124
extern mysql_pfs_key_t log_cmdq_mutex_key;
124125
extern mysql_pfs_key_t log_sn_lock_key;
125126
extern mysql_pfs_key_t log_sn_mutex_key;

storage/innobase/include/sync0types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ enum latch_level_t {
250250
SYNC_LOG_CHECKPOINTER,
251251
SYNC_LOG_SN,
252252
SYNC_LOG_SN_MUTEX,
253+
SYNC_LOG_GOVERNOR_MUTEX,
253254
SYNC_PAGE_ARCH,
254255
SYNC_PAGE_ARCH_CLIENT,
255256
SYNC_LOG_ARCH,
@@ -383,6 +384,7 @@ enum latch_id_t {
383384
LATCH_ID_LOG_FLUSH_NOTIFIER,
384385
LATCH_ID_LOG_LIMITS,
385386
LATCH_ID_LOG_FILES,
387+
LATCH_ID_LOG_GOVERNOR_MUTEX,
386388
LATCH_ID_PARSER,
387389
LATCH_ID_LOG_ARCH,
388390
LATCH_ID_PAGE_ARCH,

storage/innobase/log/log0files_governor.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,8 @@ static Log_files_governor_iteration_result log_files_governor_iteration_low(
13041304
}
13051305

13061306
static void log_files_governor_iteration(log_t &log) {
1307+
IB_mutex_guard iteration_latch{&(log.governor_iteration_mutex),
1308+
UT_LOCATION_HERE};
13071309
using Iteration_result = Log_files_governor_iteration_result;
13081310

13091311
/* We can't use log_writer_mutex_own() here, because it could return true
@@ -2017,8 +2019,10 @@ void log_files_initialize_on_existing_redo(log_t &log) {
20172019
Notifies the log_files_governor thread (to ensure it is soon).
20182020
@param[in,out] log redo log */
20192021
static void log_files_wait_until_next_governor_iteration(log_t &log) {
2022+
mutex_enter(&log.governor_iteration_mutex);
20202023
const auto sig_count = os_event_reset(log.m_files_governor_iteration_event);
20212024
os_event_set(log.m_files_governor_event);
2025+
mutex_exit(&log.governor_iteration_mutex);
20222026
os_event_wait_low(log.m_files_governor_iteration_event, sig_count);
20232027
}
20242028

storage/innobase/log/log0log.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ static void log_sys_create() {
640640
mutex_create(LATCH_ID_LOG_LIMITS, &log.limits_mutex);
641641
mutex_create(LATCH_ID_LOG_FILES, &log.m_files_mutex);
642642
mutex_create(LATCH_ID_LOG_SN_MUTEX, &log.sn_x_lock_mutex);
643+
mutex_create(LATCH_ID_LOG_GOVERNOR_MUTEX, &log.governor_iteration_mutex);
643644

644645
#ifdef UNIV_PFS_RWLOCK
645646
/* pfs_psi is separated from sn_lock_inst,
@@ -835,6 +836,7 @@ static void log_sys_free() {
835836
mutex_free(&log.writer_mutex);
836837
mutex_free(&log.closer_mutex);
837838
mutex_free(&log.checkpointer_mutex);
839+
mutex_free(&log.governor_iteration_mutex);
838840

839841
os_event_destroy(log.next_checkpoint_event);
840842
os_event_destroy(log.write_notifier_event);

storage/innobase/sync/sync0debug.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ LatchDebug::LatchDebug() {
479479
LEVEL_MAP_INSERT(SYNC_LOG_WRITER);
480480
LEVEL_MAP_INSERT(SYNC_LOG_WRITE_NOTIFIER);
481481
LEVEL_MAP_INSERT(SYNC_LOG_FLUSH_NOTIFIER);
482+
LEVEL_MAP_INSERT(SYNC_LOG_GOVERNOR_MUTEX);
482483
LEVEL_MAP_INSERT(SYNC_LOG_CLOSER);
483484
LEVEL_MAP_INSERT(SYNC_LOG_CHECKPOINTER);
484485
LEVEL_MAP_INSERT(SYNC_LOG_ARCH);
@@ -728,6 +729,7 @@ Latches *LatchDebug::check_order(const latch_t *latch,
728729
case SYNC_LOG_WRITE_NOTIFIER:
729730
case SYNC_LOG_FLUSH_NOTIFIER:
730731
case SYNC_LOG_LIMITS:
732+
case SYNC_LOG_GOVERNOR_MUTEX:
731733
case SYNC_LOG_FILES:
732734
case SYNC_LOG_ARCH:
733735
case SYNC_PAGE_ARCH:
@@ -1288,6 +1290,9 @@ static void sync_latch_meta_init() UNIV_NOTHROW {
12881290

12891291
LATCH_ADD_MUTEX(LOG_FILES, SYNC_LOG_FILES, log_files_mutex_key);
12901292

1293+
LATCH_ADD_MUTEX(LOG_GOVERNOR_MUTEX, SYNC_LOG_GOVERNOR_MUTEX,
1294+
log_governor_mutex_key);
1295+
12911296
LATCH_ADD_RWLOCK(LOG_SN, SYNC_LOG_SN, log_sn_lock_key);
12921297

12931298
LATCH_ADD_MUTEX(LOG_SN_MUTEX, SYNC_LOG_SN_MUTEX, log_sn_mutex_key);

storage/innobase/sync/sync0sync.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ mysql_pfs_key_t log_write_notifier_mutex_key;
8787
mysql_pfs_key_t log_flush_notifier_mutex_key;
8888
mysql_pfs_key_t log_limits_mutex_key;
8989
mysql_pfs_key_t log_files_mutex_key;
90+
mysql_pfs_key_t log_governor_mutex_key;
9091
mysql_pfs_key_t log_cmdq_mutex_key;
9192
mysql_pfs_key_t log_sn_lock_key;
9293
mysql_pfs_key_t log_sn_mutex_key;

0 commit comments

Comments
 (0)