diff options
author | Igor Babaev <igor@askmonty.org> | 2019-02-06 18:01:29 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2019-02-06 18:01:29 -0800 |
commit | 3f9040085a0de4976f55bc7e4a2fa5fa8d923100 (patch) | |
tree | cefa82212b688d12a7ca180f7a0a8f32715e2a79 /storage/innobase/include/trx0sys.h | |
parent | 16327fc2e76e9215059894b461e8aca7f989da00 (diff) | |
parent | e80bcd7f64fc8ff6f46c1fc0d01e9c0b0fd03064 (diff) | |
download | mariadb-git-3f9040085a0de4976f55bc7e4a2fa5fa8d923100.tar.gz |
Merge branch '10.4' into bb-10.4-mdev17096
Diffstat (limited to 'storage/innobase/include/trx0sys.h')
-rw-r--r-- | storage/innobase/include/trx0sys.h | 67 |
1 files changed, 17 insertions, 50 deletions
diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index 6af212d35ff..92f24d036ae 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -27,8 +27,6 @@ Created 3/26/1996 Heikki Tuuri #ifndef trx0sys_h #define trx0sys_h -#include "univ.i" - #include "buf0buf.h" #include "fil0fil.h" #include "trx0types.h" @@ -49,9 +47,7 @@ typedef UT_LIST_BASE_NODE_T(trx_t) trx_ut_list_t; /** Checks if a page address is the trx sys header page. @param[in] page_id page id @return true if trx sys header page */ -inline -bool -trx_sys_hdr_page(const page_id_t& page_id) +inline bool trx_sys_hdr_page(const page_id_t& page_id) { return(page_id.space() == TRX_SYS_SPACE && page_id.page_no() == TRX_SYS_PAGE_NO); @@ -373,7 +369,7 @@ struct rw_trx_hash_element_t trx_id_t id; /* lf_hash_init() relies on this to be first in the struct */ - trx_id_t no; + Atomic_counter<trx_id_t> no; trx_t *trx; ib_mutex_t mutex; }; @@ -708,11 +704,7 @@ public: because it may change even before this method returns. */ - uint32_t size() - { - return uint32_t(my_atomic_load32_explicit(&hash.count, - MY_MEMORY_ORDER_RELAXED)); - } + uint32_t size() { return uint32_t(lf_hash_size(&hash)); } /** @@ -794,7 +786,7 @@ class trx_sys_t The smallest number not yet assigned as a transaction id or transaction number. Accessed and updated with atomic operations. */ - MY_ALIGNED(CACHE_LINE_SIZE) trx_id_t m_max_trx_id; + MY_ALIGNED(CACHE_LINE_SIZE) Atomic_counter<trx_id_t> m_max_trx_id; /** @@ -805,17 +797,17 @@ class trx_sys_t @sa assign_new_trx_no() @sa snapshot_ids() */ - MY_ALIGNED(CACHE_LINE_SIZE) trx_id_t m_rw_trx_hash_version; + MY_ALIGNED(CACHE_LINE_SIZE) std::atomic<trx_id_t> m_rw_trx_hash_version; + + bool m_initialised; +public: /** TRX_RSEG_HISTORY list length (number of committed transactions to purge) */ - MY_ALIGNED(CACHE_LINE_SIZE) int32 rseg_history_len; + MY_ALIGNED(CACHE_LINE_SIZE) Atomic_counter<uint32_t> rseg_history_len; - bool m_initialised; - -public: /** Mutex protecting trx_list. */ MY_ALIGNED(CACHE_LINE_SIZE) mutable TrxSysMutex mutex; @@ -891,9 +883,7 @@ public: trx_id_t get_max_trx_id() { - return static_cast<trx_id_t> - (my_atomic_load64_explicit(reinterpret_cast<int64*>(&m_max_trx_id), - MY_MEMORY_ORDER_RELAXED)); + return m_max_trx_id; } @@ -935,9 +925,7 @@ public: void assign_new_trx_no(trx_t *trx) { trx->no= get_new_trx_id_no_refresh(); - my_atomic_store64_explicit(reinterpret_cast<int64*> - (&trx->rw_trx_hash_element->no), - trx->no, MY_MEMORY_ORDER_RELAXED); + trx->rw_trx_hash_element->no= trx->no; refresh_rw_trx_hash_version(); } @@ -988,7 +976,8 @@ public: /** Initialiser for m_max_trx_id and m_rw_trx_hash_version. */ void init_max_trx_id(trx_id_t value) { - m_max_trx_id= m_rw_trx_hash_version= value; + m_max_trx_id= value; + m_rw_trx_hash_version.store(value, std::memory_order_relaxed); } @@ -1110,22 +1099,6 @@ public: return count; } - /** @return number of committed transactions waiting for purge */ - ulint history_size() const - { - return uint32(my_atomic_load32(&const_cast<trx_sys_t*>(this) - ->rseg_history_len)); - } - /** Add to the TRX_RSEG_HISTORY length (on database startup). */ - void history_add(int32 len) - { - my_atomic_add32(&rseg_history_len, len); - } - /** Register a committed transaction. */ - void history_insert() { history_add(1); } - /** Note that a committed transaction was purged. */ - void history_remove() { history_add(-1); } - private: static my_bool get_min_trx_id_callback(rw_trx_hash_element_t *element, trx_id_t *id) @@ -1156,8 +1129,7 @@ private: { if (element->id < arg->m_id) { - trx_id_t no= static_cast<trx_id_t>(my_atomic_load64_explicit( - reinterpret_cast<int64*>(&element->no), MY_MEMORY_ORDER_RELAXED)); + trx_id_t no= element->no; arg->m_ids->push_back(element->id); if (no < arg->m_no) arg->m_no= no; @@ -1169,18 +1141,14 @@ private: /** Getter for m_rw_trx_hash_version, must issue ACQUIRE memory barrier. */ trx_id_t get_rw_trx_hash_version() { - return static_cast<trx_id_t> - (my_atomic_load64_explicit(reinterpret_cast<int64*> - (&m_rw_trx_hash_version), - MY_MEMORY_ORDER_ACQUIRE)); + return m_rw_trx_hash_version.load(std::memory_order_acquire); } /** Increments m_rw_trx_hash_version, must issue RELEASE memory barrier. */ void refresh_rw_trx_hash_version() { - my_atomic_add64_explicit(reinterpret_cast<int64*>(&m_rw_trx_hash_version), - 1, MY_MEMORY_ORDER_RELEASE); + m_rw_trx_hash_version.fetch_add(1, std::memory_order_release); } @@ -1199,8 +1167,7 @@ private: trx_id_t get_new_trx_id_no_refresh() { - return static_cast<trx_id_t>(my_atomic_add64_explicit( - reinterpret_cast<int64*>(&m_max_trx_id), 1, MY_MEMORY_ORDER_RELAXED)); + return m_max_trx_id++; } }; |