Merge 10.2 into 10.3

This commit is contained in:
Marko Mäkelä 2020-04-27 14:24:41 +03:00
commit 2e12d471ea
30 changed files with 165 additions and 199 deletions

View File

@ -729,13 +729,14 @@ struct st_my_thread_var
#endif #endif
}; };
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const)); struct st_my_thread_var *_my_thread_var(void);
extern void **my_thread_var_dbug(void); extern void **my_thread_var_dbug(void);
extern safe_mutex_t **my_thread_var_mutex_in_use(void); extern safe_mutex_t **my_thread_var_mutex_in_use(void);
extern uint my_thread_end_wait_time; extern uint my_thread_end_wait_time;
extern my_bool safe_mutex_deadlock_detector; extern my_bool safe_mutex_deadlock_detector;
#define my_thread_var (_my_thread_var()) #define my_thread_var (_my_thread_var())
#define my_errno my_thread_var->thr_errno #define my_errno my_thread_var->thr_errno
int set_mysys_var(struct st_my_thread_var *mysys_var);
/* /*
Keep track of shutdown,signal, and main threads so that my_end() will not Keep track of shutdown,signal, and main threads so that my_end() will not
report errors with them report errors with them

View File

@ -3355,7 +3355,8 @@ sub mysql_install_db {
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# export MYSQLD_BOOTSTRAP_CMD variable containing <path>/mysqld <args> # export MYSQLD_BOOTSTRAP_CMD variable containing <path>/mysqld <args>
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
$ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args); $ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args)
unless defined $ENV{'MYSQLD_BOOTSTRAP_CMD'};
# Extra options can come not only from the command line, but also # Extra options can come not only from the command line, but also
# from option files or combinations. We want them on a command line # from option files or combinations. We want them on a command line

View File

@ -5,6 +5,7 @@
# #
--source include/galera_cluster.inc --source include/galera_cluster.inc
--source include/have_binlog_format_row.inc --source include/have_binlog_format_row.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc --source include/have_debug_sync.inc
--connection node_2 --connection node_2

View File

@ -706,6 +706,11 @@ FULLTEXT(f2),
FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB; FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB;
INSERT INTO mdev20987_1 VALUES(1); INSERT INTO mdev20987_1 VALUES(1);
INSERT INTO mdev20987_2 VALUES(1, 'mariadb'); INSERT INTO mdev20987_2 VALUES(1, 'mariadb');
CREATE TABLE mdev22358 (a INT, b TEXT, FULLTEXT KEY ftidx (b)) ENGINE=InnoDB;
ALTER TABLE mdev22358 DROP KEY ftidx;
INSERT INTO mdev22358 (a) VALUES (2),(2);
ALTER TABLE mdev22358 ADD UNIQUE KEY uidx (a), ADD FULLTEXT KEY ftidx (b);
ERROR 23000: Duplicate entry '2' for key 'uidx'
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
@ -713,7 +718,7 @@ t2 CREATE TABLE `t2` (
PRIMARY KEY (`FTS_DOC_ID`) PRIMARY KEY (`FTS_DOC_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb'); DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
DROP TABLE t1, t2, mdev20987_2, mdev20987_1; DROP TABLE t1, t2, mdev20987_2, mdev20987_1, mdev22358;
"----------Test28---------" "----------Test28---------"
create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb; create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb;
set session autocommit=0; set session autocommit=0;

View File

@ -673,10 +673,16 @@ CREATE TABLE mdev20987_2(f1 INT NOT NULL, f2 CHAR(100),
FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB; FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB;
INSERT INTO mdev20987_1 VALUES(1); INSERT INTO mdev20987_1 VALUES(1);
INSERT INTO mdev20987_2 VALUES(1, 'mariadb'); INSERT INTO mdev20987_2 VALUES(1, 'mariadb');
CREATE TABLE mdev22358 (a INT, b TEXT, FULLTEXT KEY ftidx (b)) ENGINE=InnoDB;
ALTER TABLE mdev22358 DROP KEY ftidx;
INSERT INTO mdev22358 (a) VALUES (2),(2);
--error ER_DUP_ENTRY
ALTER TABLE mdev22358 ADD UNIQUE KEY uidx (a), ADD FULLTEXT KEY ftidx (b);
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb'); DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
DROP TABLE t1, t2, mdev20987_2, mdev20987_1; DROP TABLE t1, t2, mdev20987_2, mdev20987_1, mdev22358;
--echo "----------Test28---------" --echo "----------Test28---------"
create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb; create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb;

View File

@ -141,7 +141,7 @@ void my_thread_global_reinit(void)
my_thread_destroy_internal_mutex(); my_thread_destroy_internal_mutex();
my_thread_init_internal_mutex(); my_thread_init_internal_mutex();
tmp= my_pthread_getspecific(struct st_my_thread_var*, THR_KEY_mysys); tmp= my_thread_var;
DBUG_ASSERT(tmp); DBUG_ASSERT(tmp);
my_thread_destory_thr_mutex(tmp); my_thread_destory_thr_mutex(tmp);
@ -279,7 +279,7 @@ my_bool my_thread_init(void)
fprintf(stderr,"my_thread_init(): pthread_self: %p\n", pthread_self()); fprintf(stderr,"my_thread_init(): pthread_self: %p\n", pthread_self());
#endif #endif
if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys)) if (my_thread_var)
{ {
#ifdef EXTRA_DEBUG_THREADS #ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_init() called more than once in thread 0x%lx\n", fprintf(stderr,"my_thread_init() called more than once in thread 0x%lx\n",
@ -297,7 +297,7 @@ my_bool my_thread_init(void)
error= 1; error= 1;
goto end; goto end;
} }
pthread_setspecific(THR_KEY_mysys,tmp); set_mysys_var(tmp);
tmp->pthread_self= pthread_self(); tmp->pthread_self= pthread_self();
my_thread_init_thr_mutex(tmp); my_thread_init_thr_mutex(tmp);
@ -334,7 +334,7 @@ end:
void my_thread_end(void) void my_thread_end(void)
{ {
struct st_my_thread_var *tmp; struct st_my_thread_var *tmp;
tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); tmp= my_thread_var;
#ifdef EXTRA_DEBUG_THREADS #ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_end(): tmp: %p pthread_self: %p thread_id: %ld\n", fprintf(stderr,"my_thread_end(): tmp: %p pthread_self: %p thread_id: %ld\n",
@ -355,7 +355,7 @@ void my_thread_end(void)
as the key is used by DBUG. as the key is used by DBUG.
*/ */
DBUG_POP(); DBUG_POP();
pthread_setspecific(THR_KEY_mysys,0); set_mysys_var(NULL);
if (tmp && tmp->init) if (tmp && tmp->init)
{ {
@ -439,7 +439,7 @@ extern void **my_thread_var_dbug()
struct st_my_thread_var *tmp; struct st_my_thread_var *tmp;
if (!my_thread_global_init_done) if (!my_thread_global_init_done)
return NULL; return NULL;
tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); tmp= my_thread_var;
return tmp && tmp->init ? &tmp->dbug : 0; return tmp && tmp->init ? &tmp->dbug : 0;
} }
#endif /* DBUG_OFF */ #endif /* DBUG_OFF */
@ -451,7 +451,7 @@ safe_mutex_t **my_thread_var_mutex_in_use()
struct st_my_thread_var *tmp; struct st_my_thread_var *tmp;
if (!my_thread_global_init_done) if (!my_thread_global_init_done)
return NULL; return NULL;
tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); tmp= my_thread_var;
return tmp ? &tmp->mutex_in_use : 0; return tmp ? &tmp->mutex_in_use : 0;
} }

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. /* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
Copyright (c) 2009, 2019, MariaDB Copyright (c) 2009, 2020, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -2616,19 +2616,20 @@ void Item_func_rand::seed_random(Item *arg)
TODO: do not do reinit 'rand' for every execute of PS/SP if TODO: do not do reinit 'rand' for every execute of PS/SP if
args[0] is a constant. args[0] is a constant.
*/ */
uint32 tmp; uint32 tmp= (uint32) arg->val_int();
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (WSREP_ON)
{
THD *thd= current_thd; THD *thd= current_thd;
if (WSREP(thd)) if (WSREP(thd))
{ {
if (thd->wsrep_exec_mode==REPL_RECV) if (thd->wsrep_exec_mode==REPL_RECV)
tmp= thd->wsrep_rand; tmp= thd->wsrep_rand;
else else
tmp= thd->wsrep_rand= (uint32) arg->val_int(); thd->wsrep_rand= tmp;
}
} }
else
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
tmp= (uint32) arg->val_int();
my_rnd_init(rand, (uint32) (tmp*0x10001L+55555555L), my_rnd_init(rand, (uint32) (tmp*0x10001L+55555555L),
(uint32) (tmp*0x10000001L)); (uint32) (tmp*0x10000001L));

View File

@ -1818,7 +1818,7 @@ binlog_commit_flush_stmt_cache(THD *thd, bool all,
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (thd->wsrep_mysql_replicated > 0) if (thd->wsrep_mysql_replicated > 0)
{ {
DBUG_ASSERT(WSREP_ON); DBUG_ASSERT(WSREP(thd));
WSREP_DEBUG("avoiding binlog_commit_flush_trx_cache: %d", WSREP_DEBUG("avoiding binlog_commit_flush_trx_cache: %d",
thd->wsrep_mysql_replicated); thd->wsrep_mysql_replicated);
return 0; return 0;
@ -6680,14 +6680,15 @@ int MYSQL_BIN_LOG::rotate(bool force_rotate, bool* check_purge)
int error= 0; int error= 0;
DBUG_ENTER("MYSQL_BIN_LOG::rotate"); DBUG_ENTER("MYSQL_BIN_LOG::rotate");
if (wsrep_to_isolation) #ifdef WITH_WSREP
if (WSREP_ON && wsrep_to_isolation)
{ {
DBUG_ASSERT(WSREP_ON);
*check_purge= false; *check_purge= false;
WSREP_DEBUG("avoiding binlog rotate due to TO isolation: %d", WSREP_DEBUG("avoiding binlog rotate due to TO isolation: %d",
wsrep_to_isolation); wsrep_to_isolation);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
#endif /* WITH_WSREP */
//todo: fix the macro def and restore safe_mutex_assert_owner(&LOCK_log); //todo: fix the macro def and restore safe_mutex_assert_owner(&LOCK_log);
*check_purge= false; *check_purge= false;

View File

@ -5929,7 +5929,7 @@ Query_log_event::do_shall_skip(rpl_group_info *rgi)
} }
} }
#ifdef WITH_WSREP #ifdef WITH_WSREP
else if (WSREP_ON && wsrep_mysql_replication_bundle && opt_slave_domain_parallel_threads == 0 && else if (WSREP(thd) && wsrep_mysql_replication_bundle && opt_slave_domain_parallel_threads == 0 &&
thd->wsrep_mysql_replicated > 0 && thd->wsrep_mysql_replicated > 0 &&
(is_begin() || is_commit())) (is_begin() || is_commit()))
{ {
@ -5943,7 +5943,7 @@ Query_log_event::do_shall_skip(rpl_group_info *rgi)
thd->wsrep_mysql_replicated = 0; thd->wsrep_mysql_replicated = 0;
} }
} }
#endif #endif /* WITH_WSREP */
DBUG_RETURN(Log_event::do_shall_skip(rgi)); DBUG_RETURN(Log_event::do_shall_skip(rgi));
} }
@ -9043,7 +9043,7 @@ Xid_log_event::do_shall_skip(rpl_group_info *rgi)
DBUG_RETURN(Log_event::EVENT_SKIP_COUNT); DBUG_RETURN(Log_event::EVENT_SKIP_COUNT);
} }
#ifdef WITH_WSREP #ifdef WITH_WSREP
else if (wsrep_mysql_replication_bundle && WSREP_ON && else if (WSREP(thd) && wsrep_mysql_replication_bundle &&
opt_slave_domain_parallel_threads == 0) opt_slave_domain_parallel_threads == 0)
{ {
if (++thd->wsrep_mysql_replicated < (int)wsrep_mysql_replication_bundle) if (++thd->wsrep_mysql_replicated < (int)wsrep_mysql_replication_bundle)

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. /* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
Copyright (c) 2008, 2020, MariaDB Corporation. Copyright (c) 2008, 2020, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -6013,8 +6013,10 @@ int mysqld_main(int argc, char **argv)
set_user(mysqld_user, user_info); set_user(mysqld_user, user_info);
} }
#ifdef WITH_WSREP
if (WSREP_ON && wsrep_check_opts()) if (WSREP_ON && wsrep_check_opts())
global_system_variables.wsrep_on= 0; global_system_variables.wsrep_on= 0;
#endif
/* /*
The subsequent calls may take a long time : e.g. innodb log read. The subsequent calls may take a long time : e.g. innodb log read.

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. /* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
Copyright (c) 2009, 2017, MariaDB Corporation Copyright (c) 2009, 2020, MariaDB Corporation
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -5562,9 +5562,11 @@ pthread_handler_t handle_slave_sql(void *arg)
if (!sql_slave_killed(serial_rgi)) if (!sql_slave_killed(serial_rgi))
{ {
slave_output_error_info(serial_rgi, thd); slave_output_error_info(serial_rgi, thd);
if (WSREP_ON && rli->last_error().number == ER_UNKNOWN_COM_ERROR) if (WSREP(thd) && rli->last_error().number == ER_UNKNOWN_COM_ERROR)
{
wsrep_node_dropped= TRUE; wsrep_node_dropped= TRUE;
} }
}
goto err; goto err;
} }
} }
@ -5696,7 +5698,7 @@ err_during_init:
If slave stopped due to node going non primary, we set global flag to If slave stopped due to node going non primary, we set global flag to
trigger automatic restart of slave when node joins back to cluster. trigger automatic restart of slave when node joins back to cluster.
*/ */
if (WSREP_ON && wsrep_node_dropped && wsrep_restart_slave) if (WSREP(thd) && wsrep_node_dropped && wsrep_restart_slave)
{ {
if (wsrep_ready_get()) if (wsrep_ready_get())
{ {

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. /* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2010, 2019, MariaDB Copyright (c) 2010, 2020, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -4301,7 +4301,7 @@ restart:
} }
} }
if (WSREP_ON && if (WSREP(thd) &&
wsrep_replicate_myisam && wsrep_replicate_myisam &&
(*start) && (*start) &&
(*start)->table && (*start)->table &&

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. /* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
Copyright (c) 2008, 2019, MariaDB Copyright (c) 2008, 2020, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -1848,7 +1848,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (unlikely(parser_state.init(thd, thd->query(), thd->query_length()))) if (unlikely(parser_state.init(thd, thd->query(), thd->query_length())))
break; break;
if (WSREP_ON) if (WSREP(thd))
wsrep_mysql_parse(thd, thd->query(), thd->query_length(), &parser_state, wsrep_mysql_parse(thd, thd->query(), thd->query_length(), &parser_state,
is_com_multi, is_next_command); is_com_multi, is_next_command);
else else
@ -1937,7 +1937,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
parser_state.reset(beginning_of_next_stmt, length); parser_state.reset(beginning_of_next_stmt, length);
if (WSREP_ON) if (WSREP(thd))
wsrep_mysql_parse(thd, beginning_of_next_stmt, length, &parser_state, wsrep_mysql_parse(thd, beginning_of_next_stmt, length, &parser_state,
is_com_multi, is_next_command); is_com_multi, is_next_command);
else else

View File

@ -5582,7 +5582,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
DBUG_ENTER("mysql_create_like_table"); DBUG_ENTER("mysql_create_like_table");
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (WSREP_ON && !thd->wsrep_applier && if (WSREP(thd) && !thd->wsrep_applier &&
wsrep_create_like_table(thd, table, src_table, create_info)) wsrep_create_like_table(thd, table, src_table, create_info))
DBUG_RETURN(res); DBUG_RETURN(res);
#endif #endif

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Monty Program Ab /* Copyright (C) 2012, 2020, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -45,7 +45,6 @@ static void threadpool_remove_connection(THD *thd);
static int threadpool_process_request(THD *thd); static int threadpool_process_request(THD *thd);
static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data); static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data);
extern "C" pthread_key(struct st_my_thread_var*, THR_KEY_mysys);
extern bool do_command(THD*); extern bool do_command(THD*);
static inline TP_connection *get_TP_connection(THD *thd) static inline TP_connection *get_TP_connection(THD *thd)
@ -85,13 +84,13 @@ struct Worker_thread_context
void save() void save()
{ {
psi_thread= PSI_CALL_get_thread(); psi_thread= PSI_CALL_get_thread();
mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys); mysys_var= my_thread_var;
} }
void restore() void restore()
{ {
PSI_CALL_set_thread(psi_thread); PSI_CALL_set_thread(psi_thread);
pthread_setspecific(THR_KEY_mysys,mysys_var); set_mysys_var(mysys_var);
pthread_setspecific(THR_THD, 0); pthread_setspecific(THR_THD, 0);
} }
}; };
@ -137,7 +136,7 @@ static inline void set_thd_idle(THD *thd)
*/ */
static void thread_attach(THD* thd) static void thread_attach(THD* thd)
{ {
pthread_setspecific(THR_KEY_mysys,thd->mysys_var); set_mysys_var(thd->mysys_var);
thd->thread_stack=(char*)&thd; thd->thread_stack=(char*)&thd;
thd->store_globals(); thd->store_globals();
PSI_CALL_set_thread(thd->event_scheduler.m_psi); PSI_CALL_set_thread(thd->event_scheduler.m_psi);
@ -222,9 +221,9 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
Store them in THD. Store them in THD.
*/ */
pthread_setspecific(THR_KEY_mysys, 0); set_mysys_var(NULL);
my_thread_init(); my_thread_init();
st_my_thread_var* mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys); st_my_thread_var* mysys_var= my_thread_var;
if (!mysys_var ||!(thd= connect->create_thd(NULL))) if (!mysys_var ||!(thd= connect->create_thd(NULL)))
{ {
/* Out of memory? */ /* Out of memory? */

View File

@ -157,5 +157,9 @@ void wsrep_unlock_rollback()
void wsrep_set_data_home_dir(const char *) void wsrep_set_data_home_dir(const char *)
{ } { }
void wsrep_log(void (*)(const char *, ...), const char *, ...)
{
}
my_bool wsrep_thd_is_applier(MYSQL_THD thd) my_bool wsrep_thd_is_applier(MYSQL_THD thd)
{ return false; } { return false; }

View File

@ -181,13 +181,7 @@ extern void wsrep_prepend_PATH (const char* path);
/* Other global variables */ /* Other global variables */
extern wsrep_seqno_t wsrep_locked_seqno; extern wsrep_seqno_t wsrep_locked_seqno;
#define WSREP_ON \ #define WSREP_ON unlikely(global_system_variables.wsrep_on)
(global_system_variables.wsrep_on)
#define WSREP_ON_NEW \
((global_system_variables.wsrep_on) && \
wsrep_provider && \
strcmp(wsrep_provider, WSREP_NONE))
#define WSREP(thd) \ #define WSREP(thd) \
(WSREP_ON && thd->variables.wsrep_on) (WSREP_ON && thd->variables.wsrep_on)

View File

@ -1686,20 +1686,14 @@ thd_trx_is_auto_commit(
/** Enter InnoDB engine after checking the max number of user threads /** Enter InnoDB engine after checking the max number of user threads
allowed, else the thread is put into sleep. allowed, else the thread is put into sleep.
@param[in,out] prebuilt row prebuilt handler */ @param[in,out] prebuilt row prebuilt handler */
static inline static inline void innobase_srv_conc_enter_innodb(row_prebuilt_t *prebuilt)
void
innobase_srv_conc_enter_innodb(
row_prebuilt_t* prebuilt)
{ {
#ifdef WITH_WSREP
if (wsrep_on(prebuilt->trx->mysql_thd) &&
wsrep_thd_is_BF(prebuilt->trx->mysql_thd, FALSE)) {
return;
}
#endif /* WITH_WSREP */
trx_t* trx = prebuilt->trx; trx_t* trx = prebuilt->trx;
#ifdef WITH_WSREP
if (trx->is_wsrep() && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) return;
#endif /* WITH_WSREP */
if (srv_thread_concurrency) { if (srv_thread_concurrency) {
if (trx->n_tickets_to_enter_innodb > 0) { if (trx->n_tickets_to_enter_innodb > 0) {
@ -1726,22 +1720,16 @@ innobase_srv_conc_enter_innodb(
/** Note that the thread wants to leave InnoDB only if it doesn't have /** Note that the thread wants to leave InnoDB only if it doesn't have
any spare tickets. any spare tickets.
@param[in,out] m_prebuilt row prebuilt handler */ @param[in,out] m_prebuilt row prebuilt handler */
static inline static inline void innobase_srv_conc_exit_innodb(row_prebuilt_t *prebuilt)
void
innobase_srv_conc_exit_innodb(
row_prebuilt_t* prebuilt)
{ {
ut_ad(!sync_check_iterate(sync_check())); ut_ad(!sync_check_iterate(sync_check()));
#ifdef WITH_WSREP
if (wsrep_on(prebuilt->trx->mysql_thd) &&
wsrep_thd_is_BF(prebuilt->trx->mysql_thd, FALSE)) {
return;
}
#endif /* WITH_WSREP */
trx_t* trx = prebuilt->trx; trx_t* trx = prebuilt->trx;
#ifdef WITH_WSREP
if (trx->is_wsrep() && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) return;
#endif /* WITH_WSREP */
/* This is to avoid making an unnecessary function call. */ /* This is to avoid making an unnecessary function call. */
if (trx->declared_to_be_inside_innodb if (trx->declared_to_be_inside_innodb
&& trx->n_tickets_to_enter_innodb == 0) { && trx->n_tickets_to_enter_innodb == 0) {
@ -2698,6 +2686,9 @@ innobase_trx_init(
trx->check_unique_secondary = !thd_test_options( trx->check_unique_secondary = !thd_test_options(
thd, OPTION_RELAXED_UNIQUE_CHECKS); thd, OPTION_RELAXED_UNIQUE_CHECKS);
#ifdef WITH_WSREP
trx->wsrep = wsrep_on(thd);
#endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -4372,19 +4363,17 @@ innobase_commit_low(
trx_t* trx) /*!< in: transaction handle */ trx_t* trx) /*!< in: transaction handle */
{ {
#ifdef WITH_WSREP #ifdef WITH_WSREP
THD* thd = (THD*)trx->mysql_thd;
const char* tmp = 0; const char* tmp = 0;
if (thd && wsrep_on(thd)) { if (trx->is_wsrep()) {
#ifdef WSREP_PROC_INFO #ifdef WSREP_PROC_INFO
char info[64]; char info[64];
info[sizeof(info) - 1] = '\0'; info[sizeof(info) - 1] = '\0';
snprintf(info, sizeof(info) - 1, snprintf(info, sizeof(info) - 1,
"innobase_commit_low():trx_commit_for_mysql(%lld)", "innobase_commit_low():trx_commit_for_mysql(%lld)",
(long long) wsrep_thd_trx_seqno(thd)); (long long) wsrep_thd_trx_seqno(trx->mysql_thd));
tmp = thd_proc_info(thd, info); tmp = thd_proc_info(trx->mysql_thd, info);
#else #else
tmp = thd_proc_info(thd, "innobase_commit_low()"); tmp = thd_proc_info(trx->mysql_thd, "innobase_commit_low()");
#endif /* WSREP_PROC_INFO */ #endif /* WSREP_PROC_INFO */
} }
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
@ -4394,7 +4383,7 @@ innobase_commit_low(
} }
trx->will_lock = 0; trx->will_lock = 0;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (thd && wsrep_on(thd)) { thd_proc_info(thd, tmp); } if (trx->is_wsrep()) { thd_proc_info(trx->mysql_thd, tmp); }
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
} }
@ -7959,7 +7948,7 @@ ha_innobase::write_row(
{ {
dberr_t error; dberr_t error;
#ifdef WITH_WSREP #ifdef WITH_WSREP
ibool auto_inc_inserted= FALSE; /* if NULL was inserted */ bool wsrep_auto_inc_inserted= false;
#endif #endif
int error_result = 0; int error_result = 0;
bool auto_inc_used = false; bool auto_inc_used = false;
@ -7981,7 +7970,7 @@ ha_innobase::write_row(
} }
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_is_load_multi_commit(m_user_thd)) if (trx->is_wsrep() && wsrep_is_load_multi_commit(m_user_thd))
{ {
/* Note that this transaction is still active. */ /* Note that this transaction is still active. */
trx_register_for_2pc(m_prebuilt->trx); trx_register_for_2pc(m_prebuilt->trx);
@ -7999,7 +7988,9 @@ ha_innobase::write_row(
m_prebuilt->autoinc_error = DB_SUCCESS; m_prebuilt->autoinc_error = DB_SUCCESS;
#ifdef WITH_WSREP #ifdef WITH_WSREP
auto_inc_inserted= (table->next_number_field->val_int() == 0); wsrep_auto_inc_inserted = trx->is_wsrep()
&& wsrep_drupal_282555_workaround
&& table->next_number_field->val_int() == 0;
#endif #endif
if ((error_result = update_auto_increment())) { if ((error_result = update_auto_increment())) {
@ -8096,18 +8087,14 @@ ha_innobase::write_row(
m_prebuilt->autoinc_offset, m_prebuilt->autoinc_offset,
m_prebuilt->autoinc_increment); m_prebuilt->autoinc_increment);
if (wsrep_on(m_user_thd) && if (wsrep_auto_inc_inserted &&
auto_inc_inserted &&
wsrep_drupal_282555_workaround &&
wsrep_thd_retry_counter(m_user_thd) == 0 && wsrep_thd_retry_counter(m_user_thd) == 0 &&
!thd_test_options(m_user_thd, !thd_test_options(m_user_thd,
OPTION_NOT_AUTOCOMMIT | OPTION_NOT_AUTOCOMMIT |
OPTION_BEGIN)) { OPTION_BEGIN)) {
WSREP_DEBUG( WSREP_DEBUG(
"retrying insert: %s", "retrying insert: %s",
(*wsrep_thd_query(m_user_thd)) ? wsrep_thd_query(m_user_thd));
wsrep_thd_query(m_user_thd) :
(char *)"void");
error= DB_SUCCESS; error= DB_SUCCESS;
wsrep_thd_set_conflict_state( wsrep_thd_set_conflict_state(
m_user_thd, MUST_ABORT); m_user_thd, MUST_ABORT);
@ -8147,7 +8134,7 @@ set_max_autoinc:
m_prebuilt autoinc values don't get m_prebuilt autoinc values don't get
properly assigned. Fetch values from properly assigned. Fetch values from
server side. */ server side. */
if (wsrep_on(m_user_thd) && if (trx->is_wsrep() &&
wsrep_thd_exec_mode(m_user_thd) == REPL_RECV) wsrep_thd_exec_mode(m_user_thd) == REPL_RECV)
{ {
wsrep_thd_auto_increment_variables( wsrep_thd_auto_increment_variables(
@ -8196,8 +8183,7 @@ report_error:
error, m_prebuilt->table->flags, m_user_thd); error, m_prebuilt->table->flags, m_user_thd);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (!error_result if (!error_result && trx->is_wsrep()
&& wsrep_on(m_user_thd)
&& wsrep_thd_exec_mode(m_user_thd) == LOCAL_STATE && wsrep_thd_exec_mode(m_user_thd) == LOCAL_STATE
&& !wsrep_consistency_check(m_user_thd) && !wsrep_consistency_check(m_user_thd)
&& !wsrep_thd_ignore_table(m_user_thd)) { && !wsrep_thd_ignore_table(m_user_thd)) {
@ -8205,10 +8191,9 @@ report_error:
NULL)) { NULL)) {
DBUG_PRINT("wsrep", ("row key failed")); DBUG_PRINT("wsrep", ("row key failed"));
error_result = HA_ERR_INTERNAL_ERROR; error_result = HA_ERR_INTERNAL_ERROR;
goto wsrep_error; goto func_exit;
} }
} }
wsrep_error:
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
if (error_result == HA_FTS_INVALID_DOCID) { if (error_result == HA_FTS_INVALID_DOCID) {
@ -8859,7 +8844,7 @@ ha_innobase::update_row(
m_prebuilt autoinc values don't get m_prebuilt autoinc values don't get
properly assigned. Fetch values from properly assigned. Fetch values from
server side. */ server side. */
if (wsrep_on(m_user_thd) && if (trx->is_wsrep() &&
wsrep_thd_exec_mode(m_user_thd) == REPL_RECV) wsrep_thd_exec_mode(m_user_thd) == REPL_RECV)
{ {
wsrep_thd_auto_increment_variables( wsrep_thd_auto_increment_variables(
@ -8910,9 +8895,8 @@ func_exit:
innobase_active_small(); innobase_active_small();
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (error == DB_SUCCESS && if (error == DB_SUCCESS && trx->is_wsrep() &&
wsrep_thd_exec_mode(m_user_thd) == LOCAL_STATE && wsrep_thd_exec_mode(m_user_thd) == LOCAL_STATE &&
wsrep_on(m_user_thd) &&
!wsrep_thd_ignore_table(m_user_thd)) { !wsrep_thd_ignore_table(m_user_thd)) {
DBUG_PRINT("wsrep", ("update row key")); DBUG_PRINT("wsrep", ("update row key"));
@ -8920,14 +8904,11 @@ func_exit:
new_row)) { new_row)) {
WSREP_DEBUG("WSREP: UPDATE_ROW_KEY FAILED"); WSREP_DEBUG("WSREP: UPDATE_ROW_KEY FAILED");
DBUG_PRINT("wsrep", ("row key failed")); DBUG_PRINT("wsrep", ("row key failed"));
err = HA_ERR_INTERNAL_ERROR; DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
goto wsrep_error;
} }
} }
wsrep_error:
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
DBUG_RETURN(err); DBUG_RETURN(err);
} }
@ -8977,18 +8958,15 @@ ha_innobase::delete_row(
innobase_active_small(); innobase_active_small();
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (error == DB_SUCCESS if (error == DB_SUCCESS && trx->is_wsrep()
&& wsrep_thd_exec_mode(m_user_thd) == LOCAL_STATE && wsrep_thd_exec_mode(m_user_thd) == LOCAL_STATE
&& wsrep_on(m_user_thd)
&& !wsrep_thd_ignore_table(m_user_thd)) { && !wsrep_thd_ignore_table(m_user_thd)) {
if (wsrep_append_keys(m_user_thd, WSREP_KEY_EXCLUSIVE, record, if (wsrep_append_keys(m_user_thd, WSREP_KEY_EXCLUSIVE, record,
NULL)) { NULL)) {
DBUG_PRINT("wsrep", ("delete fail")); DBUG_PRINT("wsrep", ("delete fail"));
error = (dberr_t) HA_ERR_INTERNAL_ERROR; DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
goto wsrep_error;
} }
} }
wsrep_error:
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
DBUG_RETURN(convert_error_code_to_mysql( DBUG_RETURN(convert_error_code_to_mysql(
error, m_prebuilt->table->flags, m_user_thd)); error, m_prebuilt->table->flags, m_user_thd));
@ -10177,30 +10155,27 @@ wsrep_append_foreign_key(
wsrep_key_type key_type) /*!< in: access type of this key wsrep_key_type key_type) /*!< in: access type of this key
(shared, exclusive, semi...) */ (shared, exclusive, semi...) */
{ {
ut_a(trx); THD* thd = trx->mysql_thd;
THD* thd = (THD*)trx->mysql_thd;
if (!trx->is_wsrep() || wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
return DB_SUCCESS;
}
if (!foreign ||
(!foreign->referenced_table && !foreign->foreign_table)) {
WSREP_INFO("FK: %s missing in: %s",
(!foreign ? "constraint" :
(!foreign->referenced_table ?
"referenced table" : "foreign table")),
wsrep_thd_query(thd));
return DB_ERROR;
}
ulint rcode = DB_SUCCESS; ulint rcode = DB_SUCCESS;
char cache_key[513] = {'\0'}; char cache_key[513] = {'\0'};
int cache_key_len=0; int cache_key_len=0;
bool const copy = true; bool const copy = true;
if (!wsrep_on(trx->mysql_thd) ||
wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
return DB_SUCCESS;
}
if (!thd || !foreign ||
(!foreign->referenced_table && !foreign->foreign_table)) {
WSREP_INFO("FK: %s missing in: %s",
(!thd) ? "thread" :
((!foreign) ? "constraint" :
((!foreign->referenced_table) ?
"referenced table" : "foreign table")),
(thd && wsrep_thd_query(thd)) ?
wsrep_thd_query(thd) : "void");
return DB_ERROR;
}
if ( !((referenced) ? if ( !((referenced) ?
foreign->referenced_table : foreign->foreign_table)) { foreign->referenced_table : foreign->foreign_table)) {
WSREP_DEBUG("pulling %s table into cache", WSREP_DEBUG("pulling %s table into cache",
@ -15724,9 +15699,7 @@ ha_innobase::external_lock(
DBUG_PRINT("enter",("lock_type: %d", lock_type)); DBUG_PRINT("enter",("lock_type: %d", lock_type));
update_thd(thd); update_thd(thd);
trx_t* trx = m_prebuilt->trx; trx_t* trx = m_prebuilt->trx;
ut_ad(m_prebuilt->table); ut_ad(m_prebuilt->table);
/* Statement based binlogging does not work in isolation level /* Statement based binlogging does not work in isolation level
@ -15741,26 +15714,21 @@ ha_innobase::external_lock(
&& thd_binlog_format(thd) == BINLOG_FORMAT_STMT && thd_binlog_format(thd) == BINLOG_FORMAT_STMT
&& thd_binlog_filter_ok(thd) && thd_binlog_filter_ok(thd)
&& thd_sqlcom_can_generate_row_events(thd)) { && thd_sqlcom_can_generate_row_events(thd)) {
bool skip = false; bool skip = false;
#ifdef WITH_WSREP
skip = trx->is_wsrep()
&& wsrep_thd_exec_mode(thd) != LOCAL_STATE;
#endif /* WITH_WSREP */
/* used by test case */ /* used by test case */
DBUG_EXECUTE_IF("no_innodb_binlog_errors", skip = true;); DBUG_EXECUTE_IF("no_innodb_binlog_errors", skip = true;);
if (!skip) { if (!skip) {
#ifdef WITH_WSREP
if (!wsrep_on(thd) || wsrep_thd_exec_mode(thd) == LOCAL_STATE)
{
#endif /* WITH_WSREP */
my_error(ER_BINLOG_STMT_MODE_AND_ROW_ENGINE, MYF(0), my_error(ER_BINLOG_STMT_MODE_AND_ROW_ENGINE, MYF(0),
" InnoDB is limited to row-logging when" " InnoDB is limited to row-logging when"
" transaction isolation level is" " transaction isolation level is"
" READ COMMITTED or READ UNCOMMITTED."); " READ COMMITTED or READ UNCOMMITTED.");
DBUG_RETURN(HA_ERR_LOGGING_IMPOSSIBLE); DBUG_RETURN(HA_ERR_LOGGING_IMPOSSIBLE);
#ifdef WITH_WSREP
}
#endif /* WITH_WSREP */
} }
} }

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, 2019, MariaDB Corporation. Copyright (c) 2017, 2020, 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
@ -1044,10 +1044,6 @@ std::string
lock_get_info( lock_get_info(
const lock_t*); const lock_t*);
/*******************************************************************//**
@return whether wsrep_on is true on trx->mysql_thd*/
#define wsrep_on_trx(trx) ((trx)->mysql_thd && wsrep_on((trx)->mysql_thd))
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
#include "lock0lock.ic" #include "lock0lock.ic"

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation. Copyright (c) 2017, 2020, 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
@ -363,16 +363,6 @@ row_upd_changes_some_index_ord_field_binary(
/*========================================*/ /*========================================*/
const dict_table_t* table, /*!< in: table */ const dict_table_t* table, /*!< in: table */
const upd_t* update);/*!< in: update vector for the row */ const upd_t* update);/*!< in: update vector for the row */
/** Stores to the heap the row on which the node->pcur is positioned.
@param[in] node row update node
@param[in] thd mysql thread handle
@param[in,out] mysql_table NULL, or mysql table object when
user thread invokes dml */
void
row_upd_store_row(
upd_node_t* node,
THD* thd,
TABLE* mysql_table);
/***********************************************************//** /***********************************************************//**
Updates a row in a table. This is a high-level function used Updates a row in a table. This is a high-level function used
in SQL execution graphs. in SQL execution graphs.

View File

@ -831,6 +831,13 @@ public:
Transitions to COMMITTED are protected by trx_t::mutex. */ Transitions to COMMITTED are protected by trx_t::mutex. */
trx_state_t state; trx_state_t state;
#ifdef WITH_WSREP
/** whether wsrep_on(mysql_thd) held at the start of transaction */
bool wsrep;
bool is_wsrep() const { return UNIV_UNLIKELY(wsrep); }
#else /* WITH_WSREP */
bool is_wsrep() const { return false; }
#endif /* WITH_WSREP */
ReadView read_view; /*!< consistent read view used in the ReadView read_view; /*!< consistent read view used in the
transaction, or NULL if not yet set */ transaction, or NULL if not yet set */

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) 2014, 2019, MariaDB Corporation. Copyright (c) 2014, 2020, 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
@ -1090,9 +1090,7 @@ wsrep_kill_victim(
ut_ad(trx_mutex_own(lock->trx)); ut_ad(trx_mutex_own(lock->trx));
/* quit for native mysql */ /* quit for native mysql */
if (!wsrep_on(trx->mysql_thd)) { if (!trx->is_wsrep()) return;
return;
}
my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE); my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE);
my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE); my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE);
@ -1175,7 +1173,7 @@ lock_rec_other_has_conflicting(
if (lock_rec_has_to_wait(true, trx, mode, lock, is_supremum)) { if (lock_rec_has_to_wait(true, trx, mode, lock, is_supremum)) {
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on_trx(trx)) { if (trx->is_wsrep()) {
trx_mutex_enter(lock->trx); trx_mutex_enter(lock->trx);
/* Below function will roll back either trx /* Below function will roll back either trx
or lock->trx depending on priority of the or lock->trx depending on priority of the
@ -1417,7 +1415,7 @@ lock_rec_create_low(
ut_ad(index->table->get_ref_count() > 0 || !index->table->can_be_evicted); ut_ad(index->table->get_ref_count() > 0 || !index->table->can_be_evicted);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (c_lock && wsrep_on_trx(trx) if (c_lock && trx->is_wsrep()
&& wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
lock_t *hash = (lock_t *)c_lock->hash; lock_t *hash = (lock_t *)c_lock->hash;
lock_t *prev = NULL; lock_t *prev = NULL;
@ -1823,8 +1821,7 @@ lock_rec_add_to_queue(
#ifdef WITH_WSREP #ifdef WITH_WSREP
//ut_a(!other_lock || (wsrep_thd_is_BF(trx->mysql_thd, FALSE) && //ut_a(!other_lock || (wsrep_thd_is_BF(trx->mysql_thd, FALSE) &&
// wsrep_thd_is_BF(other_lock->trx->mysql_thd, TRUE))); // wsrep_thd_is_BF(other_lock->trx->mysql_thd, TRUE)));
if (other_lock && if (other_lock && trx->is_wsrep() &&
wsrep_on(trx->mysql_thd) &&
!wsrep_thd_is_BF(trx->mysql_thd, FALSE) && !wsrep_thd_is_BF(trx->mysql_thd, FALSE) &&
!wsrep_thd_is_BF(other_lock->trx->mysql_thd, TRUE)) { !wsrep_thd_is_BF(other_lock->trx->mysql_thd, TRUE)) {
@ -3522,7 +3519,7 @@ lock_table_create(
UT_LIST_ADD_LAST(trx->lock.trx_locks, lock); UT_LIST_ADD_LAST(trx->lock.trx_locks, lock);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (c_lock && wsrep_on_trx(trx)) { if (c_lock && trx->is_wsrep()) {
if (wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { if (wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
ut_list_insert(table->locks, c_lock, lock, ut_list_insert(table->locks, c_lock, lock,
TableLockGetNode()); TableLockGetNode());
@ -3752,7 +3749,7 @@ lock_table_enqueue_waiting(
} }
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (trx->lock.was_chosen_as_deadlock_victim && wsrep_on_trx(trx)) { if (trx->is_wsrep() && trx->lock.was_chosen_as_deadlock_victim) {
return(DB_DEADLOCK); return(DB_DEADLOCK);
} }
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
@ -3825,7 +3822,7 @@ lock_table_other_has_incompatible(
&& (wait || !lock_get_wait(lock))) { && (wait || !lock_get_wait(lock))) {
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(lock->trx->mysql_thd)) { if (lock->trx->is_wsrep()) {
if (wsrep_debug) { if (wsrep_debug) {
ib::info() << "WSREP: table lock abort for table:" ib::info() << "WSREP: table lock abort for table:"
<< table->name.m_name; << table->name.m_name;
@ -4892,7 +4889,7 @@ func_exit:
explicit granted lock. */ explicit granted lock. */
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(other_lock->trx->mysql_thd)) { if (other_lock->trx->is_wsrep()) {
if (!lock_get_wait(other_lock) ) { if (!lock_get_wait(other_lock) ) {
ib::info() << "WSREP impl BF lock conflict for my impl lock:\n BF:" << ib::info() << "WSREP impl BF lock conflict for my impl lock:\n BF:" <<
((wsrep_thd_is_BF(impl_trx->mysql_thd, FALSE)) ? "BF" : "normal") << " exec: " << ((wsrep_thd_is_BF(impl_trx->mysql_thd, FALSE)) ? "BF" : "normal") << " exec: " <<

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) 2014, 2019, MariaDB Corporation. Copyright (c) 2014, 2020, 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
@ -192,8 +192,7 @@ wsrep_is_BF_lock_timeout(
const trx_t* trx, const trx_t* trx,
bool locked = true) bool locked = true)
{ {
if (wsrep_on_trx(trx) if (trx->is_wsrep() && wsrep_thd_is_BF(trx->mysql_thd, FALSE)
&& wsrep_thd_is_BF(trx->mysql_thd, FALSE)
&& trx->error_state != DB_DEADLOCK) { && trx->error_state != DB_DEADLOCK) {
ib::info() << "WSREP: BF lock wait long for trx:" << ib::hex(trx->id) ib::info() << "WSREP: BF lock wait long for trx:" << ib::hex(trx->id)
<< " query: " << wsrep_thd_query(trx->mysql_thd); << " query: " << wsrep_thd_query(trx->mysql_thd);
@ -399,8 +398,9 @@ lock_wait_suspend_thread(
if (lock_wait_timeout < 100000000 if (lock_wait_timeout < 100000000
&& wait_time > (double) lock_wait_timeout && wait_time > (double) lock_wait_timeout
#ifdef WITH_WSREP #ifdef WITH_WSREP
&& (!wsrep_on_trx(trx) || && (!trx->is_wsrep()
(!wsrep_is_BF_lock_timeout(trx, false) && trx->error_state != DB_DEADLOCK)) || (!wsrep_is_BF_lock_timeout(trx, false)
&& trx->error_state != DB_DEADLOCK))
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
) { ) {

View File

@ -1792,7 +1792,7 @@ row_ins_check_foreign_constraint(
if (check_ref) { if (check_ref) {
err = DB_SUCCESS; err = DB_SUCCESS;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (!wsrep_on(trx->mysql_thd)) { if (!trx->is_wsrep()) {
goto end_scan; goto end_scan;
} }
enum wsrep_key_type key_type; enum wsrep_key_type key_type;

View File

@ -1038,7 +1038,7 @@ row_prebuilt_free(
rtr_clean_rtr_info(prebuilt->rtr_info, true); rtr_clean_rtr_info(prebuilt->rtr_info, true);
} }
if (prebuilt->table) { if (prebuilt->table) {
dict_table_close(prebuilt->table, dict_locked, TRUE); dict_table_close(prebuilt->table, dict_locked, FALSE);
} }
mem_heap_free(prebuilt->heap); mem_heap_free(prebuilt->heap);

View File

@ -432,7 +432,7 @@ func_exit:
inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx) inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx)
{ {
if (!wsrep_on_trx(trx)) { if (!trx->is_wsrep()) {
return false; return false;
} }
return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE
@ -2211,6 +2211,7 @@ row_upd_store_v_row(
@param[in] thd mysql thread handle @param[in] thd mysql thread handle
@param[in,out] mysql_table NULL, or mysql table object when @param[in,out] mysql_table NULL, or mysql table object when
user thread invokes dml */ user thread invokes dml */
static
void void
row_upd_store_row( row_upd_store_row(
upd_node_t* node, upd_node_t* node,

View File

@ -616,7 +616,6 @@ row_vers_build_cur_vrow_low(
/** Check a virtual column value index secondary virtual index matches /** Check a virtual column value index secondary virtual index matches
that of current cluster index record, which is recreated from information that of current cluster index record, which is recreated from information
stored in undo log stored in undo log
@param[in] in_purge called by purge thread
@param[in] rec record in the clustered index @param[in] rec record in the clustered index
@param[in] icentry the index entry built from a cluster row @param[in] icentry the index entry built from a cluster row
@param[in] clust_index cluster index @param[in] clust_index cluster index
@ -632,7 +631,6 @@ stored in undo log
static static
bool bool
row_vers_vc_matches_cluster( row_vers_vc_matches_cluster(
bool in_purge,
const rec_t* rec, const rec_t* rec,
const dtuple_t* icentry, const dtuple_t* icentry,
dict_index_t* clust_index, dict_index_t* clust_index,
@ -693,12 +691,6 @@ row_vers_vc_matches_cluster(
version = rec; version = rec;
/* If this is called by purge thread, set TRX_UNDO_PREV_IN_PURGE
bit to search the undo log until we hit the current undo log with
roll_ptr */
ulint status = (in_purge ? TRX_UNDO_PREV_IN_PURGE : 0)
| TRX_UNDO_GET_OLD_V_VALUE;
while (n_cmp_v_col < n_fields - n_non_v_col) { while (n_cmp_v_col < n_fields - n_non_v_col) {
heap2 = heap; heap2 = heap;
heap = mem_heap_create(1024); heap = mem_heap_create(1024);
@ -706,11 +698,12 @@ row_vers_vc_matches_cluster(
version, clust_index, clust_offsets); version, clust_index, clust_offsets);
ut_ad(cur_roll_ptr != 0); ut_ad(cur_roll_ptr != 0);
ut_ad(in_purge == (roll_ptr != 0)); ut_ad(roll_ptr != 0);
trx_undo_prev_version_build( trx_undo_prev_version_build(
rec, mtr, version, clust_index, clust_offsets, rec, mtr, version, clust_index, clust_offsets,
heap, &prev_version, NULL, vrow, status); heap, &prev_version, NULL, vrow,
TRX_UNDO_PREV_IN_PURGE | TRX_UNDO_GET_OLD_V_VALUE);
if (heap2) { if (heap2) {
mem_heap_free(heap2); mem_heap_free(heap2);
@ -992,7 +985,7 @@ row_vers_old_has_index_entry(
secondary indexes.) */ secondary indexes.) */
if (entry && row_vers_vc_matches_cluster( if (entry && row_vers_vc_matches_cluster(
also_curr, rec, entry, rec, entry,
clust_index, clust_offsets, clust_index, clust_offsets,
index, ientry, roll_ptr, index, ientry, roll_ptr,
trx_id, NULL, &vrow, mtr)) { trx_id, NULL, &vrow, mtr)) {

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2018, MariaDB Corporation. Copyright (c) 2015, 2020, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
@ -120,8 +120,7 @@ srv_conc_enter_innodb_with_atomics(
for (;;) { for (;;) {
ulint sleep_in_us; ulint sleep_in_us;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(trx->mysql_thd) && if (trx->is_wsrep() && wsrep_trx_is_aborting(trx->mysql_thd)) {
wsrep_trx_is_aborting(trx->mysql_thd)) {
if (wsrep_debug) { if (wsrep_debug) {
ib::info() << ib::info() <<
"srv_conc_enter due to MUST_ABORT"; "srv_conc_enter due to MUST_ABORT";

View File

@ -109,6 +109,9 @@ trx_init(
trx->state = TRX_STATE_NOT_STARTED; trx->state = TRX_STATE_NOT_STARTED;
trx->is_recovered = false; trx->is_recovered = false;
#ifdef WITH_WSREP
trx->wsrep = false;
#endif /* WITH_WSREP */
trx->op_info = ""; trx->op_info = "";
@ -1477,12 +1480,7 @@ trx_commit_in_memory(
trx_mutex_enter(trx); trx_mutex_enter(trx);
trx->dict_operation = TRX_DICT_OP_NONE; trx->dict_operation = TRX_DICT_OP_NONE;
trx->lock.was_chosen_as_deadlock_victim = false;
#ifdef WITH_WSREP
if (trx->mysql_thd && wsrep_on(trx->mysql_thd)) {
trx->lock.was_chosen_as_deadlock_victim = FALSE;
}
#endif
DBUG_LOG("trx", "Commit in memory: " << trx); DBUG_LOG("trx", "Commit in memory: " << trx);
trx->state = TRX_STATE_NOT_STARTED; trx->state = TRX_STATE_NOT_STARTED;

View File

@ -296,7 +296,7 @@ static MYSQL_SYSVAR_BOOL(encrypt_tables, maria_encrypt_tables, PLUGIN_VAR_OPCMDA
"and not FIXED/DYNAMIC)", "and not FIXED/DYNAMIC)",
0, 0, 0); 0, 0, 0);
#ifdef HAVE_PSI_INTERFACE #if defined HAVE_PSI_INTERFACE && !defined EMBEDDED_LIBRARY
static PSI_mutex_info all_aria_mutexes[]= static PSI_mutex_info all_aria_mutexes[]=
{ {