diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-10-01 14:30:17 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-10-01 14:30:17 +0300 |
commit | 1c65ab26de97b4bdc62bcdd04817df2e8d819dcc (patch) | |
tree | fc3384a81390db49370ad8065b92aa98e16723d1 /storage/innobase/trx | |
parent | a9550c47e4e32f2df8816477e362315608194443 (diff) | |
parent | bd64c2e8cc610dc774411c5f0a8ab163fc685934 (diff) | |
download | mariadb-git-1c65ab26de97b4bdc62bcdd04817df2e8d819dcc.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'storage/innobase/trx')
-rw-r--r-- | storage/innobase/trx/trx0i_s.cc | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/storage/innobase/trx/trx0i_s.cc b/storage/innobase/trx/trx0i_s.cc index 82477399552..d3d2b742d84 100644 --- a/storage/innobase/trx/trx0i_s.cc +++ b/storage/innobase/trx/trx0i_s.cc @@ -141,12 +141,9 @@ struct i_s_table_cache_t { struct trx_i_s_cache_t { rw_lock_t rw_lock; /*!< read-write lock protecting the rest of this structure */ - ulonglong last_read; /*!< last time the cache was read; + Atomic_relaxed<ulonglong> last_read; + /*!< last time the cache was read; measured in nanoseconds */ - ib_mutex_t last_read_mutex;/*!< mutex protecting the - last_read member - it is updated - inside a shared lock of the - rw_lock member */ i_s_table_cache_t innodb_trx; /*!< innodb_trx table */ i_s_table_cache_t innodb_locks; /*!< innodb_locks table */ i_s_table_cache_t innodb_lock_waits;/*!< innodb_lock_waits table */ @@ -1136,8 +1133,7 @@ Checks if the cache can safely be updated. @return whether the cache can be updated */ static bool can_cache_be_updated(trx_i_s_cache_t* cache) { - /* Here we read cache->last_read without acquiring its mutex - because last_read is only updated when a shared rw lock on the + /* cache->last_read is only updated when a shared rw lock on the whole cache is being held (see trx_i_s_cache_end_read()) and we are currently holding an exclusive rw lock on the cache. So it is not possible for last_read to be updated while we are @@ -1269,8 +1265,6 @@ trx_i_s_cache_init( release lock mutex release trx_i_s_cache_t::rw_lock acquire trx_i_s_cache_t::rw_lock, S - acquire trx_i_s_cache_t::last_read_mutex - release trx_i_s_cache_t::last_read_mutex release trx_i_s_cache_t::rw_lock */ rw_lock_create(trx_i_s_cache_lock_key, &cache->rw_lock, @@ -1278,8 +1272,6 @@ trx_i_s_cache_init( cache->last_read = 0; - mutex_create(LATCH_ID_CACHE_LAST_READ, &cache->last_read_mutex); - table_cache_init(&cache->innodb_trx, sizeof(i_s_trx_row_t)); table_cache_init(&cache->innodb_locks, sizeof(i_s_locks_row_t)); table_cache_init(&cache->innodb_lock_waits, @@ -1303,7 +1295,6 @@ trx_i_s_cache_free( trx_i_s_cache_t* cache) /*!< in, own: cache to free */ { rw_lock_free(&cache->rw_lock); - mutex_free(&cache->last_read_mutex); cache->locks_hash.free(); ha_storage_free(cache->storage); @@ -1329,14 +1320,7 @@ trx_i_s_cache_end_read( /*===================*/ trx_i_s_cache_t* cache) /*!< in: cache */ { - ut_ad(rw_lock_own(&cache->rw_lock, RW_LOCK_S)); - - /* update cache last read time */ - const ulonglong now = my_interval_timer(); - mutex_enter(&cache->last_read_mutex); - cache->last_read = now; - mutex_exit(&cache->last_read_mutex); - + cache->last_read = my_interval_timer(); rw_lock_s_unlock(&cache->rw_lock); } |