diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2023-02-28 10:36:17 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2023-02-28 10:36:17 +0200 |
commit | 6ac44ac3abec2263bc7ab9745cd52cc0ad214d8a (patch) | |
tree | ba2be2818fa9d2e191ea7307851324113f0a1647 /storage/innobase/include | |
parent | b62123e0d517a63fb7a1192093fd3cafcfe9d480 (diff) | |
parent | 3e2ad0e918d5d38322994ec9e08fc5dda3a80707 (diff) | |
download | mariadb-git-6ac44ac3abec2263bc7ab9745cd52cc0ad214d8a.tar.gz |
Merge 10.6 into 10.8
Diffstat (limited to 'storage/innobase/include')
-rw-r--r-- | storage/innobase/include/lock0lock.h | 2 | ||||
-rw-r--r-- | storage/innobase/include/trx0rseg.h | 55 | ||||
-rw-r--r-- | storage/innobase/include/trx0undo.h | 6 |
3 files changed, 24 insertions, 39 deletions
diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index b67a1011f6b..16acd031177 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -891,8 +891,8 @@ public: /** Cancel a waiting lock request. @tparam check_victim whether to check for DB_DEADLOCK - @param lock waiting lock request @param trx active transaction + @param lock waiting lock request @retval DB_SUCCESS if no lock existed @retval DB_DEADLOCK if trx->lock.was_chosen_as_deadlock_victim was set @retval DB_LOCK_WAIT if the lock was canceled */ diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index 7ad20b0fff0..8b7eacbbc18 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -65,53 +65,44 @@ struct alignas(CPU_LEVEL1_DCACHE_LINESIZE) trx_rseg_t /** length of the TRX_RSEG_HISTORY list (number of transactions) */ uint32_t history_size; + /** Last known transaction that has not been purged yet, + or 0 if everything has been purged. */ + trx_id_t needs_purge; + private: - /** Reference counter to track rseg allocated transactions, - with SKIP and NEEDS_PURGE flags. */ + /** Reference counter to track is_persistent() transactions, + with SKIP flag. */ std::atomic<uint32_t> ref; /** Whether undo tablespace truncation is pending */ static constexpr uint32_t SKIP= 1; - /** Whether the log segment needs purge */ - static constexpr uint32_t NEEDS_PURGE= 2; /** Transaction reference count multiplier */ - static constexpr uint32_t REF= 4; + static constexpr uint32_t REF= 2; uint32_t ref_load() const { return ref.load(std::memory_order_relaxed); } - /** Set a bit in ref */ - template<bool needs_purge> void ref_set() + /** Set the SKIP bit */ + void ref_set_skip() { - static_assert(SKIP == 1U << 0, "compatibility"); - static_assert(NEEDS_PURGE == 1U << 1, "compatibility"); + static_assert(SKIP == 1U, "compatibility"); #if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - if (needs_purge) - __asm__ __volatile__("lock btsl $1, %0" : "+m" (ref)); - else - __asm__ __volatile__("lock btsl $0, %0" : "+m" (ref)); + __asm__ __volatile__("lock btsl $0, %0" : "+m" (ref)); #elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) - _interlockedbittestandset(reinterpret_cast<volatile long*>(&ref), - needs_purge); + _interlockedbittestandset(reinterpret_cast<volatile long*>(&ref), 0); #else - ref.fetch_or(needs_purge ? NEEDS_PURGE : SKIP, std::memory_order_relaxed); + ref.fetch_or(SKIP, std::memory_order_relaxed); #endif } /** Clear a bit in ref */ - template<bool needs_purge> void ref_reset() + void ref_reset_skip() { - static_assert(SKIP == 1U << 0, "compatibility"); - static_assert(NEEDS_PURGE == 1U << 1, "compatibility"); + static_assert(SKIP == 1U, "compatibility"); #if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - if (needs_purge) - __asm__ __volatile__("lock btrl $1, %0" : "+m" (ref)); - else - __asm__ __volatile__("lock btrl $0, %0" : "+m" (ref)); + __asm__ __volatile__("lock btrl $0, %0" : "+m" (ref)); #elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) - _interlockedbittestandreset(reinterpret_cast<volatile long*>(&ref), - needs_purge); + _interlockedbittestandreset(reinterpret_cast<volatile long*>(&ref), 0); #else - ref.fetch_and(needs_purge ? ~NEEDS_PURGE : ~SKIP, - std::memory_order_relaxed); + ref.fetch_and(~SKIP, std::memory_order_relaxed); #endif } @@ -125,26 +116,20 @@ public: void destroy(); /** Note that undo tablespace truncation was started. */ - void set_skip_allocation() { ut_ad(is_persistent()); ref_set<false>(); } + void set_skip_allocation() { ut_ad(is_persistent()); ref_set_skip(); } /** Note that undo tablespace truncation was completed. */ void clear_skip_allocation() { ut_ad(is_persistent()); #if defined DBUG_OFF - ref_reset<false>(); + ref_reset_skip(); #else ut_d(auto r=) ref.fetch_and(~SKIP, std::memory_order_relaxed); ut_ad(r == SKIP); #endif } - /** Note that the rollback segment requires purge. */ - void set_needs_purge() { ref_set<true>(); } - /** Note that the rollback segment will not require purge. */ - void clear_needs_purge() { ref_reset<true>(); } /** @return whether the segment is marked for undo truncation */ bool skip_allocation() const { return ref_load() & SKIP; } - /** @return whether the segment needs purge */ - bool needs_purge() const { return ref_load() & NEEDS_PURGE; } /** Increment the reference count */ void acquire() { ut_d(auto r=) ref.fetch_add(REF); ut_ad(!(r & SKIP)); } diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index a8cddd6575d..3474a903f6c 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -246,12 +246,10 @@ trx_undo_free_at_shutdown(trx_t *trx); @param[in,out] rseg rollback segment @param[in] id rollback segment slot @param[in] page_no undo log segment page number -@param[in,out] max_trx_id the largest observed transaction ID @return the undo log @retval nullptr on error */ trx_undo_t * -trx_undo_mem_create_at_db_start(trx_rseg_t *rseg, ulint id, uint32_t page_no, - trx_id_t &max_trx_id); +trx_undo_mem_create_at_db_start(trx_rseg_t *rseg, ulint id, uint32_t page_no); #endif /* !UNIV_INNOCHECKSUM */ @@ -493,6 +491,8 @@ or 0 if the transaction has not been committed */ /** Before MariaDB 10.3.1, when purge did not reset DB_TRX_ID of surviving user records, this used to be called TRX_UNDO_DEL_MARKS. +This field is redundant; it is only being read by some debug assertions. + The value 1 indicates that purge needs to process the undo log segment. The value 0 indicates that all of it has been processed, and trx_purge_free_segment() has been invoked, so the log is not safe to access. |