diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 42062e452ee4b..fdc5a55a1c700 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -311,7 +311,8 @@ thd_destructor_proxy(void *) myvar->current_cond = &thd_destructor_cond; mysql_mutex_lock(&thd_destructor_mutex); - srv_running = myvar; + my_atomic_storeptr_explicit(&srv_running, myvar, + MY_MEMORY_ORDER_RELAXED); /* wait until the server wakes the THD to abort and die */ while (!srv_running->abort) mysql_cond_wait(&thd_destructor_cond, &thd_destructor_mutex); @@ -4209,7 +4210,8 @@ innobase_init( mysql_thread_create(thd_destructor_thread_key, &thd_destructor_thread, NULL, thd_destructor_proxy, NULL); - while (!srv_running) + while (!my_atomic_loadptr_explicit(&srv_running, + MY_MEMORY_ORDER_RELAXED)) os_thread_sleep(20); } diff --git a/storage/innobase/include/ib0mutex.h b/storage/innobase/include/ib0mutex.h index 76f02cc152115..afa8f295e1c8b 100644 --- a/storage/innobase/include/ib0mutex.h +++ b/storage/innobase/include/ib0mutex.h @@ -527,7 +527,8 @@ struct TTASEventMutex { int32 state() const UNIV_NOTHROW { - return(m_lock_word); + return(my_atomic_load32_explicit(&m_lock_word, + MY_MEMORY_ORDER_RELAXED)); } /** The event that the mutex will wait in sync0arr.cc diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index af0ff2d31687d..608866aa8b8a5 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1162,7 +1162,8 @@ srv_refresh_innodb_monitor_stats(void) { mutex_enter(&srv_innodb_monitor_mutex); - srv_last_monitor_time = time(NULL); + my_atomic_store32_explicit(&srv_last_monitor_time, time(NULL), + MY_MEMORY_ORDER_RELAXED); os_aio_refresh_stats(); @@ -1216,10 +1217,14 @@ srv_printf_innodb_monitor( by zero if two users happen to call SHOW ENGINE INNODB STATUS at the same time */ - time_elapsed = difftime(current_time, srv_last_monitor_time) + time_elapsed = + difftime(current_time, + my_atomic_load32_explicit(&srv_last_monitor_time, + MY_MEMORY_ORDER_RELAXED)) + 0.001; - srv_last_monitor_time = time(NULL); + my_atomic_store32_explicit(&srv_last_monitor_time, time(NULL), + MY_MEMORY_ORDER_RELAXED); fputs("\n=====================================\n", file); @@ -1696,7 +1701,8 @@ DECLARE_THREAD(srv_monitor_thread)(void*) pfs_register_thread(srv_monitor_thread_key); #endif /* UNIV_PFS_THREAD */ - srv_last_monitor_time = ut_time(); + my_atomic_store32_explicit(&srv_last_monitor_time, ut_time(), + MY_MEMORY_ORDER_RELAXED); last_monitor_time = ut_time(); mutex_skipped = 0; last_srv_print_monitor = srv_print_innodb_monitor; @@ -1829,7 +1835,10 @@ DECLARE_THREAD(srv_error_monitor_thread)(void*) old_lsn = new_lsn; } - if (difftime(time(NULL), srv_last_monitor_time) > 60) { + if (difftime(time(NULL), + my_atomic_load32_explicit(&srv_last_monitor_time, + MY_MEMORY_ORDER_RELAXED)) + > 60) { /* We referesh InnoDB Monitor values so that averages are printed from at most 60 last seconds */