diff options
author | Jan Lindström <jplindst@mariadb.org> | 2014-09-16 07:37:00 +0300 |
---|---|---|
committer | Jan Lindström <jplindst@mariadb.org> | 2014-09-16 07:37:00 +0300 |
commit | ec46381990af84e22d1598e6ca84f0647b177f76 (patch) | |
tree | 25bb644c970a0b98c4a5c160b46321294b1ebb6b /storage/xtradb | |
parent | 8db1f728e626be9f95db524d8a6afefdc3e1edb2 (diff) | |
download | mariadb-git-ec46381990af84e22d1598e6ca84f0647b177f76.tar.gz |
Avoid using log_sys mutex when printing out show engine innodb status,
instead peek (maybe) old data.
Diffstat (limited to 'storage/xtradb')
-rw-r--r-- | storage/xtradb/buf/buf0buf.cc | 42 | ||||
-rw-r--r-- | storage/xtradb/include/buf0buf.h | 9 | ||||
-rw-r--r-- | storage/xtradb/include/log0log.h | 9 | ||||
-rw-r--r-- | storage/xtradb/include/log0log.ic | 19 | ||||
-rw-r--r-- | storage/xtradb/log/log0log.cc | 31 |
5 files changed, 103 insertions, 7 deletions
diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index d4c8218b339..bd0929dd36c 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -379,6 +379,48 @@ buf_pool_get_oldest_modification(void) } /********************************************************************//** +Gets the smallest oldest_modification lsn for any page in the pool. Returns +zero if all modified pages have been flushed to disk. +@return oldest modification in pool, zero if none */ +UNIV_INTERN +lsn_t +buf_pool_get_oldest_modification_peek(void) +/*=======================================*/ +{ + ulint i; + buf_page_t* bpage; + lsn_t lsn = 0; + lsn_t oldest_lsn = 0; + + /* Dirsty read to buffer pool array */ + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + buf_flush_list_mutex_enter(buf_pool); + + bpage = UT_LIST_GET_LAST(buf_pool->flush_list); + + if (bpage != NULL) { + ut_ad(bpage->in_flush_list); + lsn = bpage->oldest_modification; + } + + buf_flush_list_mutex_exit(buf_pool); + + if (!oldest_lsn || oldest_lsn > lsn) { + oldest_lsn = lsn; + } + } + + /* The returned answer may be out of date: the flush_list can + change after the mutex has been released. */ + + return(oldest_lsn); +} + +/********************************************************************//** Get total buffer pool statistics. */ UNIV_INTERN void diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index 904822a7ce6..0f77404b1de 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -272,6 +272,15 @@ buf_pool_get_oldest_modification(void); /*==================================*/ /********************************************************************//** +Gets the smallest oldest_modification lsn for any page in the pool. Returns +zero if all modified pages have been flushed to disk. +@return oldest modification in pool, zero if none */ +UNIV_INTERN +lsn_t +buf_pool_get_oldest_modification_peek(void); +/*=======================================*/ + +/********************************************************************//** Allocates a buf_page_t descriptor. This function must succeed. In case of failure we assert in this function. */ UNIV_INLINE diff --git a/storage/xtradb/include/log0log.h b/storage/xtradb/include/log0log.h index cd65fcac50b..f130c8de423 100644 --- a/storage/xtradb/include/log0log.h +++ b/storage/xtradb/include/log0log.h @@ -633,6 +633,15 @@ UNIV_INLINE lsn_t log_get_tracked_lsn(void); /*=====================*/ +/****************************************************************//** +Unsafely reads the log_sys->tracked_lsn value. Uses atomic operations +if available, or use dirty read. Use for printing only. + +@return log_sys->tracked_lsn value. */ +UNIV_INLINE +lsn_t +log_get_tracked_lsn_peek(void); +/*==========================*/ extern log_t* log_sys; diff --git a/storage/xtradb/include/log0log.ic b/storage/xtradb/include/log0log.ic index bc076c954ad..853027daa7e 100644 --- a/storage/xtradb/include/log0log.ic +++ b/storage/xtradb/include/log0log.ic @@ -553,11 +553,27 @@ log_free_check(void) #endif /* !UNIV_HOTBACKUP */ /****************************************************************//** +Unsafely reads the log_sys->tracked_lsn value. Uses atomic operations +if available, or use dirty read. Use for printing only. + +@return log_sys->tracked_lsn value. */ +UNIV_INLINE +lsn_t +log_get_tracked_lsn_peek(void) +/*==========================*/ +{ +#ifdef HAVE_ATOMIC_BUILTINS_64 + return os_atomic_increment_uint64(&log_sys->tracked_lsn, 0); +#else + return log_sys->tracked_lsn; +#endif +} + +/****************************************************************//** Safely reads the log_sys->tracked_lsn value. Uses atomic operations if available, otherwise this field is protected with the log system mutex. The writer counterpart function is log_set_tracked_lsn() in log0online.c. - @return log_sys->tracked_lsn value. */ UNIV_INLINE lsn_t @@ -571,4 +587,3 @@ log_get_tracked_lsn(void) return log_sys->tracked_lsn; #endif } - diff --git a/storage/xtradb/log/log0log.cc b/storage/xtradb/log/log0log.cc index a34a7c1d1f1..2dc129b1bb3 100644 --- a/storage/xtradb/log/log0log.cc +++ b/storage/xtradb/log/log0log.cc @@ -197,6 +197,27 @@ log_buf_pool_get_oldest_modification(void) } /****************************************************************//** +Returns the oldest modified block lsn in the pool, or log_sys->lsn if none +exists. +@return LSN of oldest modification */ +static +lsn_t +log_buf_pool_get_oldest_modification_peek(void) +/*===========================================*/ +{ + lsn_t lsn; + + lsn = buf_pool_get_oldest_modification_peek(); + + if (!lsn) { + + lsn = log_sys->lsn; + } + + return(lsn); +} + +/****************************************************************//** Checks if the log groups have a big enough margin of free space in so that a new log entry can be written without overwriting log data that is not read by the changed page bitmap thread. @@ -3875,7 +3896,7 @@ log_print( double time_elapsed; time_t current_time; - mutex_enter(&(log_sys->mutex)); + // mutex_enter(&(log_sys->mutex)); fprintf(file, "Log sequence number " LSN_PF "\n" @@ -3884,7 +3905,7 @@ log_print( "Last checkpoint at " LSN_PF "\n", log_sys->lsn, log_sys->flushed_to_disk_lsn, - log_buf_pool_get_oldest_modification(), + log_buf_pool_get_oldest_modification_peek(), log_sys->last_checkpoint_lsn); fprintf(file, @@ -3894,7 +3915,7 @@ log_print( "Checkpoint age " LSN_PF "\n", log_sys->max_checkpoint_age, log_sys->max_checkpoint_age_async, - log_sys->lsn -log_buf_pool_get_oldest_modification(), + log_sys->lsn -log_buf_pool_get_oldest_modification_peek(), log_sys->lsn - log_sys->last_checkpoint_lsn); current_time = time(NULL); @@ -3923,14 +3944,14 @@ log_print( "Log tracking enabled\n" "Log tracked up to " LSN_PF "\n" "Max tracked LSN age " LSN_PF "\n", - log_get_tracked_lsn(), + log_get_tracked_lsn_peek(), log_sys->max_checkpoint_age); } log_sys->n_log_ios_old = log_sys->n_log_ios; log_sys->last_printout_time = current_time; - mutex_exit(&(log_sys->mutex)); + //mutex_exit(&(log_sys->mutex)); } /**********************************************************************//** |