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 function get_name;
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 function get_name;
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_unit(thd_arg), result(result_arg), materialized_cursor(0) {}
virtual bool send_result_set_metadata(List<Item> &list, uint flags);
bool send_eof()
{
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 send_eof() { return false; }
bool view_structure_only() const
{
return result->view_structure_only();
@ -333,6 +321,8 @@ int Materialized_cursor::open(JOIN *join __attribute__((unused)))
result->abort_result_set();
}
on_table_fill_finished();
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_delete_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_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 trx_sys_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
performance schema instrumented if "UNIV_PFS_MUTEX"
@ -1235,7 +1230,7 @@ struct log_flush_request
};
/** Buffer of pending innodb_log_flush_request() */
MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) static
alignas(CPU_LEVEL1_DCACHE_LINESIZE) static
struct
{
/** first request */
@ -2402,7 +2397,7 @@ innobase_mysql_print_thd(
/******************************************************************//**
Get the variable length bounds of the given character set. */
void
static void
innobase_get_cset_width(
/*====================*/
ulint cset, /*!< in: MySQL charset-collation code */
@ -2414,7 +2409,7 @@ innobase_get_cset_width(
ut_ad(mbminlen);
ut_ad(mbmaxlen);
cs = all_charsets[cset];
cs = cset ? get_charset((uint)cset, MYF(MY_WME)) : NULL;
if (cs) {
*mbminlen = cs->mbminlen;
*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. */
void

View File

@ -1576,7 +1576,7 @@ public:
static constexpr uint32_t READ_AHEAD_PAGES= 64;
/** 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. */
ulint n_flush_LRU_;
/** 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()
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 */
FlushHp flush_hp;
/** 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. */
UNIV_INLINE
void
dtype_get_mblen(
/*============*/

View File

@ -64,30 +64,6 @@ dtype_get_mysql_type(
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. */
UNIV_INLINE
@ -374,16 +350,6 @@ dtype_get_fixed_size_low(
} else if (!comp) {
return static_cast<unsigned>(len);
} 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) {
return static_cast<unsigned>(len);
}

View File

@ -1351,7 +1351,7 @@ class dict_sys_t
std::atomic<ulonglong> latch_ex_wait_start;
/** 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
/** whether latch is being held in exclusive mode (by any thread) */
bool latch_ex;

View File

@ -139,15 +139,6 @@ at least ENUM and SET, and unsigned integer types are 'unsigned types'
uint8_t
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.
@return 0 if a=b, <0 if a<b, >1 if a>b */

View File

@ -684,7 +684,7 @@ private:
bool m_initialised;
/** 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
/** The owner of exclusive latch (0 if none); protected by latch */
std::atomic<os_thread_id_t> writer{0};
@ -707,7 +707,7 @@ public:
hash_table prdt_page_hash;
/** 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:
/** The increment of wait_count for a wait. Anything smaller is a
pending wait count. */

View File

@ -451,7 +451,7 @@ struct log_t{
private:
/** 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;
/** the first guaranteed-durable log sequence number */
std::atomic<lsn_t> flushed_to_disk_lsn;
@ -461,7 +461,7 @@ private:
std::atomic<bool> check_flush_or_checkpoint_;
public:
/** 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 */
size_t buf_free;
/** 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
to release log_sys.mutex during mtr_commit and still ensure that
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 */
byte *buf;
/** 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) 2018, 2021, MariaDB Corporation.
Copyright (c) 2018, 2022, MariaDB Corporation.
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
@ -28,12 +28,9 @@ Created 2/16/1997 Heikki Tuuri
#include "dict0mem.h"
#include "trx0types.h"
#include "srw_lock.h"
#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
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.
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
@ -70,9 +67,6 @@ protected:
trx_id_t up_limit_id() const { return m_up_limit_id; }
public:
ReadViewBase(): m_low_limit_id(0) {}
/**
Append state from another view.
@ -206,7 +200,7 @@ class ReadView: public ReadViewBase
std::atomic<bool> m_open;
/** For synchronisation with purge coordinator. */
mutable mysql_mutex_t m_mutex;
mutable srw_mutex m_mutex;
/**
trx id of creating transaction.
@ -215,9 +209,12 @@ class ReadView: public ReadViewBase
trx_id_t m_creator_trx_id;
public:
ReadView(): m_open(false)
{ mysql_mutex_init(read_view_mutex_key, &m_mutex, nullptr); }
~ReadView() { mysql_mutex_destroy(&m_mutex); }
ReadView()
{
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
{
mysql_mutex_lock(&m_mutex);
m_mutex.wr_lock();
if (is_open())
fprintf(file, "Trx read view will not see trx with"
" id >= " TRX_ID_FMT ", sees < " TRX_ID_FMT "\n",
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
{
mysql_mutex_lock(&m_mutex);
m_mutex.wr_lock();
if (is_open())
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
@tparam Type the integer type of the counter */
template <typename Type>
struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) simple_counter
struct alignas(CPU_LEVEL1_DCACHE_LINESIZE) simple_counter
{
/** Increment the counter */
Type inc() { return add(1); }

View File

@ -125,7 +125,7 @@ class purge_sys_t
{
public:
/** 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:
/** The purge will not remove undo logs which are >= this 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)
/** 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() */
fil_space_t *space;

View File

@ -1,7 +1,7 @@
/*****************************************************************************
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
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
extern mysql_pfs_key_t trx_sys_mutex_key;
extern mysql_pfs_key_t rw_trx_hash_element_mutex_key;
#endif
/** 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
{
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()
{
mysql_mutex_destroy(&mutex);
}
~rw_trx_hash_element_t() { mutex.destroy(); }
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;
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,
debug_iterator_arg<T> *arg)
{
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
if (element->trx)
validate_element(element->trx);
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
return arg->action(element, arg->argument);
}
#endif
@ -631,7 +628,7 @@ public:
sizeof(trx_id_t)));
if (element)
{
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
lf_hash_search_unpin(pins);
if ((trx= element->trx)) {
DBUG_ASSERT(trx_id == trx->id);
@ -652,7 +649,7 @@ public:
trx->reference();
}
}
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
}
if (!caller_trx)
lf_hash_put_pins(pins);
@ -686,9 +683,9 @@ public:
void erase(trx_t *trx)
{
ut_d(validate_element(trx));
mysql_mutex_lock(&trx->rw_trx_hash_element->mutex);
trx->rw_trx_hash_element->trx= 0;
mysql_mutex_unlock(&trx->rw_trx_hash_element->mutex);
trx->rw_trx_hash_element->mutex.wr_lock();
trx->rw_trx_hash_element->trx= nullptr;
trx->rw_trx_hash_element->mutex.wr_unlock();
int res= lf_hash_delete(&hash, get_pins(trx),
reinterpret_cast<const void*>(&trx->id),
sizeof(trx_id_t));
@ -722,12 +719,12 @@ public:
May return element with committed transaction. If caller doesn't like to
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)
{
// trx is protected against commit in this branch
}
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
May miss concurrently inserted transactions.
@ -833,8 +830,8 @@ public:
void unfreeze() const { mysql_mutex_unlock(&mutex); }
private:
alignas(CACHE_LINE_SIZE) mutable mysql_mutex_t mutex;
alignas(CACHE_LINE_SIZE) ilist<trx_t> trx_list;
alignas(CPU_LEVEL1_DCACHE_LINESIZE) mutable mysql_mutex_t mutex;
alignas(CPU_LEVEL1_DCACHE_LINESIZE) ilist<trx_t> trx_list;
};
/** 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
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 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;
@ -875,7 +873,7 @@ public:
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
@ -1180,11 +1178,11 @@ private:
{
if (element->id < *id)
{
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
/* We don't care about read-only transactions here. */
if (element->trx && element->trx->rsegs.m_redo.rseg)
*id= element->id;
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
}
return 0;
}

View File

@ -390,7 +390,7 @@ struct trx_lock_t
/** Pre-allocated record locks */
struct {
ib_lock_t lock; byte pad[256];
alignas(CPU_LEVEL1_DCACHE_LINESIZE) ib_lock_t lock;
} rec_pool[8];
/** Pre-allocated table locks */
@ -623,6 +623,7 @@ private:
that it is no longer "active".
*/
alignas(CPU_LEVEL1_DCACHE_LINESIZE)
Atomic_counter<int32_t> n_ref;
@ -738,7 +739,7 @@ public:
/** The locks of the transaction. Protected by lock_sys.latch
(insertions also by trx_t::mutex). */
trx_lock_t lock;
alignas(CPU_LEVEL1_DCACHE_LINESIZE) trx_lock_t lock;
#ifdef WITH_WSREP
/** 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_delete_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_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 lock_wait_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 */
# ifdef UNIV_PFS_RWLOCK

View File

@ -1,7 +1,7 @@
/*****************************************************************************
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
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 "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
as a random value. See the comments for my_timer_cycles() */
/** @return result from RDTSC or similar functions. */
@ -71,19 +64,18 @@ be zero-initialized by the run-time environment.
@see srv_stats */
template <typename Type>
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>
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
so the results are not guaranteed to be 100% accurate but close
enough. Creates an array of counters and separates each element by the
CACHE_LINE_SIZE bytes */
enough. */
template <typename Type,
template <typename T> class Element = ib_atomic_counter_element_t,
int N = 128 >
@ -123,9 +115,9 @@ struct ib_counter_t {
}
private:
static_assert(sizeof(Element<Type>) == CACHE_LINE_SIZE, "");
static_assert(sizeof(Element<Type>) == CPU_LEVEL1_DCACHE_LINESIZE, "");
/** 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 */

View File

@ -1,7 +1,7 @@
/*****************************************************************************
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
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 <functional>
#include "ut0new.h"
#include <my_global.h>
/** 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
@ -41,8 +41,6 @@ struct Pool {
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 {
Pool* m_pool;
value_type m_type;
@ -57,17 +55,30 @@ struct Pool {
m_size(size),
m_last()
{
ut_ad(ut_is_2pow(size));
ut_a(size >= sizeof(Element));
static_assert(!(sizeof(Element) % CPU_LEVEL1_DCACHE_LINESIZE),
"alignment");
m_lock_strategy.create();
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_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
allocated all the memory. This is required only because PFS
@ -90,7 +101,7 @@ struct Pool {
Factory::destroy(&elem->m_type);
}
ut_free(m_start);
IF_WIN(_aligned_free,free)(m_start);
m_end = m_last = m_start = 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*)
{
lock_sys.assert_locked();
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
if (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())
lock_table_queue_validate(lock->un_member.tab_lock.table);
}
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
return 0;
}
@ -5075,7 +5075,7 @@ static my_bool lock_rec_other_trx_holds_expl_callback(
rw_trx_hash_element_t *element,
lock_rec_other_trx_holds_expl_arg *arg)
{
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
if (element->trx)
{
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);
element->trx->mutex_unlock();
}
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
return 0;
}
@ -5835,7 +5835,7 @@ static my_bool lock_table_locks_lookup(rw_trx_hash_element_t *element,
const dict_table_t *table)
{
lock_sys.assert_locked();
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
if (element->trx)
{
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();
}
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
return 0;
}
#endif /* UNIV_DEBUG */

View File

@ -1,7 +1,7 @@
/*****************************************************************************
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
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);
else
{
mysql_mutex_lock(&m_mutex);
m_mutex.wr_lock();
snapshot(trx);
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 */
case DATA_VARMYSQL:
DBUG_ASSERT(is_strnncoll_compatible(prtype & DATA_MYSQL_TYPE_MASK));
if (CHARSET_INFO *cs= get_charset(dtype_get_charset_coll(prtype),
MYF(MY_WME)))
if (CHARSET_INFO *cs= all_charsets[dtype_get_charset_coll(prtype)])
return cs->coll->strnncollsp(cs, data1, len1, data2, len2);
no_collation:
ib::fatal() << "Unable to find charset-collation for " << prtype;
case DATA_MYSQL:
DBUG_ASSERT(is_strnncoll_compatible(prtype & DATA_MYSQL_TYPE_MASK));
if (CHARSET_INFO *cs= get_charset(dtype_get_charset_coll(prtype),
MYF(MY_WME)))
if (CHARSET_INFO *cs= all_charsets[dtype_get_charset_coll(prtype)])
return cs->coll->strnncollsp_nchars(cs, data1, len1, data2, len2,
std::max(len1, len2));
goto no_collation;

View File

@ -1,7 +1,7 @@
/*****************************************************************************
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
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].error = DB_SUCCESS;
psort_info[j].memory_used = 0;
mysql_mutex_init(fts_pll_tokenize_mutex_key,
&psort_info[j].mutex, nullptr);
mysql_mutex_init(0, &psort_info[j].mutex, nullptr);
}
/* 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) 2016, 2021, MariaDB Corporation.
Copyright (c) 2016, 2022, MariaDB Corporation.
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
@ -631,7 +631,7 @@ struct trx_roll_count_callback_arg
static my_bool trx_roll_count_callback(rw_trx_hash_element_t *element,
trx_roll_count_callback_arg *arg)
{
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
if (trx_t *trx= element->trx)
{
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;
}
}
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
return 0;
}
@ -678,7 +678,7 @@ void trx_roll_report_progress()
static my_bool trx_rollback_recovered_callback(rw_trx_hash_element_t *element,
std::vector<trx_t*> *trx_list)
{
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
if (trx_t *trx= element->trx)
{
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->mutex_unlock();
}
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
return 0;
}

View File

@ -1,7 +1,7 @@
/*****************************************************************************
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
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)
{
DBUG_ASSERT(arg->len > 0);
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
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 */
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,
void*)
{
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
if (trx_t *trx= element->trx)
{
if (trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED))
trx->state= TRX_STATE_PREPARED;
}
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
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)
{
my_bool found= 0;
mysql_mutex_lock(&element->mutex);
element->mutex.wr_lock();
if (trx_t *trx= element->trx)
{
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();
}
mysql_mutex_unlock(&element->mutex);
element->mutex.wr_unlock();
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
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.*/
struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) worker_data
struct alignas(CPU_LEVEL1_DCACHE_LINESIZE) worker_data
{
/** Condition variable to wakeup this worker.*/
std::condition_variable m_cv;