1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge 10.6 into 10.7

This commit is contained in:
Marko Mäkelä
2022-04-14 13:31:07 +03:00
27 changed files with 169 additions and 179 deletions

View File

@ -800,3 +800,15 @@ drop procedure test_proc;
drop view v1; drop view v1;
drop function get_name; drop function get_name;
drop table t1; drop table t1;
#
# MDEV-28266: Crash in Field_string::type_handler when calling procedures
#
CREATE TABLE t (f INT);
CREATE TRIGGER tr AFTER INSERT ON t FOR EACH ROW
FOR x IN (SELECT * FROM json_table(NULL, '$' COLUMNS(a CHAR(1) path '$.*')) tmp)
DO set @a=1; END FOR $
INSERT INTO t () values ();
DROP TABLE t;
#
# End of 10.6 tests
#

View File

@ -800,3 +800,24 @@ drop procedure test_proc;
drop view v1; drop view v1;
drop function get_name; drop function get_name;
drop table t1; drop table t1;
--echo #
--echo # MDEV-28266: Crash in Field_string::type_handler when calling procedures
--echo #
CREATE TABLE t (f INT);
--delimiter $
CREATE TRIGGER tr AFTER INSERT ON t FOR EACH ROW
FOR x IN (SELECT * FROM json_table(NULL, '$' COLUMNS(a CHAR(1) path '$.*')) tmp)
DO set @a=1; END FOR $
--delimiter ;
INSERT INTO t () values ();
# Cleanup
DROP TABLE t;
--echo #
--echo # End of 10.6 tests
--echo #

View File

@ -80,19 +80,7 @@ public:
Select_materialize(THD *thd_arg, select_result *result_arg): Select_materialize(THD *thd_arg, select_result *result_arg):
select_unit(thd_arg), result(result_arg), materialized_cursor(0) {} select_unit(thd_arg), result(result_arg), materialized_cursor(0) {}
virtual bool send_result_set_metadata(List<Item> &list, uint flags); virtual bool send_result_set_metadata(List<Item> &list, uint flags);
bool send_eof() bool send_eof() { return false; }
{
if (materialized_cursor)
materialized_cursor->on_table_fill_finished();
return false;
}
void abort_result_set()
{
if (materialized_cursor)
materialized_cursor->on_table_fill_finished();
}
bool view_structure_only() const bool view_structure_only() const
{ {
return result->view_structure_only(); return result->view_structure_only();
@ -333,6 +321,8 @@ int Materialized_cursor::open(JOIN *join __attribute__((unused)))
result->abort_result_set(); result->abort_result_set();
} }
on_table_fill_finished();
return rc; return rc;
} }

View File

@ -528,7 +528,6 @@ mysql_pfs_key_t fts_cache_mutex_key;
mysql_pfs_key_t fts_cache_init_mutex_key; mysql_pfs_key_t fts_cache_init_mutex_key;
mysql_pfs_key_t fts_delete_mutex_key; mysql_pfs_key_t fts_delete_mutex_key;
mysql_pfs_key_t fts_doc_id_mutex_key; mysql_pfs_key_t fts_doc_id_mutex_key;
mysql_pfs_key_t fts_pll_tokenize_mutex_key;
mysql_pfs_key_t ibuf_bitmap_mutex_key; mysql_pfs_key_t ibuf_bitmap_mutex_key;
mysql_pfs_key_t ibuf_mutex_key; mysql_pfs_key_t ibuf_mutex_key;
mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key; mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
@ -550,10 +549,6 @@ mysql_pfs_key_t trx_pool_manager_mutex_key;
mysql_pfs_key_t lock_wait_mutex_key; mysql_pfs_key_t lock_wait_mutex_key;
mysql_pfs_key_t trx_sys_mutex_key; mysql_pfs_key_t trx_sys_mutex_key;
mysql_pfs_key_t srv_threads_mutex_key; mysql_pfs_key_t srv_threads_mutex_key;
mysql_pfs_key_t thread_mutex_key;
mysql_pfs_key_t row_drop_list_mutex_key;
mysql_pfs_key_t rw_trx_hash_element_mutex_key;
mysql_pfs_key_t read_view_mutex_key;
/* all_innodb_mutexes array contains mutexes that are /* all_innodb_mutexes array contains mutexes that are
performance schema instrumented if "UNIV_PFS_MUTEX" performance schema instrumented if "UNIV_PFS_MUTEX"
@ -1235,7 +1230,7 @@ struct log_flush_request
}; };
/** Buffer of pending innodb_log_flush_request() */ /** Buffer of pending innodb_log_flush_request() */
MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) static alignas(CPU_LEVEL1_DCACHE_LINESIZE) static
struct struct
{ {
/** first request */ /** first request */
@ -2402,7 +2397,7 @@ innobase_mysql_print_thd(
/******************************************************************//** /******************************************************************//**
Get the variable length bounds of the given character set. */ Get the variable length bounds of the given character set. */
void static void
innobase_get_cset_width( innobase_get_cset_width(
/*====================*/ /*====================*/
ulint cset, /*!< in: MySQL charset-collation code */ ulint cset, /*!< in: MySQL charset-collation code */
@ -2414,7 +2409,7 @@ innobase_get_cset_width(
ut_ad(mbminlen); ut_ad(mbminlen);
ut_ad(mbmaxlen); ut_ad(mbmaxlen);
cs = all_charsets[cset]; cs = cset ? get_charset((uint)cset, MYF(MY_WME)) : NULL;
if (cs) { if (cs) {
*mbminlen = cs->mbminlen; *mbminlen = cs->mbminlen;
*mbmaxlen = cs->mbmaxlen; *mbmaxlen = cs->mbmaxlen;
@ -2442,6 +2437,29 @@ innobase_get_cset_width(
} }
} }
/*********************************************************************//**
Compute the mbminlen and mbmaxlen members of a data type structure. */
void
dtype_get_mblen(
/*============*/
ulint mtype, /*!< in: main type */
ulint prtype, /*!< in: precise type (and collation) */
unsigned*mbminlen, /*!< out: minimum length of a
multi-byte character */
unsigned*mbmaxlen) /*!< out: maximum length of a
multi-byte character */
{
if (dtype_is_string_type(mtype)) {
innobase_get_cset_width(dtype_get_charset_coll(prtype),
mbminlen, mbmaxlen);
ut_ad(*mbminlen <= *mbmaxlen);
ut_ad(*mbminlen < DATA_MBMAX);
ut_ad(*mbmaxlen < DATA_MBMAX);
} else {
*mbminlen = *mbmaxlen = 0;
}
}
/******************************************************************//** /******************************************************************//**
Converts an identifier to a table name. */ Converts an identifier to a table name. */
void void

View File

@ -1576,7 +1576,7 @@ public:
static constexpr uint32_t READ_AHEAD_PAGES= 64; static constexpr uint32_t READ_AHEAD_PAGES= 64;
/** Buffer pool mutex */ /** Buffer pool mutex */
MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t mutex; alignas(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t mutex;
/** Number of pending LRU flush; protected by mutex. */ /** Number of pending LRU flush; protected by mutex. */
ulint n_flush_LRU_; ulint n_flush_LRU_;
/** broadcast when n_flush_LRU reaches 0; protected by mutex */ /** broadcast when n_flush_LRU reaches 0; protected by mutex */
@ -1758,7 +1758,7 @@ public:
/** mutex protecting flush_list, buf_page_t::set_oldest_modification() /** mutex protecting flush_list, buf_page_t::set_oldest_modification()
and buf_page_t::list pointers when !oldest_modification() */ and buf_page_t::list pointers when !oldest_modification() */
MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t flush_list_mutex; alignas(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t flush_list_mutex;
/** "hazard pointer" for flush_list scans; protected by flush_list_mutex */ /** "hazard pointer" for flush_list scans; protected by flush_list_mutex */
FlushHp flush_hp; FlushHp flush_hp;
/** modified blocks (a subset of LRU) */ /** modified blocks (a subset of LRU) */

View File

@ -325,7 +325,6 @@ dtype_get_prtype(
/*********************************************************************//** /*********************************************************************//**
Compute the mbminlen and mbmaxlen members of a data type structure. */ Compute the mbminlen and mbmaxlen members of a data type structure. */
UNIV_INLINE
void void
dtype_get_mblen( dtype_get_mblen(
/*============*/ /*============*/

View File

@ -64,30 +64,6 @@ dtype_get_mysql_type(
return(type->prtype & 0xFFUL); return(type->prtype & 0xFFUL);
} }
/*********************************************************************//**
Compute the mbminlen and mbmaxlen members of a data type structure. */
UNIV_INLINE
void
dtype_get_mblen(
/*============*/
ulint mtype, /*!< in: main type */
ulint prtype, /*!< in: precise type (and collation) */
unsigned*mbminlen, /*!< out: minimum length of a
multi-byte character */
unsigned*mbmaxlen) /*!< out: maximum length of a
multi-byte character */
{
if (dtype_is_string_type(mtype)) {
innobase_get_cset_width(dtype_get_charset_coll(prtype),
mbminlen, mbmaxlen);
ut_ad(*mbminlen <= *mbmaxlen);
ut_ad(*mbminlen < DATA_MBMAX);
ut_ad(*mbmaxlen < DATA_MBMAX);
} else {
*mbminlen = *mbmaxlen = 0;
}
}
/*********************************************************************//** /*********************************************************************//**
Compute the mbminlen and mbmaxlen members of a data type structure. */ Compute the mbminlen and mbmaxlen members of a data type structure. */
UNIV_INLINE UNIV_INLINE
@ -374,16 +350,6 @@ dtype_get_fixed_size_low(
} else if (!comp) { } else if (!comp) {
return static_cast<unsigned>(len); return static_cast<unsigned>(len);
} else { } else {
#ifdef UNIV_DEBUG
unsigned i_mbminlen, i_mbmaxlen;
innobase_get_cset_width(
dtype_get_charset_coll(prtype),
&i_mbminlen, &i_mbmaxlen);
ut_ad(i_mbminlen == mbminlen);
ut_ad(i_mbmaxlen == mbmaxlen);
#endif /* UNIV_DEBUG */
if (mbminlen == mbmaxlen) { if (mbminlen == mbmaxlen) {
return static_cast<unsigned>(len); return static_cast<unsigned>(len);
} }

View File

@ -1351,7 +1351,7 @@ class dict_sys_t
std::atomic<ulonglong> latch_ex_wait_start; std::atomic<ulonglong> latch_ex_wait_start;
/** the rw-latch protecting the data dictionary cache */ /** the rw-latch protecting the data dictionary cache */
MY_ALIGNED(CACHE_LINE_SIZE) srw_lock latch; alignas(CPU_LEVEL1_DCACHE_LINESIZE) srw_lock latch;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/** whether latch is being held in exclusive mode (by any thread) */ /** whether latch is being held in exclusive mode (by any thread) */
bool latch_ex; bool latch_ex;

View File

@ -139,15 +139,6 @@ at least ENUM and SET, and unsigned integer types are 'unsigned types'
uint8_t uint8_t
get_innobase_type_from_mysql_type(unsigned *unsigned_flag, const Field *field); get_innobase_type_from_mysql_type(unsigned *unsigned_flag, const Field *field);
/******************************************************************//**
Get the variable length bounds of the given character set. */
void
innobase_get_cset_width(
/*====================*/
ulint cset, /*!< in: MySQL charset-collation code */
unsigned*mbminlen, /*!< out: minimum length of a char (in bytes) */
unsigned*mbmaxlen); /*!< out: maximum length of a char (in bytes) */
/******************************************************************//** /******************************************************************//**
Compares NUL-terminated UTF-8 strings case insensitively. Compares NUL-terminated UTF-8 strings case insensitively.
@return 0 if a=b, <0 if a<b, >1 if a>b */ @return 0 if a=b, <0 if a<b, >1 if a>b */

View File

@ -684,7 +684,7 @@ private:
bool m_initialised; bool m_initialised;
/** mutex proteting the locks */ /** mutex proteting the locks */
MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) srw_spin_lock latch; alignas(CPU_LEVEL1_DCACHE_LINESIZE) srw_spin_lock latch;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/** The owner of exclusive latch (0 if none); protected by latch */ /** The owner of exclusive latch (0 if none); protected by latch */
std::atomic<os_thread_id_t> writer{0}; std::atomic<os_thread_id_t> writer{0};
@ -707,7 +707,7 @@ public:
hash_table prdt_page_hash; hash_table prdt_page_hash;
/** mutex covering lock waits; @see trx_lock_t::wait_lock */ /** mutex covering lock waits; @see trx_lock_t::wait_lock */
MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t wait_mutex; alignas(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t wait_mutex;
private: private:
/** The increment of wait_count for a wait. Anything smaller is a /** The increment of wait_count for a wait. Anything smaller is a
pending wait count. */ pending wait count. */

View File

@ -451,7 +451,7 @@ struct log_t{
private: private:
/** The log sequence number of the last change of durable InnoDB files */ /** The log sequence number of the last change of durable InnoDB files */
MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) alignas(CPU_LEVEL1_DCACHE_LINESIZE)
std::atomic<lsn_t> lsn; std::atomic<lsn_t> lsn;
/** the first guaranteed-durable log sequence number */ /** the first guaranteed-durable log sequence number */
std::atomic<lsn_t> flushed_to_disk_lsn; std::atomic<lsn_t> flushed_to_disk_lsn;
@ -461,7 +461,7 @@ private:
std::atomic<bool> check_flush_or_checkpoint_; std::atomic<bool> check_flush_or_checkpoint_;
public: public:
/** mutex protecting the log */ /** mutex protecting the log */
MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t mutex; alignas(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t mutex;
/** first free offset within the log buffer in use */ /** first free offset within the log buffer in use */
size_t buf_free; size_t buf_free;
/** recommended maximum size of buf, after which the buffer is flushed */ /** recommended maximum size of buf, after which the buffer is flushed */
@ -470,7 +470,7 @@ public:
dirty blocks in the list. The idea behind this mutex is to be able dirty blocks in the list. The idea behind this mutex is to be able
to release log_sys.mutex during mtr_commit and still ensure that to release log_sys.mutex during mtr_commit and still ensure that
insertions in the flush_list happen in the LSN order. */ insertions in the flush_list happen in the LSN order. */
MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t flush_order_mutex; alignas(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t flush_order_mutex;
/** log_buffer, append data here */ /** log_buffer, append data here */
byte *buf; byte *buf;
/** log_buffer, writing data to file from this buffer. /** log_buffer, writing data to file from this buffer.

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, 2021, MariaDB Corporation. Copyright (c) 2018, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -28,12 +28,9 @@ Created 2/16/1997 Heikki Tuuri
#include "dict0mem.h" #include "dict0mem.h"
#include "trx0types.h" #include "trx0types.h"
#include "srw_lock.h"
#include <algorithm> #include <algorithm>
#ifdef UNIV_PFS_MUTEX
extern mysql_pfs_key_t read_view_mutex_key;
#endif
/** /**
Read view lists the trx ids of those transactions for which a consistent read Read view lists the trx ids of those transactions for which a consistent read
should not see the modifications to the database. should not see the modifications to the database.
@ -44,7 +41,7 @@ class ReadViewBase
The read should not see any transaction with trx id >= this value. The read should not see any transaction with trx id >= this value.
In other words, this is the "high water mark". In other words, this is the "high water mark".
*/ */
trx_id_t m_low_limit_id; trx_id_t m_low_limit_id= 0;
/** /**
The read should see all trx ids which are strictly The read should see all trx ids which are strictly
@ -70,9 +67,6 @@ protected:
trx_id_t up_limit_id() const { return m_up_limit_id; } trx_id_t up_limit_id() const { return m_up_limit_id; }
public: public:
ReadViewBase(): m_low_limit_id(0) {}
/** /**
Append state from another view. Append state from another view.
@ -206,7 +200,7 @@ class ReadView: public ReadViewBase
std::atomic<bool> m_open; std::atomic<bool> m_open;
/** For synchronisation with purge coordinator. */ /** For synchronisation with purge coordinator. */
mutable mysql_mutex_t m_mutex; mutable srw_mutex m_mutex;
/** /**
trx id of creating transaction. trx id of creating transaction.
@ -215,9 +209,12 @@ class ReadView: public ReadViewBase
trx_id_t m_creator_trx_id; trx_id_t m_creator_trx_id;
public: public:
ReadView(): m_open(false) ReadView()
{ mysql_mutex_init(read_view_mutex_key, &m_mutex, nullptr); } {
~ReadView() { mysql_mutex_destroy(&m_mutex); } memset(reinterpret_cast<void*>(this), 0, sizeof *this);
m_mutex.init();
}
~ReadView() { m_mutex.destroy(); }
/** /**
@ -265,12 +262,12 @@ public:
*/ */
void print_limits(FILE *file) const void print_limits(FILE *file) const
{ {
mysql_mutex_lock(&m_mutex); m_mutex.wr_lock();
if (is_open()) if (is_open())
fprintf(file, "Trx read view will not see trx with" fprintf(file, "Trx read view will not see trx with"
" id >= " TRX_ID_FMT ", sees < " TRX_ID_FMT "\n", " id >= " TRX_ID_FMT ", sees < " TRX_ID_FMT "\n",
low_limit_id(), up_limit_id()); low_limit_id(), up_limit_id());
mysql_mutex_unlock(&m_mutex); m_mutex.wr_unlock();
} }
@ -289,10 +286,10 @@ public:
*/ */
void append_to(ReadViewBase *to) const void append_to(ReadViewBase *to) const
{ {
mysql_mutex_lock(&m_mutex); m_mutex.wr_lock();
if (is_open()) if (is_open())
to->append(*this); to->append(*this);
mysql_mutex_unlock(&m_mutex); m_mutex.wr_unlock();
} }
/** /**

View File

@ -55,7 +55,7 @@ Created 10/10/1995 Heikki Tuuri
/** Simple non-atomic counter /** Simple non-atomic counter
@tparam Type the integer type of the counter */ @tparam Type the integer type of the counter */
template <typename Type> template <typename Type>
struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) simple_counter struct alignas(CPU_LEVEL1_DCACHE_LINESIZE) simple_counter
{ {
/** Increment the counter */ /** Increment the counter */
Type inc() { return add(1); } Type inc() { return add(1); }

View File

@ -125,7 +125,7 @@ class purge_sys_t
{ {
public: public:
/** latch protecting view, m_enabled */ /** latch protecting view, m_enabled */
MY_ALIGNED(CACHE_LINE_SIZE) mutable srw_spin_lock latch; alignas(CPU_LEVEL1_DCACHE_LINESIZE) mutable srw_spin_lock latch;
private: private:
/** The purge will not remove undo logs which are >= this view */ /** The purge will not remove undo logs which are >= this view */
ReadViewBase view; ReadViewBase view;

View File

@ -69,7 +69,7 @@ void trx_temp_rseg_create();
#define TRX_RSEG_MAX_N_TRXS (TRX_RSEG_N_SLOTS / 2) #define TRX_RSEG_MAX_N_TRXS (TRX_RSEG_N_SLOTS / 2)
/** The rollback segment memory object */ /** The rollback segment memory object */
struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) trx_rseg_t struct alignas(CPU_LEVEL1_DCACHE_LINESIZE) trx_rseg_t
{ {
/** tablespace containing the rollback segment; constant after init() */ /** tablespace containing the rollback segment; constant after init() */
fil_space_t *space; fil_space_t *space;

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2021, MariaDB Corporation. Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -40,7 +40,6 @@ Created 3/26/1996 Heikki Tuuri
#ifdef UNIV_PFS_MUTEX #ifdef UNIV_PFS_MUTEX
extern mysql_pfs_key_t trx_sys_mutex_key; extern mysql_pfs_key_t trx_sys_mutex_key;
extern mysql_pfs_key_t rw_trx_hash_element_mutex_key;
#endif #endif
/** Checks if a page address is the trx sys header page. /** Checks if a page address is the trx sys header page.
@ -335,16 +334,14 @@ trx_t* current_trx();
struct rw_trx_hash_element_t struct rw_trx_hash_element_t
{ {
rw_trx_hash_element_t(): trx(0) rw_trx_hash_element_t()
{ {
mysql_mutex_init(rw_trx_hash_element_mutex_key, &mutex, nullptr); memset(reinterpret_cast<void*>(this), 0, sizeof *this);
mutex.init();
} }
~rw_trx_hash_element_t() ~rw_trx_hash_element_t() { mutex.destroy(); }
{
mysql_mutex_destroy(&mutex);
}
trx_id_t id; /* lf_hash_init() relies on this to be first in the struct */ trx_id_t id; /* lf_hash_init() relies on this to be first in the struct */
@ -357,7 +354,7 @@ struct rw_trx_hash_element_t
*/ */
Atomic_counter<trx_id_t> no; Atomic_counter<trx_id_t> no;
trx_t *trx; trx_t *trx;
mysql_mutex_t mutex; srw_mutex mutex;
}; };
@ -526,10 +523,10 @@ class rw_trx_hash_t
static my_bool debug_iterator(rw_trx_hash_element_t *element, static my_bool debug_iterator(rw_trx_hash_element_t *element,
debug_iterator_arg<T> *arg) debug_iterator_arg<T> *arg)
{ {
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (element->trx) if (element->trx)
validate_element(element->trx); validate_element(element->trx);
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
return arg->action(element, arg->argument); return arg->action(element, arg->argument);
} }
#endif #endif
@ -631,7 +628,7 @@ public:
sizeof(trx_id_t))); sizeof(trx_id_t)));
if (element) if (element)
{ {
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
lf_hash_search_unpin(pins); lf_hash_search_unpin(pins);
if ((trx= element->trx)) { if ((trx= element->trx)) {
DBUG_ASSERT(trx_id == trx->id); DBUG_ASSERT(trx_id == trx->id);
@ -652,7 +649,7 @@ public:
trx->reference(); trx->reference();
} }
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
} }
if (!caller_trx) if (!caller_trx)
lf_hash_put_pins(pins); lf_hash_put_pins(pins);
@ -686,9 +683,9 @@ public:
void erase(trx_t *trx) void erase(trx_t *trx)
{ {
ut_d(validate_element(trx)); ut_d(validate_element(trx));
mysql_mutex_lock(&trx->rw_trx_hash_element->mutex); trx->rw_trx_hash_element->mutex.wr_lock();
trx->rw_trx_hash_element->trx= 0; trx->rw_trx_hash_element->trx= nullptr;
mysql_mutex_unlock(&trx->rw_trx_hash_element->mutex); trx->rw_trx_hash_element->mutex.wr_unlock();
int res= lf_hash_delete(&hash, get_pins(trx), int res= lf_hash_delete(&hash, get_pins(trx),
reinterpret_cast<const void*>(&trx->id), reinterpret_cast<const void*>(&trx->id),
sizeof(trx_id_t)); sizeof(trx_id_t));
@ -722,12 +719,12 @@ public:
May return element with committed transaction. If caller doesn't like to May return element with committed transaction. If caller doesn't like to
see committed transactions, it has to skip those under element mutex: see committed transactions, it has to skip those under element mutex:
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (trx_t trx= element->trx) if (trx_t trx= element->trx)
{ {
// trx is protected against commit in this branch // trx is protected against commit in this branch
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
May miss concurrently inserted transactions. May miss concurrently inserted transactions.
@ -833,8 +830,8 @@ public:
void unfreeze() const { mysql_mutex_unlock(&mutex); } void unfreeze() const { mysql_mutex_unlock(&mutex); }
private: private:
alignas(CACHE_LINE_SIZE) mutable mysql_mutex_t mutex; alignas(CPU_LEVEL1_DCACHE_LINESIZE) mutable mysql_mutex_t mutex;
alignas(CACHE_LINE_SIZE) ilist<trx_t> trx_list; alignas(CPU_LEVEL1_DCACHE_LINESIZE) ilist<trx_t> trx_list;
}; };
/** The transaction system central memory data structure. */ /** The transaction system central memory data structure. */
@ -844,7 +841,7 @@ class trx_sys_t
The smallest number not yet assigned as a transaction id or transaction The smallest number not yet assigned as a transaction id or transaction
number. Accessed and updated with atomic operations. number. Accessed and updated with atomic operations.
*/ */
MY_ALIGNED(CACHE_LINE_SIZE) Atomic_counter<trx_id_t> m_max_trx_id; alignas(CPU_LEVEL1_DCACHE_LINESIZE) Atomic_counter<trx_id_t> m_max_trx_id;
/** /**
@ -855,7 +852,8 @@ class trx_sys_t
@sa assign_new_trx_no() @sa assign_new_trx_no()
@sa snapshot_ids() @sa snapshot_ids()
*/ */
MY_ALIGNED(CACHE_LINE_SIZE) std::atomic<trx_id_t> m_rw_trx_hash_version; alignas(CPU_LEVEL1_DCACHE_LINESIZE)
std::atomic<trx_id_t> m_rw_trx_hash_version;
bool m_initialised; bool m_initialised;
@ -875,7 +873,7 @@ public:
Works faster when it is on it's own cache line (tested). Works faster when it is on it's own cache line (tested).
*/ */
MY_ALIGNED(CACHE_LINE_SIZE) rw_trx_hash_t rw_trx_hash; alignas(CPU_LEVEL1_DCACHE_LINESIZE) rw_trx_hash_t rw_trx_hash;
#ifdef WITH_WSREP #ifdef WITH_WSREP
@ -1180,11 +1178,11 @@ private:
{ {
if (element->id < *id) if (element->id < *id)
{ {
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
/* We don't care about read-only transactions here. */ /* We don't care about read-only transactions here. */
if (element->trx && element->trx->rsegs.m_redo.rseg) if (element->trx && element->trx->rsegs.m_redo.rseg)
*id= element->id; *id= element->id;
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
} }
return 0; return 0;
} }

View File

@ -388,13 +388,13 @@ struct trx_lock_t
only be modified by the thread that is only be modified by the thread that is
serving the running transaction. */ serving the running transaction. */
/** Pre-allocated record locks */ /** Pre-allocated record locks */
struct { struct {
ib_lock_t lock; byte pad[256]; alignas(CPU_LEVEL1_DCACHE_LINESIZE) ib_lock_t lock;
} rec_pool[8]; } rec_pool[8];
/** Pre-allocated table locks */ /** Pre-allocated table locks */
ib_lock_t table_pool[8]; ib_lock_t table_pool[8];
/** Memory heap for trx_locks. Protected by lock_sys.assert_locked() /** Memory heap for trx_locks. Protected by lock_sys.assert_locked()
and lock_sys.is_writer() || trx->mutex_is_owner(). */ and lock_sys.is_writer() || trx->mutex_is_owner(). */
@ -623,6 +623,7 @@ private:
that it is no longer "active". that it is no longer "active".
*/ */
alignas(CPU_LEVEL1_DCACHE_LINESIZE)
Atomic_counter<int32_t> n_ref; Atomic_counter<int32_t> n_ref;
@ -738,7 +739,7 @@ public:
/** The locks of the transaction. Protected by lock_sys.latch /** The locks of the transaction. Protected by lock_sys.latch
(insertions also by trx_t::mutex). */ (insertions also by trx_t::mutex). */
trx_lock_t lock; alignas(CPU_LEVEL1_DCACHE_LINESIZE) trx_lock_t lock;
#ifdef WITH_WSREP #ifdef WITH_WSREP
/** whether wsrep_on(mysql_thd) held at the start of transaction */ /** whether wsrep_on(mysql_thd) held at the start of transaction */

View File

@ -510,7 +510,6 @@ extern mysql_pfs_key_t fts_cache_mutex_key;
extern mysql_pfs_key_t fts_cache_init_mutex_key; extern mysql_pfs_key_t fts_cache_init_mutex_key;
extern mysql_pfs_key_t fts_delete_mutex_key; extern mysql_pfs_key_t fts_delete_mutex_key;
extern mysql_pfs_key_t fts_doc_id_mutex_key; extern mysql_pfs_key_t fts_doc_id_mutex_key;
extern mysql_pfs_key_t fts_pll_tokenize_mutex_key;
extern mysql_pfs_key_t ibuf_bitmap_mutex_key; extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
extern mysql_pfs_key_t ibuf_mutex_key; extern mysql_pfs_key_t ibuf_mutex_key;
extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key; extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
@ -531,8 +530,6 @@ extern mysql_pfs_key_t trx_pool_mutex_key;
extern mysql_pfs_key_t trx_pool_manager_mutex_key; extern mysql_pfs_key_t trx_pool_manager_mutex_key;
extern mysql_pfs_key_t lock_wait_mutex_key; extern mysql_pfs_key_t lock_wait_mutex_key;
extern mysql_pfs_key_t srv_threads_mutex_key; extern mysql_pfs_key_t srv_threads_mutex_key;
extern mysql_pfs_key_t thread_mutex_key;
extern mysql_pfs_key_t row_drop_list_mutex_key;
# endif /* UNIV_PFS_MUTEX */ # endif /* UNIV_PFS_MUTEX */
# ifdef UNIV_PFS_RWLOCK # ifdef UNIV_PFS_RWLOCK

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation. Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -31,13 +31,6 @@ Created 2012/04/12 by Sunny Bains
#include "os0thread.h" #include "os0thread.h"
#include "my_rdtsc.h" #include "my_rdtsc.h"
/** CPU cache line size */
#ifdef CPU_LEVEL1_DCACHE_LINESIZE
# define CACHE_LINE_SIZE CPU_LEVEL1_DCACHE_LINESIZE
#else
# error CPU_LEVEL1_DCACHE_LINESIZE is undefined
#endif /* CPU_LEVEL1_DCACHE_LINESIZE */
/** Use the result of my_timer_cycles(), which mainly uses RDTSC for cycles /** Use the result of my_timer_cycles(), which mainly uses RDTSC for cycles
as a random value. See the comments for my_timer_cycles() */ as a random value. See the comments for my_timer_cycles() */
/** @return result from RDTSC or similar functions. */ /** @return result from RDTSC or similar functions. */
@ -71,19 +64,18 @@ be zero-initialized by the run-time environment.
@see srv_stats */ @see srv_stats */
template <typename Type> template <typename Type>
struct ib_atomic_counter_element_t { struct ib_atomic_counter_element_t {
MY_ALIGNED(CACHE_LINE_SIZE) Atomic_relaxed<Type> value; alignas(CPU_LEVEL1_DCACHE_LINESIZE) Atomic_relaxed<Type> value;
}; };
template <typename Type> template <typename Type>
struct ib_counter_element_t { struct ib_counter_element_t {
MY_ALIGNED(CACHE_LINE_SIZE) Type value; alignas(CPU_LEVEL1_DCACHE_LINESIZE) Type value;
}; };
/** Class for using fuzzy counters. The counter is multi-instance relaxed atomic /** Class for using fuzzy counters. The counter is multi-instance relaxed atomic
so the results are not guaranteed to be 100% accurate but close so the results are not guaranteed to be 100% accurate but close
enough. Creates an array of counters and separates each element by the enough. */
CACHE_LINE_SIZE bytes */
template <typename Type, template <typename Type,
template <typename T> class Element = ib_atomic_counter_element_t, template <typename T> class Element = ib_atomic_counter_element_t,
int N = 128 > int N = 128 >
@ -123,9 +115,9 @@ struct ib_counter_t {
} }
private: private:
static_assert(sizeof(Element<Type>) == CACHE_LINE_SIZE, ""); static_assert(sizeof(Element<Type>) == CPU_LEVEL1_DCACHE_LINESIZE, "");
/** Array of counter elements */ /** Array of counter elements */
MY_ALIGNED(CACHE_LINE_SIZE) Element<Type> m_counter[N]; alignas(CPU_LEVEL1_DCACHE_LINESIZE) Element<Type> m_counter[N];
}; };
#endif /* ut0counter_h */ #endif /* ut0counter_h */

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2013, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, 2021, MariaDB Corporation. Copyright (c) 2018, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -31,7 +31,7 @@ Created 2012-Feb-26 Sunny Bains
#include <queue> #include <queue>
#include <functional> #include <functional>
#include "ut0new.h" #include <my_global.h>
/** Allocate the memory for the object in blocks. We keep the objects sorted /** Allocate the memory for the object in blocks. We keep the objects sorted
on pointer so that they are closer together in case they have to be iterated on pointer so that they are closer together in case they have to be iterated
@ -41,8 +41,6 @@ struct Pool {
typedef Type value_type; typedef Type value_type;
// FIXME: Add an assertion to check alignment and offset is
// as we expect it. Also, sizeof(void*) can be 8, can we impove on this.
struct Element { struct Element {
Pool* m_pool; Pool* m_pool;
value_type m_type; value_type m_type;
@ -57,17 +55,30 @@ struct Pool {
m_size(size), m_size(size),
m_last() m_last()
{ {
ut_ad(ut_is_2pow(size));
ut_a(size >= sizeof(Element)); ut_a(size >= sizeof(Element));
static_assert(!(sizeof(Element) % CPU_LEVEL1_DCACHE_LINESIZE),
"alignment");
m_lock_strategy.create(); m_lock_strategy.create();
ut_a(m_start == 0); ut_a(m_start == 0);
m_start = reinterpret_cast<Element*>(ut_zalloc_nokey(m_size)); #ifdef _MSC_VER
m_start = static_cast<Element*>(
_aligned_malloc(m_size, CPU_LEVEL1_DCACHE_LINESIZE));
#else
void* start;
ut_a(!posix_memalign(&start, CPU_LEVEL1_DCACHE_LINESIZE,
m_size));
m_start = static_cast<Element*>(start);
#endif
memset_aligned<CPU_LEVEL1_DCACHE_LINESIZE>(
m_start, 0, m_size);
m_last = m_start; m_last = m_start;
m_end = &m_start[m_size / sizeof(*m_start)]; m_end = &m_start[m_size / sizeof *m_start];
/* Note: Initialise only a small subset, even though we have /* Note: Initialise only a small subset, even though we have
allocated all the memory. This is required only because PFS allocated all the memory. This is required only because PFS
@ -90,7 +101,7 @@ struct Pool {
Factory::destroy(&elem->m_type); Factory::destroy(&elem->m_type);
} }
ut_free(m_start); IF_WIN(_aligned_free,free)(m_start);
m_end = m_last = m_start = 0; m_end = m_last = m_start = 0;
m_size = 0; m_size = 0;
} }

View File

@ -4868,7 +4868,7 @@ static void lock_rec_block_validate(const page_id_t page_id)
static my_bool lock_validate_table_locks(rw_trx_hash_element_t *element, void*) static my_bool lock_validate_table_locks(rw_trx_hash_element_t *element, void*)
{ {
lock_sys.assert_locked(); lock_sys.assert_locked();
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (element->trx) if (element->trx)
{ {
check_trx_state(element->trx); check_trx_state(element->trx);
@ -4878,7 +4878,7 @@ static my_bool lock_validate_table_locks(rw_trx_hash_element_t *element, void*)
if (lock->is_table()) if (lock->is_table())
lock_table_queue_validate(lock->un_member.tab_lock.table); lock_table_queue_validate(lock->un_member.tab_lock.table);
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
return 0; return 0;
} }
@ -5075,7 +5075,7 @@ static my_bool lock_rec_other_trx_holds_expl_callback(
rw_trx_hash_element_t *element, rw_trx_hash_element_t *element,
lock_rec_other_trx_holds_expl_arg *arg) lock_rec_other_trx_holds_expl_arg *arg)
{ {
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (element->trx) if (element->trx)
{ {
element->trx->mutex_lock(); element->trx->mutex_lock();
@ -5091,7 +5091,7 @@ static my_bool lock_rec_other_trx_holds_expl_callback(
ut_ad(!expl_lock || expl_lock->trx == &arg->impl_trx); ut_ad(!expl_lock || expl_lock->trx == &arg->impl_trx);
element->trx->mutex_unlock(); element->trx->mutex_unlock();
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
return 0; return 0;
} }
@ -5835,7 +5835,7 @@ static my_bool lock_table_locks_lookup(rw_trx_hash_element_t *element,
const dict_table_t *table) const dict_table_t *table)
{ {
lock_sys.assert_locked(); lock_sys.assert_locked();
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (element->trx) if (element->trx)
{ {
element->trx->mutex_lock(); element->trx->mutex_lock();
@ -5859,7 +5859,7 @@ static my_bool lock_table_locks_lookup(rw_trx_hash_element_t *element,
} }
element->trx->mutex_unlock(); element->trx->mutex_unlock();
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
return 0; return 0;
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, 2021, MariaDB Corporation. Copyright (c) 2018, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -226,10 +226,10 @@ void ReadView::open(trx_t *trx)
m_open.store(true, std::memory_order_relaxed); m_open.store(true, std::memory_order_relaxed);
else else
{ {
mysql_mutex_lock(&m_mutex); m_mutex.wr_lock();
snapshot(trx); snapshot(trx);
m_open.store(true, std::memory_order_relaxed); m_open.store(true, std::memory_order_relaxed);
mysql_mutex_unlock(&m_mutex); m_mutex.wr_unlock();
} }
} }
} }

View File

@ -281,15 +281,13 @@ static int cmp_data(ulint mtype, ulint prtype, const byte *data1, ulint len1,
/* fall through */ /* fall through */
case DATA_VARMYSQL: case DATA_VARMYSQL:
DBUG_ASSERT(is_strnncoll_compatible(prtype & DATA_MYSQL_TYPE_MASK)); DBUG_ASSERT(is_strnncoll_compatible(prtype & DATA_MYSQL_TYPE_MASK));
if (CHARSET_INFO *cs= get_charset(dtype_get_charset_coll(prtype), if (CHARSET_INFO *cs= all_charsets[dtype_get_charset_coll(prtype)])
MYF(MY_WME)))
return cs->coll->strnncollsp(cs, data1, len1, data2, len2); return cs->coll->strnncollsp(cs, data1, len1, data2, len2);
no_collation: no_collation:
ib::fatal() << "Unable to find charset-collation for " << prtype; ib::fatal() << "Unable to find charset-collation for " << prtype;
case DATA_MYSQL: case DATA_MYSQL:
DBUG_ASSERT(is_strnncoll_compatible(prtype & DATA_MYSQL_TYPE_MASK)); DBUG_ASSERT(is_strnncoll_compatible(prtype & DATA_MYSQL_TYPE_MASK));
if (CHARSET_INFO *cs= get_charset(dtype_get_charset_coll(prtype), if (CHARSET_INFO *cs= all_charsets[dtype_get_charset_coll(prtype)])
MYF(MY_WME)))
return cs->coll->strnncollsp_nchars(cs, data1, len1, data2, len2, return cs->coll->strnncollsp_nchars(cs, data1, len1, data2, len2,
std::max(len1, len2)); std::max(len1, len2));
goto no_collation; goto no_collation;

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2021, MariaDB Corporation. Copyright (c) 2015, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -285,8 +285,7 @@ row_fts_psort_info_init(
psort_info[j].psort_common = common_info; psort_info[j].psort_common = common_info;
psort_info[j].error = DB_SUCCESS; psort_info[j].error = DB_SUCCESS;
psort_info[j].memory_used = 0; psort_info[j].memory_used = 0;
mysql_mutex_init(fts_pll_tokenize_mutex_key, mysql_mutex_init(0, &psort_info[j].mutex, nullptr);
&psort_info[j].mutex, nullptr);
} }
/* Initialize merge_info structures parallel merge and insert /* Initialize merge_info structures parallel merge and insert

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, 2021, MariaDB Corporation. Copyright (c) 2016, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -631,7 +631,7 @@ struct trx_roll_count_callback_arg
static my_bool trx_roll_count_callback(rw_trx_hash_element_t *element, static my_bool trx_roll_count_callback(rw_trx_hash_element_t *element,
trx_roll_count_callback_arg *arg) trx_roll_count_callback_arg *arg)
{ {
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (trx_t *trx= element->trx) if (trx_t *trx= element->trx)
{ {
if (trx->is_recovered && trx_state_eq(trx, TRX_STATE_ACTIVE)) if (trx->is_recovered && trx_state_eq(trx, TRX_STATE_ACTIVE))
@ -640,7 +640,7 @@ static my_bool trx_roll_count_callback(rw_trx_hash_element_t *element,
arg->n_rows+= trx->undo_no; arg->n_rows+= trx->undo_no;
} }
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
return 0; return 0;
} }
@ -678,7 +678,7 @@ void trx_roll_report_progress()
static my_bool trx_rollback_recovered_callback(rw_trx_hash_element_t *element, static my_bool trx_rollback_recovered_callback(rw_trx_hash_element_t *element,
std::vector<trx_t*> *trx_list) std::vector<trx_t*> *trx_list)
{ {
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (trx_t *trx= element->trx) if (trx_t *trx= element->trx)
{ {
trx->mutex_lock(); trx->mutex_lock();
@ -686,7 +686,7 @@ static my_bool trx_rollback_recovered_callback(rw_trx_hash_element_t *element,
trx_list->push_back(trx); trx_list->push_back(trx);
trx->mutex_unlock(); trx->mutex_unlock();
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2021, MariaDB Corporation. Copyright (c) 2015, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -1915,7 +1915,7 @@ static my_bool trx_recover_for_mysql_callback(rw_trx_hash_element_t *element,
trx_recover_for_mysql_callback_arg *arg) trx_recover_for_mysql_callback_arg *arg)
{ {
DBUG_ASSERT(arg->len > 0); DBUG_ASSERT(arg->len > 0);
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (trx_t *trx= element->trx) if (trx_t *trx= element->trx)
{ {
/* /*
@ -1941,7 +1941,7 @@ static my_bool trx_recover_for_mysql_callback(rw_trx_hash_element_t *element,
} }
} }
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
/* Do not terminate upon reaching arg->len; count all transactions */ /* Do not terminate upon reaching arg->len; count all transactions */
return false; return false;
} }
@ -1950,13 +1950,13 @@ static my_bool trx_recover_for_mysql_callback(rw_trx_hash_element_t *element,
static my_bool trx_recover_reset_callback(rw_trx_hash_element_t *element, static my_bool trx_recover_reset_callback(rw_trx_hash_element_t *element,
void*) void*)
{ {
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (trx_t *trx= element->trx) if (trx_t *trx= element->trx)
{ {
if (trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)) if (trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED))
trx->state= TRX_STATE_PREPARED; trx->state= TRX_STATE_PREPARED;
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
return false; return false;
} }
@ -2005,7 +2005,7 @@ static my_bool trx_get_trx_by_xid_callback(rw_trx_hash_element_t *element,
trx_get_trx_by_xid_callback_arg *arg) trx_get_trx_by_xid_callback_arg *arg)
{ {
my_bool found= 0; my_bool found= 0;
mysql_mutex_lock(&element->mutex); element->mutex.wr_lock();
if (trx_t *trx= element->trx) if (trx_t *trx= element->trx)
{ {
trx->mutex_lock(); trx->mutex_lock();
@ -2027,7 +2027,7 @@ static my_bool trx_get_trx_by_xid_callback(rw_trx_hash_element_t *element,
} }
trx->mutex_unlock(); trx->mutex_unlock();
} }
mysql_mutex_unlock(&element->mutex); element->mutex.wr_unlock();
return found; return found;
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2019, 2021, MariaDB Corporation. /* Copyright (C) 2019, 2022, MariaDB Corporation.
This program is free software; you can redistribute itand /or modify This program is free software; you can redistribute itand /or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -128,7 +128,7 @@ enum worker_wake_reason
/* A per-worker thread structure.*/ /* A per-worker thread structure.*/
struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) worker_data struct alignas(CPU_LEVEL1_DCACHE_LINESIZE) worker_data
{ {
/** Condition variable to wakeup this worker.*/ /** Condition variable to wakeup this worker.*/
std::condition_variable m_cv; std::condition_variable m_cv;