mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
Merge branch '5.5-galera' into 10.0-galera
This commit is contained in:
12
debian/mariadb-galera-server-10.0.mysql.init
vendored
12
debian/mariadb-galera-server-10.0.mysql.init
vendored
@@ -17,6 +17,9 @@ set -e
|
|||||||
set -u
|
set -u
|
||||||
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
|
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
|
||||||
|
|
||||||
|
# Prevent Debian's init scripts from calling systemctl
|
||||||
|
_SYSTEMCTL_SKIP_REDIRECT=true
|
||||||
|
|
||||||
test -x /usr/sbin/mysqld || exit 0
|
test -x /usr/sbin/mysqld || exit 0
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
. /lib/lsb/init-functions
|
||||||
@@ -179,8 +182,15 @@ case "${1:-''}" in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
'bootstrap')
|
||||||
|
# Bootstrap the cluster, start the first node
|
||||||
|
# that initiates the cluster
|
||||||
|
log_daemon_msg "Bootstrapping the cluster" "mysqld"
|
||||||
|
$SELF start "${@:2}" --wsrep-new-cluster
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
|
echo "Usage: $SELF start|stop|restart|reload|force-reload|status|bootstrap"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@@ -4,5 +4,15 @@ INSERT INTO t1 VALUES (1);
|
|||||||
SELECT COUNT(*) = 1 FROM t1;
|
SELECT COUNT(*) = 1 FROM t1;
|
||||||
COUNT(*) = 1
|
COUNT(*) = 1
|
||||||
1
|
1
|
||||||
|
CREATE USER foo@localhost;
|
||||||
|
# Open connection to node 2 using 'foo' user.
|
||||||
|
|
||||||
|
# Connect with foo_node_2
|
||||||
|
INSERT INTO t1 VALUES (2);
|
||||||
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||||
|
SELECT COUNT(*) = 1 FROM t1;
|
||||||
|
COUNT(*) = 1
|
||||||
|
1
|
||||||
SET GLOBAL read_only=FALSE;
|
SET GLOBAL read_only=FALSE;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
DROP USER foo@localhost;
|
||||||
|
@@ -17,7 +17,23 @@ INSERT INTO t1 VALUES (1);
|
|||||||
--connection node_2
|
--connection node_2
|
||||||
SELECT COUNT(*) = 1 FROM t1;
|
SELECT COUNT(*) = 1 FROM t1;
|
||||||
|
|
||||||
|
CREATE USER foo@localhost;
|
||||||
|
|
||||||
|
--echo # Open connection to node 2 using 'foo' user.
|
||||||
|
--let $port_2= \$NODE_MYPORT_2
|
||||||
|
--connect(foo_node_2,127.0.0.1,foo,,test,$port_2,)
|
||||||
|
|
||||||
|
--echo
|
||||||
|
--echo # Connect with foo_node_2
|
||||||
|
--connection foo_node_2
|
||||||
|
--error ER_OPTION_PREVENTS_STATEMENT
|
||||||
|
INSERT INTO t1 VALUES (2);
|
||||||
|
|
||||||
|
--connection node_2
|
||||||
|
SELECT COUNT(*) = 1 FROM t1;
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
SET GLOBAL read_only=FALSE;
|
SET GLOBAL read_only=FALSE;
|
||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
DROP USER foo@localhost;
|
||||||
|
|
||||||
|
@@ -104,6 +104,7 @@ void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
|
|||||||
void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
||||||
size_t pre_alloc_size __attribute__((unused)))
|
size_t pre_alloc_size __attribute__((unused)))
|
||||||
{
|
{
|
||||||
|
DBUG_ENTER("reset_root_defaults");
|
||||||
DBUG_ASSERT(alloc_root_inited(mem_root));
|
DBUG_ASSERT(alloc_root_inited(mem_root));
|
||||||
|
|
||||||
mem_root->block_size= (((block_size - ALLOC_ROOT_MIN_BLOCK_SIZE) & ~1) |
|
mem_root->block_size= (((block_size - ALLOC_ROOT_MIN_BLOCK_SIZE) & ~1) |
|
||||||
@@ -126,7 +127,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
|||||||
{
|
{
|
||||||
/* We found a suitable block, no need to do anything else */
|
/* We found a suitable block, no need to do anything else */
|
||||||
mem_root->pre_alloc= mem;
|
mem_root->pre_alloc= mem;
|
||||||
return;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
if (mem->left + ALIGN_SIZE(sizeof(USED_MEM)) == mem->size)
|
if (mem->left + ALIGN_SIZE(sizeof(USED_MEM)) == mem->size)
|
||||||
{
|
{
|
||||||
@@ -156,6 +157,8 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
mem_root->pre_alloc= 0;
|
mem_root->pre_alloc= 0;
|
||||||
|
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -5104,6 +5104,39 @@ static int init_server_components()
|
|||||||
}
|
}
|
||||||
plugins_are_initialized= TRUE; /* Don't separate from init function */
|
plugins_are_initialized= TRUE; /* Don't separate from init function */
|
||||||
|
|
||||||
|
#ifdef WITH_WSREP
|
||||||
|
/* Wait for wsrep threads to get created. */
|
||||||
|
if (wsrep_creating_startup_threads == 1) {
|
||||||
|
mysql_mutex_lock(&LOCK_thread_count);
|
||||||
|
while (wsrep_running_threads < 2)
|
||||||
|
{
|
||||||
|
mysql_cond_wait(&COND_thread_count, &LOCK_thread_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now is the time to initialize threads for queries. */
|
||||||
|
THD *tmp;
|
||||||
|
I_List_iterator<THD> it(threads);
|
||||||
|
while ((tmp= it++))
|
||||||
|
{
|
||||||
|
if (tmp->wsrep_applier == true)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Set THR_THD to temporally point to this THD to register all the
|
||||||
|
variables that allocates memory for this THD.
|
||||||
|
*/
|
||||||
|
THD *current_thd_saved= current_thd;
|
||||||
|
set_current_thd(tmp);
|
||||||
|
|
||||||
|
tmp->init_for_queries();
|
||||||
|
|
||||||
|
/* Restore current_thd. */
|
||||||
|
set_current_thd(current_thd_saved);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* we do want to exit if there are any other unknown options */
|
/* we do want to exit if there are any other unknown options */
|
||||||
if (remaining_argc > 1)
|
if (remaining_argc > 1)
|
||||||
{
|
{
|
||||||
@@ -5340,16 +5373,11 @@ pthread_handler_t start_wsrep_THD(void *arg)
|
|||||||
THD *thd;
|
THD *thd;
|
||||||
wsrep_thd_processor_fun processor= (wsrep_thd_processor_fun)arg;
|
wsrep_thd_processor_fun processor= (wsrep_thd_processor_fun)arg;
|
||||||
|
|
||||||
if (my_thread_init())
|
if (my_thread_init() || (!(thd= new THD(true))))
|
||||||
{
|
{
|
||||||
WSREP_ERROR("Could not initialize thread");
|
goto error;
|
||||||
return(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(thd= new THD(true)))
|
|
||||||
{
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
mysql_mutex_lock(&LOCK_thread_count);
|
mysql_mutex_lock(&LOCK_thread_count);
|
||||||
thd->thread_id=thread_id++;
|
thd->thread_id=thread_id++;
|
||||||
|
|
||||||
@@ -5374,13 +5402,13 @@ pthread_handler_t start_wsrep_THD(void *arg)
|
|||||||
|
|
||||||
mysql_thread_set_psi_id(thd->thread_id);
|
mysql_thread_set_psi_id(thd->thread_id);
|
||||||
thd->thr_create_utime= microsecond_interval_timer();
|
thd->thr_create_utime= microsecond_interval_timer();
|
||||||
|
|
||||||
if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0))
|
if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0))
|
||||||
{
|
{
|
||||||
close_connection(thd, ER_OUT_OF_RESOURCES);
|
close_connection(thd, ER_OUT_OF_RESOURCES);
|
||||||
statistic_increment(aborted_connects,&LOCK_status);
|
statistic_increment(aborted_connects,&LOCK_status);
|
||||||
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
|
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
|
||||||
|
goto error;
|
||||||
return(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// </5.1.17>
|
// </5.1.17>
|
||||||
@@ -5403,8 +5431,7 @@ pthread_handler_t start_wsrep_THD(void *arg)
|
|||||||
statistic_increment(aborted_connects,&LOCK_status);
|
statistic_increment(aborted_connects,&LOCK_status);
|
||||||
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
|
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
|
||||||
delete thd;
|
delete thd;
|
||||||
|
goto error;
|
||||||
return(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
thd->system_thread= SYSTEM_THREAD_SLAVE_SQL;
|
thd->system_thread= SYSTEM_THREAD_SLAVE_SQL;
|
||||||
@@ -5414,12 +5441,21 @@ pthread_handler_t start_wsrep_THD(void *arg)
|
|||||||
//thd->version= refresh_version;
|
//thd->version= refresh_version;
|
||||||
thd->proc_info= 0;
|
thd->proc_info= 0;
|
||||||
thd->set_command(COM_SLEEP);
|
thd->set_command(COM_SLEEP);
|
||||||
thd->set_time();
|
|
||||||
thd->init_for_queries();
|
if (wsrep_creating_startup_threads == 0)
|
||||||
|
{
|
||||||
|
thd->init_for_queries();
|
||||||
|
}
|
||||||
|
|
||||||
mysql_mutex_lock(&LOCK_thread_count);
|
mysql_mutex_lock(&LOCK_thread_count);
|
||||||
wsrep_running_threads++;
|
wsrep_running_threads++;
|
||||||
mysql_cond_broadcast(&COND_thread_count);
|
mysql_cond_broadcast(&COND_thread_count);
|
||||||
|
|
||||||
|
if (wsrep_running_threads > 2)
|
||||||
|
{
|
||||||
|
wsrep_creating_startup_threads= 0;
|
||||||
|
}
|
||||||
|
|
||||||
mysql_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
|
|
||||||
processor(thd);
|
processor(thd);
|
||||||
@@ -5457,6 +5493,15 @@ pthread_handler_t start_wsrep_THD(void *arg)
|
|||||||
mysql_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
}
|
}
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
|
error:
|
||||||
|
WSREP_ERROR("Failed to create/initialize system thread");
|
||||||
|
|
||||||
|
/* Abort if its the first applier/rollbacker thread. */
|
||||||
|
if (wsrep_creating_startup_threads < 2)
|
||||||
|
unireg_abort(1);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1199,22 +1199,6 @@ static my_bool deny_updates_if_read_only_option(THD *thd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
static my_bool wsrep_read_only_option(THD *thd, TABLE_LIST *all_tables)
|
|
||||||
{
|
|
||||||
int opt_readonly_saved = opt_readonly;
|
|
||||||
ulong flag_saved = (ulong)(thd->security_ctx->master_access & SUPER_ACL);
|
|
||||||
|
|
||||||
opt_readonly = 0;
|
|
||||||
thd->security_ctx->master_access &= ~SUPER_ACL;
|
|
||||||
|
|
||||||
my_bool ret = !deny_updates_if_read_only_option(thd, all_tables);
|
|
||||||
|
|
||||||
opt_readonly = opt_readonly_saved;
|
|
||||||
thd->security_ctx->master_access |= flag_saved;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wsrep_copy_query(THD *thd)
|
static void wsrep_copy_query(THD *thd)
|
||||||
{
|
{
|
||||||
thd->wsrep_retry_command = thd->get_command();
|
thd->wsrep_retry_command = thd->get_command();
|
||||||
@@ -1228,6 +1212,7 @@ static void wsrep_copy_query(THD *thd)
|
|||||||
thd->wsrep_retry_query[thd->wsrep_retry_query_len] = '\0';
|
thd->wsrep_retry_query[thd->wsrep_retry_query_len] = '\0';
|
||||||
}
|
}
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perform one connection-level (COM_XXXX) command.
|
Perform one connection-level (COM_XXXX) command.
|
||||||
|
|
||||||
@@ -6989,8 +6974,7 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
|
|||||||
bool is_autocommit=
|
bool is_autocommit=
|
||||||
!thd->in_multi_stmt_transaction_mode() &&
|
!thd->in_multi_stmt_transaction_mode() &&
|
||||||
thd->wsrep_conflict_state == NO_CONFLICT &&
|
thd->wsrep_conflict_state == NO_CONFLICT &&
|
||||||
!thd->wsrep_applier &&
|
!thd->wsrep_applier;
|
||||||
wsrep_read_only_option(thd, thd->lex->query_tables);
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@@ -71,6 +71,13 @@ my_bool wsrep_restart_slave_activated = 0; // node has dropped, and slave
|
|||||||
// restart will be needed
|
// restart will be needed
|
||||||
my_bool wsrep_slave_UK_checks = 0; // slave thread does UK checks
|
my_bool wsrep_slave_UK_checks = 0; // slave thread does UK checks
|
||||||
my_bool wsrep_slave_FK_checks = 0; // slave thread does FK checks
|
my_bool wsrep_slave_FK_checks = 0; // slave thread does FK checks
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set during the creation of first wsrep applier and rollback threads.
|
||||||
|
Since these threads are critical, abort if the thread creation fails.
|
||||||
|
*/
|
||||||
|
my_bool wsrep_creating_startup_threads = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End configuration options
|
* End configuration options
|
||||||
*/
|
*/
|
||||||
@@ -671,6 +678,7 @@ void wsrep_init_startup (bool first)
|
|||||||
|
|
||||||
if (!wsrep_start_replication()) unireg_abort(1);
|
if (!wsrep_start_replication()) unireg_abort(1);
|
||||||
|
|
||||||
|
wsrep_creating_startup_threads= 1;
|
||||||
wsrep_create_rollbacker();
|
wsrep_create_rollbacker();
|
||||||
wsrep_create_appliers(1);
|
wsrep_create_appliers(1);
|
||||||
|
|
||||||
|
@@ -107,6 +107,7 @@ extern my_bool wsrep_restart_slave_activated;
|
|||||||
extern my_bool wsrep_slave_FK_checks;
|
extern my_bool wsrep_slave_FK_checks;
|
||||||
extern my_bool wsrep_slave_UK_checks;
|
extern my_bool wsrep_slave_UK_checks;
|
||||||
extern bool wsrep_new_cluster; // bootstrap the cluster ?
|
extern bool wsrep_new_cluster; // bootstrap the cluster ?
|
||||||
|
extern my_bool wsrep_creating_startup_threads;
|
||||||
|
|
||||||
enum enum_wsrep_OSU_method {
|
enum enum_wsrep_OSU_method {
|
||||||
WSREP_OSU_TOI,
|
WSREP_OSU_TOI,
|
||||||
|
@@ -25,6 +25,14 @@
|
|||||||
# Description: MySQL is a very fast and reliable SQL database engine.
|
# Description: MySQL is a very fast and reliable SQL database engine.
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Prevent OpenSUSE's init scripts from calling systemd, so that
|
||||||
|
# both 'bootstrap' and 'start' are handled entirely within this
|
||||||
|
# script
|
||||||
|
SYSTEMD_NO_WRAP=1
|
||||||
|
|
||||||
|
# Prevent Debian's init scripts from calling systemctl
|
||||||
|
_SYSTEMCTL_SKIP_REDIRECT=true
|
||||||
|
|
||||||
# If you install MySQL on some other places than @prefix@, then you
|
# If you install MySQL on some other places than @prefix@, then you
|
||||||
# have to do one of the following things for this script to work:
|
# have to do one of the following things for this script to work:
|
||||||
#
|
#
|
||||||
|
Reference in New Issue
Block a user