summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/wsrep.cmake2
-rw-r--r--debian/mariadb-server-10.1.mysql.init12
-rw-r--r--mysql-test/include/wait_condition.inc1
-rw-r--r--mysql-test/lib/mtr_cases.pm2
-rwxr-xr-xmysql-test/mysql-test-run.pl16
-rw-r--r--mysql-test/std_data/binlog-header.logbin0 -> 120 bytes
-rw-r--r--mysql-test/std_data/galera-cert.pem6
-rw-r--r--mysql-test/std_data/galera-upgrade-ca-cert.pem40
-rw-r--r--mysql-test/std_data/galera-upgrade-server-cert.pem20
-rw-r--r--mysql-test/std_data/galera-upgrade-server-key.pem28
-rw-r--r--mysql-test/suite/galera/disabled.def8
-rw-r--r--mysql-test/suite/galera/galera_2nodes_as_slave.cnf12
-rw-r--r--mysql-test/suite/galera/galera_3nodes_as_slave.cnf91
-rw-r--r--mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc5
-rw-r--r--mysql-test/suite/galera/include/kill_galera.inc1
-rw-r--r--mysql-test/suite/galera/r/galera_applier_ftwrl_table.result15
-rw-r--r--mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result26
-rw-r--r--mysql-test/suite/galera/r/galera_as_slave.result1
-rw-r--r--mysql-test/suite/galera/r/galera_as_slave_nonprim.result20
-rw-r--r--mysql-test/suite/galera/r/galera_as_slave_preordered.result19
-rw-r--r--mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result15
-rw-r--r--mysql-test/suite/galera/r/galera_autoinc_sst_xtrabackup.result36
-rw-r--r--mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result14
-rw-r--r--mysql-test/suite/galera/r/galera_bf_abort_lock_table.result6
-rw-r--r--mysql-test/suite/galera/r/galera_drop_multi.result20
-rw-r--r--mysql-test/suite/galera/r/galera_flush.result22
-rw-r--r--mysql-test/suite/galera/r/galera_forced_binlog_format.result18
-rw-r--r--mysql-test/suite/galera/r/galera_ftwrl_drain.result24
-rw-r--r--mysql-test/suite/galera/r/galera_fulltext.result10
-rw-r--r--mysql-test/suite/galera/r/galera_gcs_fc_limit.result6
-rw-r--r--mysql-test/suite/galera/r/galera_gra_log.result41
-rw-r--r--mysql-test/suite/galera/r/galera_ist_mysqldump.result4
-rw-r--r--mysql-test/suite/galera/r/galera_kill_applier.result4
-rw-r--r--mysql-test/suite/galera/r/galera_many_rows.result19
-rw-r--r--mysql-test/suite/galera/r/galera_migrate.result6
-rw-r--r--mysql-test/suite/galera/r/galera_parallel_simple.result14
-rw-r--r--mysql-test/suite/galera/r/galera_prepared_statement.result33
-rw-r--r--mysql-test/suite/galera/r/galera_read_only.result10
-rw-r--r--mysql-test/suite/galera/r/galera_serializable.result27
-rw-r--r--mysql-test/suite/galera/r/galera_ssl_compression.result22
-rw-r--r--mysql-test/suite/galera/r/galera_ssl_upgrade.result24
-rw-r--r--mysql-test/suite/galera/r/galera_sst_mysqldump.result4
-rw-r--r--mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result106
-rw-r--r--mysql-test/suite/galera/r/galera_sst_xtrabackup-v2-options.result3
-rw-r--r--mysql-test/suite/galera/r/galera_sst_xtrabackup-v2_encrypt_with_key.result3
-rw-r--r--mysql-test/suite/galera/r/galera_status_local_index.result13
-rw-r--r--mysql-test/suite/galera/r/galera_transaction_replay.result4
-rw-r--r--mysql-test/suite/galera/r/galera_var_log_bin.result10
-rw-r--r--mysql-test/suite/galera/r/galera_var_node_address.result9
-rw-r--r--mysql-test/suite/galera/r/galera_var_slave_threads.result8
-rw-r--r--mysql-test/suite/galera/r/galera_wan_restart_ist.result53
-rw-r--r--mysql-test/suite/galera/r/galera_wan_restart_sst.result54
-rw-r--r--mysql-test/suite/galera/r/lp1438990.result21
-rw-r--r--mysql-test/suite/galera/r/mysql-wsrep#110.result38
-rw-r--r--mysql-test/suite/galera/r/mysql-wsrep#33.result4
-rw-r--r--mysql-test/suite/galera/r/mysql-wsrep#90.result31
-rw-r--r--mysql-test/suite/galera/suite.pm4
-rw-r--r--mysql-test/suite/galera/t/galera_applier_ftwrl_table.test34
-rw-r--r--mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter-master.opt1
-rw-r--r--mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test37
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave.test3
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_nonprim.cnf1
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_nonprim.test96
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_preordered.cnf3
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_preordered.test84
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf4
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test48
-rw-r--r--mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.cnf13
-rw-r--r--mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.test95
-rw-r--r--mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test40
-rw-r--r--mysql-test/suite/galera/t/galera_bf_abort_lock_table.test23
-rw-r--r--mysql-test/suite/galera/t/galera_binlog_event_max_size_max.test1
-rw-r--r--mysql-test/suite/galera/t/galera_drop_multi.test41
-rw-r--r--mysql-test/suite/galera/t/galera_flush.test68
-rw-r--r--mysql-test/suite/galera/t/galera_forced_binlog_format-master.opt1
-rw-r--r--mysql-test/suite/galera/t/galera_forced_binlog_format.test25
-rw-r--r--mysql-test/suite/galera/t/galera_ftwrl.test7
-rw-r--r--mysql-test/suite/galera/t/galera_ftwrl_drain.test68
-rw-r--r--mysql-test/suite/galera/t/galera_fulltext.test8
-rw-r--r--mysql-test/suite/galera/t/galera_gcs_fc_limit.test8
-rw-r--r--mysql-test/suite/galera/t/galera_gcs_max_packet_size.test1
-rw-r--r--mysql-test/suite/galera/t/galera_gra_log.test38
-rw-r--r--mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf2
-rw-r--r--mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.cnf1
-rw-r--r--mysql-test/suite/galera/t/galera_kill_applier.test26
-rw-r--r--mysql-test/suite/galera/t/galera_many_rows.test29
-rw-r--r--mysql-test/suite/galera/t/galera_migrate.test6
-rw-r--r--mysql-test/suite/galera/t/galera_parallel_autoinc_largetrx.test1
-rw-r--r--mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test1
-rw-r--r--mysql-test/suite/galera/t/galera_parallel_simple.test6
-rw-r--r--mysql-test/suite/galera/t/galera_prepared_statement.test45
-rw-r--r--mysql-test/suite/galera/t/galera_read_only.test18
-rw-r--r--mysql-test/suite/galera/t/galera_restart_nochanges.test1
-rw-r--r--mysql-test/suite/galera/t/galera_serializable.test76
-rw-r--r--mysql-test/suite/galera/t/galera_split_brain.test2
-rw-r--r--mysql-test/suite/galera/t/galera_ssl_compression.cnf7
-rw-r--r--mysql-test/suite/galera/t/galera_ssl_compression.test34
-rw-r--r--mysql-test/suite/galera/t/galera_ssl_upgrade.cnf7
-rw-r--r--mysql-test/suite/galera/t/galera_ssl_upgrade.test46
-rw-r--r--mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf22
-rw-r--r--mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test22
-rw-r--r--mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.cnf24
-rw-r--r--mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.test13
-rw-r--r--mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.cnf11
-rw-r--r--mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.test13
-rw-r--r--mysql-test/suite/galera/t/galera_status_local_index.test21
-rw-r--r--mysql-test/suite/galera/t/galera_transaction_replay.test14
-rw-r--r--mysql-test/suite/galera/t/galera_var_load_data_splitting.test1
-rw-r--r--mysql-test/suite/galera/t/galera_var_log_bin.cnf5
-rw-r--r--mysql-test/suite/galera/t/galera_var_log_bin.test22
-rw-r--r--mysql-test/suite/galera/t/galera_var_node_address.cnf10
-rw-r--r--mysql-test/suite/galera/t/galera_var_node_address.test22
-rw-r--r--mysql-test/suite/galera/t/galera_var_slave_threads.test14
-rw-r--r--mysql-test/suite/galera/t/galera_wan_restart_ist.cnf14
-rw-r--r--mysql-test/suite/galera/t/galera_wan_restart_ist.test148
-rw-r--r--mysql-test/suite/galera/t/galera_wan_restart_sst.cnf14
-rw-r--r--mysql-test/suite/galera/t/galera_wan_restart_sst.test149
-rw-r--r--mysql-test/suite/galera/t/lp1438990.test38
-rw-r--r--mysql-test/suite/galera/t/mysql-wsrep#110.test51
-rw-r--r--mysql-test/suite/galera/t/mysql-wsrep#90.test65
-rw-r--r--mysql-test/suite/galera_3nodes/disabled.def3
-rw-r--r--mysql-test/suite/galera_3nodes/r/galera_garbd.result3
-rw-r--r--mysql-test/suite/galera_3nodes/r/galera_innobackupex_backup.result11
-rw-r--r--mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result29
-rw-r--r--mysql-test/suite/galera_3nodes/r/galera_pc_weight.result7
-rw-r--r--mysql-test/suite/galera_3nodes/r/galera_slave_options_do.result28
-rw-r--r--mysql-test/suite/galera_3nodes/r/galera_slave_options_ignore.result28
-rw-r--r--mysql-test/suite/galera_3nodes/suite.pm1
-rw-r--r--mysql-test/suite/galera_3nodes/t/galera_garbd.test14
-rw-r--r--mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test58
-rw-r--r--mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test90
-rw-r--r--mysql-test/suite/galera_3nodes/t/galera_pc_weight.test17
-rw-r--r--mysql-test/suite/galera_3nodes/t/galera_slave_options_do.cnf7
-rw-r--r--mysql-test/suite/galera_3nodes/t/galera_slave_options_do.test34
-rw-r--r--mysql-test/suite/galera_3nodes/t/galera_slave_options_ignore.cnf7
-rw-r--r--mysql-test/suite/galera_3nodes/t/galera_slave_options_ignore.test34
-rw-r--r--mysql-test/suite/jp/disabled.def2
-rw-r--r--mysql-test/suite/rpl/r/mysql-wsrep#110-2.result24
-rw-r--r--mysql-test/suite/rpl/t/mysql-wsrep#110-2.test44
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_wsrep.result2
-rw-r--r--mysql-test/suite/sys_vars/r/wsrep_desync_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/t/wsrep_desync_basic.test2
-rw-r--r--mysql-test/valgrind.supp363
-rw-r--r--scripts/wsrep_sst_common.sh42
-rw-r--r--scripts/wsrep_sst_mysqldump.sh45
-rw-r--r--scripts/wsrep_sst_rsync.sh17
-rw-r--r--scripts/wsrep_sst_xtrabackup-v2.sh297
-rw-r--r--scripts/wsrep_sst_xtrabackup.sh20
-rw-r--r--sql/events.cc3
-rw-r--r--sql/mdl.cc20
-rw-r--r--sql/mdl.h2
-rw-r--r--sql/slave.cc81
-rw-r--r--sql/sql_parse.cc20
-rw-r--r--sql/sql_partition_admin.cc23
-rw-r--r--sql/wsrep_hton.cc18
-rw-r--r--sql/wsrep_mysqld.cc96
-rw-r--r--sql/wsrep_mysqld.h3
-rw-r--r--sql/wsrep_notify.cc2
-rw-r--r--sql/wsrep_sst.cc207
-rw-r--r--sql/wsrep_thd.cc12
-rw-r--r--sql/wsrep_utils.cc93
-rw-r--r--sql/wsrep_utils.h26
-rw-r--r--sql/wsrep_var.cc8
-rw-r--r--storage/innobase/handler/ha_innodb.cc53
-rw-r--r--storage/innobase/lock/lock0lock.cc25
-rw-r--r--storage/xtradb/handler/ha_innodb.cc75
-rw-r--r--storage/xtradb/lock/lock0lock.cc25
-rw-r--r--support-files/mysql.server.sh8
168 files changed, 4353 insertions, 492 deletions
diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake
index 475125a9e4c..64266811811 100644
--- a/cmake/wsrep.cmake
+++ b/cmake/wsrep.cmake
@@ -26,7 +26,7 @@ ENDIF()
OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default})
# Set the patch version
-SET(WSREP_PATCH_VERSION "10")
+SET(WSREP_PATCH_VERSION "11")
# Obtain wsrep API version
FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/wsrep_api.h" WSREP_API_VERSION
diff --git a/debian/mariadb-server-10.1.mysql.init b/debian/mariadb-server-10.1.mysql.init
index d1975bcbca7..ca1848a500b 100644
--- a/debian/mariadb-server-10.1.mysql.init
+++ b/debian/mariadb-server-10.1.mysql.init
@@ -17,6 +17,9 @@ set -e
set -u
${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
. /lib/lsb/init-functions
@@ -179,8 +182,15 @@ case "${1:-''}" in
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
;;
esac
diff --git a/mysql-test/include/wait_condition.inc b/mysql-test/include/wait_condition.inc
index ac61b76db32..5fbde6950c8 100644
--- a/mysql-test/include/wait_condition.inc
+++ b/mysql-test/include/wait_condition.inc
@@ -39,6 +39,7 @@ let $wait_timeout= 0;
let $wait_condition_reps= 0;
while ($wait_counter)
{
+ --error 0,ER_NO_SUCH_TABLE,ER_LOCK_WAIT_TIMEOUT,ER_UNKNOWN_COM_ERROR
let $success= `$wait_condition`;
inc $wait_condition_reps;
if ($success)
diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm
index 60535a2009b..0537c9623fc 100644
--- a/mysql-test/lib/mtr_cases.pm
+++ b/mysql-test/lib/mtr_cases.pm
@@ -319,7 +319,7 @@ sub parse_disabled {
chomp;
next if /^\s*#/ or /^\s*$/;
mtr_error("Syntax error in $filename line $.")
- unless /^\s*(?:([-0-9A-Za-z_\/]+)\.)?([-0-9A-Za-z_]+)\s*:\s*(.*?)\s*$/;
+ unless /^\s*(?:([-0-9A-Za-z_\/]+)\.)?([-0-9A-Za-z_#]+)\s*:\s*(.*?)\s*$/;
mtr_error("Wrong suite name in $filename line $.")
if defined $1 and defined $suitename and $1 ne $suitename;
$disabled{($1 || $suitename || '') . ".$2"} = $3;
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 2435137db6d..c03232264cb 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -354,6 +354,7 @@ my $opt_max_save_datadir= env_or_val(MTR_MAX_SAVE_DATADIR => 20);
my $opt_max_test_fail= env_or_val(MTR_MAX_TEST_FAIL => 10);
my $opt_parallel= $ENV{MTR_PARALLEL} || 1;
+my $opt_port_group_size = $ENV{MTR_PORT_GROUP_SIZE} || 10;
# lock file to stop tests
my $opt_stop_file= $ENV{MTR_STOP_FILE};
@@ -1116,6 +1117,7 @@ sub command_line_setup {
# Specify ports
'build-thread|mtr-build-thread=i' => \$opt_build_thread,
'port-base|mtr-port-base=i' => \$opt_port_base,
+ 'port-group-size=s' => \$opt_port_group_size,
# Test case authoring
'record' => \$opt_record,
@@ -1806,16 +1808,16 @@ sub set_build_thread_ports($) {
$ENV{MTR_BUILD_THREAD}= $build_thread;
# Calculate baseport
- $baseport= $build_thread * 20 + 10000;
- if ( $baseport < 5001 or $baseport + 19 >= 32767 )
+ $baseport= $build_thread * $opt_port_group_size + 10000;
+ if ( $baseport < 5001 or $baseport + $opt_port_group_size >= 32767 )
{
mtr_error("MTR_BUILD_THREAD number results in a port",
"outside 5001 - 32767",
- "($baseport - $baseport + 19)");
+ "($baseport - $baseport + $opt_port_group_size)");
}
mtr_report("Using MTR_BUILD_THREAD $build_thread,",
- "with reserved ports $baseport..".($baseport+19));
+ "with reserved ports $baseport..".($baseport+($opt_port_group_size-1)));
}
@@ -2969,8 +2971,8 @@ sub kill_leftovers ($) {
sub check_ports_free ($)
{
my $bthread= shift;
- my $portbase = $bthread * 10 + 10000;
- for ($portbase..$portbase+9){
+ my $portbase = $bthread * $opt_port_group_size + 10000;
+ for ($portbase..$portbase+($opt_port_group_size-1)){
if (mtr_ping_port($_)){
mtr_report(" - 'localhost:$_' was not free");
return 0; # One port was not free
@@ -6066,6 +6068,8 @@ Options that specify ports
build-thread=# Can be set in environment variable MTR_BUILD_THREAD.
Set MTR_BUILD_THREAD="auto" to automatically aquire
a build thread id that is unique to current host
+ port-group-size=N Reserve groups of TCP ports of size N for each MTR thread
+
Options for test case authoring
diff --git a/mysql-test/std_data/binlog-header.log b/mysql-test/std_data/binlog-header.log
new file mode 100644
index 00000000000..c415a57e616
--- /dev/null
+++ b/mysql-test/std_data/binlog-header.log
Binary files differ
diff --git a/mysql-test/std_data/galera-cert.pem b/mysql-test/std_data/galera-cert.pem
index 3b48002f47a..2996b330cc0 100644
--- a/mysql-test/std_data/galera-cert.pem
+++ b/mysql-test/std_data/galera-cert.pem
@@ -18,3 +18,9 @@ wpjhYxVxGFOx1ITN3jED64lUfoLHvR6NFbESYKAuAAzSNqX4HOQ3uGk2THM8JocZ
oH2+38d81Kd4HQ7DDDKS/isG0+rR60Ti1cMgu7OT7p1dZCwT/KQuI5eGjE9lubkc
yAJjaod4rVLdBri3XVvtySfS2+/75qUgv2TF7d/s7mxMq4DDt29yeKSUhZCs
-----END CERTIFICATE-----
+-----BEGIN DH PARAMETERS-----
+MIGHAoGBAJWyvKjE+s7OP4Lj1jXKGlJGWT4Vd5YaxPljihTsRe1aXkWAgsuwISXk
+/TQ8Rx5Zmze7rtwtU0PoYxvuam9FMXYqhw2dVe4qRdeSX78DSiL/YBkQzaxlfWVy
+RE9+9dzHbCtRVDlN7K1kA+mGWH4/r7NAu4Qm/003V0NTtMwQSqebAgEC
+-----END DH PARAMETERS-----
+
diff --git a/mysql-test/std_data/galera-upgrade-ca-cert.pem b/mysql-test/std_data/galera-upgrade-ca-cert.pem
new file mode 100644
index 00000000000..13d27e84bb3
--- /dev/null
+++ b/mysql-test/std_data/galera-upgrade-ca-cert.pem
@@ -0,0 +1,40 @@
+-----BEGIN CERTIFICATE-----
+MIIDWTCCAkGgAwIBAgIJAIlW4JmZGnU4MA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNV
+BAYTAkZJMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQg
+Q29tcGFueSBMdGQwIBcNMTQxMDI0MDc1MTU1WhgPMzAxNDAyMjQwNzUxNTVaMEIx
+CzAJBgNVBAYTAkZJMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0Rl
+ZmF1bHQgQ29tcGFueSBMdGQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
+AQDDzU6xLZDD5rZENsOpTpTmqS8YisBaefU3ZeN7VJepZZ/7unM/1YLGJtuRh2Qa
+MyTkvyjzf7bSFsDt9L5lfQwBBblVeWkrCvGnQmHDQQYB7JrSmFDPz9W9Mxf9Q2BW
+B3lcoKXXJgMnWw0WGrt0lEdFp9gWbq8H9hwJdjpyyk4ZTIuucSOD4JUP3QFEhYU5
+kdcIbDRVw81J4eAZ6EdvbjDN05S7qWjW7rJTnCHAHEd18hcsMGwjpwhjEaSdhMrM
+mhOeL8kuQV0fI8v2xfYBliIn9xBZGOVzySPzwFmQceORlW6F3V5w6mwFkmuXqXWX
+Qo98swTu7mb89qVYmR71d3L3AgMBAAGjUDBOMB0GA1UdDgQWBBRdWet/kGNTyvXK
+wuBdP/eSldOgWjAfBgNVHSMEGDAWgBRdWet/kGNTyvXKwuBdP/eSldOgWjAMBgNV
+HRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQCcJpP+DR4AJxVelNTSZa+V38c+
+jgrMD2Ku2eU8NQlsjgMfNEU5Md/g7FpP8aCFzVf0kAAT7DxZmSE3uWXQbMXyVJmy
+bF+qXinf71QzdWULm6sASoshC6wbHnXL9ZjWQ3gh1nqVgo3MmLQYrb3eJfKaaLoc
+wpjhYxVxGFOx1ITN3jED64lUfoLHvR6NFbESYKAuAAzSNqX4HOQ3uGk2THM8JocZ
+oH2+38d81Kd4HQ7DDDKS/isG0+rR60Ti1cMgu7OT7p1dZCwT/KQuI5eGjE9lubkc
+yAJjaod4rVLdBri3XVvtySfS2+/75qUgv2TF7d/s7mxMq4DDt29yeKSUhZCs
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDVzCCAj+gAwIBAgIJALBO5bqmtlYkMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNV
+BAYTAkZJMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQg
+Q29tcGFueSBMdGQwHhcNMTUwNjI2MDcxMjQ1WhcNMjUwNTA0MDcxMjQ1WjBCMQsw
+CQYDVQQGEwJGSTEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRwwGgYDVQQKDBNEZWZh
+dWx0IENvbXBhbnkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
+1DlcztIzSngGeTUFibj9GZ4ZO78ASpgYySZv/DRIVn/3hbF41ZRD/6uJlb5rf1R7
+fpFsurbXNDDxeap7b/Gz2XSQy96Dbm0SbsFSZttV/R2WtlT1Wf5n9ix6RLqhKSbg
+nPyL2fsDaxtZh2uywGJEXhwXFtdx3deIo/tYivDfl5Tcsv0NnZY8Vg0boBRP+FEn
+ReJOdSa5LLn+QJN2Xa+wutbLHe0hI6huKUXU2YUeBfgyk1nWol5241ZUDCgDsoaW
+8r2YeJNHmNInd3wERbqFgFHsR4N1+Atcyrfn/uQSj9zrTPO/Pp51KpjWf/gjxjXP
+biu5De50qZ4+U4no20EIOwIDAQABo1AwTjAdBgNVHQ4EFgQU3kSPGchrOoQJ5gq1
+mmV2HEra6GswHwYDVR0jBBgwFoAU3kSPGchrOoQJ5gq1mmV2HEra6GswDAYDVR0T
+BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAfoBD64FJ9fAR19+vwueFGmpWNIqF
+PzN7QmEpCMduV3DXuxYO73q2ikXgrVO5HWFz9IjNvzXbSRmWNzJGaZ3QYZ+Xx1JJ
+8MrAOUr6djWuyD659f64dh/2jMxiQNoEHrknXm9HSqR5oJVwndFyr/zvSkYSRexE
+KFciIprb9LOba9G3ZMBYBdqK+f3Ky16BMjaD6XfaTx+xjHk/8peSueXIQl+v2biz
+zSfpEUa0dKCIxckrzD4JknDHFimTsrzlRftcg8t8piOXwZomFcnVunyGs2bJ/Npj
+25c2e6sx7XSc5bUgPGuQcSGflZPLg9zWyJ69sVYUNAz+gqfvWfOOJuzPNg==
+-----END CERTIFICATE-----
diff --git a/mysql-test/std_data/galera-upgrade-server-cert.pem b/mysql-test/std_data/galera-upgrade-server-cert.pem
new file mode 100644
index 00000000000..3af8b1ae7dd
--- /dev/null
+++ b/mysql-test/std_data/galera-upgrade-server-cert.pem
@@ -0,0 +1,20 @@
+-----BEGIN CERTIFICATE-----
+MIIDVzCCAj+gAwIBAgIJALBO5bqmtlYkMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNV
+BAYTAkZJMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQg
+Q29tcGFueSBMdGQwHhcNMTUwNjI2MDcxMjQ1WhcNMjUwNTA0MDcxMjQ1WjBCMQsw
+CQYDVQQGEwJGSTEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRwwGgYDVQQKDBNEZWZh
+dWx0IENvbXBhbnkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
+1DlcztIzSngGeTUFibj9GZ4ZO78ASpgYySZv/DRIVn/3hbF41ZRD/6uJlb5rf1R7
+fpFsurbXNDDxeap7b/Gz2XSQy96Dbm0SbsFSZttV/R2WtlT1Wf5n9ix6RLqhKSbg
+nPyL2fsDaxtZh2uywGJEXhwXFtdx3deIo/tYivDfl5Tcsv0NnZY8Vg0boBRP+FEn
+ReJOdSa5LLn+QJN2Xa+wutbLHe0hI6huKUXU2YUeBfgyk1nWol5241ZUDCgDsoaW
+8r2YeJNHmNInd3wERbqFgFHsR4N1+Atcyrfn/uQSj9zrTPO/Pp51KpjWf/gjxjXP
+biu5De50qZ4+U4no20EIOwIDAQABo1AwTjAdBgNVHQ4EFgQU3kSPGchrOoQJ5gq1
+mmV2HEra6GswHwYDVR0jBBgwFoAU3kSPGchrOoQJ5gq1mmV2HEra6GswDAYDVR0T
+BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAfoBD64FJ9fAR19+vwueFGmpWNIqF
+PzN7QmEpCMduV3DXuxYO73q2ikXgrVO5HWFz9IjNvzXbSRmWNzJGaZ3QYZ+Xx1JJ
+8MrAOUr6djWuyD659f64dh/2jMxiQNoEHrknXm9HSqR5oJVwndFyr/zvSkYSRexE
+KFciIprb9LOba9G3ZMBYBdqK+f3Ky16BMjaD6XfaTx+xjHk/8peSueXIQl+v2biz
+zSfpEUa0dKCIxckrzD4JknDHFimTsrzlRftcg8t8piOXwZomFcnVunyGs2bJ/Npj
+25c2e6sx7XSc5bUgPGuQcSGflZPLg9zWyJ69sVYUNAz+gqfvWfOOJuzPNg==
+-----END CERTIFICATE-----
diff --git a/mysql-test/std_data/galera-upgrade-server-key.pem b/mysql-test/std_data/galera-upgrade-server-key.pem
new file mode 100644
index 00000000000..d243c9e0381
--- /dev/null
+++ b/mysql-test/std_data/galera-upgrade-server-key.pem
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDUOVzO0jNKeAZ5
+NQWJuP0Znhk7vwBKmBjJJm/8NEhWf/eFsXjVlEP/q4mVvmt/VHt+kWy6ttc0MPF5
+qntv8bPZdJDL3oNubRJuwVJm21X9HZa2VPVZ/mf2LHpEuqEpJuCc/IvZ+wNrG1mH
+a7LAYkReHBcW13Hd14ij+1iK8N+XlNyy/Q2dljxWDRugFE/4USdF4k51Jrksuf5A
+k3Zdr7C61ssd7SEjqG4pRdTZhR4F+DKTWdaiXnbjVlQMKAOyhpbyvZh4k0eY0id3
+fARFuoWAUexHg3X4C1zKt+f+5BKP3OtM878+nnUqmNZ/+CPGNc9uK7kN7nSpnj5T
+iejbQQg7AgMBAAECggEBAJ4m7VG3db+uOGzFJY5fzEX1+qn6ibYNKJNmUJfrQmkr
+zgLUoc7QQehbJhnwoN1v0OQebZ+rOC7NtnZLpNdkkPmhk3JKLTnykIT3DnhWRftt
+vG2+XGUnYMQkmy1ywz0Omt6CmZnlJMQByrNPgBM8Z+SWHGLKRTHkOBCz82T/YjDr
+wqug1Yv6W0wMNM/cikgoBldVG7hABCJuShjffIbUgVysK3dEPNywNAC78neoGECm
+evPZOaIkWEr86SpAlwA6Yh+zTQZ03CXATcGonJdWJ015DvlKRv6QyRR0Q/Y1ONwb
+f115kll15MJBEspFdSyhlMcVJlwO8WMaZ2qIzlQZmdECgYEA//P469QzX00L/urK
+7IRvtSVu5CP/A/Wui90U4KoP7XgXIeExnEtzLVs1K7vjuzdpTyq+68XuC40gPcJW
+RvoX229m6gRV8nC53UiV71jM8IvkyEqFYT/gfZC9KQCMSRJLtVnDMpZ3gMxAY6/5
+p20o616Au8DKFFetQV0aD4Hj1/MCgYEA1ENV1WkgvN6yItB77E9kN/vbKLRh0hrg
+9xj0SmMXGYyDM9NpjbgbgJIZo3ukkBtp3kEY8P9JQZRcd1EcnnSrwTB7ChdInWkR
+m/LpIZBEMqNQbeu4QSzZYYS6z4tcGGx43aHqzzNBZdnQnqhYL1CvlLwhkgX6oQCo
+woXqyfMNKJkCgYEA63gD1NGPwWkcVBSlQxpDup8JeZE0Fux6++kUP+u0Y39LqLuH
+7IXtHBkAvY9JXv8HPvHQWw/og2/97VNQFFQYhqPiRgBfIX9bPpx8c4l6YQISI8GL
+G4CsglgZ7hK2/LJ8PAascWnD3xYJVqyaPNFMB90VCaW/Qx+2IKAKTaHtfskCgYBu
+1f5C4pMqrCpeTXj4Cvis1wE4PwB5QnnH7SrakOVl/N4huLn8O2948lEa8Zwbd4UP
+ffR1Gwh4iuzBjQQhpZBt30/QFBphv5RnVy7uzLMfsfF0hEqBFdcoubMGXqGnSzTN
+nhfLO9thQJxTzFnH0xzr0FTDOAYH/h0g/eZ8r0JmuQKBgQDjhXM+hJ3Pkwua+Fnl
+nZfY5MeSzkJki/9iwVo8rSDwmZS9Nsc83oZnddM7c2x63t+zYOAcMxsVCiByMDzo
+5IB781HWRBGcU8TnW1b0bAnZimjKp/qsZ/Szr38rvImqG8TjzbcSD7w0SpyRQ/Ot
+A7SZFkWYfem8/q/VImjU/CNbOQ==
+-----END PRIVATE KEY-----
diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def
index 9c38c1296fe..85d8614c91f 100644
--- a/mysql-test/suite/galera/disabled.def
+++ b/mysql-test/suite/galera/disabled.def
@@ -19,3 +19,11 @@ galera_var_auto_inc_control_on : Failing sporadically with content mismatch
galera_parallel_simple : Failing sporadically
galera_bf_abort : Failing sporadically
galera_log_output_csv : Failing sporadically
+galera_as_slave_preordered : wsrep-preordered is not available in MariaDB Galera cluster
+galera_forced_binlog_format : TODO: investigate
+galera_gra_log : TODO: investigate
+galera_as_slave_replication_bundle : TODO: investigate
+galera_ssl_upgrade : TODO: investigate
+mysql-wsrep#90 : TODO: investigate
+galera_flush : mysql-wsrep/issues/229
+galera_transaction_read_only : mysql-wsrep/issues/229
diff --git a/mysql-test/suite/galera/galera_2nodes_as_slave.cnf b/mysql-test/suite/galera/galera_2nodes_as_slave.cnf
index 4017f69b02f..6d71649c274 100644
--- a/mysql-test/suite/galera/galera_2nodes_as_slave.cnf
+++ b/mysql-test/suite/galera/galera_2nodes_as_slave.cnf
@@ -18,6 +18,10 @@ server-id=1
#sst_port=@OPT.port
wsrep-on=1
+
+log-bin
+log-slave-updates
+
innodb-autoinc-lock-mode=2
default-storage-engine=innodb
wsrep-provider=@ENV.WSREP_PROVIDER
@@ -38,6 +42,10 @@ server-id=2
#sst_port=@OPT.port
wsrep-on=1
+
+log-bin
+log-slave-updates
+
innodb-autoinc-lock-mode=2
default-storage-engine=innodb
wsrep-provider=@ENV.WSREP_PROVIDER
@@ -59,8 +67,8 @@ NODE_MYSOCK_1= @mysqld.1.socket
NODE_MYPORT_2= @mysqld.2.port
NODE_MYSOCK_2= @mysqld.2.socket
-NODE_MYPORT_3= @mysqld.2.port
-NODE_MYSOCK_3= @mysqld.2.socket
+NODE_MYPORT_3= @mysqld.3.port
+NODE_MYSOCK_3= @mysqld.3.socket
NODE_GALERAPORT_2= @mysqld.2.#galera_port
NODE_GALERAPORT_3= @mysqld.3.#galera_port
diff --git a/mysql-test/suite/galera/galera_3nodes_as_slave.cnf b/mysql-test/suite/galera/galera_3nodes_as_slave.cnf
new file mode 100644
index 00000000000..4f3fdb02045
--- /dev/null
+++ b/mysql-test/suite/galera/galera_3nodes_as_slave.cnf
@@ -0,0 +1,91 @@
+#
+# This .cnf file creates a setup with 1 standard MySQL server, followed by a 2-node Galera cluster
+#
+
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+
+[mysqld]
+log-slave-updates
+log-bin=mysqld-bin
+binlog-format=row
+
+[mysqld.1]
+server-id=1
+
+[mysqld.2]
+server-id=2
+
+wsrep_provider=@ENV.WSREP_PROVIDER
+wsrep_cluster_address='gcomm://'
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts=1;'
+
+# enforce read-committed characteristics across the cluster
+wsrep_causal_reads=ON
+wsrep_sync_wait = 7
+
+wsrep_node_address=127.0.0.1
+wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
+wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
+
+# Required for Galera
+innodb_autoinc_lock_mode=2
+
+innodb_flush_log_at_trx_commit=2
+
+[mysqld.3]
+wsrep_provider=@ENV.WSREP_PROVIDER
+wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port'
+wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;'
+
+# enforce read-committed characteristics across the cluster
+wsrep_causal_reads=ON
+wsrep_sync_wait = 7
+
+wsrep_node_address=127.0.0.1
+wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port
+wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port
+
+# Required for Galera
+innodb_autoinc_lock_mode=2
+
+innodb_flush_log_at_trx_commit=2
+
+[mysqld.4]
+wsrep_provider=@ENV.WSREP_PROVIDER
+wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port'
+wsrep_provider_options='base_port=@mysqld.4.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;'
+
+# enforce read-committed characteristics across the cluster
+wsrep_causal_reads=ON
+wsrep_sync_wait = 7
+
+wsrep_node_address=127.0.0.1
+wsrep_sst_receive_address=127.0.0.2:@mysqld.4.#sst_port
+wsrep_node_incoming_address=127.0.0.1:@mysqld.4.port
+
+# Required for Galera
+innodb_autoinc_lock_mode=2
+
+innodb_flush_log_at_trx_commit=2
+
+[ENV]
+NODE_MYPORT_1= @mysqld.1.port
+NODE_MYSOCK_1= @mysqld.1.socket
+
+NODE_MYPORT_2= @mysqld.2.port
+NODE_MYSOCK_2= @mysqld.2.socket
+
+NODE_MYPORT_3= @mysqld.3.port
+NODE_MYSOCK_3= @mysqld.3.socket
+
+NODE_MYPORT_3= @mysqld.4.port
+NODE_MYSOCK_3= @mysqld.4.socket
+
+NODE_GALERAPORT_2= @mysqld.2.#galera_port
+NODE_GALERAPORT_3= @mysqld.3.#galera_port
+NODE_GALERAPORT_4= @mysqld.4.#galera_port
+
+NODE_SSTPORT_2= @mysqld.2.#sst_port
+NODE_SSTPORT_3= @mysqld.3.#sst_port
+NODE_SSTPORT_4= @mysqld.4.#sst_port
diff --git a/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc b/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc
index 405c16ce4f1..5f87d23dcc1 100644
--- a/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc
+++ b/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc
@@ -6,12 +6,13 @@
--connection node_1
# We need a user with a password to perform SST, otherwise we hit LP #1378253
-GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst';
+GRANT ALL PRIVILEGES ON *.* TO 'sst';
--let $wsrep_sst_auth_orig = `SELECT @@wsrep_sst_auth`
-SET GLOBAL wsrep_sst_auth = 'sst:sst';
+SET GLOBAL wsrep_sst_auth = 'sst:';
--connection node_2
+--source include/wait_until_connected_again.inc
--let $wsrep_sst_method_orig = `SELECT @@wsrep_sst_method`
--let $wsrep_sst_receive_address_orig = `SELECT @@wsrep_sst_receive_address`
diff --git a/mysql-test/suite/galera/include/kill_galera.inc b/mysql-test/suite/galera/include/kill_galera.inc
index d7f665df6c7..c61bad8e19d 100644
--- a/mysql-test/suite/galera/include/kill_galera.inc
+++ b/mysql-test/suite/galera/include/kill_galera.inc
@@ -1,6 +1,7 @@
--echo Killing server ...
# Write file to make mysql-test-run.pl expect the crash, but don't start it
+--source include/wait_until_connected_again.inc
--let $_server_id= `SELECT @@server_id`
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
--exec echo "wait" > $_expect_file_name
diff --git a/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result b/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result
new file mode 100644
index 00000000000..cecbfc1f3cf
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result
@@ -0,0 +1,15 @@
+SET SESSION wsrep_sync_wait = 0;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+FLUSH TABLE t1 WITH READ LOCK;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+SET SESSION wsrep_sync_wait = 0;
+SELECT COUNT(*) = 0 FROM t1;
+COUNT(*) = 0
+1
+UNLOCK TABLES;
+SET SESSION wsrep_sync_wait = 7;
+SELECT COUNT(*) = 2 FROM t1;
+COUNT(*) = 2
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result b/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result
new file mode 100644
index 00000000000..ee967356c85
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result
@@ -0,0 +1,26 @@
+SET SESSION wsrep_sync_wait = 0;
+SET SESSION lock_wait_timeout = 60;
+SET SESSION innodb_lock_wait_timeout=60;
+SET SESSION wait_timeout=60;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+FLUSH TABLE t1 WITH READ LOCK;
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+SELECT 1 FROM DUAL;
+1
+1
+SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock';
+COUNT(*) = 1
+1
+UNLOCK TABLES;
+SET SESSION wsrep_sync_wait = 7;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock';
+COUNT(*) = 0
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_as_slave.result b/mysql-test/suite/galera/r/galera_as_slave.result
index 1e86afa35b7..2d7d689aa36 100644
--- a/mysql-test/suite/galera/r/galera_as_slave.result
+++ b/mysql-test/suite/galera/r/galera_as_slave.result
@@ -12,3 +12,4 @@ COUNT(*) = 3
DROP TABLE t1;
STOP SLAVE;
RESET SLAVE ALL;
+RESET MASTER;
diff --git a/mysql-test/suite/galera/r/galera_as_slave_nonprim.result b/mysql-test/suite/galera/r/galera_as_slave_nonprim.result
new file mode 100644
index 00000000000..ded3caecf89
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_as_slave_nonprim.result
@@ -0,0 +1,20 @@
+START SLAVE USER='root';
+Warnings:
+Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
+SET SESSION wsrep_sync_wait = 0;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
+expected_error
+1
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+START SLAVE;
+DROP TABLE t1;
+STOP SLAVE;
+RESET SLAVE ALL;
+CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query");
+CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047");
+CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)");
+CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed, 'Deadlock found when trying to get lock; try restarting transaction', Error_code: 1213");
+CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047");
+RESET MASTER;
diff --git a/mysql-test/suite/galera/r/galera_as_slave_preordered.result b/mysql-test/suite/galera/r/galera_as_slave_preordered.result
new file mode 100644
index 00000000000..27a08e73491
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_as_slave_preordered.result
@@ -0,0 +1,19 @@
+START SLAVE USER='root';
+Warnings:
+Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
+CREATE TABLE ten (f1 INTEGER);
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB;
+SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1;
+COUNT(DISTINCT f1) = 2 * 100 * 10 * 10
+1
+SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1;
+COUNT(*) = 2 * 100 * 10 * 10
+1
+SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1;
+COUNT(DISTINCT f1) = 2 * 100 * 10 * 10
+1
+DROP TABLE t1;
+DROP TABLE ten;
+STOP SLAVE;
+RESET SLAVE ALL;
diff --git a/mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result b/mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result
new file mode 100644
index 00000000000..a86bfd20e2f
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result
@@ -0,0 +1,15 @@
+START SLAVE USER='root';
+Warnings:
+Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+INSERT INTO t1 VALUES(4);
+INSERT INTO t1 VALUES(5);
+SELECT COUNT(*) = 4 FROM t1;
+COUNT(*) = 4
+1
+DROP TABLE t1;
+STOP SLAVE;
+RESET SLAVE ALL;
diff --git a/mysql-test/suite/galera/r/galera_autoinc_sst_xtrabackup.result b/mysql-test/suite/galera/r/galera_autoinc_sst_xtrabackup.result
new file mode 100644
index 00000000000..228d7c6f041
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_autoinc_sst_xtrabackup.result
@@ -0,0 +1,36 @@
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+CREATE PROCEDURE p1 ()
+BEGIN
+DECLARE x INT DEFAULT 1;
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+WHILE 1 DO
+INSERT INTO t1 VALUES (DEFAULT);
+COMMIT;
+END WHILE;
+END|
+CALL p1();;
+CALL p1();;
+Killing server ...
+INSERT INTO t1 VALUES (DEFAULT);
+INSERT INTO t1 VALUES (DEFAULT);
+Got one of the listed errors
+Got one of the listed errors
+count_equal
+1
+CALL mtr.add_suppression("WSREP: Action message in non-primary configuration from member 0");
+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE
+2
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 2
+1
+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE
+2
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 2
+1
+DROP PROCEDURE p1;
+DROP TABLE t1;
+CALL mtr.add_suppression("gcs_caused\\(\\) returned -1 \\(Operation not permitted\\)");
+CALL mtr.add_suppression("WSREP: Action message in non-primary configuration from member 0");
diff --git a/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result
new file mode 100644
index 00000000000..8c07d87eec3
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result
@@ -0,0 +1,14 @@
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF;
+FLUSH TABLES t1 FOR EXPORT;
+INSERT INTO t1 VALUES (2);
+SET SESSION wsrep_sync_wait = 0;
+UNLOCK TABLES;
+COMMIT;
+SET AUTOCOMMIT=ON;
+SELECT * FROM t1;
+f1
+2
+wsrep_local_aborts_increment
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_bf_abort_lock_table.result b/mysql-test/suite/galera/r/galera_bf_abort_lock_table.result
index e657e724a8b..7510e48ee83 100644
--- a/mysql-test/suite/galera/r/galera_bf_abort_lock_table.result
+++ b/mysql-test/suite/galera/r/galera_bf_abort_lock_table.result
@@ -1,8 +1,12 @@
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
SET AUTOCOMMIT=OFF;
LOCK TABLE t1 WRITE;
-INSERT INTO t1 VALUES (1);;
INSERT INTO t1 VALUES (2);
+UNLOCK TABLES;
+COMMIT;
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
wsrep_local_aborts_increment
1
DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_drop_multi.result b/mysql-test/suite/galera/r/galera_drop_multi.result
new file mode 100644
index 00000000000..d82ae3bec1a
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_drop_multi.result
@@ -0,0 +1,20 @@
+CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=MyISAM;
+CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB;
+CREATE TEMPORARY TABLE t4 (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE t5 (f1 INTEGER);
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+DROP TABLE t1, t2, t3, t4;
+INSERT INTO t5 VALUES (1);
+COMMIT;
+SHOW CREATE TABLE t1;
+ERROR 42S02: Table 'test.t1' doesn't exist
+SHOW CREATE TABLE t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
+SHOW CREATE TABLE t3;
+ERROR 42S02: Table 'test.t3' doesn't exist
+SHOW CREATE TABLE t4;
+ERROR 42S02: Table 'test.t4' doesn't exist
+CALL mtr.add_suppression("Slave SQL: Error 'Unknown table 'test.t2,test.t4'' on query\. Default database: 'test'\. Query: 'DROP TABLE t1, t2, t3, t4', Error_code: 1051");
+DROP TABLE t5;
diff --git a/mysql-test/suite/galera/r/galera_flush.result b/mysql-test/suite/galera/r/galera_flush.result
index c5e47c29324..8ff32fdfff4 100644
--- a/mysql-test/suite/galera/r/galera_flush.result
+++ b/mysql-test/suite/galera/r/galera_flush.result
@@ -19,6 +19,13 @@ wsrep_last_committed_diff
FLUSH USER_RESOURCES;
wsrep_last_committed_diff
1
+FLUSH TABLES;
+wsrep_last_committed_diff
+1
+CREATE TABLE t2 (f1 INTEGER);
+FLUSH TABLES t2;
+wsrep_last_committed_diff
+1
CREATE TABLE t1 (f1 INTEGER);
FLUSH LOGS;
FLUSH TABLES WITH READ LOCK;
@@ -29,4 +36,19 @@ FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
wsrep_last_committed_diff
1
+LOCK TABLES t1 WRITE;
+FLUSH TABLES t1;
+UNLOCK TABLES;
+wsrep_last_committed_diff
+1
+LOCK TABLES t1 READ;
+FLUSH TABLES t1;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+UNLOCK TABLES;
+wsrep_last_committed_diff
+1
+FLUSH TABLES t1;
+wsrep_last_committed_diff
+1
DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/suite/galera/r/galera_forced_binlog_format.result b/mysql-test/suite/galera/r/galera_forced_binlog_format.result
new file mode 100644
index 00000000000..857e44d2dfc
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_forced_binlog_format.result
@@ -0,0 +1,18 @@
+RESET MASTER;
+SET SESSION binlog_format = 'STATEMENT';
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+SET SESSION binlog_format = 'MIXED';
+INSERT INTO t1 VALUES (2);
+SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120;
+Log_name Pos Event_type Server_id End_log_pos Info
+mysqld-bin.000001 <Pos> Query 1 <End_log_pos> use `test`; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB
+mysqld-bin.000001 <Pos> Query 1 <End_log_pos> BEGIN
+mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1)
+mysqld-bin.000001 <Pos> Write_rows 1 <End_log_pos> table_id: ### flags: STMT_END_F
+mysqld-bin.000001 <Pos> Xid 1 <End_log_pos> COMMIT /* xid=### */
+mysqld-bin.000001 <Pos> Query 1 <End_log_pos> BEGIN
+mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1)
+mysqld-bin.000001 <Pos> Write_rows 1 <End_log_pos> table_id: ### flags: STMT_END_F
+mysqld-bin.000001 <Pos> Xid 1 <End_log_pos> COMMIT /* xid=### */
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_ftwrl_drain.result b/mysql-test/suite/galera/r/galera_ftwrl_drain.result
new file mode 100644
index 00000000000..a4879838d11
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_ftwrl_drain.result
@@ -0,0 +1,24 @@
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync';
+INSERT INTO t1 VALUES (1);
+SET SESSION wsrep_sync_wait = 0;
+SELECT COUNT(*) = 0 FROM t1;
+COUNT(*) = 0
+1
+FLUSH TABLES WITH READ LOCK;;
+SET GLOBAL wsrep_provider_options = 'dbug=';
+SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync';
+SET SESSION lock_wait_timeout = 1;
+SET SESSION innodb_lock_wait_timeout=1;
+SET SESSION wait_timeout=1;
+INSERT INTO t2 VALUES (2);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UNLOCK TABLES;
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
+INSERT INTO t1 VALUES (3);
+SELECT COUNT(*) = 2 FROM t1;
+COUNT(*) = 2
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_fulltext.result b/mysql-test/suite/galera/r/galera_fulltext.result
index 72577695202..84ae0a116a1 100644
--- a/mysql-test/suite/galera/r/galera_fulltext.result
+++ b/mysql-test/suite/galera/r/galera_fulltext.result
@@ -4,13 +4,13 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 VARCHAR(100), FULLTEXT (f
SELECT COUNT(*) = 13 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name LIKE 'test/%';
COUNT(*) = 13
1
-INSERT INTO t1 (f2) SELECT 'foobarbaz' FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
-SELECT COUNT(f2) = 10000 FROM t1 WHERE MATCH(f2) AGAINST ('foobarbaz');
-COUNT(f2) = 10000
+INSERT INTO t1 (f2) SELECT 'foobarbaz' FROM ten AS a1, ten AS a2, ten AS a3;
+SELECT COUNT(f2) = 1000 FROM t1 WHERE MATCH(f2) AGAINST ('foobarbaz');
+COUNT(f2) = 1000
1
UPDATE t1 SET f2 = 'abcdefjhk';
-SELECT COUNT(f2) = 10000 FROM t1 WHERE MATCH(f2) AGAINST ('abcdefjhk');
-COUNT(f2) = 10000
+SELECT COUNT(f2) = 1000 FROM t1 WHERE MATCH(f2) AGAINST ('abcdefjhk');
+COUNT(f2) = 1000
1
DROP TABLE t1;
CREATE TABLE t1 (f1 VARCHAR(100), FULLTEXT (f1)) ENGINE=InnoDB;
diff --git a/mysql-test/suite/galera/r/galera_gcs_fc_limit.result b/mysql-test/suite/galera/r/galera_gcs_fc_limit.result
index 99c710f25a5..ad60ead4b8a 100644
--- a/mysql-test/suite/galera/r/galera_gcs_fc_limit.result
+++ b/mysql-test/suite/galera/r/galera_gcs_fc_limit.result
@@ -1,14 +1,14 @@
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1';
FLUSH TABLES WITH READ LOCK;
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);
-SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'query end' AND INFO = 'INSERT INTO t1 VALUES (5)';
-COUNT(*) = 1
-1
UNLOCK TABLES;
INSERT INTO t1 VALUES (6);
SELECT COUNT(*) = 6 FROM t1;
diff --git a/mysql-test/suite/galera/r/galera_gra_log.result b/mysql-test/suite/galera/r/galera_gra_log.result
new file mode 100644
index 00000000000..9f5cbdd75fc
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_gra_log.result
@@ -0,0 +1,41 @@
+SET SESSION wsrep_on=OFF;
+CREATE TABLE t1 (f1 INTEGER);
+CREATE TABLE t1 (f1 INTEGER);
+SELECT COUNT(*) = 0 FROM t1;
+COUNT(*) = 0
+1
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# at 4
+<ISO TIMESTAMP> server id 2 end_log_pos 120 Start: binlog v 4, server v 5.6.24-debug-log created 150804 11:37:14 at startup
+# Warning: this binlog is either in use or was not closed properly.
+ROLLBACK/*!*/;
+BINLOG '
+unnAVQ8CAAAAdAAAAHgAAAABAAQANS42LjI0LWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAC6ecBVEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAKNu
+Jfk=
+'/*!*/;
+# at 120
+<ISO TIMESTAMP> server id 1 end_log_pos 91 Query thread_id=<QUERY_THREAD_ID> exec_time=0 error_code=0
+use `test`/*!*/;
+SET TIMESTAMP=<TIMESTAMP>/*!*/;
+SET @@session.pseudo_thread_id=<PSEUDO_THREAD_ID>/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=1073741824/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+CREATE TABLE t1 (f1 INTEGER)
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
+SET SESSION wsrep_on=ON;
+CALL mtr.add_suppression("Slave SQL: Error 'Table 't1' already exists' on query");
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_ist_mysqldump.result b/mysql-test/suite/galera/r/galera_ist_mysqldump.result
index 4b5a8fe948a..9a5b4e8a76f 100644
--- a/mysql-test/suite/galera/r/galera_ist_mysqldump.result
+++ b/mysql-test/suite/galera/r/galera_ist_mysqldump.result
@@ -1,6 +1,6 @@
Setting SST method to mysqldump ...
-GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst';
-SET GLOBAL wsrep_sst_auth = 'sst:sst';
+GRANT ALL PRIVILEGES ON *.* TO 'sst';
+SET GLOBAL wsrep_sst_auth = 'sst:';
SET GLOBAL wsrep_sst_method = 'mysqldump';
Performing State Transfer on a server that has been shut down cleanly and restarted
CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
diff --git a/mysql-test/suite/galera/r/galera_kill_applier.result b/mysql-test/suite/galera/r/galera_kill_applier.result
new file mode 100644
index 00000000000..fe4911639ed
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_kill_applier.result
@@ -0,0 +1,4 @@
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
diff --git a/mysql-test/suite/galera/r/galera_many_rows.result b/mysql-test/suite/galera/r/galera_many_rows.result
index 6ec0add8ba8..a34367d6e46 100644
--- a/mysql-test/suite/galera/r/galera_many_rows.result
+++ b/mysql-test/suite/galera/r/galera_many_rows.result
@@ -1,7 +1,12 @@
+SET SESSION innodb_lock_wait_timeout=600;
+SET SESSION lock_wait_timeout=600;
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB;
INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
+SET SESSION wsrep_sync_wait = 0;
+SET SESSION wsrep_sync_wait = 7;
+SET GLOBAL wsrep_provider_options = 'repl.causal_read_timeout=PT1H';
SELECT COUNT(*) = 100000 FROM t1;
COUNT(*) = 100000
1
@@ -13,20 +18,6 @@ UPDATE t1 SET f2 = 1;
SELECT COUNT(*) = 200000 FROM t1 WHERE f2 = 1;
COUNT(*) = 200000
1
-SET AUTOCOMMIT=OFF;
-START TRANSACTION;
-INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
-ROLLBACK;
-SELECT COUNT(*) = 200000 FROM t1;
-COUNT(*) = 200000
-1
-SELECT COUNT(*) = 200000 FROM t1;
-COUNT(*) = 200000
-1
-SET AUTOCOMMIT=OFF;
-START TRANSACTION;
-UPDATE t1 SET f2 = 2;
-ROLLBACK;
START TRANSACTION;
SELECT COUNT(*) = 200000 FROM t1;
COUNT(*) = 200000
diff --git a/mysql-test/suite/galera/r/galera_migrate.result b/mysql-test/suite/galera/r/galera_migrate.result
index 7c92d66ff97..aab3ffbd6b6 100644
--- a/mysql-test/suite/galera/r/galera_migrate.result
+++ b/mysql-test/suite/galera/r/galera_migrate.result
@@ -21,9 +21,9 @@ SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N
VARIABLE_VALUE = 1
1
INSERT INTO t1 VALUES (6);
-GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst';
-SET GLOBAL wsrep_sst_auth = 'sst:sst';
-GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst';
+GRANT ALL PRIVILEGES ON *.* TO 'sst';
+SET GLOBAL wsrep_sst_auth = 'sst:';
+GRANT ALL PRIVILEGES ON *.* TO 'sst';
SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
VARIABLE_VALUE = 'Synced'
1
diff --git a/mysql-test/suite/galera/r/galera_parallel_simple.result b/mysql-test/suite/galera/r/galera_parallel_simple.result
index 880d4e8ae3d..294a94baed3 100644
--- a/mysql-test/suite/galera/r/galera_parallel_simple.result
+++ b/mysql-test/suite/galera/r/galera_parallel_simple.result
@@ -13,13 +13,13 @@ INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
-SELECT COUNT(*) = 6 FROM t1;
-COUNT(*) = 6
-1
-SELECT COUNT(*) = 6 FROM t2;
-COUNT(*) = 6
-1
-SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'closing tables';
+SELECT COUNT(*) = 10 FROM t1;
+COUNT(*) = 10
+0
+SELECT COUNT(*) = 10 FROM t2;
+COUNT(*) = 10
+0
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'committed%';
COUNT(*) = 2
1
SET GLOBAL wsrep_slave_threads = 1;;
diff --git a/mysql-test/suite/galera/r/galera_prepared_statement.result b/mysql-test/suite/galera/r/galera_prepared_statement.result
new file mode 100644
index 00000000000..de5ac9c760a
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_prepared_statement.result
@@ -0,0 +1,33 @@
+CREATE TABLE t1 (f1 CHAR(5)) ENGINE=InnoDB;
+CREATE TABLE t2 (f1 CHAR(5)) ENGINE=InnoDB;
+CREATE TABLE t3 (f1 CHAR(5)) ENGINE=InnoDB;
+CREATE TABLE t4 (f1 CHAR(5)) ENGINE=InnoDB;
+SET SESSION sql_mode='STRICT_ALL_TABLES';
+PREPARE st1 FROM 'INSERT INTO t1 VALUES ("abc")';
+PREPARE st2 FROM 'INSERT INTO t2 VALUES ("abc")';
+PREPARE st3 FROM 'INSERT INTO t3 VALUES ("abc")';
+PREPARE st4 FROM 'INSERT INTO t4 VALUES ("abc")';
+EXECUTE st1;
+EXECUTE st2;
+EXECUTE st3;
+EXECUTE st4;
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM t2;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM t3;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM t4;
+COUNT(*) = 1
+1
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+ALTER TABLE t1 DROP COLUMN f1;
+EXECUTE st1;
+ERROR 22007: Incorrect integer value: 'abc' for column 'f2' at row 1
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
diff --git a/mysql-test/suite/galera/r/galera_read_only.result b/mysql-test/suite/galera/r/galera_read_only.result
index d2af3867fe7..82736c5f4ba 100644
--- a/mysql-test/suite/galera/r/galera_read_only.result
+++ b/mysql-test/suite/galera/r/galera_read_only.result
@@ -4,5 +4,15 @@ INSERT INTO t1 VALUES (1);
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 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;
DROP TABLE t1;
+DROP USER foo@localhost;
diff --git a/mysql-test/suite/galera/r/galera_serializable.result b/mysql-test/suite/galera/r/galera_serializable.result
new file mode 100644
index 00000000000..90fe628e505
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_serializable.result
@@ -0,0 +1,27 @@
+CREATE TABLE t1 (id INT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+START TRANSACTION;
+SELECT * FROM t1;
+id f2
+INSERT INTO t1 VALUES (1,1);
+SELECT * FROM t1;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+ROLLBACK;
+DELETE FROM t1;
+INSERT INTO t1 VALUES (1,1);
+START TRANSACTION;
+SELECT * FROM t1;
+id f2
+1 1
+UPDATE t1 SET f2 = 2;
+UPDATE t1 SET f2 = 3;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+ROLLBACK;
+DELETE FROM t1;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (1,2);
+COMMIT;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_ssl_compression.result b/mysql-test/suite/galera/r/galera_ssl_compression.result
new file mode 100644
index 00000000000..f25b614d139
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_ssl_compression.result
@@ -0,0 +1,22 @@
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+VARIABLE_VALUE = 'Synced'
+1
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 2
+1
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+VARIABLE_VALUE = 'Synced'
+1
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 2
+1
+SET GLOBAL wsrep_provider_options = "socket.ssl_compression=No";
+ERROR HY000: Incorrect arguments to SET
+CREATE TABLE t1 (f1 VARCHAR(333) PRIMARY KEY, f2 BLOB) Engine=InnoDB;
+INSERT INTO t1 VALUES (REPEAT('a', 333), REPEAT('b', 65535));
+SELECT COUNT(*) = 1 FROM t1 WHERE f1 = REPEAT('a', 333) AND f2 = REPEAT('b', 65535);
+COUNT(*) = 1
+1
+DROP TABLE t1;
+CALL mtr.add_suppression("Unknown parameter 'socket\.ssl_compression'");
+CALL mtr.add_suppression("Set options returned 7");
diff --git a/mysql-test/suite/galera/r/galera_ssl_upgrade.result b/mysql-test/suite/galera/r/galera_ssl_upgrade.result
new file mode 100644
index 00000000000..c0f2e84dc6f
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_ssl_upgrade.result
@@ -0,0 +1,24 @@
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+VARIABLE_VALUE = 'Synced'
+1
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 2
+1
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+VARIABLE_VALUE = 'Synced'
+1
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 2
+1
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+VARIABLE_VALUE = 'Synced'
+1
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 2
+1
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+VARIABLE_VALUE = 'Synced'
+1
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 2
+1
diff --git a/mysql-test/suite/galera/r/galera_sst_mysqldump.result b/mysql-test/suite/galera/r/galera_sst_mysqldump.result
index 1be2002001b..e35c4055f45 100644
--- a/mysql-test/suite/galera/r/galera_sst_mysqldump.result
+++ b/mysql-test/suite/galera/r/galera_sst_mysqldump.result
@@ -1,6 +1,6 @@
Setting SST method to mysqldump ...
-GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst';
-SET GLOBAL wsrep_sst_auth = 'sst:sst';
+GRANT ALL PRIVILEGES ON *.* TO 'sst';
+SET GLOBAL wsrep_sst_auth = 'sst:';
SET GLOBAL wsrep_sst_method = 'mysqldump';
Performing State Transfer on a server that has been temporarily disconnected
CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
diff --git a/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result b/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result
new file mode 100644
index 00000000000..93557cc91d4
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result
@@ -0,0 +1,106 @@
+Setting SST method to mysqldump ...
+GRANT ALL PRIVILEGES ON *.* TO 'sst';
+SET GLOBAL wsrep_sst_auth = 'sst:';
+SET GLOBAL wsrep_sst_method = 'mysqldump';
+CREATE USER sslsst;
+GRANT ALL PRIVILEGES ON *.* TO sslsst;
+GRANT USAGE ON *.* TO sslsst REQUIRE SSL;
+SET GLOBAL wsrep_sst_auth = 'sslsst:';
+Performing State Transfer on a server that has been temporarily disconnected
+CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+COMMIT;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+COMMIT;
+Unloading wsrep provider ...
+SET GLOBAL wsrep_provider = 'none';
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+Loading wsrep provider ...
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+COMMIT;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+COMMIT;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+COMMIT;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+ROLLBACK;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+COMMIT;
+SET AUTOCOMMIT=ON;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+DROP TABLE t1;
+COMMIT;
+SET AUTOCOMMIT=ON;
+CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query");
+DROP USER sst;
+CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query");
+CALL mtr.add_suppression("InnoDB: Error: Table \"mysql\"\\.\"innodb_index_stats\" not found");
+CALL mtr.add_suppression("InnoDB: New log files created");
+CALL mtr.add_suppression("InnoDB: Creating foreign key constraint system tables");
+CALL mtr.add_suppression("Can't open and lock time zone table");
+CALL mtr.add_suppression("Can't open and lock privilege tables");
+CALL mtr.add_suppression("Info table is not ready to be used");
+CALL mtr.add_suppression("Native table .* has the wrong structure");
+DROP USER sslsst;
diff --git a/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2-options.result b/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2-options.result
new file mode 100644
index 00000000000..990e0a29506
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2-options.result
@@ -0,0 +1,3 @@
+SELECT 1;
+1
+1
diff --git a/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2_encrypt_with_key.result b/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2_encrypt_with_key.result
new file mode 100644
index 00000000000..990e0a29506
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2_encrypt_with_key.result
@@ -0,0 +1,3 @@
+SELECT 1;
+1
+1
diff --git a/mysql-test/suite/galera/r/galera_status_local_index.result b/mysql-test/suite/galera/r/galera_status_local_index.result
new file mode 100644
index 00000000000..4e886ac8921
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_status_local_index.result
@@ -0,0 +1,13 @@
+CREATE TABLE wsrep_local_indexes (wsrep_local_index INTEGER);
+INSERT INTO wsrep_local_indexes VALUES ((SELECT variable_value FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_local_index'));
+INSERT INTO wsrep_local_indexes VALUES ((SELECT variable_value FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_local_index'));
+SELECT COUNT(*) = 2 FROM wsrep_local_indexes;
+COUNT(*) = 2
+1
+SELECT COUNT(DISTINCT wsrep_local_index) = 2 FROM wsrep_local_indexes;
+COUNT(DISTINCT wsrep_local_index) = 2
+1
+SELECT COUNT(*) = 0 FROM wsrep_local_indexes WHERE wsrep_local_index NOT IN (0, 1);
+COUNT(*) = 0
+1
+DROP TABLE wsrep_local_indexes;
diff --git a/mysql-test/suite/galera/r/galera_transaction_replay.result b/mysql-test/suite/galera/r/galera_transaction_replay.result
index 23ed87ffe22..54ea8db699d 100644
--- a/mysql-test/suite/galera/r/galera_transaction_replay.result
+++ b/mysql-test/suite/galera/r/galera_transaction_replay.result
@@ -7,12 +7,12 @@ UPDATE t1 SET f2 = 'b' WHERE f1 = 1;
SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE;
f1 f2
2 a
-SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_enter_sync';
+SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync';
COMMIT;;
SET SESSION wsrep_sync_wait = 0;
UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
SET GLOBAL wsrep_provider_options = 'dbug=';
-SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_enter_sync';
+SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync';
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
COUNT(*) = 1
1
diff --git a/mysql-test/suite/galera/r/galera_var_log_bin.result b/mysql-test/suite/galera/r/galera_var_log_bin.result
new file mode 100644
index 00000000000..a6ab62350b1
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_var_log_bin.result
@@ -0,0 +1,10 @@
+CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
+UPDATE t1 SET f1 = 2 WHERE f1 = 1;
+SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2;
+COUNT(*) = 1
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_var_node_address.result b/mysql-test/suite/galera/r/galera_var_node_address.result
new file mode 100644
index 00000000000..fa88f4b3128
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_var_node_address.result
@@ -0,0 +1,9 @@
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 4
+1
+CREATE TABLE t1 (f1 INTEGER);
+INSERT INTO t1 VALUES (1);
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_var_slave_threads.result b/mysql-test/suite/galera/r/galera_var_slave_threads.result
index 6b84f03737b..603dfaeacc7 100644
--- a/mysql-test/suite/galera/r/galera_var_slave_threads.result
+++ b/mysql-test/suite/galera/r/galera_var_slave_threads.result
@@ -104,3 +104,11 @@ COUNT(*) = 1
SET GLOBAL wsrep_slave_threads = 1;
DROP TABLE t1;
DROP TABLE t2;
+#
+# lp:1372840 - Changing wsrep_slave_threads causes future connections to hang
+#
+CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=INNODB;
+SET GLOBAL wsrep_slave_threads = 4;
+SET GLOBAL wsrep_slave_threads = 1;
+DROP TABLE t1;
+# End of tests
diff --git a/mysql-test/suite/galera/r/galera_wan_restart_ist.result b/mysql-test/suite/galera/r/galera_wan_restart_ist.result
new file mode 100644
index 00000000000..e58bff34e54
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_wan_restart_ist.result
@@ -0,0 +1,53 @@
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 4
+1
+CREATE TABLE t1 (f1 INTEGER);
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (3);
+INSERT INTO t1 VALUES (4);
+INSERT INTO t1 VALUES (13);
+Shutting down server ...
+INSERT INTO t1 VALUES (11);
+INSERT INTO t1 VALUES (12);
+INSERT INTO t1 VALUES (14);
+INSERT INTO t1 VALUES (131);
+INSERT INTO t1 VALUES (22);
+Shutting down server ...
+INSERT INTO t1 VALUES (21);
+INSERT INTO t1 VALUES (23);
+INSERT INTO t1 VALUES (24);
+INSERT INTO t1 VALUES (221);
+INSERT INTO t1 VALUES (34);
+Shutting down server ...
+INSERT INTO t1 VALUES (31);
+INSERT INTO t1 VALUES (32);
+INSERT INTO t1 VALUES (33);
+INSERT INTO t1 VALUES (341);
+SELECT COUNT(*) = 19 FROM t1;
+COUNT(*) = 19
+1
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 4
+1
+SELECT COUNT(*) = 19 FROM t1;
+COUNT(*) = 19
+1
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 4
+1
+SELECT COUNT(*) = 19 FROM t1;
+COUNT(*) = 19
+1
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 4
+1
+SELECT COUNT(*) = 19 FROM t1;
+COUNT(*) = 19
+1
+DROP TABLE t1;
+CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside");
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
+CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside");
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
diff --git a/mysql-test/suite/galera/r/galera_wan_restart_sst.result b/mysql-test/suite/galera/r/galera_wan_restart_sst.result
new file mode 100644
index 00000000000..15de0fab342
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_wan_restart_sst.result
@@ -0,0 +1,54 @@
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 4
+1
+CREATE TABLE t1 (f1 INTEGER);
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (3);
+INSERT INTO t1 VALUES (4);
+INSERT INTO t1 VALUES (13);
+Killing server ...
+INSERT INTO t1 VALUES (11);
+INSERT INTO t1 VALUES (12);
+INSERT INTO t1 VALUES (14);
+INSERT INTO t1 VALUES (131);
+INSERT INTO t1 VALUES (22);
+Killing server ...
+INSERT INTO t1 VALUES (21);
+INSERT INTO t1 VALUES (23);
+INSERT INTO t1 VALUES (24);
+INSERT INTO t1 VALUES (221);
+INSERT INTO t1 VALUES (34);
+Killing server ...
+INSERT INTO t1 VALUES (31);
+INSERT INTO t1 VALUES (32);
+INSERT INTO t1 VALUES (33);
+INSERT INTO t1 VALUES (341);
+SELECT COUNT(*) = 19 FROM t1;
+COUNT(*) = 19
+1
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 4
+1
+SELECT COUNT(*) = 19 FROM t1;
+COUNT(*) = 19
+1
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 4
+1
+SELECT COUNT(*) = 19 FROM t1;
+COUNT(*) = 19
+1
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+VARIABLE_VALUE = 4
+1
+SELECT COUNT(*) = 19 FROM t1;
+COUNT(*) = 19
+1
+DROP TABLE t1;
+CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside");
+CALL mtr.add_suppression("WSREP: gcs_caused\\(\\) returned -1 \\(Operation not permitted\\)");
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
+CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside");
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
diff --git a/mysql-test/suite/galera/r/lp1438990.result b/mysql-test/suite/galera/r/lp1438990.result
new file mode 100644
index 00000000000..b53bc186953
--- /dev/null
+++ b/mysql-test/suite/galera/r/lp1438990.result
@@ -0,0 +1,21 @@
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t2 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t3 (f1 INTEGER PRIMARY KEY);
+CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CALL p1(NEW.f1);
+CREATE PROCEDURE p1 (IN x INT)
+BEGIN
+DECLARE EXIT HANDLER FOR SQLEXCEPTION
+BEGIN
+ROLLBACK TO event_logging;
+INSERT t3 VALUES (x);
+END;
+SAVEPOINT event_logging;
+INSERT INTO t2 VALUES (x);
+RELEASE SAVEPOINT event_logging;
+END|
+INSERT INTO t2 VALUES (1);
+INSERT INTO t1 VALUES (1);
+DROP PROCEDURE p1;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
diff --git a/mysql-test/suite/galera/r/mysql-wsrep#110.result b/mysql-test/suite/galera/r/mysql-wsrep#110.result
new file mode 100644
index 00000000000..551c3666fb4
--- /dev/null
+++ b/mysql-test/suite/galera/r/mysql-wsrep#110.result
@@ -0,0 +1,38 @@
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t2 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t3 (f1 INTEGER PRIMARY KEY);
+CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CALL p1(NEW.f1);
+CREATE PROCEDURE p1 (IN x INT)
+BEGIN
+DECLARE EXIT HANDLER FOR SQLEXCEPTION
+BEGIN
+ROLLBACK TO event_logging;
+INSERT t3 VALUES (x);
+END;
+SAVEPOINT event_logging;
+INSERT INTO t2 VALUES (x);
+END|
+INSERT INTO t2 VALUES (1);
+INSERT INTO t1 VALUES (1);
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM t2;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM t3;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM t2;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM t3;
+COUNT(*) = 1
+1
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP PROCEDURE p1;
diff --git a/mysql-test/suite/galera/r/mysql-wsrep#33.result b/mysql-test/suite/galera/r/mysql-wsrep#33.result
index 153d8084bec..62af519ad32 100644
--- a/mysql-test/suite/galera/r/mysql-wsrep#33.result
+++ b/mysql-test/suite/galera/r/mysql-wsrep#33.result
@@ -1,6 +1,6 @@
Setting SST method to mysqldump ...
-GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst';
-SET GLOBAL wsrep_sst_auth = 'sst:sst';
+GRANT ALL PRIVILEGES ON *.* TO 'sst';
+SET GLOBAL wsrep_sst_auth = 'sst:';
SET GLOBAL wsrep_sst_method = 'mysqldump';
Performing State Transfer on a server that has been temporarily disconnected
CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
diff --git a/mysql-test/suite/galera/r/mysql-wsrep#90.result b/mysql-test/suite/galera/r/mysql-wsrep#90.result
new file mode 100644
index 00000000000..da57b9d0068
--- /dev/null
+++ b/mysql-test/suite/galera/r/mysql-wsrep#90.result
@@ -0,0 +1,31 @@
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB;
+SET GLOBAL wsrep_OSU_method = "RSU";
+SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue';
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;;
+SET SESSION wsrep_sync_wait = 0;
+SET GLOBAL wsrep_OSU_method = "TOI";
+SET DEBUG_SYNC= 'now SIGNAL continue';
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+COUNT(*) = 2
+1
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+COUNT(*) = 2
+1
+DROP TABLE t1;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB;
+SET GLOBAL wsrep_OSU_method = "TOI";
+SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue';
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;;
+SET SESSION wsrep_sync_wait = 0;
+SET GLOBAL wsrep_OSU_method = "RSU";
+SET DEBUG_SYNC= 'now SIGNAL continue';
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+COUNT(*) = 2
+1
+INSERT INTO t1 VALUES (1,2);
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+COUNT(*) = 2
+1
+INSERT INTO t1 VALUES (3,4);
+DROP TABLE t1;
+SET GLOBAL WSREP_OSU_METHOD = TOI;
diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm
index c44aece09e3..2da2b3ad503 100644
--- a/mysql-test/suite/galera/suite.pm
+++ b/mysql-test/suite/galera/suite.pm
@@ -60,8 +60,8 @@ push @::global_suppressions,
qr(WSREP: .*Failed to open backend connection: -110 .*),
qr(WSREP: .*Failed to open channel 'my_wsrep_cluster' at .*),
qr(WSREP: gcs connect failed: Connection timed out),
- qr|WSREP: wsrep::connect\(\) failed: 7|,
- qr(WSREP: SYNC message from member [0-9]* in non-primary configuration. Ignored.),
+ qr|WSREP: wsrep::connect\(.*\) failed: 7|,
+ qr(WSREP: SYNC message from member .* in non-primary configuration. Ignored.),
qr(WSREP: Could not find peer:),
qr(WSREP: TO isolation failed for: .*),
qr|WSREP: gcs_caused\(\) returned .*|,
diff --git a/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test b/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test
new file mode 100644
index 00000000000..6747977812b
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test
@@ -0,0 +1,34 @@
+#
+# Test that applying plays well with FLUSH TABLE table_name WITH READ LOCK. The applier
+# thread should block until UNLOCK TABLEs.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+SET SESSION wsrep_sync_wait = 0;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+
+FLUSH TABLE t1 WITH READ LOCK;
+
+--connection node_2
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+
+--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1a
+SET SESSION wsrep_sync_wait = 0;
+
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
+--source include/wait_condition.inc
+
+SELECT COUNT(*) = 0 FROM t1;
+
+--connection node_1
+UNLOCK TABLES;
+
+SET SESSION wsrep_sync_wait = 7;
+SELECT COUNT(*) = 2 FROM t1;
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter-master.opt b/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter-master.opt
new file mode 100644
index 00000000000..d8ecaacaa4c
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter-master.opt
@@ -0,0 +1 @@
+--lock_wait_timeout=5 --innodb_lock_wait_timeout=5 --wait_timeout=5
diff --git a/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test b/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test
new file mode 100644
index 00000000000..99c45c04ba0
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test
@@ -0,0 +1,37 @@
+#
+# Test that applying a DDL plays well with FLUSH TABLE table_name WITH READ LOCK. The applier
+# thread should block until UNLOCK TABLEs.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+SET SESSION wsrep_sync_wait = 0;
+
+# Those values are valid only for connection node_1. The global values from the -master.opt file apply to applier threads.
+SET SESSION lock_wait_timeout = 60;
+SET SESSION innodb_lock_wait_timeout=60;
+SET SESSION wait_timeout=60;
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+
+FLUSH TABLE t1 WITH READ LOCK;
+
+--connection node_2
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+
+--connection node_1
+SELECT 1 FROM DUAL;
+# Sleep for longer than the global timeout ...
+--sleep 6
+SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock';
+
+UNLOCK TABLES;
+
+SET SESSION wsrep_sync_wait = 7;
+
+SHOW CREATE TABLE t1;
+SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock';
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_as_slave.test b/mysql-test/suite/galera/t/galera_as_slave.test
index 79b9e5071a3..849b75eadd1 100644
--- a/mysql-test/suite/galera/t/galera_as_slave.test
+++ b/mysql-test/suite/galera/t/galera_as_slave.test
@@ -45,3 +45,6 @@ DROP TABLE t1;
STOP SLAVE;
RESET SLAVE ALL;
+
+--connection node_1
+RESET MASTER;
diff --git a/mysql-test/suite/galera/t/galera_as_slave_nonprim.cnf b/mysql-test/suite/galera/t/galera_as_slave_nonprim.cnf
new file mode 100644
index 00000000000..5a44e5664b5
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_as_slave_nonprim.cnf
@@ -0,0 +1 @@
+!include ../galera_3nodes_as_slave.cnf
diff --git a/mysql-test/suite/galera/t/galera_as_slave_nonprim.test b/mysql-test/suite/galera/t/galera_as_slave_nonprim.test
new file mode 100644
index 00000000000..5c53ff79cc1
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_as_slave_nonprim.test
@@ -0,0 +1,96 @@
+#
+# Test the behavior of a Galera async slave if it goes non-prim. Async replication
+# should abort with an error but it should be possible to restart it.
+#
+# The galera/galera_2node_slave.cnf describes the setup of the nodes
+#
+
+--source include/have_innodb.inc
+--source include/have_log_bin.inc
+--source include/big_test.inc
+
+# Step #1. Establish replication
+#
+# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
+#
+--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
+--source include/galera_cluster.inc
+
+--connection node_2
+--disable_query_log
+--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1;
+--enable_query_log
+START SLAVE USER='root';
+SET SESSION wsrep_sync_wait = 0;
+
+--connection node_1
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+--source include/wait_condition.inc
+
+# Step #2. Force async slave to go non-primary
+
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+--source include/wait_until_connected_again.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
+--source include/wait_condition.inc
+
+# Step #3. Force async replication to fail by creating a replication event while the slave is non-prim
+
+--connection node_1
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
+
+--connection node_2
+--sleep 5
+
+--let $value = query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1)
+--connection node_3
+--disable_query_log
+--eval SELECT "$value" IN ("Error 'Unknown command' on query. Default database: 'test'. Query: 'BEGIN'", "Node has dropped from cluster") AS expected_error
+--enable_query_log
+
+# Step #4. Bring back the async slave and restart replication
+--connection node_2
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+
+--connection node_3
+--source include/wait_until_connected_again.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
+--source include/wait_condition.inc
+
+--connection node_2
+--source include/galera_wait_ready.inc
+--source include/wait_until_connected_again.inc
+
+START SLAVE;
+
+# Confirm that the replication events have arrived
+
+--let $wait_condition = SELECT COUNT(*) = 5 FROM t1;
+--source include/wait_condition.inc
+
+--connection node_1
+DROP TABLE t1;
+
+--sleep 2
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+--source include/wait_condition.inc
+
+STOP SLAVE;
+RESET SLAVE ALL;
+
+CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query");
+CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047");
+CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)");
+CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed, 'Deadlock found when trying to get lock; try restarting transaction', Error_code: 1213");
+CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047");
+
+
+--connection node_1
+RESET MASTER;
diff --git a/mysql-test/suite/galera/t/galera_as_slave_preordered.cnf b/mysql-test/suite/galera/t/galera_as_slave_preordered.cnf
new file mode 100644
index 00000000000..d1a0fb15ff3
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_as_slave_preordered.cnf
@@ -0,0 +1,3 @@
+!include ../galera_2nodes_as_slave.cnf
+[mysqld]
+wsrep-preordered=TRUE
diff --git a/mysql-test/suite/galera/t/galera_as_slave_preordered.test b/mysql-test/suite/galera/t/galera_as_slave_preordered.test
new file mode 100644
index 00000000000..6f221f83b3a
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_as_slave_preordered.test
@@ -0,0 +1,84 @@
+#
+# Test Galera as a slave to a MySQL master with --wsrep-preordered=TRUE
+#
+# The galera/galera_2node_slave.cnf describes the setup of the nodes
+#
+
+--source include/have_innodb.inc
+--source include/have_log_bin.inc
+
+# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
+--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
+--source include/galera_cluster.inc
+
+--connection node_2
+--disable_query_log
+--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1;
+--enable_query_log
+START SLAVE USER='root';
+
+#
+# Issue many large-ish transaction on the async master
+#
+
+--connection node_1
+CREATE TABLE ten (f1 INTEGER);
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB;
+
+--disable_query_log
+--let $count = 100
+while ($count)
+{
+ --eval INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2;
+ --dec $count
+}
+--enable_query_log
+
+#
+# While the async transactions are being applied, issue another set of transactions
+# on the Galera node.
+#
+
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+--source include/wait_condition.inc
+
+--let $count = 100
+--disable_query_log
+while ($count)
+{
+ --eval INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2;
+ --dec $count
+}
+--enable_query_log
+
+#
+# Confirm that all transactions successfully committed
+#
+
+--let $wait_condition = SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1;
+--source include/wait_condition.inc
+
+SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1;
+
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1;
+SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1;
+
+#
+# Cleanup
+#
+
+--connection node_1
+DROP TABLE t1;
+DROP TABLE ten;
+
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+--source include/wait_condition.inc
+
+STOP SLAVE;
+RESET SLAVE ALL;
diff --git a/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf
new file mode 100644
index 00000000000..d092d88bfaf
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf
@@ -0,0 +1,4 @@
+!include ../galera_2nodes_as_slave.cnf
+
+[mysqld]
+wsrep-mysql-replication-bundle=2
diff --git a/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test
new file mode 100644
index 00000000000..460e040c010
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test
@@ -0,0 +1,48 @@
+#
+# Test the wsrep_replication_bundle variable. We expect that multiple async replication events
+# will be grouped together and thus a smaller number of wsrep_last_committed transactions will
+# be reported.
+#
+
+--source include/have_innodb.inc
+
+# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
+--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
+--source include/galera_cluster.inc
+
+--connection node_2
+--disable_query_log
+--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1;
+--enable_query_log
+START SLAVE;
+
+--connection node_1
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+INSERT INTO t1 VALUES(4);
+INSERT INTO t1 VALUES(5);
+
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+--source include/wait_condition.inc
+
+--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
+--source include/wait_condition.inc
+
+# With wsrep_mysql_replication_bundle = 2, the last insert is not delivered
+# because there are not enough events remaining to complete an entire bundle
+SELECT COUNT(*) = 4 FROM t1;
+
+# Bundle is now complete, the last INSERT and the DROP are delivered
+--connection node_1
+DROP TABLE t1;
+
+--connection node_2
+--sleep 1
+--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+--source include/wait_condition.inc
+
+STOP SLAVE;
+RESET SLAVE ALL;
diff --git a/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.cnf b/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.cnf
new file mode 100644
index 00000000000..7d684cef67d
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.cnf
@@ -0,0 +1,13 @@
+!include ../galera_2nodes.cnf
+
+[mysqld]
+#wsrep_sst_method=xtrabackup-v2
+#wsrep_sst_auth="root:"
+#wsrep_debug=ON
+
+[mysqld.1]
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true'
+
+[mysqld.2]
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'
+
diff --git a/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.test b/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.test
new file mode 100644
index 00000000000..251450f7099
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.test
@@ -0,0 +1,95 @@
+#
+# Test that autoincrement works correctly while the cluster membership
+# is changing and IST takes place.
+#
+
+--source include/big_test.inc
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+--let $connection_id = `SELECT CONNECTION_ID()`
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+
+# Issue an endless stream of autoincrement inserts
+
+DELIMITER |;
+CREATE PROCEDURE p1 ()
+BEGIN
+ DECLARE x INT DEFAULT 1;
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+
+ WHILE 1 DO
+ INSERT INTO t1 VALUES (DEFAULT);
+ COMMIT;
+ END WHILE;
+END|
+DELIMITER ;|
+
+--send CALL p1();
+--sleep 2
+
+--connection node_2
+--send CALL p1();
+--sleep 2
+
+# Kill and restart node #2
+
+--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
+--connection node_2a
+--source include/kill_galera.inc
+
+--sleep 10
+--source include/start_mysqld.inc
+--sleep 25
+--source include/wait_until_connected_again.inc
+
+INSERT INTO t1 VALUES (DEFAULT);
+
+# Terminate the stored procedure
+
+--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1a
+--disable_query_log
+--eval KILL CONNECTION $connection_id
+--enable_query_log
+
+INSERT INTO t1 VALUES (DEFAULT);
+
+--connection node_1
+# CR_SERVER_LOST
+--error 2013,2006
+--reap
+
+--connection node_2
+# CR_SERVER_LOST
+--error 2013,2006
+--reap
+
+--sleep 10
+
+# Confirm that the count is correct and that the cluster is intact
+
+--connection node_1a
+--let $count = `SELECT COUNT(*) FROM t1`
+
+--connection node_2a
+--disable_query_log
+--eval SELECT COUNT(*) = $count AS count_equal FROM t1
+--enable_query_log
+
+CALL mtr.add_suppression("WSREP: Action message in non-primary configuration from member 0");
+
+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+--connection node_1a
+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+DROP PROCEDURE p1;
+DROP TABLE t1;
+
+CALL mtr.add_suppression("gcs_caused\\(\\) returned -1 \\(Operation not permitted\\)");
+CALL mtr.add_suppression("WSREP: Action message in non-primary configuration from member 0");
diff --git a/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test
new file mode 100644
index 00000000000..dbbe3b3c483
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test
@@ -0,0 +1,40 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+#
+# Test that a local FLUSH TABLES FOR EXPORT will NOT be broken by an incoming remote transaction against that table
+#
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+
+--connection node_2
+SET AUTOCOMMIT=OFF;
+--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
+FLUSH TABLES t1 FOR EXPORT;
+
+--connection node_1
+INSERT INTO t1 VALUES (2);
+
+--connection node_2
+SET SESSION wsrep_sync_wait = 0;
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
+--source include/wait_condition.inc
+
+UNLOCK TABLES;
+
+--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
+--source include/wait_condition.inc
+
+COMMIT;
+SET AUTOCOMMIT=ON;
+--let $wait_condition = SELECT COUNT(*) = 1 FROM t1
+--source include/wait_condition.inc
+SELECT * FROM t1;
+
+--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
+
+--disable_query_log
+--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 0 AS wsrep_local_aborts_increment;
+--enable_query_log
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_bf_abort_lock_table.test b/mysql-test/suite/galera/t/galera_bf_abort_lock_table.test
index 788427103a5..4582f3f972d 100644
--- a/mysql-test/suite/galera/t/galera_bf_abort_lock_table.test
+++ b/mysql-test/suite/galera/t/galera_bf_abort_lock_table.test
@@ -2,7 +2,7 @@
--source include/have_innodb.inc
#
-# Test that a local LOCK TABLE will be broken by an incoming remote transaction against that table
+# Test that a local LOCK TABLE will NOT be broken by an incoming remote transaction against that table
#
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
@@ -12,22 +12,25 @@ SET AUTOCOMMIT=OFF;
--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
LOCK TABLE t1 WRITE;
-# Issue a concurrent INSERT against the lock table that will block
---connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
---send INSERT INTO t1 VALUES (1);
-
--connection node_1
INSERT INTO t1 VALUES (2);
-# The concurent insert is allowed to complete because the LOCK TABLE is now broken
---connection node_2a
---error 0
---reap
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
+--source include/wait_condition.inc
+
+UNLOCK TABLES;
+
+--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
+--source include/wait_condition.inc
+
+COMMIT;
+SELECT COUNT(*) = 1 FROM t1;
--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
--disable_query_log
---eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment;
+--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 0 AS wsrep_local_aborts_increment;
--enable_query_log
DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_binlog_event_max_size_max.test b/mysql-test/suite/galera/t/galera_binlog_event_max_size_max.test
index 600432ce0ca..d0cc23446b2 100644
--- a/mysql-test/suite/galera/t/galera_binlog_event_max_size_max.test
+++ b/mysql-test/suite/galera/t/galera_binlog_event_max_size_max.test
@@ -4,6 +4,7 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
+--source include/big_test.inc
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
diff --git a/mysql-test/suite/galera/t/galera_drop_multi.test b/mysql-test/suite/galera/t/galera_drop_multi.test
new file mode 100644
index 00000000000..44b1b619b2b
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_drop_multi.test
@@ -0,0 +1,41 @@
+#
+# Test that multi-table DROP TABLE statements are properly replicated
+# See http://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-20.html
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=MyISAM;
+CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB;
+CREATE TEMPORARY TABLE t4 (f1 INTEGER) ENGINE=InnoDB;
+
+CREATE TABLE t5 (f1 INTEGER);
+
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+
+DROP TABLE t1, t2, t3, t4;
+
+INSERT INTO t5 VALUES (1);
+
+COMMIT;
+
+--connection node_2
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t1;
+
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t2;
+
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t3;
+
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t4;
+
+CALL mtr.add_suppression("Slave SQL: Error 'Unknown table 'test.t2,test.t4'' on query\. Default database: 'test'\. Query: 'DROP TABLE t1, t2, t3, t4', Error_code: 1051");
+
+--connection node_1
+DROP TABLE t5;
diff --git a/mysql-test/suite/galera/t/galera_flush.test b/mysql-test/suite/galera/t/galera_flush.test
index 5845fadd562..3ba5edbae6f 100644
--- a/mysql-test/suite/galera/t/galera_flush.test
+++ b/mysql-test/suite/galera/t/galera_flush.test
@@ -77,8 +77,32 @@ FLUSH USER_RESOURCES;
--enable_query_log
+--connection node_2
+--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+--connection node_1
+FLUSH TABLES;
+--connection node_2
+--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+--disable_query_log
+--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff;
+--enable_query_log
+
+--connection node_1
+CREATE TABLE t2 (f1 INTEGER);
+
+--connection node_2
+--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+--connection node_1
+FLUSH TABLES t2;
+--connection node_2
+--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+--disable_query_log
+--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff;
+--enable_query_log
+
+
#
-# The following statements should not be replicated: FLUSH LOGS, FLUSH TABLES
+# The following statements should not be replicated: FLUSH LOGS, FLUSH TABLES WITH LOCKS
#
@@ -103,5 +127,47 @@ UNLOCK TABLES;
--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before AS wsrep_last_committed_diff;
--enable_query_log
+
+## Test LOCK TABLES with FLUSH TABLES
+## LOCK TABLES t1 write followed by flush tables t1 should succeed due to MDL upgrade.
+## LOCK tables t2 read followed by flush tables t2 should fail with ER_TABLE_NOT_LOCKED_FOR_WRITE
+
+
+--connection node_2
+--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+--connection node_1
+LOCK TABLES t1 WRITE;
+FLUSH TABLES t1;
+UNLOCK TABLES;
+--connection node_2
+--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+--disable_query_log
+--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff;
+--enable_query_log
+
+
+--connection node_2
+--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+--connection node_1
+LOCK TABLES t1 READ;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLES t1;
+UNLOCK TABLES;
+--connection node_2
+--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+--disable_query_log
+--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before AS wsrep_last_committed_diff;
+--enable_query_log
+--connection node_1
+FLUSH TABLES t1;
+--connection node_2
+--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+--disable_query_log
+--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff;
+--enable_query_log
+
+
+
--connection node_1
DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/suite/galera/t/galera_forced_binlog_format-master.opt b/mysql-test/suite/galera/t/galera_forced_binlog_format-master.opt
new file mode 100644
index 00000000000..8c58b59b45d
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_forced_binlog_format-master.opt
@@ -0,0 +1 @@
+--log-bin --wsrep_forced_binlog_format=ROW
diff --git a/mysql-test/suite/galera/t/galera_forced_binlog_format.test b/mysql-test/suite/galera/t/galera_forced_binlog_format.test
new file mode 100644
index 00000000000..934c15399e0
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_forced_binlog_format.test
@@ -0,0 +1,25 @@
+#
+# Test that wsrep_forced_binlog_format=ROW indeed prevents the log to be switched to STATEMENT format on a per-connection basis
+#
+
+--source include/have_log_bin.inc
+--source include/have_innodb.inc
+--source include/galera_cluster.inc
+
+--connection node_1
+RESET MASTER;
+
+SET SESSION binlog_format = 'STATEMENT';
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+
+SET SESSION binlog_format = 'MIXED';
+
+INSERT INTO t1 VALUES (2);
+
+--replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/
+--replace_column 2 <Pos> 5 <End_log_pos>
+SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120;
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_ftwrl.test b/mysql-test/suite/galera/t/galera_ftwrl.test
index db9bd132566..de8310e52d2 100644
--- a/mysql-test/suite/galera/t/galera_ftwrl.test
+++ b/mysql-test/suite/galera/t/galera_ftwrl.test
@@ -2,9 +2,10 @@
--source include/have_innodb.inc
#
-# At this time, issing a FLUSH TABLES WITH READ LOCK causes SELECT and SHOW to hang if
-# casuality can not be ensured because another node issued a statement in the meantime
-# which could not be applied because FTWRL blocks the applier as well
+# At this time, issing a FLUSH TABLES WITH READ LOCK causes SELECT and SHOW to
+# hang if causality can not be ensured because another node issued a statement
+# in the meantime which could not be applied because FTWRL blocks the applier
+# as well
#
# See LP bug 1271177
#
diff --git a/mysql-test/suite/galera/t/galera_ftwrl_drain.test b/mysql-test/suite/galera/t/galera_ftwrl_drain.test
new file mode 100644
index 00000000000..f022a9437c2
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_ftwrl_drain.test
@@ -0,0 +1,68 @@
+#
+# Test the following sequence of events:
+#
+# 1. issue a remote transaction
+# 2. applier is blocked from applying the transaction locally using apply_monitor_slave_enter_sync
+# 3. FTWRL is issued and blocks in ApplyOrder>::drain_common
+# 4. applier is unblocked
+# 5. remote transaction is applied
+# 6. FTWRL is granted
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source include/have_debug_sync.inc
+--source suite/galera/include/galera_have_debug_sync.inc
+
+--connection node_1
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+
+--connection node_2
+SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync';
+
+--connection node_1
+INSERT INTO t1 VALUES (1);
+
+--connection node_2
+SET SESSION wsrep_sync_wait = 0;
+
+# Wait until applier has blocked
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters' AND VARIABLE_VALUE = 'apply_monitor_slave_enter_sync'
+--source include/wait_condition.inc
+
+SELECT COUNT(*) = 0 FROM t1;
+
+--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
+--connection node_2a
+--send FLUSH TABLES WITH READ LOCK;
+
+--connection node_2
+--sleep 1
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'Init' AND INFO = 'FLUSH TABLES WITH READ LOCK'
+--source include/wait_condition.inc
+
+SET GLOBAL wsrep_provider_options = 'dbug=';
+SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync';
+
+--connection node_2a
+--reap
+
+--connection node_2
+
+SET SESSION lock_wait_timeout = 1;
+SET SESSION innodb_lock_wait_timeout=1;
+SET SESSION wait_timeout=1;
+
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t2 VALUES (2);
+
+--connection node_2a
+UNLOCK TABLES;
+
+--connection node_2
+SELECT COUNT(*) = 1 FROM t1;
+INSERT INTO t1 VALUES (3);
+
+--connection node_1
+SELECT COUNT(*) = 2 FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_fulltext.test b/mysql-test/suite/galera/t/galera_fulltext.test
index aa93a336f92..a90cab1aa1a 100644
--- a/mysql-test/suite/galera/t/galera_fulltext.test
+++ b/mysql-test/suite/galera/t/galera_fulltext.test
@@ -24,16 +24,16 @@ SELECT COUNT(*) = 13 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name LIKE '
#
--connection node_1
-# Insert 10K rows
-INSERT INTO t1 (f2) SELECT 'foobarbaz' FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
+# Insert 1K rows
+INSERT INTO t1 (f2) SELECT 'foobarbaz' FROM ten AS a1, ten AS a2, ten AS a3;
--connection node_2
-SELECT COUNT(f2) = 10000 FROM t1 WHERE MATCH(f2) AGAINST ('foobarbaz');
+SELECT COUNT(f2) = 1000 FROM t1 WHERE MATCH(f2) AGAINST ('foobarbaz');
UPDATE t1 SET f2 = 'abcdefjhk';
--connection node_1
-SELECT COUNT(f2) = 10000 FROM t1 WHERE MATCH(f2) AGAINST ('abcdefjhk');
+SELECT COUNT(f2) = 1000 FROM t1 WHERE MATCH(f2) AGAINST ('abcdefjhk');
--connection node_2
diff --git a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test
index e15da0e35ad..fd77ec0a0eb 100644
--- a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test
+++ b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test
@@ -9,6 +9,9 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--connection node_2
+SELECT COUNT(*) = 1 FROM t1;
+--sleep 1
+
--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options`
SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1';
@@ -24,13 +27,14 @@ INSERT INTO t1 VALUES (4);
# This query will hang because flow control will kick in
--send
INSERT INTO t1 VALUES (5);
---sleep 1
+--sleep 2
--let $galera_connection_name = node_1a
--let $galera_server_number = 1
--source include/galera_connect.inc
--connection node_1a
-SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'query end' AND INFO = 'INSERT INTO t1 VALUES (5)';
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'query end' AND INFO = 'INSERT INTO t1 VALUES (5)';
+--source include/wait_condition.inc
--connection node_2
# Unblock the slave applier thread
diff --git a/mysql-test/suite/galera/t/galera_gcs_max_packet_size.test b/mysql-test/suite/galera/t/galera_gcs_max_packet_size.test
index cafd8acfdd9..98be4f6a300 100644
--- a/mysql-test/suite/galera/t/galera_gcs_max_packet_size.test
+++ b/mysql-test/suite/galera/t/galera_gcs_max_packet_size.test
@@ -6,6 +6,7 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
+--source include/big_test.inc
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
diff --git a/mysql-test/suite/galera/t/galera_gra_log.test b/mysql-test/suite/galera/t/galera_gra_log.test
new file mode 100644
index 00000000000..5329dc24546
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_gra_log.test
@@ -0,0 +1,38 @@
+#
+# Test that GRA_* files are generated on applier failure and are readable.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_2
+--exec rm -rf $MYSQLTEST_VARDIR/mysqld.2/data/GRA_*.log
+
+# Create applier failure
+
+SET SESSION wsrep_on=OFF;
+CREATE TABLE t1 (f1 INTEGER);
+
+--connection node_1
+CREATE TABLE t1 (f1 INTEGER);
+
+--connection node_2
+SELECT COUNT(*) = 0 FROM t1;
+
+# Compose a valid binlog from a header file and the GRA file
+
+--let $gra_binlog_file = $MYSQLTEST_VARDIR/tmp/gra.log
+--exec rm -rf $gra_binlog_file
+
+--exec cp std_data/binlog-header.log $gra_binlog_file
+--exec cat $MYSQLTEST_VARDIR/mysqld.2/data/GRA_*.log >> $gra_binlog_file
+
+# Make sure the binlog thus produced is readable and contains the failure
+--replace_regex /SET TIMESTAMP=[0-9]+/SET TIMESTAMP=<TIMESTAMP>/ /#[0-9]+ +[0-9]+:[0-9]+:[0-9]+/<ISO TIMESTAMP>/ /pseudo_thread_id=[0-9]+/pseudo_thread_id=<PSEUDO_THREAD_ID>/ /thread_id=[0-9]+/thread_id=<QUERY_THREAD_ID>/
+--exec $MYSQL_BINLOG $gra_binlog_file
+
+SET SESSION wsrep_on=ON;
+
+CALL mtr.add_suppression("Slave SQL: Error 'Table 't1' already exists' on query");
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf
index 85245ff464a..41a1aab382b 100644
--- a/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf
+++ b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf
@@ -2,6 +2,8 @@
[mysqld]
wsrep_sst_method=xtrabackup-v2
+wsrep_sst_auth=root:
+
innodb_flush_log_at_trx_commit=0
[mysqld.1]
diff --git a/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.cnf b/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.cnf
index 21e597445a8..a762b939f69 100644
--- a/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.cnf
+++ b/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.cnf
@@ -2,6 +2,7 @@
[mysqld]
wsrep_sst_method=xtrabackup-v2
+wsrep_sst_auth=root:
[mysqld.1]
wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true'
diff --git a/mysql-test/suite/galera/t/galera_kill_applier.test b/mysql-test/suite/galera/t/galera_kill_applier.test
new file mode 100644
index 00000000000..e14a8b9af23
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_kill_applier.test
@@ -0,0 +1,26 @@
+#
+# This test checks that applier threads are immune to KILL QUERY and KILL STATEMENT
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+
+--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
+
+--disable_query_log
+--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
+--eval KILL $applier_thread
+
+--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
+--eval KILL QUERY $applier_thread
+
+--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
+
+--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
+--eval KILL $aborter_thread
+
+--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
+--eval KILL QUERY $aborter_thread
+--enable_query_log
diff --git a/mysql-test/suite/galera/t/galera_many_rows.test b/mysql-test/suite/galera/t/galera_many_rows.test
index 0f4c4c0db78..653dc2dd75a 100644
--- a/mysql-test/suite/galera/t/galera_many_rows.test
+++ b/mysql-test/suite/galera/t/galera_many_rows.test
@@ -3,6 +3,10 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
+--connection node_1
+SET SESSION innodb_lock_wait_timeout=600;
+SET SESSION lock_wait_timeout=600;
+
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
@@ -10,6 +14,12 @@ CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoD
INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
--connection node_2
+SET SESSION wsrep_sync_wait = 0;
+--let $wsrep_provider_options_node2 = `SELECT @@wsrep_provider_options`
+SET SESSION wsrep_sync_wait = 7;
+
+SET GLOBAL wsrep_provider_options = 'repl.causal_read_timeout=PT1H';
+
SELECT COUNT(*) = 100000 FROM t1;
INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
@@ -20,21 +30,6 @@ UPDATE t1 SET f2 = 1;
--connection node_2
SELECT COUNT(*) = 200000 FROM t1 WHERE f2 = 1;
-# Rollback
---connection node_1
-SET AUTOCOMMIT=OFF;
-START TRANSACTION;
-INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
-ROLLBACK;
-SELECT COUNT(*) = 200000 FROM t1;
-
---connection node_2
-SELECT COUNT(*) = 200000 FROM t1;
-SET AUTOCOMMIT=OFF;
-START TRANSACTION;
-UPDATE t1 SET f2 = 2;
-ROLLBACK;
-
--connection node_1
START TRANSACTION;
SELECT COUNT(*) = 200000 FROM t1;
@@ -51,5 +46,9 @@ COMMIT;
--error ER_LOCK_DEADLOCK
COMMIT;
+--disable_query_log
+--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_node2';
+--enable_query_log
+
DROP TABLE t1;
DROP TABLE ten;
diff --git a/mysql-test/suite/galera/t/galera_migrate.test b/mysql-test/suite/galera/t/galera_migrate.test
index 873640b88d4..84897b66c6d 100644
--- a/mysql-test/suite/galera/t/galera_migrate.test
+++ b/mysql-test/suite/galera/t/galera_migrate.test
@@ -104,11 +104,11 @@ INSERT INTO t1 VALUES (6);
--connection node_3
# We need a user with a password for mysqldump SST
-GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst';
-SET GLOBAL wsrep_sst_auth = 'sst:sst';
+GRANT ALL PRIVILEGES ON *.* TO 'sst';
+SET GLOBAL wsrep_sst_auth = 'sst:';
--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
-GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst';
+GRANT ALL PRIVILEGES ON *.* TO 'sst';
--disable_query_log
--eval SET GLOBAL wsrep_sst_method = 'mysqldump';
diff --git a/mysql-test/suite/galera/t/galera_parallel_autoinc_largetrx.test b/mysql-test/suite/galera/t/galera_parallel_autoinc_largetrx.test
index a192044754d..f280e49d206 100644
--- a/mysql-test/suite/galera/t/galera_parallel_autoinc_largetrx.test
+++ b/mysql-test/suite/galera/t/galera_parallel_autoinc_largetrx.test
@@ -4,6 +4,7 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
+--source include/big_test.inc
# Create a second connection to node1 so that we can run transactions concurrently
--let $galera_connection_name = node_1a
diff --git a/mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test b/mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test
index cf984f92b2f..8680d62a36d 100644
--- a/mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test
+++ b/mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test
@@ -4,6 +4,7 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
+--source include/big_test.inc
# Create a second connection to node1 so that we can run transactions concurrently
--let $galera_connection_name = node_1a
diff --git a/mysql-test/suite/galera/t/galera_parallel_simple.test b/mysql-test/suite/galera/t/galera_parallel_simple.test
index a1429954980..b1dc14deb5b 100644
--- a/mysql-test/suite/galera/t/galera_parallel_simple.test
+++ b/mysql-test/suite/galera/t/galera_parallel_simple.test
@@ -35,9 +35,9 @@ INSERT INTO t2 VALUES (1);
--connection node_2
-SELECT COUNT(*) = 6 FROM t1;
-SELECT COUNT(*) = 6 FROM t2;
-SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'closing tables';
+SELECT COUNT(*) = 10 FROM t1;
+SELECT COUNT(*) = 10 FROM t2;
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'committed%';
--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig;
diff --git a/mysql-test/suite/galera/t/galera_prepared_statement.test b/mysql-test/suite/galera/t/galera_prepared_statement.test
new file mode 100644
index 00000000000..3bee097ff39
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_prepared_statement.test
@@ -0,0 +1,45 @@
+#
+# A simple test for PREPARE / EXECUTE -style prepared statements with Galera
+#
+# C-API-level prepared-statements can not be triggered from inside mysqltest, however
+# can be exercised when running an MTR test suite with the --ps-protocol switch.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (f1 CHAR(5)) ENGINE=InnoDB;
+CREATE TABLE t2 (f1 CHAR(5)) ENGINE=InnoDB;
+CREATE TABLE t3 (f1 CHAR(5)) ENGINE=InnoDB;
+CREATE TABLE t4 (f1 CHAR(5)) ENGINE=InnoDB;
+
+SET SESSION sql_mode='STRICT_ALL_TABLES';
+
+PREPARE st1 FROM 'INSERT INTO t1 VALUES ("abc")';
+PREPARE st2 FROM 'INSERT INTO t2 VALUES ("abc")';
+PREPARE st3 FROM 'INSERT INTO t3 VALUES ("abc")';
+PREPARE st4 FROM 'INSERT INTO t4 VALUES ("abc")';
+
+EXECUTE st1;
+EXECUTE st2;
+EXECUTE st3;
+EXECUTE st4;
+
+--connection node_2
+SELECT COUNT(*) = 1 FROM t1;
+SELECT COUNT(*) = 1 FROM t2;
+SELECT COUNT(*) = 1 FROM t3;
+SELECT COUNT(*) = 1 FROM t4;
+
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+ALTER TABLE t1 DROP COLUMN f1;
+
+--connection node_1
+--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
+EXECUTE st1;
+
+--connection node_1
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
diff --git a/mysql-test/suite/galera/t/galera_read_only.test b/mysql-test/suite/galera/t/galera_read_only.test
index 828f35d2ba3..c0fa4af07e0 100644
--- a/mysql-test/suite/galera/t/galera_read_only.test
+++ b/mysql-test/suite/galera/t/galera_read_only.test
@@ -17,7 +17,23 @@ INSERT INTO t1 VALUES (1);
--connection node_2
SELECT COUNT(*) = 1 FROM t1;
-SET GLOBAL read_only=FALSE;
+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;
DROP TABLE t1;
+DROP USER foo@localhost;
diff --git a/mysql-test/suite/galera/t/galera_restart_nochanges.test b/mysql-test/suite/galera/t/galera_restart_nochanges.test
index 4021ab39cc0..a61332cefd6 100644
--- a/mysql-test/suite/galera/t/galera_restart_nochanges.test
+++ b/mysql-test/suite/galera/t/galera_restart_nochanges.test
@@ -22,6 +22,7 @@ INSERT INTO t1 VALUES (1);
--let $galera_server_number = 2
--source include/galera_connect.inc
--connection node_2a
+--source include/wait_until_ready.inc
SELECT COUNT(*) = 1 FROM t1;
SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
diff --git a/mysql-test/suite/galera/t/galera_serializable.test b/mysql-test/suite/galera/t/galera_serializable.test
new file mode 100644
index 00000000000..b12d57fd488
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_serializable.test
@@ -0,0 +1,76 @@
+#
+# Test that the SERIALIZABLE isolation level behaves as expected.
+# A local serializable transaction is aborted by an incoming remote update
+#
+# wsrep_sync_wait does not work well with serializable, see mysql-wsrep#130
+# hence the need to use --sleep .
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+
+CREATE TABLE t1 (id INT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB;
+
+#
+# Read (local transaction) / Write (remote transaction) conflict
+#
+
+SET AUTOCOMMIT=OFF;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+START TRANSACTION;
+
+SELECT * FROM t1;
+
+--connection node_2
+INSERT INTO t1 VALUES (1,1);
+
+--sleep 2
+--connection node_1
+--error ER_LOCK_DEADLOCK
+SELECT * FROM t1;
+
+ROLLBACK;
+DELETE FROM t1;
+
+#
+# Write (local transaction) / Write (remote transaction) conflict
+#
+
+--connection node_1
+INSERT INTO t1 VALUES (1,1);
+START TRANSACTION;
+SELECT * FROM t1;
+
+--connection node_2
+UPDATE t1 SET f2 = 2;
+
+--sleep 2
+--connection node_1
+--error ER_LOCK_DEADLOCK
+UPDATE t1 SET f2 = 3;
+
+ROLLBACK;
+DELETE FROM t1;
+
+#
+# Write (local transaction) / Write (remote transaction) conflict
+# Local transaction writes before remote one.
+# Nothing special happens here - ordinary deadlock on COMMIT
+#
+
+--connection node_1
+START TRANSACTION;
+
+--connection node_1
+INSERT INTO t1 VALUES (1,1);
+
+--connection node_2
+INSERT INTO t1 VALUES (1,2);
+
+--connection node_1
+--error ER_LOCK_DEADLOCK
+COMMIT;
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_split_brain.test b/mysql-test/suite/galera/t/galera_split_brain.test
index c3e779618df..e0298e55422 100644
--- a/mysql-test/suite/galera/t/galera_split_brain.test
+++ b/mysql-test/suite/galera/t/galera_split_brain.test
@@ -38,7 +38,7 @@ SET GLOBAL wsrep_cluster_address = '';
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
---sleep 5
+--sleep 10
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--source include/wait_until_connected_again.inc
diff --git a/mysql-test/suite/galera/t/galera_ssl_compression.cnf b/mysql-test/suite/galera/t/galera_ssl_compression.cnf
new file mode 100644
index 00000000000..d6fd2c4d510
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_ssl_compression.cnf
@@ -0,0 +1,7 @@
+!include ../galera_2nodes.cnf
+
+[mysqld.1]
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;socket.ssl=yes;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem;socket.ssl_compression=YES'
+
+[mysqld.2]
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;socket.ssl=yes;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem;socket.ssl_compression=YES'
diff --git a/mysql-test/suite/galera/t/galera_ssl_compression.test b/mysql-test/suite/galera/t/galera_ssl_compression.test
new file mode 100644
index 00000000000..cdecf4807d4
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_ssl_compression.test
@@ -0,0 +1,34 @@
+#
+# Test SSL compression. The accompanying galera_ssl_compression.cnf has a customized wsrep_provider_options setting that enables SSL and compression.
+#
+# Unfortunately there is no wire-level traffic bytes counter that would allow us to determine that compression kicked in, so we can only
+# perform a most basic replication check.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+--connection node_2
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+--connection node_1
+
+# Check that the socket.ssl_compression provider option is not dynamic
+--error ER_WRONG_ARGUMENTS
+SET GLOBAL wsrep_provider_options = "socket.ssl_compression=No";
+
+CREATE TABLE t1 (f1 VARCHAR(333) PRIMARY KEY, f2 BLOB) Engine=InnoDB;
+INSERT INTO t1 VALUES (REPEAT('a', 333), REPEAT('b', 65535));
+
+--connection node_2
+SELECT COUNT(*) = 1 FROM t1 WHERE f1 = REPEAT('a', 333) AND f2 = REPEAT('b', 65535);
+
+--connection node_1
+DROP TABLE t1;
+
+CALL mtr.add_suppression("Unknown parameter 'socket\.ssl_compression'");
+CALL mtr.add_suppression("Set options returned 7");
diff --git a/mysql-test/suite/galera/t/galera_ssl_upgrade.cnf b/mysql-test/suite/galera/t/galera_ssl_upgrade.cnf
new file mode 100644
index 00000000000..2954ae0f4cb
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_ssl_upgrade.cnf
@@ -0,0 +1,7 @@
+!include ../galera_2nodes.cnf
+
+[mysqld.1]
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;socket.ssl=yes;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem'
+
+[mysqld.2]
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;socket.ssl=yes;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem'
diff --git a/mysql-test/suite/galera/t/galera_ssl_upgrade.test b/mysql-test/suite/galera/t/galera_ssl_upgrade.test
new file mode 100644
index 00000000000..07aac0fbe92
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_ssl_upgrade.test
@@ -0,0 +1,46 @@
+#
+# Test upgrading the SSL certificates in a rolling fashion.
+#
+# 1. The starting state with the old key and cert is is described in galera_ssl_upgrade.cnf
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+# 2. Restart node #1 with a socket.ssl_ca that includes both the new and the old certificate
+
+--connection node_1
+--source include/shutdown_mysqld.inc
+--let $start_mysqld_params = --wsrep-cluster-address=gcomm://127.0.0.1:$NODE_GALERAPORT_2 --wsrep_provider_options=base_port=$NODE_GALERAPORT_1;socket.ssl=yes;socket.ssl_ca=$MYSQL_TEST_DIR/std_data/galera-upgrade-ca-cert.pem;socket.ssl_cert=$MYSQL_TEST_DIR/std_data/galera-cert.pem;socket.ssl_key=$MYSQL_TEST_DIR/std_data/galera-key.pem
+--source include/start_mysqld.inc
+--source include/wait_until_connected_again.inc
+
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+# 3. Restart node #2 with the new socket.ssl_ca , socket.ssl_cert and socket.ssl_key
+
+--connection node_2
+--source include/shutdown_mysqld.inc
+--let $start_mysqld_params = --wsrep_provider_options=base_port=$NODE_GALERAPORT_2;socket.ssl=yes;socket.ssl_ca=$MYSQL_TEST_DIR/std_data/galera-upgrade-ca-cert.pem;socket.ssl_cert=$MYSQL_TEST_DIR/std_data/galera-upgrade-server-cert.pem;socket.ssl_key=$MYSQL_TEST_DIR/std_data/galera-upgrade-server-key.pem
+--source include/start_mysqld.inc
+--source include/wait_until_connected_again.inc
+
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+# 4. Restart node #1 with the new socket.ssl_ca , socket.ssl_cert and socket.ssl_key
+
+--connection node_1
+--source include/shutdown_mysqld.inc
+--let $start_mysqld_params = --wsrep-cluster-address=gcomm://127.0.0.1:$NODE_GALERAPORT_2 --wsrep_provider_options=base_port=$NODE_GALERAPORT_1;socket.ssl=yes;socket.ssl_ca=$MYSQL_TEST_DIR/std_data/galera-upgrade-ca-cert.pem;socket.ssl_cert=$MYSQL_TEST_DIR/std_data/galera-upgrade-server-cert.pem;socket.ssl_key=$MYSQL_TEST_DIR/std_data/galera-upgrade-server-key.pem
+--source include/start_mysqld.inc
+--source include/wait_until_connected_again.inc
+
+SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+# Upgrade complete. Both nodes now use the new key and certificate
diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf
new file mode 100644
index 00000000000..e108484b248
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf
@@ -0,0 +1,22 @@
+!include ../galera_2nodes.cnf
+
+# We do not set mysqldump-related SST options here because doing so on startup
+# causes the first MTR connection to be forefully dropped by Galera, which in turn confuses MTR
+
+[mysqld.1]
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true'
+
+[mysqld.2]
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'
+
+[mysqld]
+wsrep_debug=ON
+
+ssl-ca=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem
+ssl-cert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem
+ssl-key=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem
+
+[client]
+ssl-ca=@ENV.MYSQL_TEST_DIR/std_data/cacert.pem
+ssl-cert=@ENV.MYSQL_TEST_DIR/std_data/client-cert.pem
+ssl-key=@ENV.MYSQL_TEST_DIR/std_data/client-key.pem
diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test
new file mode 100644
index 00000000000..0b3edeb75ff
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test
@@ -0,0 +1,22 @@
+#
+# Test mysqldump SST with client SSL key. See galera_sst_mysqldump_with_key.cnf for the configuration on the client side.
+#
+
+--source include/big_test.inc
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source include/have_openssl.inc
+
+--source suite/galera/include/galera_sst_set_mysqldump.inc
+
+--connection node_1
+CREATE USER sslsst;
+GRANT ALL PRIVILEGES ON *.* TO sslsst;
+GRANT USAGE ON *.* TO sslsst REQUIRE SSL;
+
+SET GLOBAL wsrep_sst_auth = 'sslsst:';
+
+--source suite/galera/include/galera_st_disconnect_slave.inc
+
+--source suite/galera/include/galera_sst_restore.inc
+DROP USER sslsst;
diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.cnf b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.cnf
new file mode 100644
index 00000000000..31bd1af07c2
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.cnf
@@ -0,0 +1,24 @@
+!include ../galera_2nodes.cnf
+
+[mysqld]
+wsrep_sst_method=xtrabackup-v2
+wsrep_sst_auth="root:"
+wsrep_debug=ON
+
+[xtrabackup]
+backup-locks
+close-files
+compact
+# compression requires qpress from the Percona repositories
+# compress
+# compress-threads=2
+encryption=AES256
+encrypt-key=4FA92C5873672E20FB163A0BCB2BB4A4
+galera-info
+history=backup
+parallel=2
+
+[SST]
+encrypt=1
+encrypt-algo=AES256
+encrypt-key=4FA92C5873672E20FB163A0BCB2BB4A4
diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.test b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.test
new file mode 100644
index 00000000000..4573f176482
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.test
@@ -0,0 +1,13 @@
+#
+# This test checks that various options can be passed to xtrabackup via the my.cnf file
+# Initial SST happens via xtrabackup, so there is not much to do in the body of the test
+#
+
+--source include/big_test.inc
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+SELECT 1;
+
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.cnf b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.cnf
new file mode 100644
index 00000000000..969516f5f3b
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.cnf
@@ -0,0 +1,11 @@
+!include ../galera_2nodes.cnf
+
+[mysqld]
+wsrep_sst_method=xtrabackup-v2
+wsrep_sst_auth="root:"
+wsrep_debug=ON
+
+[SST]
+tkey=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem
+tcert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem
+encrypt=3
diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.test b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.test
new file mode 100644
index 00000000000..24d9589d111
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.test
@@ -0,0 +1,13 @@
+#
+# This test checks that key and cert encryption options can be passed to xtrabackup via the my.cnf file
+# Initial SST happens via xtrabackup, so there is not much to do in the body of the test
+#
+
+--source include/big_test.inc
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+SELECT 1;
+
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
diff --git a/mysql-test/suite/galera/t/galera_status_local_index.test b/mysql-test/suite/galera/t/galera_status_local_index.test
new file mode 100644
index 00000000000..b61b8ced863
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_status_local_index.test
@@ -0,0 +1,21 @@
+#
+# Test that a two-node cluster has distinct values for wsrep_local_index for its nodes
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+CREATE TABLE wsrep_local_indexes (wsrep_local_index INTEGER);
+INSERT INTO wsrep_local_indexes VALUES ((SELECT variable_value FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_local_index'));
+
+--connection node_2
+INSERT INTO wsrep_local_indexes VALUES ((SELECT variable_value FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_local_index'));
+
+
+--connection node_1
+SELECT COUNT(*) = 2 FROM wsrep_local_indexes;
+SELECT COUNT(DISTINCT wsrep_local_index) = 2 FROM wsrep_local_indexes;
+SELECT COUNT(*) = 0 FROM wsrep_local_indexes WHERE wsrep_local_index NOT IN (0, 1);
+
+DROP TABLE wsrep_local_indexes;
diff --git a/mysql-test/suite/galera/t/galera_transaction_replay.test b/mysql-test/suite/galera/t/galera_transaction_replay.test
index d2c74ab192b..632aa5cc0d5 100644
--- a/mysql-test/suite/galera/t/galera_transaction_replay.test
+++ b/mysql-test/suite/galera/t/galera_transaction_replay.test
@@ -23,7 +23,7 @@ SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE;
# Block the commit
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
-SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_enter_sync';
+SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync';
--connection node_1
--send COMMIT;
@@ -31,17 +31,25 @@ SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_enter_sync';
# Wait until commit is blocked
--connection node_1a
SET SESSION wsrep_sync_wait = 0;
---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters' AND VARIABLE_VALUE = 'apply_monitor_enter_sync'
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters' AND VARIABLE_VALUE = 'commit_monitor_enter_sync'
--source include/wait_condition.inc
# Issue a conflicting update on node #2
--connection node_2
UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
+# Wait for both transactions to be blocked
+--connection node_1a
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'System lock';
+--source include/wait_condition.inc
+
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT';
+--source include/wait_condition.inc
+
# Unblock the commit
--connection node_1a
SET GLOBAL wsrep_provider_options = 'dbug=';
-SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_enter_sync';
+SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync';
# Commit succeeds
--connection node_1
diff --git a/mysql-test/suite/galera/t/galera_var_load_data_splitting.test b/mysql-test/suite/galera/t/galera_var_load_data_splitting.test
index 0783dc897f8..38dab0a981b 100644
--- a/mysql-test/suite/galera/t/galera_var_load_data_splitting.test
+++ b/mysql-test/suite/galera/t/galera_var_load_data_splitting.test
@@ -1,5 +1,6 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
+--source include/big_test.inc
--let $wsrep_load_data_splitting_orig = `SELECT @@wsrep_load_data_splitting`
diff --git a/mysql-test/suite/galera/t/galera_var_log_bin.cnf b/mysql-test/suite/galera/t/galera_var_log_bin.cnf
new file mode 100644
index 00000000000..f7f17e3720a
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_var_log_bin.cnf
@@ -0,0 +1,5 @@
+!include ../galera_2nodes.cnf
+
+[mysqld]
+log-bin
+
diff --git a/mysql-test/suite/galera/t/galera_var_log_bin.test b/mysql-test/suite/galera/t/galera_var_log_bin.test
new file mode 100644
index 00000000000..1b1886b996d
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_var_log_bin.test
@@ -0,0 +1,22 @@
+#
+# A simple test that confirms that Galera works with log-bin enabled, that is
+# when MySQL's binlog is in effect rather than the Galera 'dummy' implementation.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (1);
+
+--connection node_2
+SELECT COUNT(*) = 1 FROM t1;
+
+--connection node_1
+UPDATE t1 SET f1 = 2 WHERE f1 = 1;
+
+--connection node_2
+SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2;
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_var_node_address.cnf b/mysql-test/suite/galera/t/galera_var_node_address.cnf
new file mode 100644
index 00000000000..0de0edaa396
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_var_node_address.cnf
@@ -0,0 +1,10 @@
+!include ../galera_4nodes.cnf
+
+[mysqld.2]
+wsrep_node_address=127.0.0.1
+
+[mysqld.3]
+wsrep_node_address=localhost
+
+[mysqld.4]
+wsrep_node_address=lo
diff --git a/mysql-test/suite/galera/t/galera_var_node_address.test b/mysql-test/suite/galera/t/galera_var_node_address.test
new file mode 100644
index 00000000000..cf118cf9934
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_var_node_address.test
@@ -0,0 +1,22 @@
+#
+# Test wsrep_node_address . The galera_var_node_address.cnf contains various settings for
+# wsrep_node_address, so in this test we simply confirm that the cluster has started up correctly.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+--connection node_1
+CREATE TABLE t1 (f1 INTEGER);
+
+--connection node_2
+INSERT INTO t1 VALUES (1);
+
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+SELECT COUNT(*) = 1 FROM t1;
+
+--connection node_1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_var_slave_threads.test b/mysql-test/suite/galera/t/galera_var_slave_threads.test
index a83924c13ce..50e22fbef66 100644
--- a/mysql-test/suite/galera/t/galera_var_slave_threads.test
+++ b/mysql-test/suite/galera/t/galera_var_slave_threads.test
@@ -68,3 +68,17 @@ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system use
DROP TABLE t1;
DROP TABLE t2;
+
+--echo #
+--echo # lp:1372840 - Changing wsrep_slave_threads causes future connections to hang
+--echo #
+
+--connection node_1
+CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=INNODB;
+
+--connection node_2
+SET GLOBAL wsrep_slave_threads = 4;
+SET GLOBAL wsrep_slave_threads = 1;
+DROP TABLE t1;
+
+--echo # End of tests
diff --git a/mysql-test/suite/galera/t/galera_wan_restart_ist.cnf b/mysql-test/suite/galera/t/galera_wan_restart_ist.cnf
new file mode 100644
index 00000000000..3f7d2a2448f
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_wan_restart_ist.cnf
@@ -0,0 +1,14 @@
+!include ../galera_4nodes.cnf
+
+[mysqld.1]
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.segment=1'
+
+[mysqld.2]
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;gmcast.segment=1'
+
+[mysqld.3]
+wsrep_provider_options='base_port=@mysqld.3.#galera_port;gmcast.segment=2'
+
+[mysqld.4]
+wsrep_provider_options='base_port=@mysqld.4.#galera_port;gmcast.segment=2'
+
diff --git a/mysql-test/suite/galera/t/galera_wan_restart_ist.test b/mysql-test/suite/galera/t/galera_wan_restart_ist.test
new file mode 100644
index 00000000000..42f63df3acc
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_wan_restart_ist.test
@@ -0,0 +1,148 @@
+#
+# Test that even after multiple restarts in a WAN context with two segments, the cluster continues to operate correctly.
+#
+# We can not easily restart the first node, so instead we restart all the other nodes. MTR does not allow multiple nodes
+# to be down at the same time, so restarts are sequential.
+#
+# We can not test any of the actual WAN optimizations from inside MTR and no
+# status variables are provided. So we only check that simple replication works.
+#
+
+--source include/big_test.inc
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+--connection node_1
+CREATE TABLE t1 (f1 INTEGER);
+INSERT INTO t1 VALUES (1);
+
+--connection node_2
+INSERT INTO t1 VALUES (2);
+
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+INSERT INTO t1 VALUES (3);
+
+--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
+--connection node_4
+INSERT INTO t1 VALUES (4);
+
+#
+# Restart node #3
+#
+
+--connection node_3
+INSERT INTO t1 VALUES (13);
+
+--echo Shutting down server ...
+--source include/shutdown_mysqld.inc
+--sleep 5
+
+--connection node_1
+INSERT INTO t1 VALUES (11);
+
+--connection node_2
+INSERT INTO t1 VALUES (12);
+
+--connection node_4
+INSERT INTO t1 VALUES (14);
+
+--connection node_3
+--source include/start_mysqld.inc
+--sleep 5
+--source include/wait_until_connected_again.inc
+
+INSERT INTO t1 VALUES (131);
+
+#
+# Restart node #2
+#
+
+--connection node_2
+INSERT INTO t1 VALUES (22);
+
+--echo Shutting down server ...
+--source include/shutdown_mysqld.inc
+--sleep 5
+
+--connection node_1
+INSERT INTO t1 VALUES (21);
+
+--connection node_3
+INSERT INTO t1 VALUES (23);
+
+--connection node_4
+INSERT INTO t1 VALUES (24);
+
+--connection node_2
+--source include/start_mysqld.inc
+--sleep 5
+--source include/wait_until_connected_again.inc
+
+INSERT INTO t1 VALUES (221);
+
+#
+# Restart node #4
+#
+
+--connection node_4
+INSERT INTO t1 VALUES (34);
+
+--echo Shutting down server ...
+--source include/shutdown_mysqld.inc
+--sleep 5
+
+--connection node_1
+INSERT INTO t1 VALUES (31);
+
+--connection node_2
+INSERT INTO t1 VALUES (32);
+
+--connection node_3
+INSERT INTO t1 VALUES (33);
+
+--connection node_4
+--source include/start_mysqld.inc
+--sleep 5
+--source include/wait_until_connected_again.inc
+
+INSERT INTO t1 VALUES (341);
+
+
+#
+# Check all nodes
+#
+
+--connection node_1
+--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+SELECT COUNT(*) = 19 FROM t1;
+
+--connection node_2
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+SELECT COUNT(*) = 19 FROM t1;
+
+--connection node_3
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+SELECT COUNT(*) = 19 FROM t1;
+
+--connection node_4
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+SELECT COUNT(*) = 19 FROM t1;
+
+--connection node_1
+DROP TABLE t1;
+CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside");
+
+--connection node_2
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
+
+--connection node_3
+CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside");
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
+
+--connection node_4
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
diff --git a/mysql-test/suite/galera/t/galera_wan_restart_sst.cnf b/mysql-test/suite/galera/t/galera_wan_restart_sst.cnf
new file mode 100644
index 00000000000..3f7d2a2448f
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_wan_restart_sst.cnf
@@ -0,0 +1,14 @@
+!include ../galera_4nodes.cnf
+
+[mysqld.1]
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.segment=1'
+
+[mysqld.2]
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;gmcast.segment=1'
+
+[mysqld.3]
+wsrep_provider_options='base_port=@mysqld.3.#galera_port;gmcast.segment=2'
+
+[mysqld.4]
+wsrep_provider_options='base_port=@mysqld.4.#galera_port;gmcast.segment=2'
+
diff --git a/mysql-test/suite/galera/t/galera_wan_restart_sst.test b/mysql-test/suite/galera/t/galera_wan_restart_sst.test
new file mode 100644
index 00000000000..9b12eeed1ac
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_wan_restart_sst.test
@@ -0,0 +1,149 @@
+#
+# Test that even after multiple restarts in a WAN context with two segments, the cluster continues to operate correctly.
+#
+# We can not easily restart the first node, so instead we restart all the other nodes. MTR does not allow multiple nodes
+# to be down at the same time, so restarts are sequential.
+#
+# We can not test any of the actual WAN optimizations from inside MTR and no
+# status variables are provided. So we only check that simple replication works.
+#
+
+--source include/big_test.inc
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+--connection node_1
+CREATE TABLE t1 (f1 INTEGER);
+INSERT INTO t1 VALUES (1);
+
+--connection node_2
+INSERT INTO t1 VALUES (2);
+
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+INSERT INTO t1 VALUES (3);
+
+--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
+--connection node_4
+INSERT INTO t1 VALUES (4);
+
+#
+# Restart node #3
+#
+
+--connection node_3
+INSERT INTO t1 VALUES (13);
+
+--source include/kill_galera.inc
+--sleep 5
+
+--connection node_1
+--source include/wait_until_connected_again.inc
+INSERT INTO t1 VALUES (11);
+
+--connection node_2
+INSERT INTO t1 VALUES (12);
+
+--connection node_4
+INSERT INTO t1 VALUES (14);
+
+--connection node_3
+--source include/start_mysqld.inc
+--sleep 5
+--source include/wait_until_connected_again.inc
+
+INSERT INTO t1 VALUES (131);
+
+#
+# Restart node #2
+#
+
+--connection node_2
+INSERT INTO t1 VALUES (22);
+
+--source include/kill_galera.inc
+--sleep 5
+
+--connection node_1
+--source include/wait_until_connected_again.inc
+INSERT INTO t1 VALUES (21);
+
+--connection node_3
+INSERT INTO t1 VALUES (23);
+
+--connection node_4
+INSERT INTO t1 VALUES (24);
+
+--connection node_2
+--source include/start_mysqld.inc
+--sleep 5
+--source include/wait_until_connected_again.inc
+
+INSERT INTO t1 VALUES (221);
+
+#
+# Restart node #4
+#
+
+--connection node_4
+INSERT INTO t1 VALUES (34);
+
+--source include/kill_galera.inc
+--sleep 5
+
+--connection node_1
+--source include/wait_until_connected_again.inc
+INSERT INTO t1 VALUES (31);
+
+--connection node_2
+INSERT INTO t1 VALUES (32);
+
+--connection node_3
+INSERT INTO t1 VALUES (33);
+
+--connection node_4
+--source include/start_mysqld.inc
+--sleep 5
+--source include/wait_until_connected_again.inc
+
+INSERT INTO t1 VALUES (341);
+
+
+#
+# Check all nodes
+#
+
+--connection node_1
+--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+SELECT COUNT(*) = 19 FROM t1;
+
+--connection node_2
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+SELECT COUNT(*) = 19 FROM t1;
+
+--connection node_3
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+SELECT COUNT(*) = 19 FROM t1;
+
+--connection node_4
+SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+SELECT COUNT(*) = 19 FROM t1;
+
+--connection node_1
+DROP TABLE t1;
+CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside");
+CALL mtr.add_suppression("WSREP: gcs_caused\\(\\) returned -1 \\(Operation not permitted\\)");
+
+--connection node_2
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
+
+--connection node_3
+CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside");
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
+
+--connection node_4
+CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
diff --git a/mysql-test/suite/galera/t/lp1438990.test b/mysql-test/suite/galera/t/lp1438990.test
new file mode 100644
index 00000000000..5d54c3338e5
--- /dev/null
+++ b/mysql-test/suite/galera/t/lp1438990.test
@@ -0,0 +1,38 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t2 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t3 (f1 INTEGER PRIMARY KEY);
+
+CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CALL p1(NEW.f1);
+
+
+DELIMITER |;
+
+CREATE PROCEDURE p1 (IN x INT)
+BEGIN
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK TO event_logging;
+ INSERT t3 VALUES (x);
+ END;
+ SAVEPOINT event_logging;
+
+ INSERT INTO t2 VALUES (x);
+
+ RELEASE SAVEPOINT event_logging;
+END|
+DELIMITER ;|
+
+
+INSERT INTO t2 VALUES (1);
+INSERT INTO t1 VALUES (1);
+
+DROP PROCEDURE p1;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
diff --git a/mysql-test/suite/galera/t/mysql-wsrep#110.test b/mysql-test/suite/galera/t/mysql-wsrep#110.test
new file mode 100644
index 00000000000..43520f257a1
--- /dev/null
+++ b/mysql-test/suite/galera/t/mysql-wsrep#110.test
@@ -0,0 +1,51 @@
+#
+# codership/mysql-wsrep/110 - Assertion `table_found' failed in unpack_row() with SAVEPOINT, trigger, error handler
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t2 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t3 (f1 INTEGER PRIMARY KEY);
+
+CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CALL p1(NEW.f1);
+
+
+DELIMITER |;
+
+CREATE PROCEDURE p1 (IN x INT)
+BEGIN
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK TO event_logging;
+ INSERT t3 VALUES (x);
+ END;
+ SAVEPOINT event_logging;
+
+ INSERT INTO t2 VALUES (x);
+END|
+DELIMITER ;|
+
+
+INSERT INTO t2 VALUES (1);
+INSERT INTO t1 VALUES (1);
+
+SELECT COUNT(*) = 1 FROM t1;
+SELECT COUNT(*) = 1 FROM t2;
+SELECT COUNT(*) = 1 FROM t3;
+
+--connection node_2
+
+SELECT COUNT(*) = 1 FROM t1;
+SELECT COUNT(*) = 1 FROM t2;
+SELECT COUNT(*) = 1 FROM t3;
+
+--connection node_1
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP PROCEDURE p1;
diff --git a/mysql-test/suite/galera/t/mysql-wsrep#90.test b/mysql-test/suite/galera/t/mysql-wsrep#90.test
new file mode 100644
index 00000000000..5af86fb2872
--- /dev/null
+++ b/mysql-test/suite/galera/t/mysql-wsrep#90.test
@@ -0,0 +1,65 @@
+# Crash in galera_to_execute_end when wsrep_OSU_method is changed from RSU to TOI during a DDL
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source include/have_debug_sync.inc
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB;
+
+--connection node_1
+SET GLOBAL wsrep_OSU_method = "RSU";
+SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue';
+--send ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+
+
+--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1a
+SET SESSION wsrep_sync_wait = 0;
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_before_open_tables'
+--source include/wait_condition.inc
+
+SET GLOBAL wsrep_OSU_method = "TOI";
+SET DEBUG_SYNC= 'now SIGNAL continue';
+
+--connection node_1
+--reap
+
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+
+--connection node_2
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+
+--connection node_1
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB;
+
+--connection node_1
+SET GLOBAL wsrep_OSU_method = "TOI";
+SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue';
+--send ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+
+--connection node_1a
+SET SESSION wsrep_sync_wait = 0;
+
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_before_open_tables'
+--source include/wait_condition.inc
+
+SET GLOBAL wsrep_OSU_method = "RSU";
+SET DEBUG_SYNC= 'now SIGNAL continue';
+
+--connection node_1
+--reap
+
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+INSERT INTO t1 VALUES (1,2);
+
+--connection node_2
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+INSERT INTO t1 VALUES (3,4);
+
+--connection node_1
+DROP TABLE t1;
+
+SET GLOBAL WSREP_OSU_METHOD = TOI;
diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def
index ec02e73b4a3..fb23a81bfb8 100644
--- a/mysql-test/suite/galera_3nodes/disabled.def
+++ b/mysql-test/suite/galera_3nodes/disabled.def
@@ -1,2 +1,5 @@
galera_garbd : Fix the test case
galera_evs_suspect_timeout : TODO: investigate
+galera_innobackupex_backup : TODO: investigate
+galera_slave_options_do :MDEV-8798
+galera_slave_options_ignore : MDEV-8798
diff --git a/mysql-test/suite/galera_3nodes/r/galera_garbd.result b/mysql-test/suite/galera_3nodes/r/galera_garbd.result
index 616c9d33303..180aade029c 100644
--- a/mysql-test/suite/galera_3nodes/r/galera_garbd.result
+++ b/mysql-test/suite/galera_3nodes/r/galera_garbd.result
@@ -12,3 +12,6 @@ COUNT(*) = 2
1
DROP TABLE t1;
Restarting node #3 to satisfy MTR's end-of-test checks
+CALL mtr.add_suppression("WSREP: Protocol violation\. JOIN message sender 1\.0 \(.*\) is not in state transfer \(SYNCED\)");
+CALL mtr.add_suppression("WSREP: Protocol violation\. JOIN message sender 1\.0 \(.*\) is not in state transfer \(SYNCED\)");
+CALL mtr.add_suppression("WSREP: Protocol violation\. JOIN message sender 1\.0 \(.*\) is not in state transfer \(SYNCED\)");
diff --git a/mysql-test/suite/galera_3nodes/r/galera_innobackupex_backup.result b/mysql-test/suite/galera_3nodes/r/galera_innobackupex_backup.result
new file mode 100644
index 00000000000..85000db8e77
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/r/galera_innobackupex_backup.result
@@ -0,0 +1,11 @@
+CREATE TABLE t1 (f1 INTEGER);
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+SELECT COUNT(*) = 10 FROM t1;
+COUNT(*) = 10
+1
+Killing server ...
+INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
+SELECT COUNT(*) = 20 FROM t1;
+COUNT(*) = 20
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result b/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result
new file mode 100644
index 00000000000..f5a4cad4a23
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result
@@ -0,0 +1,29 @@
+CREATE TABLE t1 (f1 INTEGER);
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+SET SESSION wsrep_sync_wait = 0;
+SHOW STATUS LIKE 'wsrep_cluster_status';
+Variable_name Value
+wsrep_cluster_status non-Primary
+SET GLOBAL wsrep_provider_options = 'pc.bootstrap=1';
+SHOW STATUS LIKE 'wsrep_cluster_size';
+Variable_name Value
+wsrep_cluster_size 1
+SHOW STATUS LIKE 'wsrep_cluster_status';
+Variable_name Value
+wsrep_cluster_status Primary
+INSERT INTO t1 VALUES (1);
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result b/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result
index ca051436491..85f923ad55e 100644
--- a/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result
+++ b/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result
@@ -39,9 +39,6 @@ SHOW STATUS LIKE 'wsrep_local_state_comment';
Variable_name Value
wsrep_local_state_comment Initialized
Resuming node ...
-SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
-VARIABLE_VALUE = 1
-1
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
VARIABLE_VALUE = 'Primary'
1
@@ -57,6 +54,7 @@ VARIABLE_VALUE = 4
SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
VARIABLE_VALUE = 'Synced'
1
+SET GLOBAL wsrep_provider_options = 'pc.weight=1';
SET SESSION wsrep_sync_wait=0;
SET SESSION wsrep_sync_wait=0;
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
@@ -113,6 +111,9 @@ VARIABLE_VALUE = 4
SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
VARIABLE_VALUE = 'Synced'
1
+SET GLOBAL wsrep_provider_options = 'pc.weight=1';
CALL mtr.add_suppression('WSREP: gcs_caused\\(\\) returned -1');
+CALL mtr.add_suppression('overriding reported weight for');
CALL mtr.add_suppression('WSREP: user message in state LEAVING');
CALL mtr.add_suppression('sending install message failed: Transport endpoint is not connected');
+CALL mtr.add_suppression('overriding reported weight for');
diff --git a/mysql-test/suite/galera_3nodes/r/galera_slave_options_do.result b/mysql-test/suite/galera_3nodes/r/galera_slave_options_do.result
new file mode 100644
index 00000000000..7185e92863d
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/r/galera_slave_options_do.result
@@ -0,0 +1,28 @@
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+CREATE TABLE db1.t1 (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE db2.t2A (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE db2.t2B (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO db1.t1 VALUES (1);
+INSERT INTO db2.t2A VALUES (2);
+INSERT INTO db2.t2B VALUES (3);
+SELECT COUNT(*) = 0 FROM db1.t1;
+COUNT(*) = 0
+1
+SELECT COUNT(*) = 0 FROM db2.t2A;
+COUNT(*) = 0
+1
+SELECT COUNT(*) = 1 FROM db2.t2B;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 0 FROM db1.t1;
+COUNT(*) = 0
+1
+SELECT COUNT(*) = 1 FROM db2.t2A;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM db2.t2B;
+COUNT(*) = 1
+1
+DROP SCHEMA db1;
+DROP SCHEMA db2;
diff --git a/mysql-test/suite/galera_3nodes/r/galera_slave_options_ignore.result b/mysql-test/suite/galera_3nodes/r/galera_slave_options_ignore.result
new file mode 100644
index 00000000000..7185e92863d
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/r/galera_slave_options_ignore.result
@@ -0,0 +1,28 @@
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+CREATE TABLE db1.t1 (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE db2.t2A (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE db2.t2B (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO db1.t1 VALUES (1);
+INSERT INTO db2.t2A VALUES (2);
+INSERT INTO db2.t2B VALUES (3);
+SELECT COUNT(*) = 0 FROM db1.t1;
+COUNT(*) = 0
+1
+SELECT COUNT(*) = 0 FROM db2.t2A;
+COUNT(*) = 0
+1
+SELECT COUNT(*) = 1 FROM db2.t2B;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 0 FROM db1.t1;
+COUNT(*) = 0
+1
+SELECT COUNT(*) = 1 FROM db2.t2A;
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM db2.t2B;
+COUNT(*) = 1
+1
+DROP SCHEMA db1;
+DROP SCHEMA db2;
diff --git a/mysql-test/suite/galera_3nodes/suite.pm b/mysql-test/suite/galera_3nodes/suite.pm
index 1f00e37bdc3..39d5acbcc1b 100644
--- a/mysql-test/suite/galera_3nodes/suite.pm
+++ b/mysql-test/suite/galera_3nodes/suite.pm
@@ -42,6 +42,7 @@ push @::global_suppressions,
qr|WSREP: Ignoring possible split-brain (allowed by configuration) from view:.*|,
qr(WSREP: Could not find peer:),
qr(WSREP: Protocol violation. JOIN message sender .*),
+ qr(WSREP: JOIN message from member [0-9]* in non-primary configuration. Ignored.),
);
diff --git a/mysql-test/suite/galera_3nodes/t/galera_garbd.test b/mysql-test/suite/galera_3nodes/t/galera_garbd.test
index 3f58783ad31..a68ba8ce15b 100644
--- a/mysql-test/suite/galera_3nodes/t/galera_garbd.test
+++ b/mysql-test/suite/galera_3nodes/t/galera_garbd.test
@@ -34,6 +34,8 @@ SELECT COUNT(*) = 1 FROM t1;
--echo Killing garbd ...
--exec pkill --oldest --full garbd.*$NODE_GALERAPORT_3
+--sleep 5
+
--connection node_1
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
@@ -48,3 +50,15 @@ DROP TABLE t1;
--echo Restarting node #3 to satisfy MTR's end-of-test checks
--connection node_3
--source include/start_mysqld.inc
+
+
+# Workaround for galera#101
+
+--connection node_1
+CALL mtr.add_suppression("WSREP: Protocol violation\. JOIN message sender 1\.0 \(.*\) is not in state transfer \(SYNCED\)");
+
+--connection node_2
+CALL mtr.add_suppression("WSREP: Protocol violation\. JOIN message sender 1\.0 \(.*\) is not in state transfer \(SYNCED\)");
+
+--connection node_3
+CALL mtr.add_suppression("WSREP: Protocol violation\. JOIN message sender 1\.0 \(.*\) is not in state transfer \(SYNCED\)");
diff --git a/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test b/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test
new file mode 100644
index 00000000000..af4a5fbf9d6
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test
@@ -0,0 +1,58 @@
+#
+# This test uses innobackupex to take a backup on node #2 and then restores that node from backup
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+CREATE TABLE t1 (f1 INTEGER);
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+--connection node_2
+SELECT COUNT(*) = 10 FROM t1;
+
+--exec rm -rf $MYSQL_TMP_DIR/innobackupex_backup
+--exec innobackupex $MYSQL_TMP_DIR/innobackupex_backup --galera-info --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-backup.log
+--exec innobackupex $MYSQL_TMP_DIR/innobackupex_backup --apply-log --galera-info --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-apply.log
+
+--source include/kill_galera.inc
+--sleep 1
+
+--connection node_1
+INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
+
+--exec rm -rf $MYSQLTEST_VARDIR/mysqld.2/data/*
+--exec innobackupex --copy-back $MYSQL_TMP_DIR/innobackupex_backup --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 > $MYSQL_TMP_DIR/innobackupex-restore.log
+
+#
+# Convert the xtrabackup_galera_info into a grastate.dat file
+#
+
+--perl
+ use strict;
+ my $xtrabackup_galera_info_file = $ENV{'MYSQL_TMP_DIR'}.'/innobackupex_backup/xtrabackup_galera_info';
+ open(XTRABACKUP_GALERA_INFO, $xtrabackup_galera_info_file) or die "Can not open $xtrabackup_galera_info_file: $!";
+ my $xtrabackup_galera_info = <XTRABACKUP_GALERA_INFO>;
+ my ($uuid, $seqno) = split(':', $xtrabackup_galera_info);
+
+ my $grastate_dat_file = $ENV{'MYSQLTEST_VARDIR'}.'/mysqld.2/data/grastate.dat';
+ die "grastate.dat already exists" if -e $grastate_dat_file;
+
+ open(GRASTATE_DAT, ">$grastate_dat_file") or die "Can not write to $grastate_dat_file: $!";
+ print GRASTATE_DAT "version: 2.1\n";
+ print GRASTATE_DAT "uuid: $uuid\n";
+ print GRASTATE_DAT "seqno: $seqno\n";
+ print GRASTATE_DAT "cert_index:\n";
+ exit(0);
+EOF
+
+--source include/start_mysqld.inc
+--sleep 5
+
+--source include/wait_until_connected_again.inc
+SELECT COUNT(*) = 20 FROM t1;
+
+DROP TABLE t1;
+
+--sleep 10
diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test
new file mode 100644
index 00000000000..6172ffcc743
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test
@@ -0,0 +1,90 @@
+#
+# Test the operation of pc.bootstrap
+#
+
+--source include/big_test.inc
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (f1 INTEGER);
+
+# Force all nodes to become non-primary
+--connection node_1
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+
+--connection node_2
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+
+--sleep 10
+
+# Node #2 should be non-primary
+SET SESSION wsrep_sync_wait = 0;
+SHOW STATUS LIKE 'wsrep_cluster_status';
+
+# Signal node #2 to bootstrap
+--connection node_2
+SET GLOBAL wsrep_provider_options = 'pc.bootstrap=1';
+
+# Wait until node becomes available for queries again
+--source include/wait_until_connected_again.inc
+
+# Node #2 should now be a primary of a 1-node cluster
+
+SHOW STATUS LIKE 'wsrep_cluster_size';
+SHOW STATUS LIKE 'wsrep_cluster_status';
+
+# Perform an insert on node #2
+INSERT INTO t1 VALUES (1);
+
+# Reconnect all nodes
+--connection node_2
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+--sleep 10
+--source include/wait_until_connected_again.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+
+--connection node_1
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+--source include/wait_until_connected_again.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+
+--connection node_3
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+--sleep 10
+--source include/wait_until_connected_again.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+# Check that all nodes have the same view of the database
+
+--connection node_1
+SELECT COUNT(*) FROM t1;
+
+--connection node_2
+SELECT COUNT(*) FROM t1;
+
+--connection node_3
+SELECT COUNT(*) FROM t1;
+
+# Test cleanup
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test
index 8956bae98ec..6585f1934a4 100644
--- a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test
+++ b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test
@@ -7,7 +7,7 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
---let $wsrep_provider_options_node1 = `SELECT @@wsrep_provider_options`
+--connection node_1
SET GLOBAL wsrep_provider_options = 'pc.weight=3';
--source include/wait_until_connected_again.inc
@@ -50,13 +50,17 @@ SHOW STATUS LIKE 'wsrep_local_state_comment';
# For Node #1, we expect a primary component of size 1
-SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
+--source include/wait_condition.inc
+
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state';
SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+SET GLOBAL wsrep_provider_options = 'pc.weight=1';
+
# Restore the cluster by resetting wsrep_cluster_address on nodes #1 and #2
--connection node_2
@@ -103,8 +107,17 @@ SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N
SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
--connection node_1
+
+SET GLOBAL wsrep_provider_options = 'pc.weight=1';
+--let $wait_condition = SELECT @@wsrep_provider_options LIKE '%pc.weight = 1%'
+--source include/wait_condition.inc
+
CALL mtr.add_suppression('WSREP: gcs_caused\\(\\) returned -1');
+--connection node_2
+CALL mtr.add_suppression('overriding reported weight for');
+
--connection node_3
CALL mtr.add_suppression('WSREP: user message in state LEAVING');
CALL mtr.add_suppression('sending install message failed: Transport endpoint is not connected');
+CALL mtr.add_suppression('overriding reported weight for');
diff --git a/mysql-test/suite/galera_3nodes/t/galera_slave_options_do.cnf b/mysql-test/suite/galera_3nodes/t/galera_slave_options_do.cnf
new file mode 100644
index 00000000000..1ebde6186c1
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/t/galera_slave_options_do.cnf
@@ -0,0 +1,7 @@
+!include ../galera_3nodes.cnf
+
+[mysqld.1]
+binlog-do-db=db2
+
+[mysqld.2]
+replicate-wild-do-table=db2.t2B
diff --git a/mysql-test/suite/galera_3nodes/t/galera_slave_options_do.test b/mysql-test/suite/galera_3nodes/t/galera_slave_options_do.test
new file mode 100644
index 00000000000..1437c90c670
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/t/galera_slave_options_do.test
@@ -0,0 +1,34 @@
+#
+# This tests checks the operation of binlog-do-db , replicate-wild-do-table
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+CREATE TABLE db1.t1 (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE db2.t2A (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE db2.t2B (f1 INTEGER) ENGINE=InnoDB;
+
+INSERT INTO db1.t1 VALUES (1);
+INSERT INTO db2.t2A VALUES (2);
+INSERT INTO db2.t2B VALUES (3);
+
+--connection node_2
+SELECT COUNT(*) = 0 FROM db1.t1;
+SELECT COUNT(*) = 0 FROM db2.t2A;
+SELECT COUNT(*) = 1 FROM db2.t2B;
+
+
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+SELECT COUNT(*) = 0 FROM db1.t1;
+SELECT COUNT(*) = 1 FROM db2.t2A;
+SELECT COUNT(*) = 1 FROM db2.t2B;
+
+--connection node_1
+DROP SCHEMA db1;
+DROP SCHEMA db2;
diff --git a/mysql-test/suite/galera_3nodes/t/galera_slave_options_ignore.cnf b/mysql-test/suite/galera_3nodes/t/galera_slave_options_ignore.cnf
new file mode 100644
index 00000000000..9b78d47e254
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/t/galera_slave_options_ignore.cnf
@@ -0,0 +1,7 @@
+!include ../galera_3nodes.cnf
+
+[mysqld.1]
+binlog-ignore-db=db1
+
+[mysqld.2]
+replicate-wild-ignore-table=db2.t2A
diff --git a/mysql-test/suite/galera_3nodes/t/galera_slave_options_ignore.test b/mysql-test/suite/galera_3nodes/t/galera_slave_options_ignore.test
new file mode 100644
index 00000000000..3e8b1557e7b
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/t/galera_slave_options_ignore.test
@@ -0,0 +1,34 @@
+#
+# This tests checks the operation of binlog-ignore-db , replicate-wild-ignore-table
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+CREATE TABLE db1.t1 (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE db2.t2A (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE db2.t2B (f1 INTEGER) ENGINE=InnoDB;
+
+INSERT INTO db1.t1 VALUES (1);
+INSERT INTO db2.t2A VALUES (2);
+INSERT INTO db2.t2B VALUES (3);
+
+--connection node_2
+SELECT COUNT(*) = 0 FROM db1.t1;
+SELECT COUNT(*) = 0 FROM db2.t2A;
+SELECT COUNT(*) = 1 FROM db2.t2B;
+
+
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+SELECT COUNT(*) = 0 FROM db1.t1;
+SELECT COUNT(*) = 1 FROM db2.t2A;
+SELECT COUNT(*) = 1 FROM db2.t2B;
+
+--connection node_1
+DROP SCHEMA db1;
+DROP SCHEMA db2;
diff --git a/mysql-test/suite/jp/disabled.def b/mysql-test/suite/jp/disabled.def
index 888298bbb09..b74382895d2 100644
--- a/mysql-test/suite/jp/disabled.def
+++ b/mysql-test/suite/jp/disabled.def
@@ -9,3 +9,5 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
+
+binlog_index : codership/mysql-wsrep##71 Regression: Duplicate "file was not purged because it is the active log file" warning
diff --git a/mysql-test/suite/rpl/r/mysql-wsrep#110-2.result b/mysql-test/suite/rpl/r/mysql-wsrep#110-2.result
new file mode 100644
index 00000000000..fd07dfce188
--- /dev/null
+++ b/mysql-test/suite/rpl/r/mysql-wsrep#110-2.result
@@ -0,0 +1,24 @@
+include/master-slave.inc
+[connection master]
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t2 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t3 (f1 INTEGER PRIMARY KEY);
+CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CALL p1(NEW.f1);
+CREATE PROCEDURE p1 (IN x INT)
+BEGIN
+DECLARE EXIT HANDLER FOR SQLEXCEPTION
+BEGIN
+ROLLBACK TO event_logging;
+INSERT t3 VALUES (x);
+END;
+SAVEPOINT event_logging;
+INSERT INTO t2 VALUES (x);
+RELEASE SAVEPOINT event_logging;
+END|
+INSERT INTO t2 VALUES (1);
+INSERT INTO t1 VALUES (1);
+DROP TABLE t3;
+DROP TABLE t2;
+DROP TABLE t1;
+DROP PROCEDURE p1;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/mysql-wsrep#110-2.test b/mysql-test/suite/rpl/t/mysql-wsrep#110-2.test
new file mode 100644
index 00000000000..2b6d07913ab
--- /dev/null
+++ b/mysql-test/suite/rpl/t/mysql-wsrep#110-2.test
@@ -0,0 +1,44 @@
+#
+# codership/mysql-wsrep/110 - Assertion `table_found' failed in unpack_row() with SAVEPOINT, trigger, error handler
+#
+
+--source include/have_innodb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t2 (f1 INTEGER PRIMARY KEY);
+CREATE TABLE t3 (f1 INTEGER PRIMARY KEY);
+
+CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CALL p1(NEW.f1);
+
+DELIMITER |;
+
+CREATE PROCEDURE p1 (IN x INT)
+BEGIN
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ ROLLBACK TO event_logging;
+ INSERT t3 VALUES (x);
+ END;
+ SAVEPOINT event_logging;
+
+ INSERT INTO t2 VALUES (x);
+
+ RELEASE SAVEPOINT event_logging;
+END|
+DELIMITER ;|
+
+INSERT INTO t2 VALUES (1);
+INSERT INTO t1 VALUES (1);
+
+
+DROP TABLE t3;
+DROP TABLE t2;
+DROP TABLE t1;
+
+DROP PROCEDURE p1;
+
+sync_slave_with_master;
+--source include/rpl_end.inc
+
diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
index 54fd0beafdc..3dd9cc541c4 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
@@ -367,7 +367,7 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME WSREP_PATCH_VERSION
SESSION_VALUE NULL
-GLOBAL_VALUE wsrep_25.10
+GLOBAL_VALUE wsrep_25.11
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL
diff --git a/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result b/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result
index 991be9ade86..52fede2f538 100644
--- a/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result
+++ b/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result
@@ -1,7 +1,7 @@
#
# wsrep_desync
#
-call mtr.add_suppression("WSREP: SET desync failed 9 for SET @@global.wsrep_desync=ON");
+call mtr.add_suppression("WSREP: SET desync failed 9 for schema: test, query: SET @@global.wsrep_desync=ON");
# save the initial value
SET @wsrep_desync_global_saved = @@global.wsrep_desync;
# default
diff --git a/mysql-test/suite/sys_vars/t/wsrep_desync_basic.test b/mysql-test/suite/sys_vars/t/wsrep_desync_basic.test
index 67fe2402aed..e386004b92f 100644
--- a/mysql-test/suite/sys_vars/t/wsrep_desync_basic.test
+++ b/mysql-test/suite/sys_vars/t/wsrep_desync_basic.test
@@ -5,7 +5,7 @@
--echo #
# expected as no wsrep provider is currently loaded
-call mtr.add_suppression("WSREP: SET desync failed 9 for SET @@global.wsrep_desync=ON");
+call mtr.add_suppression("WSREP: SET desync failed 9 for schema: test, query: SET @@global.wsrep_desync=ON");
--echo # save the initial value
SET @wsrep_desync_global_saved = @@global.wsrep_desync;
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index 53ddda21258..a9e1a9e9d8e 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -1276,3 +1276,366 @@
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
}
+
+{
+ GitHub codership/galera#308
+ Memcheck:Leak
+ match-leak-kinds: definite
+ fun:malloc
+ fun:_ZNK6galera13ReplicatorSMM9stats_getEv
+ fun:_ZL28export_wsrep_status_to_mysqlP3THD
+ fun:_Z17wsrep_show_statusP3THDP17st_mysql_show_varPc
+ fun:_ZL17show_status_arrayP3THDPKcP17st_mysql_show_var13enum_var_typeP17system_status_varS2_P5TABLEbP4Item
+ fun:_Z11fill_statusP3THDP10TABLE_LISTP4Item
+ fun:_ZL13do_fill_tableP3THDP10TABLE_LISTP13st_join_table
+ fun:_Z24get_schema_tables_resultP4JOIN23enum_schema_table_state
+ fun:_ZN4JOIN14prepare_resultEPP4ListI4ItemE
+ fun:_ZN4JOIN4execEv
+ fun:_ZL20mysql_execute_selectP3THDP13st_select_lexb
+ fun:_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_P10SQL_I_ListI8st_orderESB_S7_yP13select_resultP18st_select_lex_unitP13st_select_lex
+ fun:_Z13handle_selectP3THDP13select_resultm
+ fun:_ZL21execute_sqlcom_selectP3THDP10TABLE_LIST
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+}
+
+{
+ GitHub codership/mysql-wsrep#176
+ Memcheck:Leak
+ fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE
+ fun:galera_parameters_get
+ fun:_ZL24refresh_provider_optionsv
+ fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+ fun:_Z24do_handle_one_connectionP3THD
+ fun:handle_one_connection
+}
+
+{
+ GitHub codership/galera#330
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:CRYPTO_malloc
+ fun:sk_new
+ obj:/usr/lib64/libssl.so.1.0.1e
+ fun:SSL_COMP_get_compression_methods
+ fun:SSL_library_init
+ fun:_ZN4asio3ssl6detail12openssl_initILb1EE7do_initC1Ev
+ fun:_ZN4asio3ssl6detail12openssl_initILb1EE7do_init8instanceEv
+ fun:_ZN4asio3ssl6detail12openssl_initILb1EEC1Ev
+ fun:_Z41__static_initialization_and_destruction_0ii.constprop.120
+ fun:call_init.part.0
+ fun:_dl_init
+ fun:dl_open_worker
+ fun:_dl_catch_error
+ fun:_dl_open
+ fun:dlopen_doit
+}
+{
+ GitHub codership/galera#330
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:CRYPTO_malloc
+ fun:sk_new
+ obj:/usr/lib64/libssl.so.1.0.1e
+ fun:SSL_COMP_get_compression_methods
+ fun:SSL_library_init
+ fun:_ZN4asio3ssl6detail12openssl_initILb1EE7do_initC1Ev
+ fun:_ZN4asio3ssl6detail12openssl_initILb1EE7do_init8instanceEv
+ fun:_ZN4asio3ssl6detail12openssl_initILb1EEC1Ev
+ fun:_Z41__static_initialization_and_destruction_0ii.constprop.120
+ fun:call_init.part.0
+ fun:_dl_init
+ fun:dl_open_worker
+ fun:_dl_catch_error
+ fun:_dl_open
+ fun:dlopen_doit
+}
+
+{
+ GitHub codership/mysql-wsrep#175
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:calloc
+ fun:do_lookup_x
+ fun:_dl_lookup_symbol_x
+ fun:_dl_relocate_object
+ fun:dl_open_worker
+ fun:_dl_catch_error
+ fun:_dl_open
+ fun:dlopen_doit
+ fun:_dl_catch_error
+ fun:_dlerror_run
+ fun:dlopen@@GLIBC_2.2.5
+ fun:wsrep_load
+ fun:_Z10wsrep_initv
+ fun:_Z18wsrep_init_startupb
+ fun:_ZL22init_server_componentsv
+ fun:_Z11mysqld_mainiPPc
+}
+
+{
+ galera/mysql-wsrep#147
+ Memcheck:Leak
+ match-leak-kinds: possible
+ fun:malloc
+ fun:_ZNK6galera13ReplicatorSMM9stats_getEv
+ fun:_ZL28export_wsrep_status_to_mysqlP3THD
+ fun:_Z17wsrep_show_statusP3THDP17st_mysql_show_varPc
+ fun:_ZL17show_status_arrayP3THDPKcP17st_mysql_show_var13enum_var_typeP17system_status_varS2_P5TABLEbP4Item
+ fun:_Z11fill_statusP3THDP10TABLE_LISTP4Item
+ fun:_ZL13do_fill_tableP3THDP10TABLE_LISTP13st_join_table
+ fun:_Z24get_schema_tables_resultP4JOIN23enum_schema_table_state
+ fun:_ZN4JOIN14prepare_resultEPP4ListI4ItemE
+ fun:_ZN4JOIN4execEv
+ fun:_ZL20mysql_execute_selectP3THDP13st_select_lexb
+ fun:_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_P10SQL_I_ListI8st_orderESB_S7_yP13select_resultP18st_select_lex_unitP13st_select_lex
+ fun:_Z13handle_selectP3THDP13select_resultm
+ fun:_ZL21execute_sqlcom_selectP3THDP10TABLE_LIST
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+}
+
+{
+g codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ fun:_Z16wsrep_set_paramsRN6galera10ReplicatorEPKc
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE
+ fun:galera_parameters_get
+ fun:_ZL24refresh_provider_optionsv
+ fun:_Z21wsrep_provider_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+ fun:_Z24do_handle_one_connectionP3THD
+ fun:handle_one_connection
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:DbugMalloc
+ fun:ListParse
+ fun:_gu_db_push_
+ fun:_Z16wsrep_set_paramsRN6galera10ReplicatorEPKc
+ fun:galera_parameters_set
+ fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+ fun:_Z24do_handle_one_connectionP3THD
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:state_map_insert
+ fun:code_state
+ fun:_gu_db_push_
+ fun:_Z16wsrep_set_paramsRN6galera10ReplicatorEPKc
+ fun:galera_parameters_set
+ fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+ fun:_Z24do_handle_one_connectionP3THD
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:DbugMalloc
+ fun:StrDup
+ fun:ListParse
+ fun:_gu_db_push_
+ fun:_Z16wsrep_set_paramsRN6galera10ReplicatorEPKc
+ fun:galera_parameters_set
+ fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:code_state
+ fun:_gu_db_push_
+ fun:_Z16wsrep_set_paramsRN6galera10ReplicatorEPKc
+ fun:galera_parameters_set
+ fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+ fun:_Z24do_handle_one_connectionP3THD
+ fun:handle_one_connection
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:DbugMalloc
+ fun:PushState
+ fun:_gu_db_push_
+ fun:_Z16wsrep_set_paramsRN6galera10ReplicatorEPKc
+ fun:galera_parameters_set
+ fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+ fun:_Z24do_handle_one_connectionP3THD
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ match-leak-kinds: possible
+ fun:malloc
+ fun:strdup
+ fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE
+ fun:galera_parameters_get
+ fun:_ZL24refresh_provider_optionsv
+ fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+ fun:_Z24do_handle_one_connectionP3THD
+ fun:handle_one_connection
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ match-leak-kinds: definite
+ fun:malloc
+ fun:strdup
+ fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE
+ fun:galera_parameters_get
+ fun:_ZL24refresh_provider_optionsv
+ fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+ fun:_Z24do_handle_one_connectionP3THD
+ fun:handle_one_connection
+}
+
+{
+ codership/mysql-wsrep/issues#176
+ Memcheck:Leak
+ match-leak-kinds: definite
+ fun:malloc
+ fun:strdup
+ fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE
+ fun:galera_parameters_get
+ fun:_ZL24refresh_provider_optionsv
+ fun:_Z21wsrep_provider_updateP7sys_varP3THD13enum_var_type
+ fun:_ZN7sys_var6updateEP3THDP7set_var
+ fun:_ZN7set_var6updateEP3THD
+ fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE
+ fun:_Z21mysql_execute_commandP3THD
+ fun:_Z11mysql_parseP3THDPcjP12Parser_state
+ fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state
+ fun:_Z16dispatch_command19enum_server_commandP3THDPcj
+ fun:_Z10do_commandP3THD
+ fun:_Z24do_handle_one_connectionP3THD
+ fun:handle_one_connection
+}
+
+{
+ codership/galera#331
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:state_map_insert
+ fun:code_state
+ fun:_gu_db_keyword_
+ fun:_ZN6galera3ist6Sender4sendEll
+ fun:run_async_sender
+ fun:start_thread
+ fun:clone
+}
+
+{
+ codership/galera#331
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:code_state
+ fun:_gu_db_keyword_
+ fun:_ZN6galera3ist6Sender4sendEll
+ fun:run_async_sender
+ fun:start_thread
+ fun:clone
+}
+
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh
index 78060f70ca5..fb8289d06df 100644
--- a/scripts/wsrep_sst_common.sh
+++ b/scripts/wsrep_sst_common.sh
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2014 Codership Oy
+# Copyright (C) 2012-2015 Codership Oy
#
# 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
@@ -20,22 +20,20 @@ set -u
WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_BINLOG=""
+WSREP_SST_OPT_CONF_SUFFIX=""
WSREP_SST_OPT_DATA=""
-WSREP_SST_OPT_AUTH=""
+WSREP_SST_OPT_AUTH=${WSREP_SST_OPT_AUTH:-}
+WSREP_SST_OPT_USER=${WSREP_SST_OPT_USER:-}
+WSREP_SST_OPT_PSWD=${WSREP_SST_OPT_PSWD:-}
WSREP_SST_OPT_DEFAULT=""
WSREP_SST_OPT_EXTRA_DEFAULT=""
-
while [ $# -gt 0 ]; do
case "$1" in
'--address')
readonly WSREP_SST_OPT_ADDR="$2"
shift
;;
- '--auth')
- WSREP_SST_OPT_AUTH="$2"
- shift
- ;;
'--bypass')
WSREP_SST_OPT_BYPASS=1
;;
@@ -50,6 +48,9 @@ case "$1" in
'--defaults-extra-file')
readonly WSREP_SST_OPT_EXTRA_DEFAULT="$1=$2"
shift
+ '--defaults-group-suffix')
+ WSREP_SST_OPT_CONF_SUFFIX="$2"
+ shift
;;
'--host')
readonly WSREP_SST_OPT_HOST="$2"
@@ -104,6 +105,7 @@ shift
done
readonly WSREP_SST_OPT_BYPASS
readonly WSREP_SST_OPT_BINLOG
+readonly WSREP_SST_OPT_CONF_SUFFIX
# try to use my_print_defaults, mysql and mysqldump that come with the sources
# (for MTR suite)
@@ -133,13 +135,30 @@ fi
readonly WSREP_SST_OPT_CONF="$WSREP_SST_OPT_DEFAULT $WSREP_SST_OPT_EXTRA_DEFAULT"
MY_PRINT_DEFAULTS="$MY_PRINT_DEFAULTS $WSREP_SST_OPT_CONF"
+wsrep_auth_not_set()
+{
+ [ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ]
+}
-# State Snapshot Transfer authentication password was displayed in the ps output. Bug fixed #1200727.
-if $MY_PRINT_DEFAULTS sst | grep -q "wsrep_sst_auth";then
- if [ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ];then
- WSREP_SST_OPT_AUTH=$($MY_PRINT_DEFAULTS sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
+# For Bug:1200727
+if $MY_PRINT_DEFAULTS sst | grep -q "wsrep_sst_auth"
+then
+ if wsrep_auth_not_set
+ then
+ WSREP_SST_OPT_AUTH=$($MY_PRINT_DEFAULTS sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
fi
fi
+readonly WSREP_SST_OPT_AUTH
+
+# Splitting AUTH into potential user:password pair
+if ! wsrep_auth_not_set
+then
+ readonly AUTH_VEC=(${WSREP_SST_OPT_AUTH//:/ })
+ WSREP_SST_OPT_USER="${AUTH_VEC[0]:-}"
+ WSREP_SST_OPT_PSWD="${AUTH_VEC[1]:-}"
+fi
+readonly WSREP_SST_OPT_USER
+readonly WSREP_SST_OPT_PSWD
if [ -n "${WSREP_SST_OPT_DATA:-}" ]
then
@@ -148,7 +167,6 @@ else
SST_PROGRESS_FILE=""
fi
-
wsrep_log()
{
# echo everything to stderr so that it gets into common error log
diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh
index a05e42f31b3..21c4bf62130 100644
--- a/scripts/wsrep_sst_mysqldump.sh
+++ b/scripts/wsrep_sst_mysqldump.sh
@@ -1,5 +1,5 @@
-#!/bin/bash -e
-# Copyright (C) 2009 Codership Oy
+#!/bin/bash -ue
+# Copyright (C) 2009-2015 Codership Oy
#
# 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
@@ -41,7 +41,6 @@ local_ip()
return 1
}
-if test -z "$WSREP_SST_OPT_USER"; then wsrep_log_error "USER cannot be nil"; exit $EINVAL; fi
if test -z "$WSREP_SST_OPT_HOST"; then wsrep_log_error "HOST cannot be nil"; exit $EINVAL; fi
if test -z "$WSREP_SST_OPT_PORT"; then wsrep_log_error "PORT cannot be nil"; exit $EINVAL; fi
if test -z "$WSREP_SST_OPT_LPORT"; then wsrep_log_error "LPORT cannot be nil"; exit $EINVAL; fi
@@ -64,13 +63,29 @@ then
exit $EINVAL
fi
-# For Bug:1293798
-if [ -z "$WSREP_SST_OPT_PSWD" -a -n "$WSREP_SST_OPT_AUTH" ]; then
- WSREP_SST_OPT_USER=$(echo $WSREP_SST_OPT_AUTH | cut -d: -f1)
- WSREP_SST_OPT_PSWD=$(echo $WSREP_SST_OPT_AUTH | cut -d: -f2)
-fi
-AUTH="-u$WSREP_SST_OPT_USER"
-if test -n "$WSREP_SST_OPT_PSWD"; then AUTH="$AUTH -p$WSREP_SST_OPT_PSWD"; fi
+[ -n "$WSREP_SST_OPT_USER" ] && AUTH="-u$WSREP_SST_OPT_USER" || AUTH=
+
+# Refs https://github.com/codership/mysql-wsrep/issues/141
+# Passing password in MYSQL_PWD environment variable is considered
+# "extremely insecure" by MySQL Guidelines for Password Security
+# (https://dev.mysql.com/doc/refman/5.6/en/password-security-user.html)
+# that is even less secure than passing it on a command line! It is doubtful:
+# the whole command line is easily observable by any unprivileged user via ps,
+# whereas (at least on Linux) unprivileged user can't see process environment
+# that he does not own. So while it may be not secure in the NSA sense of the
+# word, it is arguably more secure than passing password on the command line.
+[ -n "$WSREP_SST_OPT_PSWD" ] && export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
+
+# Refs https://github.com/codership/mysql-wsrep/issues/141
+# Passing password in MYSQL_PWD environment variable is considered
+# "extremely insecure" by MySQL Guidelines for Password Security
+# (https://dev.mysql.com/doc/refman/5.6/en/password-security-user.html)
+# that is even less secure than passing it on a command line! It is doubtful:
+# the whole command line is easily observable by any unprivileged user via ps,
+# whereas (at least on Linux) unprivileged user can't see process environment
+# that he does not own. So while it may be not secure in the NSA sense of the
+# word, it is arguably more secure than passing password on the command line.
+[ -n "$WSREP_SST_OPT_PSWD" ] && export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
STOP_WSREP="SET wsrep_on=OFF;"
@@ -147,15 +162,15 @@ fi
MYSQLDUMP="$MYSQLDUMP $AUTH -S$WSREP_SST_OPT_SOCKET \
--add-drop-database --add-drop-table --skip-add-locks --create-options \
--disable-keys --extended-insert --skip-lock-tables --quick --set-charset \
---skip-comments --flush-privileges --all-databases"
+--skip-comments --flush-privileges --all-databases --events"
# need to disable logging when loading the dump
# reason is that dump contains ALTER TABLE for log tables, and
# this causes an error if logging is enabled
-GENERAL_LOG_OPT=`$MYSQL --skip-column-names -e"$STOP_WSREP SELECT @@GENERAL_LOG"`
-SLOW_LOG_OPT=`$MYSQL --skip-column-names -e"$STOP_WSREP SELECT @@SLOW_QUERY_LOG"`
-$MYSQL -e"$STOP_WSREP SET GLOBAL GENERAL_LOG=OFF"
-$MYSQL -e"$STOP_WSREP SET GLOBAL SLOW_QUERY_LOG=OFF"
+GENERAL_LOG_OPT=`$MYSQL --skip-column-names -e "$STOP_WSREP SELECT @@GENERAL_LOG"`
+SLOW_LOG_OPT=`$MYSQL --skip-column-names -e "$STOP_WSREP SELECT @@SLOW_QUERY_LOG"`
+$MYSQL -e "$STOP_WSREP SET GLOBAL GENERAL_LOG=OFF"
+$MYSQL -e "$STOP_WSREP SET GLOBAL SLOW_QUERY_LOG=OFF"
# commands to restore log settings
RESTORE_GENERAL_LOG="SET GLOBAL GENERAL_LOG=$GENERAL_LOG_OPT;"
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index ee63fe04fe7..a93ab940593 100644
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -18,8 +18,10 @@
# This is a reference script for rsync-based state snapshot tansfer
-RSYNC_PID=
-RSYNC_CONF=
+RSYNC_PID= # rsync pid file
+RSYNC_CONF= # rsync configuration file
+RSYNC_REAL_PID= # rsync process id
+
OS=$(uname)
[ "$OS" == "Darwin" ] && export -n LD_LIBRARY_PATH
@@ -32,10 +34,12 @@ wsrep_check_programs rsync
cleanup_joiner()
{
- wsrep_log_info "Joiner cleanup."
- local PID=$(cat "$RSYNC_PID" 2>/dev/null || echo 0)
- [ "0" != "$PID" ] && kill $PID && sleep 0.5 && kill -9 $PID >/dev/null 2>&1 \
- || :
+ wsrep_log_info "Joiner cleanup. rsync PID: $RSYNC_REAL_PID"
+ [ "0" != "$RSYNC_REAL_PID" ] && \
+ kill $RSYNC_REAL_PID && \
+ sleep 0.5 && \
+ kill -9 $RSYNC_REAL_PID >/dev/null 2>&1 || \
+ :
rm -rf "$RSYNC_CONF"
rm -rf "$MAGIC_FILE"
rm -rf "$RSYNC_PID"
@@ -45,6 +49,7 @@ cleanup_joiner()
fi
}
+# Check whether rsync process is still running.
check_pid()
{
local pid_file=$1
diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh
index bba187ed2f9..68e250d2157 100644
--- a/scripts/wsrep_sst_xtrabackup-v2.sh
+++ b/scripts/wsrep_sst_xtrabackup-v2.sh
@@ -29,6 +29,8 @@ ekeyfile=""
encrypt=0
nproc=1
ecode=0
+ssyslog=""
+ssystag=""
XTRABACKUP_PID=""
SST_PORT=""
REMOTEIP=""
@@ -40,15 +42,15 @@ progress=""
ttime=0
totime=0
lsn=""
-incremental=0
ecmd=""
rlimit=""
# Initially
stagemsg="${WSREP_SST_OPT_ROLE}"
cpat=""
-speciald=0
+speciald=1
ib_home_dir=""
ib_log_dir=""
+ib_undo_dir=""
sfmt="tar"
strmcmd=""
@@ -70,6 +72,11 @@ xtmpdir=""
scomp=""
sdecomp=""
+# Required for backup locks
+# For backup locks it is 1 sent by joiner
+# 5.6.21 PXC and later can't donate to an older joiner
+sst_ver=1
+
if which pv &>/dev/null && pv --help | grep -q FORMAT;then
pvopts+=$pvformat
fi
@@ -77,7 +84,6 @@ pcmd="pv $pvopts"
declare -a RC
INNOBACKUPEX_BIN=innobackupex
-readonly AUTH=(${WSREP_SST_OPT_AUTH//:/ })
DATA="${WSREP_SST_OPT_DATA}"
INFO_FILE="xtrabackup_galera_info"
IST_FILE="xtrabackup_ist"
@@ -169,7 +175,11 @@ get_transfer()
fi
wsrep_log_info "Using netcat as streamer"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- tcmd="nc -dl ${TSST_PORT}"
+ if nc -h | grep -q ncat;then
+ tcmd="nc -l ${TSST_PORT}"
+ else
+ tcmd="nc -dl ${TSST_PORT}"
+ fi
else
tcmd="nc ${REMOTEIP} ${TSST_PORT}"
fi
@@ -253,6 +263,16 @@ get_footprint()
adjust_progress()
{
+
+ if [[ ! -x `which pv` ]];then
+ wsrep_log_error "pv not found in path: $PATH"
+ wsrep_log_error "Disabling all progress/rate-limiting"
+ pcmd=""
+ rlimit=""
+ progress=""
+ return
+ fi
+
if [[ -n $progress && $progress != '1' ]];then
if [[ -e $progress ]];then
pcmd+=" 2>>$progress"
@@ -282,8 +302,7 @@ read_cnf()
progress=$(parse_cnf sst progress "")
rebuild=$(parse_cnf sst rebuild 0)
ttime=$(parse_cnf sst time 0)
- cpat=$(parse_cnf sst cpat '.*galera\.cache$\|.*sst_in_progress$\|.*grastate\.dat$\|.*gvwstate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$')
- incremental=$(parse_cnf sst incremental 0)
+ cpat=$(parse_cnf sst cpat '.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$')
ealgo=$(parse_cnf xtrabackup encrypt "")
ekey=$(parse_cnf xtrabackup encrypt-key "")
ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
@@ -304,6 +323,20 @@ read_cnf()
iapts=$(parse_cnf sst inno-apply-opts "")
impts=$(parse_cnf sst inno-move-opts "")
stimeout=$(parse_cnf sst sst-initial-timeout 100)
+ ssyslog=$(parse_cnf sst sst-syslog 0)
+ ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
+ ssystag+="-"
+
+ if [[ $speciald -eq 0 ]];then
+ wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1"
+ speciald=1
+ fi
+
+ if [[ $ssyslog -ne -1 ]];then
+ if $MY_PRINT_DEFAULTS mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then
+ ssyslog=1
+ fi
+ fi
}
get_stream()
@@ -347,8 +380,7 @@ cleanup_joiner()
local estatus=$?
if [[ $estatus -ne 0 ]];then
wsrep_log_error "Cleanup after exit with status:$estatus"
- fi
- if [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
+ elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
wsrep_log_info "Removing the sst_in_progress file"
wsrep_cleanup_progress_file
fi
@@ -359,6 +391,23 @@ cleanup_joiner()
if [[ -n ${STATDIR:-} ]];then
[[ -d $STATDIR ]] && rm -rf $STATDIR
fi
+
+ # Final cleanup
+ pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
+
+ # This means no setsid done in mysqld.
+ # We don't want to kill mysqld here otherwise.
+ if [[ $$ -eq $pgid ]];then
+
+ # This means a signal was delivered to the process.
+ # So, more cleanup.
+ if [[ $estatus -ge 128 ]];then
+ kill -KILL -$$ || true
+ fi
+
+ fi
+
+ exit $estatus
}
check_pid()
@@ -399,6 +448,24 @@ cleanup_donor()
if [[ -n $itmpdir ]];then
[[ -d $itmpdir ]] && rm -rf $itmpdir || true
fi
+
+ # Final cleanup
+ pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
+
+ # This means no setsid done in mysqld.
+ # We don't want to kill mysqld here otherwise.
+ if [[ $$ -eq $pgid ]];then
+
+ # This means a signal was delivered to the process.
+ # So, more cleanup.
+ if [[ $estatus -ge 128 ]];then
+ kill -KILL -$$ || true
+ fi
+
+ fi
+
+ exit $estatus
+
}
kill_xtrabackup()
@@ -415,6 +482,7 @@ setup_ports()
SST_PORT=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $2 }')
REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F ':' '{ print $1 }')
lsn=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $4 }')
+ sst_ver=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $5 }')
else
SST_PORT=$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $2 }')
fi
@@ -432,11 +500,7 @@ wait_for_listen()
ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
sleep 0.2
done
- if [[ $incremental -eq 1 ]];then
- echo "ready ${ADDR}/${MODULE}/$lsn"
- else
- echo "ready ${ADDR}/${MODULE}"
- fi
+ echo "ready ${ADDR}/${MODULE}//$sst_ver"
}
check_extra()
@@ -469,8 +533,14 @@ recv_joiner()
local dir=$1
local msg=$2
local tmt=$3
+ local checkf=$4
local ltcmd
+ if [[ ! -d ${dir} ]];then
+ # This indicates that IST is in progress
+ return
+ fi
+
pushd ${dir} 1>/dev/null
set +e
@@ -478,7 +548,7 @@ recv_joiner()
if timeout --help | grep -q -- '-k';then
ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
else
- ltcmd="timeout $tmt $tcmd"
+ ltcmd="timeout -s9 $tmt $tcmd"
fi
timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
else
@@ -501,7 +571,7 @@ recv_joiner()
fi
done
- if [ ! -r "${MAGIC_FILE}" ];then
+ if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then
# this message should cause joiner to abort
wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
wsrep_log_info "Contents of datadir"
@@ -547,18 +617,52 @@ fi
read_cnf
setup_ports
-get_stream
-get_transfer
-if ${INNOBACKUPEX_BIN} /tmp --help | grep -- '--version-check' >/dev/null ; then
+if ${INNOBACKUPEX_BIN} /tmp --help 2>/dev/null | grep -q -- '--version-check'; then
disver="--no-version-check"
fi
+if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then
+ wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
+ iopts+=" --no-backup-locks "
+fi
+
INNOEXTRA=""
-INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
-INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log"
-INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2>\${DATA}/innobackup.backup.log"
+
+if [[ $ssyslog -eq 1 ]];then
+
+ if [[ ! -x `which logger` ]];then
+ wsrep_log_error "logger not in path: $PATH. Ignoring"
+ else
+
+ wsrep_log_info "Logging all stderr of SST/Innobackupex to syslog"
+
+ exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE)
+
+ wsrep_log_error()
+ {
+ logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
+ }
+
+ wsrep_log_info()
+ {
+ logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
+ }
+
+ INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply "
+ INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move "
+ INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
+ fi
+
+else
+ INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
+ INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log"
+ INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2>\${DATA}/innobackup.backup.log"
+fi
+
+get_stream
+get_transfer
if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
then
@@ -566,6 +670,11 @@ then
if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
then
+ if [[ -z $sst_ver ]];then
+ wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support"
+ wsrep_log_error "The joiner is not supported for this version of donor"
+ exit 93
+ fi
if [[ -z $(parse_cnf mysqld tmpdir "") && -z $(parse_cnf xtrabackup tmpdir "") ]];then
xtmpdir=$(mktemp -d)
@@ -576,13 +685,14 @@ then
itmpdir=$(mktemp -d)
wsrep_log_info "Using $itmpdir as innobackupex temporary directory"
- if [ "${AUTH[0]}" != "(null)" ]; then
- INNOEXTRA+=" --user=${AUTH[0]}"
- fi
+ if [ "$WSREP_SST_OPT_USER" != "(null)" ]; then
+ INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
+ fi
- if [ ${#AUTH[*]} -eq 2 ]; then
- INNOEXTRA+=" --password=${AUTH[1]}"
- elif [ "${AUTH[0]}" != "(null)" ]; then
+ if [ -n "$WSREP_SST_OPT_PSWD" ]; then
+# INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
+ export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
+ else
# Empty password, used for testing, debugging etc.
INNOEXTRA+=" --password="
fi
@@ -596,9 +706,6 @@ then
fi
fi
- if [[ -n $lsn ]];then
- INNOEXTRA+=" --incremental --incremental-lsn=$lsn "
- fi
check_extra
@@ -691,25 +798,12 @@ then
[[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
[[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE
- if [[ $speciald -eq 1 ]];then
- ib_home_dir=$(parse_cnf mysqld innodb-data-home-dir "")
- ib_log_dir=$(parse_cnf mysqld innodb-log-group-home-dir "")
- if [[ -z $ib_home_dir && -z $ib_log_dir ]];then
- speciald=0
- fi
- fi
+ ib_home_dir=$(parse_cnf mysqld innodb-data-home-dir "")
+ ib_log_dir=$(parse_cnf mysqld innodb-log-group-home-dir "")
+ ib_undo_dir=$(parse_cnf mysqld innodb-undo-directory "")
stagemsg="Joiner-Recv"
- if [[ ! -e ${DATA}/ibdata1 ]];then
- incremental=0
- fi
-
- if [[ $incremental -eq 1 ]];then
- wsrep_log_info "Incremental SST enabled: NOT SUPPORTED yet"
- lsn=$(grep to_lsn xtrabackup_checkpoints | cut -d= -f2 | tr -d ' ')
- wsrep_log_info "Recovered LSN: $lsn"
- fi
sencrypted=1
nthreads=1
@@ -738,12 +832,6 @@ then
tcmd+=" | $pcmd"
fi
- if [[ $incremental -eq 1 ]];then
- BDATA=$DATA
- DATA=$(mktemp -d)
- MAGIC_FILE="${DATA}/${INFO_FILE}"
- fi
-
get_keys
if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
if [[ -n $sdecomp ]];then
@@ -757,7 +845,8 @@ then
STATDIR=$(mktemp -d)
MAGIC_FILE="${STATDIR}/${INFO_FILE}"
- recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout
+ recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1
+
if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
then
@@ -767,51 +856,48 @@ then
if [ ! -r "${STATDIR}/${IST_FILE}" ]
then
- wsrep_log_info "Proceeding with SST"
- if [[ $speciald -eq 1 && -d ${DATA}/.sst ]];then
- wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous SST"
+ if [[ -d ${DATA}/.sst ]];then
+ wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous state transfer"
fi
+ mkdir -p ${DATA}/.sst
+ (recv_joiner $DATA/.sst "${stagemsg}-SST" 0 0) &
+ jpid=$!
+ wsrep_log_info "Proceeding with SST"
- if [[ $incremental -ne 1 ]];then
- if [[ $speciald -eq 1 ]];then
- wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
- find $ib_home_dir $ib_log_dir $DATA -mindepth 1 -regex $cpat -prune -o -exec rm -rfv {} 1>&2 \+
- else
- wsrep_log_info "Cleaning the existing datadir"
- find $DATA -mindepth 1 -regex $cpat -prune -o -exec rm -rfv {} 1>&2 \+
- fi
- tempdir=$(parse_cnf mysqld log-bin "")
- if [[ -n ${tempdir:-} ]];then
- binlog_dir=$(dirname $tempdir)
- binlog_file=$(basename $tempdir)
- if [[ -n ${binlog_dir:-} && $binlog_dir != '.' && $binlog_dir != $DATA ]];then
- pattern="$binlog_dir/$binlog_file\.[0-9]+$"
- wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
- find $binlog_dir -maxdepth 1 -type f -regex $pattern -exec rm -fv {} 1>&2 \+
- rm $binlog_dir/*.index || true
- rm $binlog_dir/*.state || true
- fi
- fi
- else
- wsrep_log_info "Removing existing ib_logfile files"
- rm -f ${BDATA}/ib_logfile*
+ wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
+ find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -regex $cpat -prune -o -exec rm -rfv {} 1>&2 \+
+
+ tempdir=$(parse_cnf mysqld log-bin "")
+ if [[ -n ${tempdir:-} ]];then
+ binlog_dir=$(dirname $tempdir)
+ binlog_file=$(basename $tempdir)
+ if [[ -n ${binlog_dir:-} && $binlog_dir != '.' && $binlog_dir != $DATA ]];then
+ pattern="$binlog_dir/$binlog_file\.[0-9]+$"
+ wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
+ find $binlog_dir -maxdepth 1 -type f -regex $pattern -exec rm -fv {} 1>&2 \+ || true
+ rm $binlog_dir/*.index || true
+ fi
fi
- if [[ $speciald -eq 1 ]];then
- mkdir -p ${DATA}/.sst
- TDATA=${DATA}
- DATA="${DATA}/.sst"
- fi
+
+ TDATA=${DATA}
+ DATA="${DATA}/.sst"
MAGIC_FILE="${DATA}/${INFO_FILE}"
- recv_joiner $DATA "${stagemsg}-SST" 0
+ wsrep_log_info "Waiting for SST streaming to complete!"
+ wait $jpid
get_proc
+ if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then
+ wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor"
+ exit 2
+ fi
+
# Rebuild indexes for compact backups
if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
wsrep_log_info "Index compaction detected"
@@ -883,12 +969,6 @@ then
fi
- if [[ $incremental -eq 1 ]];then
- # Added --ibbackup=xtrabackup_55 because it fails otherwise citing connection issues.
- INNOAPPLY="${INNOBACKUPEX_BIN} $disver ${WSREP_SST_OPT_CONF} \
- --ibbackup=xtrabackup_56 --apply-log $rebuildcmd --redo-only $BDATA --incremental-dir=${DATA} &>>${BDATA}/innobackup.prepare.log"
- fi
-
wsrep_log_info "Preparing the backup at ${DATA}"
timeit "Xtrabackup prepare stage" "$INNOAPPLY"
@@ -898,28 +978,22 @@ then
exit 22
fi
- if [[ $speciald -eq 1 ]];then
- MAGIC_FILE="${TDATA}/${INFO_FILE}"
- set +e
- rm $TDATA/innobackup.prepare.log $TDATA/innobackup.move.log
- set -e
- wsrep_log_info "Moving the backup to ${TDATA}"
- timeit "Xtrabackup move stage" "$INNOMOVE"
- if [[ $? -eq 0 ]];then
- wsrep_log_info "Move successful, removing ${DATA}"
- rm -rf $DATA
- DATA=${TDATA}
- else
- wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
- wsrep_log_error "Check ${DATA}/innobackup.move.log for details"
- fi
+ MAGIC_FILE="${TDATA}/${INFO_FILE}"
+ set +e
+ rm $TDATA/innobackup.prepare.log $TDATA/innobackup.move.log
+ set -e
+ wsrep_log_info "Moving the backup to ${TDATA}"
+ timeit "Xtrabackup move stage" "$INNOMOVE"
+ if [[ $? -eq 0 ]];then
+ wsrep_log_info "Move successful, removing ${DATA}"
+ rm -rf $DATA
+ DATA=${TDATA}
+ else
+ wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
+ wsrep_log_error "Check ${DATA}/innobackup.move.log for details"
+ exit 22
fi
- if [[ $incremental -eq 1 ]];then
- wsrep_log_info "Cleaning up ${DATA} after incremental SST"
- [[ -d ${DATA} ]] && rm -rf ${DATA}
- DATA=$BDATA
- fi
else
wsrep_log_info "${IST_FILE} received from donor: Running IST"
@@ -929,6 +1003,7 @@ then
wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
exit 2
fi
+ wsrep_log_info "Galera co-ords from recovery: $(cat ${MAGIC_FILE})"
cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
wsrep_log_info "Total time on joiner: $totime seconds"
fi
diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh
index 4b22c227dd5..1ef3c3f3ce1 100644
--- a/scripts/wsrep_sst_xtrabackup.sh
+++ b/scripts/wsrep_sst_xtrabackup.sh
@@ -61,7 +61,6 @@ pcmd="pv $pvopts"
declare -a RC
INNOBACKUPEX_BIN=innobackupex
-readonly AUTH=(${WSREP_SST_OPT_AUTH//:/ })
DATA="${WSREP_SST_OPT_DATA}"
INFO_FILE="xtrabackup_galera_info"
IST_FILE="xtrabackup_ist"
@@ -150,7 +149,11 @@ get_transfer()
fi
wsrep_log_info "Using netcat as streamer"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- tcmd="nc -dl ${TSST_PORT}"
+ if nc -h | grep -q ncat;then
+ tcmd="nc -l ${TSST_PORT}"
+ else
+ tcmd="nc -dl ${TSST_PORT}"
+ fi
else
tcmd="nc ${REMOTEIP} ${TSST_PORT}"
fi
@@ -435,13 +438,14 @@ then
then
TMPDIR="${TMPDIR:-/tmp}"
- if [ "${AUTH[0]}" != "(null)" ]; then
- INNOEXTRA+=" --user=${AUTH[0]}"
- fi
+ if [ "$WSREP_SST_OPT_USER" != "(null)" ]; then
+ INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
+ fi
- if [ ${#AUTH[*]} -eq 2 ]; then
- INNOEXTRA+=" --password=${AUTH[1]}"
- elif [ "${AUTH[0]}" != "(null)" ]; then
+ if [ -n "$WSREP_SST_OPT_PSWD" ]; then
+# INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
+ export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
+ else
# Empty password, used for testing, debugging etc.
INNOEXTRA+=" --password="
fi
diff --git a/sql/events.cc b/sql/events.cc
index abc798b659a..b80ec993ac4 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -1216,7 +1216,8 @@ int wsrep_create_event_query(THD *thd, uchar** buf, size_t* buf_len)
if (create_query_string(thd, &log_query))
{
- WSREP_WARN("events create string failed: %s", thd->query());
+ WSREP_WARN("events create string failed: schema: %s, query: %s",
+ (thd->db ? thd->db : "(null)"), thd->query());
return 1;
}
return wsrep_to_buf_helper(thd, log_query.ptr(), log_query.length(), buf, buf_len);
diff --git a/sql/mdl.cc b/sql/mdl.cc
index ec380aa7432..73b64b35dff 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -1069,7 +1069,7 @@ MDL_wait::timed_wait(MDL_context_owner *owner, struct timespec *abs_timeout,
wait_result= mysql_cond_wait(&m_COND_wait_status, &m_LOCK_wait_status);
}
else
-#endif
+#endif /* WITH_WSREP */
wait_result= mysql_cond_timedwait(&m_COND_wait_status, &m_LOCK_wait_status,
abs_timeout);
}
@@ -1170,7 +1170,8 @@ void MDL_lock::Ticket_list::add_ticket(MDL_ticket *ticket)
if (granted->get_ctx() != ticket->get_ctx() &&
granted->is_incompatible_when_granted(ticket->get_type()))
{
- if (!wsrep_grant_mdl_exception(ticket->get_ctx(), granted))
+ if (!wsrep_grant_mdl_exception(ticket->get_ctx(), granted,
+ &ticket->get_lock()->key))
{
WSREP_DEBUG("MDL victim killed at add_ticket");
}
@@ -1561,7 +1562,7 @@ MDL_lock::can_grant_lock(enum_mdl_type type_arg,
wsrep_thd_query(requestor_ctx->get_thd()));
can_grant = true;
}
- else if (!wsrep_grant_mdl_exception(requestor_ctx, ticket))
+ else if (!wsrep_grant_mdl_exception(requestor_ctx, ticket, &key))
{
wsrep_can_grant= FALSE;
if (wsrep_log_conflicts)
@@ -2904,6 +2905,19 @@ void MDL_context::release_explicit_locks()
release_locks_stored_before(MDL_EXPLICIT, NULL);
}
+bool MDL_context::has_explicit_locks()
+{
+ MDL_ticket *ticket = NULL;
+
+ Ticket_iterator it(m_tickets[MDL_EXPLICIT]);
+
+ while ((ticket = it++))
+ {
+ return true;
+ }
+
+ return false;
+}
#ifdef WITH_WSREP
void MDL_ticket::wsrep_report(bool debug)
diff --git a/sql/mdl.h b/sql/mdl.h
index a80de5a4e71..7961f1f24b2 100644
--- a/sql/mdl.h
+++ b/sql/mdl.h
@@ -458,6 +458,7 @@ public:
MDL_key key;
public:
+
static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
{ return alloc_root(mem_root, size); }
static void operator delete(void *ptr, MEM_ROOT *mem_root) {}
@@ -930,6 +931,7 @@ private:
public:
THD *get_thd() const { return m_owner->get_thd(); }
+ bool has_explicit_locks();
void find_deadlock();
ulong get_thread_id() const { return thd_get_thread_id(get_thd()); }
diff --git a/sql/slave.cc b/sql/slave.cc
index 58cb508f8c8..895a8c2167e 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3374,6 +3374,17 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd,
if (reason == Log_event::EVENT_SKIP_NOT)
exec_res= ev->apply_event(rgi);
+#ifdef WITH_WSREP
+ if (exec_res && thd->wsrep_conflict_state != NO_CONFLICT)
+ {
+ WSREP_DEBUG("SQL apply failed, res %d conflict state: %d",
+ exec_res, thd->wsrep_conflict_state);
+ rli->abort_slave= 1;
+ rli->report(ERROR_LEVEL, ER_UNKNOWN_COM_ERROR, rgi->gtid_info(),
+ "Node has dropped from cluster");
+ }
+#endif
+
#ifndef DBUG_OFF
/*
This only prints information to the debug trace.
@@ -3693,6 +3704,10 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
serial_rgi->event_relay_log_pos= rli->event_relay_log_pos;
exec_res= apply_event_and_update_pos(ev, thd, serial_rgi, NULL);
+#ifdef WITH_WSREP
+ WSREP_DEBUG("apply_event_and_update_pos() result: %d", exec_res);
+#endif /* WITH_WSREP */
+
delete_or_keep_event_post_apply(serial_rgi, typ, ev);
/*
@@ -3702,6 +3717,12 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
if (exec_res == 2)
DBUG_RETURN(1);
+#ifdef WITH_WSREP
+ mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ if (thd->wsrep_conflict_state == NO_CONFLICT)
+ {
+ mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+#endif /* WITH_WSREP */
if (slave_trans_retries)
{
int UNINIT_VAR(temp_err);
@@ -3774,6 +3795,12 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
serial_rgi->trans_retries));
}
}
+#ifdef WITH_WSREP
+ }
+ else
+ mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+#endif /* WITH_WSREP */
+
thread_safe_increment64(&rli->executed_entries);
DBUG_RETURN(exec_res);
}
@@ -4756,15 +4783,21 @@ pthread_handler_t handle_slave_sql(void *arg)
if (exec_relay_log_event(thd, rli, serial_rgi))
{
+#ifdef WITH_WSREP
+ if (thd->wsrep_conflict_state != NO_CONFLICT)
+ {
+ wsrep_node_dropped= TRUE;
+ rli->abort_slave= TRUE;
+ }
+#endif /* WITH_WSREP */
+
DBUG_PRINT("info", ("exec_relay_log_event() failed"));
// do not scare the user if SQL thread was simply killed or stopped
if (!sql_slave_killed(serial_rgi))
{
slave_output_error_info(serial_rgi, thd);
if (WSREP_ON && rli->last_error().number == ER_UNKNOWN_COM_ERROR)
- {
- wsrep_node_dropped= TRUE;
- }
+ wsrep_node_dropped= TRUE;
}
goto err;
}
@@ -4889,27 +4922,33 @@ err_during_init:
thd->rgi_fake= thd->rgi_slave= NULL;
delete serial_rgi;
mysql_mutex_unlock(&LOCK_thread_count);
+
#ifdef WITH_WSREP
- /* 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 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_ready)
- {
- WSREP_INFO("Slave error due to node temporarily non-primary"
- "SQL slave will continue");
- wsrep_node_dropped= FALSE;
- mysql_mutex_unlock(&rli->run_lock);
- goto wsrep_restart_point;
- } else {
- WSREP_INFO("Slave error due to node going non-primary");
- WSREP_INFO("wsrep_restart_slave was set and therefore slave will be "
- "automatically restarted when node joins back to cluster");
- wsrep_restart_slave_activated= TRUE;
- }
- }
+ if (WSREP_ON && wsrep_node_dropped && wsrep_restart_slave)
+ {
+ if (wsrep_ready)
+ {
+ WSREP_INFO("Slave error due to node temporarily non-primary"
+ "SQL slave will continue");
+ wsrep_node_dropped= FALSE;
+ mysql_mutex_unlock(&rli->run_lock);
+ WSREP_DEBUG("wsrep_conflict_state now: %d", thd->wsrep_conflict_state);
+ WSREP_INFO("slave restart: %d", thd->wsrep_conflict_state);
+ thd->wsrep_conflict_state= NO_CONFLICT;
+ goto wsrep_restart_point;
+ } else {
+ WSREP_INFO("Slave error due to node going non-primary");
+ WSREP_INFO("wsrep_restart_slave was set and therefore slave will be "
+ "automatically restarted when node joins back to cluster.");
+ wsrep_restart_slave_activated= TRUE;
+ }
+ }
#endif /* WITH_WSREP */
+
/*
Note: the order of the broadcast and unlock calls below (first broadcast, then unlock)
is important. Otherwise a killer_thread can execute between the calls and
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 1388ec01459..ba9dc7eb854 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4829,6 +4829,25 @@ end_with_restore_list:
*/
if (!reload_acl_and_cache(thd, lex->type, first_table, &write_to_binlog))
{
+#ifdef WITH_WSREP
+ if ((lex->type & REFRESH_TABLES) && !(lex->type & (REFRESH_FOR_EXPORT|REFRESH_READ_LOCK)))
+ {
+ /*
+ This is done after reload_acl_and_cache is because
+ LOCK TABLES is not replicated in galera, the upgrade of which
+ is checked in reload_acl_and_cache.
+ Hence, done after/if we are able to upgrade locks.
+ */
+ if (first_table)
+ {
+ WSREP_TO_ISOLATION_BEGIN(NULL, NULL, first_table);
+ }
+ else
+ {
+ WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
+ }
+ }
+#endif /* WITH_WSREP */
/*
We WANT to write and we CAN write.
! we write after unlocking the table.
@@ -7134,6 +7153,7 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
/* Performance Schema Interface instrumentation, end */
MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
thd->m_statement_psi= NULL;
+ thd->m_digest= NULL;
close_thread_tables(thd);
thd->wsrep_conflict_state= RETRY_AUTOCOMMIT;
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index e237fb1ad00..9e67a21e8f4 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -783,20 +783,17 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd)
DBUG_RETURN(TRUE);
#ifdef WITH_WSREP
- if (WSREP_ON)
+ /* Forward declaration */
+ TABLE *find_temporary_table(THD *thd, const TABLE_LIST *tl);
+
+ if (WSREP(thd) && (!thd->is_current_stmt_binlog_format_row() ||
+ !find_temporary_table(thd, first_table)) &&
+ wsrep_to_isolation_begin(
+ thd, first_table->db, first_table->table_name, NULL)
+ )
{
- /* Forward declaration */
- TABLE *find_temporary_table(THD *thd, const TABLE_LIST *tl);
-
- if ((!thd->is_current_stmt_binlog_format_row() ||
- !find_temporary_table(thd, first_table)) &&
- wsrep_to_isolation_begin(
- thd, first_table->db, first_table->table_name, NULL)
- )
- {
- WSREP_WARN("ALTER TABLE TRUNCATE PARTITION isolation failure");
- DBUG_RETURN(TRUE);
- }
+ WSREP_WARN("ALTER TABLE TRUNCATE PARTITION isolation failure");
+ DBUG_RETURN(TRUE);
}
#endif /* WITH_WSREP */
diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc
index f45ba5e5a39..5bec467708c 100644
--- a/sql/wsrep_hton.cc
+++ b/sql/wsrep_hton.cc
@@ -245,8 +245,9 @@ static int wsrep_rollback(handlerton *hton, THD *thd, bool all)
if (wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle))
{
DBUG_PRINT("wsrep", ("setting rollback fail"));
- WSREP_ERROR("settting rollback fail: thd: %llu SQL: %s",
- (long long)thd->real_id, thd->query());
+ WSREP_ERROR("settting rollback fail: thd: %llu, schema: %s, SQL: %s",
+ (long long)thd->real_id, (thd->db ? thd->db : "(null)"),
+ thd->query());
}
wsrep_cleanup_transaction(thd);
}
@@ -286,8 +287,9 @@ int wsrep_commit(handlerton *hton, THD *thd, bool all)
if (wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle))
{
DBUG_PRINT("wsrep", ("setting rollback fail"));
- WSREP_ERROR("settting rollback fail: thd: %llu SQL: %s",
- (long long)thd->real_id, thd->query());
+ WSREP_ERROR("settting rollback fail: thd: %llu, schema: %s, SQL: %s",
+ (long long)thd->real_id, (thd->db ? thd->db : "(null)"),
+ thd->query());
}
}
wsrep_cleanup_transaction(thd);
@@ -448,9 +450,11 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
if (WSREP_UNDEFINED_TRX_ID == thd->wsrep_ws_handle.trx_id)
{
WSREP_WARN("SQL statement was ineffective, THD: %lu, buf: %zu\n"
+ "schema: %s \n"
"QUERY: %s\n"
" => Skipping replication",
- thd->thread_id, data_len, thd->query());
+ thd->thread_id, data_len,
+ (thd->db ? thd->db : "(null)"), thd->query());
rcode = WSREP_TRX_FAIL;
}
else if (!rcode)
@@ -465,8 +469,8 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
&thd->wsrep_trx_meta);
if (rcode == WSREP_TRX_MISSING) {
- WSREP_WARN("Transaction missing in provider, thd: %ld, SQL: %s",
- thd->thread_id, thd->query());
+ WSREP_WARN("Transaction missing in provider, thd: %ld, schema: %s, SQL: %s",
+ thd->thread_id, (thd->db ? thd->db : "(null)"), thd->query());
rcode = WSREP_TRX_FAIL;
} else if (rcode == WSREP_BF_ABORT) {
WSREP_DEBUG("thd %lu seqno %lld BF aborted by provider, will replay",
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 0158a78a10b..90b1c132ae9 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -922,19 +922,10 @@ bool wsrep_start_replication()
wsrep_sst_donor,
bootstrap)))
{
- if (-ESOCKTNOSUPPORT == rcode)
- {
- DBUG_PRINT("wsrep",("unrecognized cluster address: '%s', rcode: %d",
- wsrep_cluster_address, rcode));
- WSREP_ERROR("unrecognized cluster address: '%s', rcode: %d",
- wsrep_cluster_address, rcode);
- }
- else
- {
- DBUG_PRINT("wsrep",("wsrep->connect() failed: %d", rcode));
- WSREP_ERROR("wsrep::connect() failed: %d", rcode);
- }
-
+ DBUG_PRINT("wsrep",("wsrep->connect(%s) failed: %d",
+ wsrep_cluster_address, rcode));
+ WSREP_ERROR("wsrep::connect(%s) failed: %d",
+ wsrep_cluster_address, rcode);
return false;
}
else
@@ -1277,7 +1268,8 @@ int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len)
if (wsrep_alter_query_string(thd, &log_query))
{
- WSREP_WARN("events alter string failed: %s", thd->query());
+ WSREP_WARN("events alter string failed: schema: %s, query: %s",
+ (thd->db ? thd->db : "(null)"), thd->query());
return 1;
}
return wsrep_to_buf_helper(thd, log_query.ptr(), log_query.length(), buf, buf_len);
@@ -1425,9 +1417,11 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
}
else if (key_arr.keys_len > 0) {
/* jump to error handler in mysql_execute_command() */
- WSREP_WARN("TO isolation failed for: %d, sql: %s. Check wsrep "
+ WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. Check wsrep "
"connection state and retry the query.",
- ret, (thd->query()) ? thd->query() : "void");
+ ret,
+ (thd->db ? thd->db : "(null)"),
+ (thd->query()) ? thd->query() : "void");
my_error(ER_LOCK_DEADLOCK, MYF(0), "WSREP replication failed. Check "
"your wsrep connection state and retry the query.");
wsrep_keys_free(&key_arr);
@@ -1460,8 +1454,10 @@ static void wsrep_TOI_end(THD *thd) {
WSREP_DEBUG("TO END: %lld", (long long)wsrep_thd_trx_seqno(thd));
}
else {
- WSREP_WARN("TO isolation end failed for: %d, sql: %s",
- ret, (thd->query()) ? thd->query() : "void");
+ WSREP_WARN("TO isolation end failed for: %d, schema: %s, sql: %s",
+ ret,
+ (thd->db ? thd->db : "(null)"),
+ (thd->query()) ? thd->query() : "void");
}
}
@@ -1474,7 +1470,10 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
ret = wsrep->desync(wsrep);
if (ret != WSREP_OK)
{
- WSREP_WARN("RSU desync failed %d for %s", ret, thd->query());
+ WSREP_WARN("RSU desync failed %d for schema: %s, query: %s",
+ ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
my_error(ER_LOCK_DEADLOCK, MYF(0));
return(ret);
}
@@ -1485,7 +1484,9 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
if (wsrep_wait_committing_connections_close(5000))
{
/* no can do, bail out from DDL */
- WSREP_WARN("RSU failed due to pending transactions, %s", thd->query());
+ WSREP_WARN("RSU failed due to pending transactions, schema: %s, query %s",
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
mysql_mutex_lock(&LOCK_wsrep_replaying);
wsrep_replaying--;
mysql_mutex_unlock(&LOCK_wsrep_replaying);
@@ -1493,7 +1494,10 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
ret = wsrep->resync(wsrep);
if (ret != WSREP_OK)
{
- WSREP_WARN("resync failed %d for %s", ret, thd->query());
+ WSREP_WARN("resync failed %d for schema: %s, query: %s",
+ ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
}
my_error(ER_LOCK_DEADLOCK, MYF(0));
return(1);
@@ -1502,7 +1506,9 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
wsrep_seqno_t seqno = wsrep->pause(wsrep);
if (seqno == WSREP_SEQNO_UNDEFINED)
{
- WSREP_WARN("pause failed %lld for %s", (long long)seqno, thd->query());
+ WSREP_WARN("pause failed %lld for schema: %s, query: %s", (long long)seqno,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
return(1);
}
WSREP_DEBUG("paused at %lld", (long long)seqno);
@@ -1524,12 +1530,16 @@ static void wsrep_RSU_end(THD *thd)
ret = wsrep->resume(wsrep);
if (ret != WSREP_OK)
{
- WSREP_WARN("resume failed %d for %s", ret, thd->query());
+ WSREP_WARN("resume failed %d for schema: %s, query: %s", ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
}
ret = wsrep->resync(wsrep);
if (ret != WSREP_OK)
{
- WSREP_WARN("resync failed %d for %s", ret, thd->query());
+ WSREP_WARN("resync failed %d for schema: %s, query: %s", ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
return;
}
thd->variables.wsrep_on = 1;
@@ -1550,8 +1560,10 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
if (thd->wsrep_conflict_state == MUST_ABORT)
{
- WSREP_INFO("thread: %lu, %s has been aborted due to multi-master conflict",
- thd->thread_id, thd->query());
+ WSREP_INFO("thread: %lu, schema: %s, query: %s has been aborted due to multi-master conflict",
+ thd->thread_id,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
return WSREP_TRX_FAIL;
}
@@ -1629,15 +1641,16 @@ void wsrep_to_isolation_end(THD *thd)
}
}
-#define WSREP_MDL_LOG(severity, msg, req, gra) \
+#define WSREP_MDL_LOG(severity, msg, schema, schema_len, req, gra) \
WSREP_##severity( \
"%s\n" \
+ "schema: %.*s\n" \
"request: (%lu \tseqno %lld \twsrep (%d, %d, %d) cmd %d %d \t%s)\n" \
"granted: (%lu \tseqno %lld \twsrep (%d, %d, %d) cmd %d %d \t%s)", \
- msg, \
+ msg, schema_len, schema, \
req->thread_id, (long long)wsrep_thd_trx_seqno(req), \
req->wsrep_exec_mode, req->wsrep_query_state, req->wsrep_conflict_state, \
- req->get_command(), req->lex->sql_command, req->query(), \
+ req->get_command(), req->lex->sql_command, req->query(), \
gra->thread_id, (long long)wsrep_thd_trx_seqno(gra), \
gra->wsrep_exec_mode, gra->wsrep_query_state, gra->wsrep_conflict_state, \
gra->get_command(), gra->lex->sql_command, gra->query());
@@ -1654,7 +1667,8 @@ void wsrep_to_isolation_end(THD *thd)
bool
wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
- MDL_ticket *ticket
+ MDL_ticket *ticket,
+ const MDL_key *key
) {
/* Fallback to the non-wsrep behaviour */
if (!WSREP_ON) return FALSE;
@@ -1663,29 +1677,35 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
THD *granted_thd = ticket->get_ctx()->get_thd();
bool ret = FALSE;
+ const char* schema= key->db_name();
+ int schema_len= key->db_name_length();
+
mysql_mutex_lock(&request_thd->LOCK_wsrep_thd);
if (request_thd->wsrep_exec_mode == TOTAL_ORDER ||
request_thd->wsrep_exec_mode == REPL_RECV)
{
mysql_mutex_unlock(&request_thd->LOCK_wsrep_thd);
- WSREP_MDL_LOG(DEBUG, "MDL conflict ", request_thd, granted_thd);
+ WSREP_MDL_LOG(DEBUG, "MDL conflict ", schema, schema_len,
+ request_thd, granted_thd);
ticket->wsrep_report(wsrep_debug);
mysql_mutex_lock(&granted_thd->LOCK_wsrep_thd);
if (granted_thd->wsrep_exec_mode == TOTAL_ORDER ||
granted_thd->wsrep_exec_mode == REPL_RECV)
{
- WSREP_MDL_LOG(INFO, "MDL BF-BF conflict", request_thd, granted_thd);
+ WSREP_MDL_LOG(INFO, "MDL BF-BF conflict", schema, schema_len,
+ request_thd, granted_thd);
ticket->wsrep_report(true);
mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
ret = TRUE;
}
- else if (granted_thd->lex->sql_command == SQLCOM_FLUSH)
+ else if (granted_thd->lex->sql_command == SQLCOM_FLUSH ||
+ granted_thd->mdl_context.has_explicit_locks())
{
- WSREP_DEBUG("MDL granted over FLUSH BF");
+ WSREP_DEBUG("BF thread waiting for FLUSH");
ticket->wsrep_report(wsrep_debug);
mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
- ret = TRUE;
+ ret = FALSE;
}
else if (request_thd->lex->sql_command == SQLCOM_DROP_TABLE)
{
@@ -1705,7 +1725,8 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
}
else
{
- WSREP_MDL_LOG(DEBUG, "MDL conflict-> BF abort", request_thd, granted_thd);
+ WSREP_MDL_LOG(DEBUG, "MDL conflict-> BF abort", schema, schema_len,
+ request_thd, granted_thd);
ticket->wsrep_report(wsrep_debug);
mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
wsrep_abort_thd((void*)request_thd, (void*)granted_thd, 1);
@@ -2177,7 +2198,8 @@ int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len)
&(thd->lex->definer->host),
saved_mode))
{
- WSREP_WARN("SP create string failed: %s", thd->query());
+ WSREP_WARN("SP create string failed: schema: %s, query: %s",
+ (thd->db ? thd->db : "(null)"), thd->query());
return 1;
}
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index 24af4ec0953..3c36e88eb6d 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -289,7 +289,8 @@ int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len);
extern bool
wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
- MDL_ticket *ticket);
+ MDL_ticket *ticket,
+ const MDL_key *key);
IO_CACHE * get_trans_log(THD * thd);
bool wsrep_trans_cache_is_empty(THD *thd);
void thd_binlog_flush_pending_rows_event(THD *thd, bool stmt_end);
diff --git a/sql/wsrep_notify.cc b/sql/wsrep_notify.cc
index 6eefb961b62..e7d30d5a9c1 100644
--- a/sql/wsrep_notify.cc
+++ b/sql/wsrep_notify.cc
@@ -97,7 +97,7 @@ void wsrep_notify_status (wsrep_member_status_t status,
return;
}
- wsp::process p(cmd_ptr, "r");
+ wsp::process p(cmd_ptr, "r", NULL);
p.wait();
int err = p.error();
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index b31d433de08..c75f2c116ec 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -315,12 +315,14 @@ void wsrep_sst_continue ()
struct sst_thread_arg
{
const char* cmd;
- int err;
+ char** env;
char* ret_str;
+ int err;
mysql_mutex_t lock;
mysql_cond_t cond;
- sst_thread_arg (const char* c) : cmd(c), err(-1), ret_str(0)
+ sst_thread_arg (const char* c, char** e)
+ : cmd(c), env(e), ret_str(0), err(-1)
{
mysql_mutex_init(key_LOCK_wsrep_sst_thread, &lock, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_COND_wsrep_sst_thread, &cond, NULL);
@@ -405,7 +407,7 @@ static void* sst_joiner_thread (void* a)
WSREP_INFO("Running: '%s'", arg->cmd);
- wsp::process proc (arg->cmd, "r");
+ wsp::process proc (arg->cmd, "r", arg->env);
if (proc.pipe() && !proc.error())
{
@@ -519,12 +521,44 @@ err:
return NULL;
}
+#define WSREP_SST_AUTH_ENV "WSREP_SST_OPT_AUTH"
+
+static int sst_append_auth_env(wsp::env& env, const char* sst_auth)
+{
+ int const sst_auth_size= strlen(WSREP_SST_AUTH_ENV) + 1 /* = */
+ + (sst_auth ? strlen(sst_auth) : 0) + 1 /* \0 */;
+
+ wsp::string sst_auth_str(sst_auth_size); // for automatic cleanup on return
+ if (!sst_auth_str()) return -ENOMEM;
+
+ int ret= snprintf(sst_auth_str(), sst_auth_size, "%s=%s",
+ WSREP_SST_AUTH_ENV, sst_auth ? sst_auth : "");
+
+ if (ret < 0 || ret >= sst_auth_size)
+ {
+ WSREP_ERROR("sst_append_auth_env(): snprintf() failed: %d", ret);
+ return (ret < 0 ? ret : -EMSGSIZE);
+ }
+
+ env.append(sst_auth_str());
+ return -env.error();
+}
+
static ssize_t sst_prepare_other (const char* method,
+ const char* sst_auth,
const char* addr_in,
const char** addr_out)
{
- char cmd_str[1024];
- const char* sst_dir= mysql_real_data_home;
+ int const cmd_len= 4096;
+ wsp::string cmd_str(cmd_len);
+
+ if (!cmd_str())
+ {
+ WSREP_ERROR("sst_prepare_other(): could not allocate cmd buffer of %d bytes",
+ cmd_len);
+ return -ENOMEM;
+ }
+
const char* binlog_opt= "";
char* binlog_opt_val= NULL;
@@ -539,35 +573,47 @@ static ssize_t sst_prepare_other (const char* method,
make_wsrep_defaults_file();
- ret= snprintf (cmd_str, sizeof(cmd_str),
+ ret= snprintf (cmd_str(), cmd_len,
"wsrep_sst_%s "
WSREP_SST_OPT_ROLE" 'joiner' "
WSREP_SST_OPT_ADDR" '%s' "
- WSREP_SST_OPT_AUTH" '%s' "
WSREP_SST_OPT_DATA" '%s' "
" %s "
WSREP_SST_OPT_PARENT" '%d'"
" %s '%s' ",
- method, addr_in, (sst_auth_real) ? sst_auth_real : "",
- sst_dir, wsrep_defaults_file, (int)getpid(),
+ method, addr_in, mysql_real_data_home,
+ wsrep_defaults_file, (int)getpid(),
binlog_opt, binlog_opt_val);
my_free(binlog_opt_val);
- if (ret < 0 || ret >= (int)sizeof(cmd_str))
+ if (ret < 0 || ret >= cmd_len)
{
WSREP_ERROR("sst_prepare_other(): snprintf() failed: %d", ret);
return (ret < 0 ? ret : -EMSGSIZE);
}
+ wsp::env env(NULL);
+ if (env.error())
+ {
+ WSREP_ERROR("sst_prepare_other(): env. var ctor failed: %d", -env.error());
+ return -env.error();
+ }
+
+ if ((ret= sst_append_auth_env(env, sst_auth)))
+ {
+ WSREP_ERROR("sst_prepare_other(): appending auth failed: %d", ret);
+ return ret;
+ }
+
pthread_t tmp;
- sst_thread_arg arg(cmd_str);
+ sst_thread_arg arg(cmd_str(), env());
mysql_mutex_lock (&arg.lock);
ret = pthread_create (&tmp, NULL, sst_joiner_thread, &arg);
if (ret)
{
WSREP_ERROR("sst_prepare_other(): pthread_create() failed: %d (%s)",
ret, strerror(ret));
- return ret;
+ return -ret;
}
mysql_cond_wait (&arg.cond, &arg.lock);
@@ -713,7 +759,8 @@ ssize_t wsrep_sst_prepare (void** msg)
return 0;
}
- addr_len = sst_prepare_other (wsrep_sst_method, addr_in, &addr_out);
+ addr_len = sst_prepare_other (wsrep_sst_method, sst_auth_real,
+ addr_in, &addr_out);
if (addr_len < 0)
{
WSREP_ERROR("Failed to prepare for '%s' SST. Unrecoverable.",
@@ -746,13 +793,13 @@ ssize_t wsrep_sst_prepare (void** msg)
}
// helper method for donors
-static int sst_run_shell (const char* cmd_str, int max_tries)
+static int sst_run_shell (const char* cmd_str, char** env, int max_tries)
{
int ret = 0;
for (int tries=1; tries <= max_tries; tries++)
{
- wsp::process proc (cmd_str, "r");
+ wsp::process proc (cmd_str, "r", env);
if (NULL != proc.pipe())
{
@@ -782,19 +829,12 @@ static void sst_reject_queries(my_bool close_conn)
if (TRUE == close_conn) wsrep_close_client_connections(FALSE);
}
-static int sst_mysqldump_check_addr (const char* user,
- const char* pswd,
- const char* host,
- int port)
-{
- return 0;
-}
-
static int sst_donate_mysqldump (const char* addr,
const wsrep_uuid_t* uuid,
const char* uuid_str,
wsrep_seqno_t seqno,
- bool bypass)
+ bool bypass,
+ char** env) // carries auth info
{
char host[256];
wsp::Address address(addr);
@@ -807,56 +847,46 @@ static int sst_donate_mysqldump (const char* addr,
memcpy(host, address.get_address(), address.get_address_len());
int port= address.get_port();
- const char* auth = sst_auth_real;
- const char* pswd = (auth) ? strchr (auth, ':') : NULL;
- size_t user_len;
- if (pswd)
- {
- pswd += 1;
- user_len = pswd - auth;
- }
- else
+ int const cmd_len= 4096;
+ wsp::string cmd_str(cmd_len);
+
+ if (!cmd_str())
{
- pswd = "";
- user_len = (auth) ? strlen (auth) + 1 : 1;
+ WSREP_ERROR("sst_donate_mysqldump(): "
+ "could not allocate cmd buffer of %d bytes", cmd_len);
+ return -ENOMEM;
}
- char *user= (char *) alloca(user_len);
+ if (!bypass && wsrep_sst_donor_rejects_queries) sst_reject_queries(TRUE);
- strncpy (user, (auth) ? auth : "", user_len - 1);
- user[user_len - 1] = '\0';
+ make_wsrep_defaults_file();
- int ret = sst_mysqldump_check_addr (user, pswd, host, port);
- if (!ret)
+ int ret= snprintf (cmd_str(), cmd_len,
+ "wsrep_sst_mysqldump "
+ WSREP_SST_OPT_HOST" '%s' "
+ WSREP_SST_OPT_PORT" '%d' "
+ WSREP_SST_OPT_LPORT" '%u' "
+ WSREP_SST_OPT_SOCKET" '%s' "
+ " %s "
+ WSREP_SST_OPT_GTID" '%s:%lld' "
+ WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'"
+ "%s",
+ host, port, mysqld_port, mysqld_unix_port,
+ wsrep_defaults_file, uuid_str,
+ (long long)seqno, wsrep_gtid_domain_id,
+ bypass ? " "WSREP_SST_OPT_BYPASS : "");
+
+ if (ret < 0 || ret >= cmd_len)
{
- char cmd_str[1024];
-
- if (!bypass && wsrep_sst_donor_rejects_queries) sst_reject_queries(TRUE);
-
- make_wsrep_defaults_file();
-
- snprintf (cmd_str, sizeof(cmd_str),
- "wsrep_sst_mysqldump "
- WSREP_SST_OPT_USER" '%s' "
- WSREP_SST_OPT_PSWD" '%s' "
- WSREP_SST_OPT_HOST" '%s' "
- WSREP_SST_OPT_PORT" '%d' "
- WSREP_SST_OPT_LPORT" '%u' "
- WSREP_SST_OPT_SOCKET" '%s' "
- " %s "
- WSREP_SST_OPT_GTID" '%s:%lld' "
- WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'"
- "%s",
- user, pswd, host, port, mysqld_port, mysqld_unix_port,
- wsrep_defaults_file, uuid_str, (long long)seqno,
- wsrep_gtid_domain_id, bypass ? " "WSREP_SST_OPT_BYPASS : "");
-
- WSREP_DEBUG("Running: '%s'", cmd_str);
-
- ret= sst_run_shell (cmd_str, 3);
+ WSREP_ERROR("sst_donate_mysqldump(): snprintf() failed: %d", ret);
+ return (ret < 0 ? ret : -EMSGSIZE);
}
+ WSREP_DEBUG("Running: '%s'", cmd_str());
+
+ ret= sst_run_shell (cmd_str(), env, 3);
+
wsrep_gtid_t const state_id = { *uuid, (ret ? WSREP_SEQNO_UNDEFINED : seqno)};
wsrep->sst_sent (wsrep, &state_id, ret);
@@ -1012,7 +1042,7 @@ static void* sst_donor_thread (void* a)
wsp::thd thd(FALSE); // we turn off wsrep_on for this THD so that it can
// operate with wsrep_ready == OFF
- wsp::process proc(arg->cmd, "r");
+ wsp::process proc(arg->cmd, "r", arg->env);
err= proc.error();
@@ -1099,9 +1129,19 @@ static int sst_donate_other (const char* method,
const char* addr,
const char* uuid,
wsrep_seqno_t seqno,
- bool bypass)
+ bool bypass,
+ char** env) // carries auth info
{
- char cmd_str[4096];
+ int const cmd_len= 4096;
+ wsp::string cmd_str(cmd_len);
+
+ if (!cmd_str())
+ {
+ WSREP_ERROR("sst_donate_other(): "
+ "could not allocate cmd buffer of %d bytes", cmd_len);
+ return -ENOMEM;
+ }
+
const char* binlog_opt= "";
char* binlog_opt_val= NULL;
@@ -1115,11 +1155,10 @@ static int sst_donate_other (const char* method,
make_wsrep_defaults_file();
- ret= snprintf (cmd_str, sizeof(cmd_str),
+ ret= snprintf (cmd_str(), cmd_len,
"wsrep_sst_%s "
WSREP_SST_OPT_ROLE" 'donor' "
WSREP_SST_OPT_ADDR" '%s' "
- WSREP_SST_OPT_AUTH" '%s' "
WSREP_SST_OPT_SOCKET" '%s' "
WSREP_SST_OPT_DATA" '%s' "
" %s "
@@ -1127,14 +1166,14 @@ static int sst_donate_other (const char* method,
WSREP_SST_OPT_GTID" '%s:%lld' "
WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'"
"%s",
- method, addr, sst_auth_real, mysqld_unix_port,
- mysql_real_data_home, wsrep_defaults_file,
+ method, addr, mysqld_unix_port, mysql_real_data_home,
+ wsrep_defaults_file,
binlog_opt, binlog_opt_val,
uuid, (long long) seqno, wsrep_gtid_domain_id,
bypass ? " "WSREP_SST_OPT_BYPASS : "");
my_free(binlog_opt_val);
- if (ret < 0 || ret >= (int) sizeof(cmd_str))
+ if (ret < 0 || ret >= cmd_len)
{
WSREP_ERROR("sst_donate_other(): snprintf() failed: %d", ret);
return (ret < 0 ? ret : -EMSGSIZE);
@@ -1143,7 +1182,7 @@ static int sst_donate_other (const char* method,
if (!bypass && wsrep_sst_donor_rejects_queries) sst_reject_queries(FALSE);
pthread_t tmp;
- sst_thread_arg arg(cmd_str);
+ sst_thread_arg arg(cmd_str(), env);
mysql_mutex_lock (&arg.lock);
ret = pthread_create (&tmp, NULL, sst_donor_thread, &arg);
if (ret)
@@ -1176,18 +1215,32 @@ wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
char uuid_str[37];
wsrep_uuid_print (&current_gtid->uuid, uuid_str, sizeof(uuid_str));
+ wsp::env env(NULL);
+ if (env.error())
+ {
+ WSREP_ERROR("wsrep_sst_donate_cb(): env var ctor failed: %d", -env.error());
+ return WSREP_CB_FAILURE;
+ }
+
int ret;
+ if ((ret= sst_append_auth_env(env, sst_auth_real)))
+ {
+ WSREP_ERROR("wsrep_sst_donate_cb(): appending auth env failed: %d", ret);
+ return WSREP_CB_FAILURE;
+ }
+
if (!strcmp (WSREP_SST_MYSQLDUMP, method))
{
ret = sst_donate_mysqldump(data, &current_gtid->uuid, uuid_str,
- current_gtid->seqno, bypass);
+ current_gtid->seqno, bypass, env());
}
else
{
- ret = sst_donate_other(method, data, uuid_str, current_gtid->seqno,bypass);
+ ret = sst_donate_other(method, data, uuid_str,
+ current_gtid->seqno, bypass, env());
}
- return (ret > 0 ? WSREP_CB_SUCCESS : WSREP_CB_FAILURE);
+ return (ret >= 0 ? WSREP_CB_SUCCESS : WSREP_CB_FAILURE);
}
void wsrep_SE_init_grab()
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 9e608f94848..ab09a9e3a99 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -215,6 +215,7 @@ void wsrep_replay_transaction(THD *thd)
*/
MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
thd->m_statement_psi= NULL;
+ thd->m_digest= NULL;
thd_proc_info(thd, "wsrep replaying trx");
WSREP_DEBUG("replay trx: %s %lld",
thd->query() ? thd->query() : "void",
@@ -274,8 +275,10 @@ void wsrep_replay_transaction(THD *thd)
wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle);
break;
default:
- WSREP_ERROR("trx_replay failed for: %d, query: %s",
- rcode, thd->query() ? thd->query() : "void");
+ WSREP_ERROR("trx_replay failed for: %d, schema: %s, query: %s",
+ rcode,
+ (thd->db ? thd->db : "(null)"),
+ thd->query() ? thd->query() : "void");
/* we're now in inconsistent state, must abort */
/* http://bazaar.launchpad.net/~codership/codership-mysql/5.6/revision/3962#sql/wsrep_thd.cc */
@@ -608,3 +611,8 @@ int wsrep_thd_in_locking_session(void *thd_ptr)
return 0;
}
+bool wsrep_thd_has_explicit_locks(THD *thd)
+{
+ assert(thd);
+ return thd->mdl_context.has_explicit_locks();
+}
diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc
index 2998a5b04ac..56f1018deac 100644
--- a/sql/wsrep_utils.cc
+++ b/sql/wsrep_utils.cc
@@ -63,7 +63,7 @@ wsrep_prepend_PATH (const char* path)
size_t const new_path_len(strlen(old_path) + strlen(":") +
strlen(path) + 1);
- char* const new_path (reinterpret_cast<char*>(malloc(new_path_len)));
+ char* const new_path (static_cast<char*>(malloc(new_path_len)));
if (new_path)
{
@@ -89,6 +89,90 @@ wsrep_prepend_PATH (const char* path)
namespace wsp
{
+bool
+env::ctor_common(char** e)
+{
+ env_ = static_cast<char**>(malloc((len_ + 1) * sizeof(char*)));
+
+ if (env_)
+ {
+ for (size_t i(0); i < len_; ++i)
+ {
+ assert(e[i]); // caller should make sure about len_
+ env_[i] = strdup(e[i]);
+ if (!env_[i])
+ {
+ errno_ = errno;
+ WSREP_ERROR("Failed to allocate env. var: %s", e[i]);
+ return true;
+ }
+ }
+
+ env_[len_] = NULL;
+ return false;
+ }
+ else
+ {
+ errno_ = errno;
+ WSREP_ERROR("Failed to allocate env. var vector of length: %zu", len_);
+ return true;
+ }
+}
+
+void
+env::dtor()
+{
+ if (env_)
+ {
+ /* don't need to go beyond the first NULL */
+ for (size_t i(0); env_[i] != NULL; ++i) { free(env_[i]); }
+ free(env_);
+ env_ = NULL;
+ }
+ len_ = 0;
+}
+
+env::env(char** e)
+ : len_(0), env_(NULL), errno_(0)
+{
+ if (!e) { e = environ; }
+ /* count the size of the vector */
+ while (e[len_]) { ++len_; }
+
+ if (ctor_common(e)) dtor();
+}
+
+env::env(const env& e)
+ : len_(e.len_), env_(0), errno_(0)
+{
+ if (ctor_common(e.env_)) dtor();
+}
+
+env::~env() { dtor(); }
+
+int
+env::append(const char* val)
+{
+ char** tmp = static_cast<char**>(realloc(env_, (len_ + 2)*sizeof(char*)));
+
+ if (tmp)
+ {
+ env_ = tmp;
+ env_[len_] = strdup(val);
+
+ if (env_[len_])
+ {
+ ++len_;
+ env_[len_] = NULL;
+ }
+ else errno_ = errno;
+ }
+ else errno_ = errno;
+
+ return errno_;
+}
+
+
#define PIPE_READ 0
#define PIPE_WRITE 1
#define STDIN_FD 0
@@ -98,7 +182,7 @@ namespace wsp
# define POSIX_SPAWN_USEVFORK 0
#endif
-process::process (const char* cmd, const char* type)
+process::process (const char* cmd, const char* type, char** env)
: str_(cmd ? strdup(cmd) : strdup("")), io_(NULL), err_(EINVAL), pid_(0)
{
if (0 == str_)
@@ -120,6 +204,8 @@ process::process (const char* cmd, const char* type)
return;
}
+ if (NULL == env) { env = environ; } // default to global environment
+
int pipe_fds[2] = { -1, };
if (::pipe(pipe_fds))
{
@@ -215,7 +301,7 @@ process::process (const char* cmd, const char* type)
goto cleanup_fact;
}
- err_ = posix_spawnp (&pid_, pargv[0], &fact, &attr, pargv, environ);
+ err_ = posix_spawnp (&pid_, pargv[0], &fact, &attr, pargv, env);
if (err_)
{
WSREP_ERROR ("posix_spawnp(%s) failed: %d (%s)",
@@ -309,6 +395,7 @@ process::wait ()
{
case 126: err_ = EACCES; break; /* Permission denied */
case 127: err_ = ENOENT; break; /* No such file or directory */
+ case 143: err_ = EINTR; break; /* Subprocess killed */
}
WSREP_ERROR("Process completed with error: %s: %d (%s)",
str_, err_, strerror(err_));
diff --git a/sql/wsrep_utils.h b/sql/wsrep_utils.h
index 32829c605fb..ed699eabec9 100644
--- a/sql/wsrep_utils.h
+++ b/sql/wsrep_utils.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2013 Codership Oy <info@codership.com>
+/* Copyright (C) 2013-2015 Codership Oy <info@codership.com>
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
@@ -236,6 +236,25 @@ private:
extern wsp::Config_state wsrep_config_state;
namespace wsp {
+/* a class to manage env vars array */
+class env
+{
+private:
+ size_t len_;
+ char** env_;
+ int errno_;
+ bool ctor_common(char** e);
+ void dtor();
+ env& operator =(env);
+public:
+ explicit env(char** env);
+ explicit env(const env&);
+ ~env();
+ int append(const char* var); /* add a new env. var */
+ int error() const { return errno_; }
+ char** operator()() { return env_; }
+};
+
/* A small class to run external programs. */
class process
{
@@ -248,8 +267,9 @@ private:
public:
/*! @arg type is a pointer to a null-terminated string which must contain
either the letter 'r' for reading or the letter 'w' for writing.
+ @arg env optional null-terminated vector of environment variables
*/
- process (const char* cmd, const char* type);
+ process (const char* cmd, const char* type, char** env);
~process ();
FILE* pipe () { return io_; }
@@ -282,6 +302,8 @@ class string
{
public:
string() : string_(0) {}
+ explicit string(size_t s) : string_(static_cast<char*>(malloc(s))) {}
+ char* operator()() { return string_; }
void set(char* str) { if (string_) free (string_); string_ = str; }
~string() { set (0); }
private:
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index d6aa1ca5c79..9c01e54f48d 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -512,14 +512,18 @@ bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type)
if (wsrep_desync) {
ret = wsrep->desync (wsrep);
if (ret != WSREP_OK) {
- WSREP_WARN ("SET desync failed %d for %s", ret, thd->query());
+ WSREP_WARN ("SET desync failed %d for schema: %s, query: %s", ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
my_error (ER_CANNOT_USER, MYF(0), "'desync'", thd->query());
return true;
}
} else {
ret = wsrep->resync (wsrep);
if (ret != WSREP_OK) {
- WSREP_WARN ("SET resync failed %d for %s", ret, thd->query());
+ WSREP_WARN ("SET resync failed %d for schema: %s, query: %s", ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
my_error (ER_CANNOT_USER, MYF(0), "'resync'", thd->query());
return true;
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 63ed1ff5b35..c2c7faad91f 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -4594,6 +4594,8 @@ innobase_kill_query(
enum thd_kill_levels level) /*!< in: kill level */
{
trx_t* trx;
+ bool took_lock_sys = false;
+
DBUG_ENTER("innobase_kill_query");
DBUG_ASSERT(hton == innodb_hton_ptr);
@@ -4618,16 +4620,25 @@ innobase_kill_query(
THD *owner = trx->current_lock_mutex_owner;
if (!owner || owner != cur) {
+ ut_ad(!lock_mutex_own());
lock_mutex_enter();
+ took_lock_sys = true;
}
+
+ ut_ad(!trx_mutex_own(trx));
trx_mutex_enter(trx);
/* Cancel a pending lock request. */
if (trx->lock.wait_lock) {
lock_cancel_waiting_and_release(trx->lock.wait_lock);
}
+
+ ut_ad(lock_mutex_own());
+ ut_ad(trx_mutex_own(trx));
+
trx_mutex_exit(trx);
- if (!owner || owner != cur) {
+
+ if (took_lock_sys) {
lock_mutex_exit();
}
}
@@ -18098,11 +18109,13 @@ wsrep_abort_slave_trx(wsrep_seqno_t bf_seqno, wsrep_seqno_t victim_seqno)
}
/*******************************************************************//**
This function is used to kill one transaction in BF. */
-
+UNIV_INTERN
int
-wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
- const trx_t * const bf_trx,
- trx_t *victim_trx, ibool signal)
+wsrep_innobase_kill_one_trx(
+ void * const bf_thd_ptr,
+ const trx_t * const bf_trx,
+ trx_t *victim_trx,
+ ibool signal)
{
ut_ad(lock_mutex_own());
ut_ad(trx_mutex_own(victim_trx));
@@ -18119,6 +18132,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
WSREP_WARN("no THD for trx: %lu", victim_trx->id);
DBUG_RETURN(1);
}
+
if (!bf_thd) {
DBUG_PRINT("wsrep", ("no BF thd for conflicting lock"));
WSREP_WARN("no BF THD for trx: %lu", (bf_trx) ? bf_trx->id : 0);
@@ -18142,6 +18156,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
}
+
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
WSREP_DEBUG("withdraw for BF trx: %lu, state: %d",
victim_trx->id,
@@ -18296,28 +18311,33 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
DBUG_RETURN(0);
}
-static int
-wsrep_abort_transaction(handlerton* hton, THD *bf_thd, THD *victim_thd,
- my_bool signal)
+static
+int
+wsrep_abort_transaction(
+ handlerton* hton,
+ THD *bf_thd,
+ THD *victim_thd,
+ my_bool signal)
{
DBUG_ENTER("wsrep_innobase_abort_thd");
trx_t* victim_trx = thd_to_trx(victim_thd);
trx_t* bf_trx = (bf_thd) ? thd_to_trx(bf_thd) : NULL;
+
WSREP_DEBUG("abort transaction: BF: %s victim: %s",
wsrep_thd_query(bf_thd),
wsrep_thd_query(victim_thd));
- if (victim_trx)
- {
- lock_mutex_enter();
- trx_mutex_enter(victim_trx);
+ if (victim_trx) {
+ lock_mutex_enter();
+ victim_trx->current_lock_mutex_owner = victim_thd;
+ trx_mutex_enter(victim_trx);
int rcode = wsrep_innobase_kill_one_trx(bf_thd, bf_trx,
victim_trx, signal);
- trx_mutex_exit(victim_trx);
- lock_mutex_exit();
+ trx_mutex_exit(victim_trx);
+ victim_trx->current_lock_mutex_owner = NULL;
+ lock_mutex_exit();
wsrep_srv_conc_cancel_wait(victim_trx);
-
- DBUG_RETURN(rcode);
+ DBUG_RETURN(rcode);
} else {
WSREP_DEBUG("victim does not have transaction");
wsrep_thd_LOCK(victim_thd);
@@ -18325,6 +18345,7 @@ wsrep_abort_transaction(handlerton* hton, THD *bf_thd, THD *victim_thd,
wsrep_thd_UNLOCK(victim_thd);
wsrep_thd_awake(victim_thd, signal);
}
+
DBUG_RETURN(-1);
}
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index 12f1ecf3a5a..36570a2a2b7 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -6812,14 +6812,16 @@ lock_clust_rec_modify_check_and_lock(
lock_rec_convert_impl_to_expl(block, rec, index, offsets);
lock_mutex_enter();
-
- ut_ad(lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+ trx_t* trx = thr_get_trx(thr);
+ trx->current_lock_mutex_owner = trx->mysql_thd;
+ ut_ad(lock_table_has(trx, index->table, LOCK_IX));
err = lock_rec_lock(TRUE, LOCK_X | LOCK_REC_NOT_GAP,
block, heap_no, index, thr);
MONITOR_INC(MONITOR_NUM_RECLOCK_REQ);
+ trx->current_lock_mutex_owner = NULL;
lock_mutex_exit();
ut_ad(lock_rec_queue_validate(FALSE, block, rec, index, offsets));
@@ -6871,15 +6873,18 @@ lock_sec_rec_modify_check_and_lock(
index record, and this would not have been possible if another active
transaction had modified this secondary index record. */
+ trx_t* trx = thr_get_trx(thr);
lock_mutex_enter();
+ trx->current_lock_mutex_owner = trx->mysql_thd;
- ut_ad(lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+ ut_ad(lock_table_has(trx, index->table, LOCK_IX));
err = lock_rec_lock(TRUE, LOCK_X | LOCK_REC_NOT_GAP,
block, heap_no, index, thr);
MONITOR_INC(MONITOR_NUM_RECLOCK_REQ);
+ trx->current_lock_mutex_owner = NULL;
lock_mutex_exit();
#ifdef UNIV_DEBUG
@@ -6970,18 +6975,21 @@ lock_sec_rec_read_check_and_lock(
lock_rec_convert_impl_to_expl(block, rec, index, offsets);
}
+ trx_t* trx = thr_get_trx(thr);
lock_mutex_enter();
+ trx->current_lock_mutex_owner = trx->mysql_thd;
ut_ad(mode != LOCK_X
- || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+ || lock_table_has(trx, index->table, LOCK_IX));
ut_ad(mode != LOCK_S
- || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS));
+ || lock_table_has(trx, index->table, LOCK_IS));
err = lock_rec_lock(FALSE, mode | gap_mode,
block, heap_no, index, thr);
MONITOR_INC(MONITOR_NUM_RECLOCK_REQ);
+ trx->current_lock_mutex_owner = NULL;
lock_mutex_exit();
ut_ad(lock_rec_queue_validate(FALSE, block, rec, index, offsets));
@@ -7043,17 +7051,20 @@ lock_clust_rec_read_check_and_lock(
}
lock_mutex_enter();
+ trx_t* trx = thr_get_trx(thr);
+ trx->current_lock_mutex_owner = trx->mysql_thd;
ut_ad(mode != LOCK_X
- || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+ || lock_table_has(trx, index->table, LOCK_IX));
ut_ad(mode != LOCK_S
- || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS));
+ || lock_table_has(trx, index->table, LOCK_IS));
err = lock_rec_lock(FALSE, mode | gap_mode,
block, heap_no, index, thr);
MONITOR_INC(MONITOR_NUM_RECLOCK_REQ);
+ trx->current_lock_mutex_owner = NULL;
lock_mutex_exit();
ut_ad(lock_rec_queue_validate(FALSE, block, rec, index, offsets));
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index da66a3f1bc6..360818eeb3b 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -5129,6 +5129,7 @@ innobase_kill_connection(
thd_kill_levels)
{
trx_t* trx;
+ bool took_lock_sys = false;
DBUG_ENTER("innobase_kill_connection");
DBUG_ASSERT(hton == innodb_hton_ptr);
@@ -5154,16 +5155,25 @@ innobase_kill_connection(
THD *owner = trx->current_lock_mutex_owner;
if (!owner || owner != cur) {
+ ut_ad(!lock_mutex_own());
lock_mutex_enter();
+ took_lock_sys = true;
}
+
+ ut_ad(!trx_mutex_own(trx));
trx_mutex_enter(trx);
/* Cancel a pending lock request. */
if (trx->lock.wait_lock) {
lock_cancel_waiting_and_release(trx->lock.wait_lock);
}
+
+ ut_ad(lock_mutex_own());
+ ut_ad(trx_mutex_own(trx));
+
trx_mutex_exit(trx);
- if (!owner || owner != cur) {
+
+ if (took_lock_sys) {
lock_mutex_exit();
}
}
@@ -10676,23 +10686,23 @@ wsrep_append_key(
static bool
referenced_by_foreign_key2(dict_table_t* table,
- dict_index_t* index) {
- ut_ad(table != NULL);
- ut_ad(index != NULL);
-
- const dict_foreign_set* fks = &table->referenced_set;
- for (dict_foreign_set::const_iterator it = fks->begin();
- it != fks->end();
- ++it)
- {
- dict_foreign_t* foreign = *it;
- if (foreign->referenced_index != index) {
- continue;
- }
- ut_ad(table == foreign->referenced_table);
- return true;
- }
- return false;
+ dict_index_t* index) {
+ ut_ad(table != NULL);
+ ut_ad(index != NULL);
+
+ const dict_foreign_set* fks = &table->referenced_set;
+ for (dict_foreign_set::const_iterator it = fks->begin();
+ it != fks->end();
+ ++it)
+ {
+ dict_foreign_t* foreign = *it;
+ if (foreign->referenced_index != index) {
+ continue;
+ }
+ ut_ad(table == foreign->referenced_table);
+ return true;
+ }
+ return false;
}
int
@@ -19077,11 +19087,13 @@ wsrep_abort_slave_trx(wsrep_seqno_t bf_seqno, wsrep_seqno_t victim_seqno)
}
/*******************************************************************//**
This function is used to kill one transaction in BF. */
-
+UNIV_INTERN
int
-wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
- const trx_t * const bf_trx,
- trx_t *victim_trx, ibool signal)
+wsrep_innobase_kill_one_trx(
+ void * const bf_thd_ptr,
+ const trx_t * const bf_trx,
+ trx_t *victim_trx,
+ ibool signal)
{
ut_ad(lock_mutex_own());
ut_ad(trx_mutex_own(victim_trx));
@@ -19098,6 +19110,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
WSREP_WARN("no THD for trx: %lu", victim_trx->id);
DBUG_RETURN(1);
}
+
if (!bf_thd) {
DBUG_PRINT("wsrep", ("no BF thd for conflicting lock"));
WSREP_WARN("no BF THD for trx: %lu", (bf_trx) ? bf_trx->id : 0);
@@ -19121,6 +19134,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
}
+
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
WSREP_DEBUG("withdraw for BF trx: %lu, state: %d",
victim_trx->id,
@@ -19286,17 +19300,17 @@ wsrep_abort_transaction(handlerton* hton, THD *bf_thd, THD *victim_thd,
wsrep_thd_query(bf_thd),
wsrep_thd_query(victim_thd));
- if (victim_trx)
- {
- lock_mutex_enter();
- trx_mutex_enter(victim_trx);
+ if (victim_trx) {
+ lock_mutex_enter();
+ victim_trx->current_lock_mutex_owner = victim_thd;
+ trx_mutex_enter(victim_trx);
int rcode = wsrep_innobase_kill_one_trx(bf_thd, bf_trx,
victim_trx, signal);
- trx_mutex_exit(victim_trx);
- lock_mutex_exit();
+ trx_mutex_exit(victim_trx);
+ victim_trx->current_lock_mutex_owner = NULL;
+ lock_mutex_exit();
wsrep_srv_conc_cancel_wait(victim_trx);
-
- DBUG_RETURN(rcode);
+ DBUG_RETURN(rcode);
} else {
WSREP_DEBUG("victim does not have transaction");
wsrep_thd_LOCK(victim_thd);
@@ -19304,6 +19318,7 @@ wsrep_abort_transaction(handlerton* hton, THD *bf_thd, THD *victim_thd,
wsrep_thd_UNLOCK(victim_thd);
wsrep_thd_awake(victim_thd, signal);
}
+
DBUG_RETURN(-1);
}
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc
index 26d868ca94d..7462474028b 100644
--- a/storage/xtradb/lock/lock0lock.cc
+++ b/storage/xtradb/lock/lock0lock.cc
@@ -6885,14 +6885,16 @@ lock_clust_rec_modify_check_and_lock(
lock_rec_convert_impl_to_expl(block, rec, index, offsets);
lock_mutex_enter();
-
- ut_ad(lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+ trx_t* trx = thr_get_trx(thr);
+ trx->current_lock_mutex_owner = trx->mysql_thd;
+ ut_ad(lock_table_has(trx, index->table, LOCK_IX));
err = lock_rec_lock(TRUE, LOCK_X | LOCK_REC_NOT_GAP,
block, heap_no, index, thr);
MONITOR_INC(MONITOR_NUM_RECLOCK_REQ);
+ trx->current_lock_mutex_owner = NULL;
lock_mutex_exit();
ut_ad(lock_rec_queue_validate(FALSE, block, rec, index, offsets));
@@ -6948,15 +6950,18 @@ lock_sec_rec_modify_check_and_lock(
index record, and this would not have been possible if another active
transaction had modified this secondary index record. */
+ trx_t* trx = thr_get_trx(thr);
lock_mutex_enter();
+ trx->current_lock_mutex_owner = trx->mysql_thd;
- ut_ad(lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+ ut_ad(lock_table_has(trx, index->table, LOCK_IX));
err = lock_rec_lock(TRUE, LOCK_X | LOCK_REC_NOT_GAP,
block, heap_no, index, thr);
MONITOR_INC(MONITOR_NUM_RECLOCK_REQ);
+ trx->current_lock_mutex_owner = NULL;
lock_mutex_exit();
#ifdef UNIV_DEBUG
@@ -7056,18 +7061,21 @@ lock_sec_rec_read_check_and_lock(
lock_rec_convert_impl_to_expl(block, rec, index, offsets);
}
+ trx_t* trx = thr_get_trx(thr);
lock_mutex_enter();
+ trx->current_lock_mutex_owner = trx->mysql_thd;
ut_ad(mode != LOCK_X
- || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+ || lock_table_has(trx, index->table, LOCK_IX));
ut_ad(mode != LOCK_S
- || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS));
+ || lock_table_has(trx, index->table, LOCK_IS));
err = lock_rec_lock(FALSE, mode | gap_mode,
block, heap_no, index, thr);
MONITOR_INC(MONITOR_NUM_RECLOCK_REQ);
+ trx->current_lock_mutex_owner = NULL;
lock_mutex_exit();
ut_ad(lock_rec_queue_validate(FALSE, block, rec, index, offsets));
@@ -7138,17 +7146,20 @@ lock_clust_rec_read_check_and_lock(
}
lock_mutex_enter();
+ trx_t* trx = thr_get_trx(thr);
+ trx->current_lock_mutex_owner = trx->mysql_thd;
ut_ad(mode != LOCK_X
- || lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+ || lock_table_has(trx, index->table, LOCK_IX));
ut_ad(mode != LOCK_S
- || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS));
+ || lock_table_has(trx, index->table, LOCK_IS));
err = lock_rec_lock(FALSE, mode | gap_mode,
block, heap_no, index, thr);
MONITOR_INC(MONITOR_NUM_RECLOCK_REQ);
+ trx->current_lock_mutex_owner = NULL;
lock_mutex_exit();
ut_ad(lock_rec_queue_validate(FALSE, block, rec, index, offsets));
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index 703d5444718..24c200acc1c 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -24,6 +24,14 @@
# Short-Description: start and stop MySQL
# Description: MySQL is a very fast and reliable SQL database engine.
### 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
# have to do one of the following things for this script to work: