Skip to content

Commit

Permalink
Merge 10.2 into 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Apr 27, 2020
2 parents 61c0df9 + c06845d commit 2e12d47
Show file tree
Hide file tree
Showing 30 changed files with 158 additions and 192 deletions.
3 changes: 2 additions & 1 deletion include/my_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,13 +729,14 @@ struct st_my_thread_var
#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 safe_mutex_t **my_thread_var_mutex_in_use(void);
extern uint my_thread_end_wait_time;
extern my_bool safe_mutex_deadlock_detector;
#define my_thread_var (_my_thread_var())
#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
report errors with them
Expand Down
3 changes: 2 additions & 1 deletion mysql-test/mysql-test-run.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3355,7 +3355,8 @@ sub mysql_install_db {
# ----------------------------------------------------------------------
# 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
# from option files or combinations. We want them on a command line
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/galera/t/MW-86-wait1.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#
--source include/galera_cluster.inc
--source include/have_binlog_format_row.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc

--connection node_2
Expand Down
7 changes: 6 additions & 1 deletion mysql-test/suite/innodb_fts/r/innodb_fts_misc.result
Original file line number Diff line number Diff line change
Expand Up @@ -706,14 +706,19 @@ FULLTEXT(f2),
FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB;
INSERT INTO mdev20987_1 VALUES(1);
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;
Table Create Table
t2 CREATE TABLE `t2` (
`FTS_DOC_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`FTS_DOC_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
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---------"
create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb;
set session autocommit=0;
Expand Down
8 changes: 7 additions & 1 deletion mysql-test/suite/innodb_fts/t/innodb_fts_misc.test
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,16 @@ CREATE TABLE mdev20987_2(f1 INT NOT NULL, f2 CHAR(100),
FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB;
INSERT INTO mdev20987_1 VALUES(1);
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
SHOW CREATE TABLE t2;
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---------"
create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb;
Expand Down
14 changes: 7 additions & 7 deletions mysys/my_thr_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void my_thread_global_reinit(void)
my_thread_destroy_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);

my_thread_destory_thr_mutex(tmp);
Expand Down Expand Up @@ -279,7 +279,7 @@ my_bool my_thread_init(void)
fprintf(stderr,"my_thread_init(): pthread_self: %p\n", pthread_self());
#endif

if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys))
if (my_thread_var)
{
#ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_init() called more than once in thread 0x%lx\n",
Expand All @@ -297,7 +297,7 @@ my_bool my_thread_init(void)
error= 1;
goto end;
}
pthread_setspecific(THR_KEY_mysys,tmp);
set_mysys_var(tmp);
tmp->pthread_self= pthread_self();
my_thread_init_thr_mutex(tmp);

Expand Down Expand Up @@ -334,7 +334,7 @@ my_bool my_thread_init(void)
void my_thread_end(void)
{
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
fprintf(stderr,"my_thread_end(): tmp: %p pthread_self: %p thread_id: %ld\n",
Expand All @@ -355,7 +355,7 @@ void my_thread_end(void)
as the key is used by DBUG.
*/
DBUG_POP();
pthread_setspecific(THR_KEY_mysys,0);
set_mysys_var(NULL);

if (tmp && tmp->init)
{
Expand Down Expand Up @@ -439,7 +439,7 @@ extern void **my_thread_var_dbug()
struct st_my_thread_var *tmp;
if (!my_thread_global_init_done)
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;
}
#endif /* DBUG_OFF */
Expand All @@ -451,7 +451,7 @@ safe_mutex_t **my_thread_var_mutex_in_use()
struct st_my_thread_var *tmp;
if (!my_thread_global_init_done)
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;
}

Expand Down
23 changes: 12 additions & 11 deletions sql/item_func.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 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
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -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
args[0] is a constant.
*/
uint32 tmp;
uint32 tmp= (uint32) arg->val_int();
#ifdef WITH_WSREP
THD *thd= current_thd;
if (WSREP(thd))
if (WSREP_ON)
{
if (thd->wsrep_exec_mode==REPL_RECV)
tmp= thd->wsrep_rand;
else
tmp= thd->wsrep_rand= (uint32) arg->val_int();
}
else
THD *thd= current_thd;
if (WSREP(thd))
{
if (thd->wsrep_exec_mode==REPL_RECV)
tmp= thd->wsrep_rand;
else
thd->wsrep_rand= tmp;
}
}
#endif /* WITH_WSREP */
tmp= (uint32) arg->val_int();

my_rnd_init(rand, (uint32) (tmp*0x10001L+55555555L),
(uint32) (tmp*0x10000001L));
Expand Down
9 changes: 5 additions & 4 deletions sql/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,7 @@ binlog_commit_flush_stmt_cache(THD *thd, bool all,
#ifdef WITH_WSREP
if (thd->wsrep_mysql_replicated > 0)
{
DBUG_ASSERT(WSREP_ON);
DBUG_ASSERT(WSREP(thd));
WSREP_DEBUG("avoiding binlog_commit_flush_trx_cache: %d",
thd->wsrep_mysql_replicated);
return 0;
Expand Down Expand Up @@ -6680,14 +6680,15 @@ int MYSQL_BIN_LOG::rotate(bool force_rotate, bool* check_purge)
int error= 0;
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;
WSREP_DEBUG("avoiding binlog rotate due to TO isolation: %d",
WSREP_DEBUG("avoiding binlog rotate due to TO isolation: %d",
wsrep_to_isolation);
DBUG_RETURN(0);
}
#endif /* WITH_WSREP */

//todo: fix the macro def and restore safe_mutex_assert_owner(&LOCK_log);
*check_purge= false;
Expand Down
6 changes: 3 additions & 3 deletions sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5929,7 +5929,7 @@ Query_log_event::do_shall_skip(rpl_group_info *rgi)
}
}
#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 &&
(is_begin() || is_commit()))
{
Expand All @@ -5943,7 +5943,7 @@ Query_log_event::do_shall_skip(rpl_group_info *rgi)
thd->wsrep_mysql_replicated = 0;
}
}
#endif
#endif /* WITH_WSREP */
DBUG_RETURN(Log_event::do_shall_skip(rgi));
}

Expand Down Expand Up @@ -9043,7 +9043,7 @@ Xid_log_event::do_shall_skip(rpl_group_info *rgi)
DBUG_RETURN(Log_event::EVENT_SKIP_COUNT);
}
#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)
{
if (++thd->wsrep_mysql_replicated < (int)wsrep_mysql_replication_bundle)
Expand Down
4 changes: 3 additions & 1 deletion sql/mysqld.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 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
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -6013,8 +6013,10 @@ int mysqld_main(int argc, char **argv)
set_user(mysqld_user, user_info);
}

#ifdef WITH_WSREP
if (WSREP_ON && wsrep_check_opts())
global_system_variables.wsrep_on= 0;
#endif

/*
The subsequent calls may take a long time : e.g. innodb log read.
Expand Down
8 changes: 5 additions & 3 deletions sql/slave.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 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
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -5562,8 +5562,10 @@ pthread_handler_t handle_slave_sql(void *arg)
if (!sql_slave_killed(serial_rgi))
{
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;
}
}
goto err;
}
Expand Down Expand Up @@ -5696,7 +5698,7 @@ pthread_handler_t handle_slave_sql(void *arg)
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.
*/
if (WSREP_ON && wsrep_node_dropped && wsrep_restart_slave)
if (WSREP(thd) && wsrep_node_dropped && wsrep_restart_slave)
{
if (wsrep_ready_get())
{
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_base.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 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
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -4301,7 +4301,7 @@ bool open_tables(THD *thd, const DDL_options_st &options,
}
}

if (WSREP_ON &&
if (WSREP(thd) &&
wsrep_replicate_myisam &&
(*start) &&
(*start)->table &&
Expand Down
8 changes: 4 additions & 4 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 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
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -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())))
break;

if (WSREP_ON)
if (WSREP(thd))
wsrep_mysql_parse(thd, thd->query(), thd->query_length(), &parser_state,
is_com_multi, is_next_command);
else
Expand Down Expand Up @@ -1932,12 +1932,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
*/
statistic_increment(thd->status_var.questions, &LOCK_status);

if(!WSREP(thd))
if (!WSREP(thd))
thd->set_time(); /* Reset the query start time. */

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,
is_com_multi, is_next_command);
else
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5582,7 +5582,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
DBUG_ENTER("mysql_create_like_table");

#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))
DBUG_RETURN(res);
#endif
Expand Down
15 changes: 7 additions & 8 deletions sql/threadpool_common.cc
Original file line number Diff line number Diff line change
@@ -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
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -45,7 +45,6 @@ static void threadpool_remove_connection(THD *thd);
static int threadpool_process_request(THD *thd);
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*);

static inline TP_connection *get_TP_connection(THD *thd)
Expand Down Expand Up @@ -84,14 +83,14 @@ struct Worker_thread_context

void save()
{
psi_thread = PSI_CALL_get_thread();
mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys);
psi_thread= PSI_CALL_get_thread();
mysys_var= my_thread_var;
}

void restore()
{
PSI_CALL_set_thread(psi_thread);
pthread_setspecific(THR_KEY_mysys,mysys_var);
set_mysys_var(mysys_var);
pthread_setspecific(THR_THD, 0);
}
};
Expand Down Expand Up @@ -137,7 +136,7 @@ static inline void set_thd_idle(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->store_globals();
PSI_CALL_set_thread(thd->event_scheduler.m_psi);
Expand Down Expand Up @@ -222,9 +221,9 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
Store them in THD.
*/

pthread_setspecific(THR_KEY_mysys, 0);
set_mysys_var(NULL);
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)))
{
/* Out of memory? */
Expand Down
4 changes: 4 additions & 0 deletions sql/wsrep_dummy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,9 @@ void wsrep_unlock_rollback()
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)
{ return false; }
Loading

0 comments on commit 2e12d47

Please sign in to comment.