Skip to content

Commit

Permalink
Merge branch 'github/10.0-galera' into 10.1
Browse files Browse the repository at this point in the history
Note: some tests fail, just as they failed before the merge!
  • Loading branch information
vuvova committed Dec 22, 2015
2 parents 0686c34 + 080da55 commit 7697bf0
Show file tree
Hide file tree
Showing 26 changed files with 382 additions and 141 deletions.
3 changes: 3 additions & 0 deletions include/mysql/service_wsrep.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ extern struct wsrep_service_st {
const char * (*wsrep_thd_query_state_str_func)(THD *thd);
int (*wsrep_thd_retry_counter_func)(THD *thd);
void (*wsrep_thd_set_conflict_state_func)(THD *thd, enum wsrep_conflict_state state);
bool (*wsrep_thd_skip_append_keys_func)(THD *thd);
long long (*wsrep_thd_trx_seqno_func)(THD *thd);
struct wsrep_ws_handle * (*wsrep_thd_ws_handle_func)(THD *thd);
int (*wsrep_trx_is_aborting_func)(MYSQL_THD thd);
Expand Down Expand Up @@ -144,6 +145,7 @@ extern struct wsrep_service_st {
#define wsrep_thd_query_state_str(T) wsrep_service->wsrep_thd_query_state_str_func(T)
#define wsrep_thd_retry_counter(T) wsrep_service->wsrep_thd_retry_counter_func(T)
#define wsrep_thd_set_conflict_state(T,S) wsrep_service->wsrep_thd_set_conflict_state_func(T,S)
#define wsrep_thd_skip_append_keys(T) wsrep_service->wsrep_thd_skip_append_keys_func(T)
#define wsrep_thd_trx_seqno(T) wsrep_service->wsrep_thd_trx_seqno_func(T)
#define wsrep_thd_ws_handle(T) wsrep_service->wsrep_thd_ws_handle_func(T)
#define wsrep_trx_is_aborting(T) wsrep_service->wsrep_trx_is_aborting_func(T)
Expand Down Expand Up @@ -204,6 +206,7 @@ void wsrep_thd_LOCK(THD *thd);
void wsrep_thd_UNLOCK(THD *thd);
void wsrep_thd_awake(THD *thd, my_bool signal);
void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state);
bool wsrep_thd_skip_append_keys(THD *thd);
void wsrep_unlock_rollback();

#endif
Expand Down
2 changes: 1 addition & 1 deletion include/service_versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define VERSION_thd_timezone 0x0100
#define VERSION_my_sha1 0x0101
#define VERSION_my_md5 0x0100
#define VERSION_wsrep 0x0200
#define VERSION_wsrep 0x0201
#define VERSION_logger 0x0100
#define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0100
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/mysql-test-run.pl
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ ($)
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;
my $opt_port_group_size = $ENV{MTR_PORT_GROUP_SIZE} || 20;

# lock file to stop tests
my $opt_stop_file= $ENV{MTR_STOP_FILE};
Expand Down
86 changes: 46 additions & 40 deletions mysql-test/suite/galera/galera_3nodes_as_slave.cnf
Original file line number Diff line number Diff line change
@@ -1,73 +1,79 @@
#
# This .cnf file creates a setup with 1 standard MySQL server, followed by a 2-node Galera cluster
# This .cnf file creates a setup with 1 standard MariaDB server, followed by a 3-node Galera cluster
#

# Use default setting for mysqld processes
!include include/default_mysqld.cnf

[mysqld]
log-slave-updates
log-bin=mysqld-bin
log-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;'
#galera_port=@OPT.port
#ist_port=@OPT.port
#sst_port=@OPT.port

# enforce read-committed characteristics across the cluster
wsrep_causal_reads=ON
wsrep_sync_wait = 7
log-slave-updates

innodb-autoinc-lock-mode=2
default-storage-engine=innodb
wsrep-provider=@ENV.WSREP_PROVIDER
wsrep_node_address=127.0.0.1
wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
wsrep-cluster-address=gcomm://
wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = PT15S;evs.max_install_timeouts=1;gcache.size=10M'
wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port'

# Required for Galera
innodb_autoinc_lock_mode=2

innodb_flush_log_at_trx_commit=2
# enforce read-committed characteristics across the cluster
wsrep-causal-reads=ON
wsrep-sync-wait=7
server-id=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;'
#galera_port=@OPT.port
#ist_port=@OPT.port
#sst_port=@OPT.port

# enforce read-committed characteristics across the cluster
wsrep_causal_reads=ON
wsrep_sync_wait = 7
log-slave-updates

innodb-autoinc-lock-mode=2
default-storage-engine=innodb
wsrep-provider=@ENV.WSREP_PROVIDER
wsrep_node_address=127.0.0.1
wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port
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;gcache.size=10M'
wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port'

# Required for Galera
innodb_autoinc_lock_mode=2

innodb_flush_log_at_trx_commit=2
# enforce read-committed characteristics across the cluster
wsrep-causal-reads=ON
wsrep-sync-wait=7
server-id=3

[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;'
#galera_port=@OPT.port
#ist_port=@OPT.port
#sst_port=@OPT.port

# enforce read-committed characteristics across the cluster
wsrep_causal_reads=ON
wsrep_sync_wait = 7
log-slave-updates

innodb-autoinc-lock-mode=2
default-storage-engine=innodb
wsrep-provider=@ENV.WSREP_PROVIDER
wsrep_node_address=127.0.0.1
wsrep_sst_receive_address=127.0.0.2:@mysqld.4.#sst_port
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;gcache.size=10M'
wsrep_node_incoming_address=127.0.0.1:@mysqld.4.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.4.#sst_port'

# Required for Galera
innodb_autoinc_lock_mode=2

innodb_flush_log_at_trx_commit=2
# enforce read-committed characteristics across the cluster
wsrep-causal-reads=ON
wsrep-sync-wait=7
server-id=4

[ENV]
NODE_MYPORT_1= @mysqld.1.port
Expand All @@ -79,8 +85,8 @@ 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_MYPORT_4= @mysqld.4.port
NODE_MYSOCK_4= @mysqld.4.socket

NODE_GALERAPORT_2= @mysqld.2.#galera_port
NODE_GALERAPORT_3= @mysqld.3.#galera_port
Expand Down
4 changes: 1 addition & 3 deletions mysql-test/suite/galera/r/galera_as_slave_nonprim.result
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
START SLAVE USER='root';
Warnings:
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
START SLAVE;
SET SESSION wsrep_sync_wait = 0;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
Expand Down
14 changes: 14 additions & 0 deletions mysql-test/suite/galera/r/mdev_9290.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# MDEV-9290 : InnoDB: Assertion failure in file trx0sys.cc line 353
# InnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno
#
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
COMMIT;
SELECT * FROM t1;
i
1
2
DROP TABLE t1;
7 changes: 3 additions & 4 deletions mysql-test/suite/galera/t/galera_as_slave_nonprim.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#

--source include/have_innodb.inc
--source include/have_log_bin.inc
--source include/big_test.inc

# Step #1. Establish replication
Expand All @@ -18,9 +17,9 @@

--connection node_2
--disable_query_log
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1;
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1, MASTER_USER='root';
--enable_query_log
START SLAVE USER='root';
START SLAVE;
SET SESSION wsrep_sync_wait = 0;

--connection node_1
Expand Down Expand Up @@ -64,7 +63,7 @@ SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
--source include/wait_condition.inc

--connection node_2
--source include/galera_wait_ready.inc
--source include/wait_until_ready.inc
--source include/wait_until_connected_again.inc

START SLAVE;
Expand Down
16 changes: 16 additions & 0 deletions mysql-test/suite/galera/t/galera_var_dirty_reads.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc

--disable_query_log
# Save original auto_increment_offset values.
--connection node_1
let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`;
--connection node_2
let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`;
--enable_query_log

--connection node_2
--let $wsrep_cluster_address_saved = `SELECT @@global.wsrep_cluster_address`

Expand Down Expand Up @@ -41,6 +49,14 @@ SELECT * FROM t1;
# Cleanup
DROP TABLE t1;

--disable_query_log
# Restore original auto_increment_offset values.
--connection node_1
--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1;
--connection node_2
--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2;
--enable_query_log

--source include/galera_end.inc
--echo # End of test

24 changes: 24 additions & 0 deletions mysql-test/suite/galera/t/mdev_9290.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc

--echo #
--echo # MDEV-9290 : InnoDB: Assertion failure in file trx0sys.cc line 353
--echo # InnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno
--echo #

--connection node_1
CREATE TABLE t1 (i INT) ENGINE=InnoDB;

--connection node_2
# Note: a multi-statement transaction should always be the "first" one to execute
# on this node.
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
COMMIT;

--connection node_1
SELECT * FROM t1;
DROP TABLE t1;

--source include/galera_end.inc
11 changes: 0 additions & 11 deletions scripts/wsrep_sst_mysqldump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ fi
# 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;"

# mysqldump cannot restore CSV tables, fix this issue
Expand Down
10 changes: 10 additions & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5230,10 +5230,20 @@ static int init_server_components()
THD *current_thd_saved= current_thd;
set_current_thd(tmp);

/*
Also save/restore server_status and variables.option_bits and they
get altered during init_for_queries().
*/
unsigned int server_status_saved= tmp->server_status;
ulonglong option_bits_saved= tmp->variables.option_bits;

tmp->init_for_queries();

/* Restore current_thd. */
set_current_thd(current_thd_saved);

tmp->server_status= server_status_saved;
tmp->variables.option_bits= option_bits_saved;
}
}
mysql_mutex_unlock(&LOCK_thread_count);
Expand Down
12 changes: 12 additions & 0 deletions sql/rpl_gtid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,14 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id,
if ((err= gtid_check_rpl_slave_state_table(table)))
goto end;

#ifdef WITH_WSREP
/*
Updates in slave state table should not be appended to galera transaction
writeset.
*/
thd->wsrep_skip_append_keys= true;
#endif

if (!in_transaction)
{
DBUG_PRINT("info", ("resetting OPTION_BEGIN"));
Expand Down Expand Up @@ -676,6 +684,10 @@ IF_DBUG(dbug_break:, )

end:

#ifdef WITH_WSREP
thd->wsrep_skip_append_keys= false;
#endif

if (table_opened)
{
if (err || (err= ha_commit_trans(thd, FALSE)))
Expand Down
3 changes: 2 additions & 1 deletion sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,8 @@ THD::THD(bool is_wsrep_applier)
wsrep_apply_toi(false),
wsrep_po_handle(WSREP_PO_INITIALIZER),
wsrep_po_cnt(0),
wsrep_apply_format(0)
wsrep_apply_format(0),
wsrep_skip_append_keys(false)
#endif
{
ulong tmp;
Expand Down
1 change: 1 addition & 0 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -3989,6 +3989,7 @@ class THD :public Statement,
#endif /* GTID_SUPPORT */
void *wsrep_apply_format;
char wsrep_info[128]; /* string for dynamic proc info */
bool wsrep_skip_append_keys;
#endif /* WITH_WSREP */

/* Handling of timeouts for commands */
Expand Down
1 change: 1 addition & 0 deletions sql/sql_plugin_services.ic
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static struct wsrep_service_st wsrep_handler = {
wsrep_thd_query_state_str,
wsrep_thd_retry_counter,
wsrep_thd_set_conflict_state,
wsrep_thd_skip_append_keys,
wsrep_thd_trx_seqno,
wsrep_thd_ws_handle,
wsrep_trx_is_aborting,
Expand Down
3 changes: 3 additions & 0 deletions sql/wsrep_dummy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ int wsrep_thd_retry_counter(THD *)
void wsrep_thd_set_conflict_state(THD *, enum wsrep_conflict_state)
{ }

bool wsrep_thd_skip_append_keys(THD *)
{ return 0; }

longlong wsrep_thd_trx_seqno(THD *)
{ return -1; }

Expand Down
Loading

0 comments on commit 7697bf0

Please sign in to comment.