Skip to content

Commit

Permalink
MDEV-15409 make sure every sst script is tested in buildbot
Browse files Browse the repository at this point in the history
fix galera.galera_sst_mysqldump test to work:
* must connect to 127.0.0.1, where mysqld is listening
* disable wsrep_sync_wait in wsrep_sst_mysqldump, otherwise
  sst can deadlock
* allow 127.0.0.1 for bind_address and wsrep_sst_receive_address.
  (it's useful in tests, or when two nodes are on the same box,
  or when nodes are on different boxes, but the connection is
  tunelled, or whatever. Don't judge user's setup). MDEV-14070
* don't wait for client connections to die when doing
  mysqldump sst. they'll die in a due time, and if needed mysql
  will wait on locks until they do. MDEV-14069

Also don't mark it big, to make sure it's sufficiently tested
  • Loading branch information
vuvova committed Mar 22, 2018
1 parent 7e30042 commit 8f1014e
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 39 deletions.
5 changes: 4 additions & 1 deletion mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc
Expand Up @@ -4,6 +4,9 @@

--echo Setting SST method to mysqldump ...

call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to '127.0.0.1'");
call mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos");

--connection node_1
# We need a user with a password to perform SST, otherwise we hit LP #1378253
CREATE USER 'sst';
Expand All @@ -19,6 +22,6 @@ SET GLOBAL wsrep_sst_auth = 'sst:';

--disable_query_log
# Set wsrep_sst_receive_address to the SQL port
--eval SET GLOBAL wsrep_sst_receive_address = '127.0.0.2:$NODE_MYPORT_2';
--eval SET GLOBAL wsrep_sst_receive_address = '127.0.0.1:$NODE_MYPORT_2';
--enable_query_log
SET GLOBAL wsrep_sst_method = 'mysqldump';
5 changes: 4 additions & 1 deletion mysql-test/suite/galera/r/galera_sst_mysqldump.result
@@ -1,4 +1,6 @@
Setting SST method to mysqldump ...
call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to '127.0.0.1'");
call mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos");
CREATE USER 'sst';
GRANT ALL PRIVILEGES ON *.* TO 'sst';
SET GLOBAL wsrep_sst_auth = 'sst:';
Expand Down Expand Up @@ -369,7 +371,7 @@ INSERT INTO t1 VALUES ('node2_committed_before');
INSERT INTO t1 VALUES ('node2_committed_before');
INSERT INTO t1 VALUES ('node2_committed_before');
COMMIT;
SET GLOBAL debug = 'd,sync.alter_opened_table';
SET GLOBAL debug_dbug = 'd,sync.alter_opened_table';
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
SET wsrep_sync_wait = 0;
Killing server ...
Expand Down Expand Up @@ -448,6 +450,7 @@ COUNT(*) = 0
DROP TABLE t1;
COMMIT;
SET AUTOCOMMIT=ON;
SET GLOBAL debug_dbug = $debug_orig;
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");
Expand Down
1 change: 0 additions & 1 deletion mysql-test/suite/galera/t/galera_sst_mysqldump.test
@@ -1,4 +1,3 @@
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc

Expand Down
Expand Up @@ -30,10 +30,6 @@ SELECT @@global.wsrep_sst_receive_address;
192.168.2.254

# invalid values
SET @@global.wsrep_sst_receive_address='127.0.0.1:4444';
ERROR 42000: Variable 'wsrep_sst_receive_address' can't be set to the value of '127.0.0.1:4444'
SET @@global.wsrep_sst_receive_address='127.0.0.1';
ERROR 42000: Variable 'wsrep_sst_receive_address' can't be set to the value of '127.0.0.1'
SELECT @@global.wsrep_sst_receive_address;
@@global.wsrep_sst_receive_address
192.168.2.254
Expand Down
Expand Up @@ -27,10 +27,6 @@ SELECT @@global.wsrep_sst_receive_address;

--echo
--echo # invalid values
--error ER_WRONG_VALUE_FOR_VAR
SET @@global.wsrep_sst_receive_address='127.0.0.1:4444';
--error ER_WRONG_VALUE_FOR_VAR
SET @@global.wsrep_sst_receive_address='127.0.0.1';
SELECT @@global.wsrep_sst_receive_address;
--error ER_WRONG_VALUE_FOR_VAR
SET @@global.wsrep_sst_receive_address=NULL;
Expand Down
4 changes: 2 additions & 2 deletions scripts/wsrep_sst_mysqldump.sh
Expand Up @@ -119,11 +119,11 @@ MYSQL="$MYSQL_CLIENT $WSREP_SST_OPT_CONF "\

# Check if binary logging is enabled on the joiner node.
# Note: SELECT cannot be used at this point.
LOG_BIN=$(echo "SHOW VARIABLES LIKE 'log_bin'" | $MYSQL |\
LOG_BIN=$(echo "set statement wsrep_sync_wait=0 for SHOW VARIABLES LIKE 'log_bin'" | $MYSQL |\
tail -1 | awk -F ' ' '{ print $2 }')

# Check the joiner node's server version.
SERVER_VERSION=$(echo "SHOW VARIABLES LIKE 'version'" | $MYSQL |\
SERVER_VERSION=$(echo "set statement wsrep_sync_wait=0 for SHOW VARIABLES LIKE 'version'" | $MYSQL |\
tail -1 | awk -F ' ' '{ print $2 }')

RESET_MASTER=""
Expand Down
3 changes: 1 addition & 2 deletions sql/wsrep_check_opts.cc
Expand Up @@ -51,15 +51,14 @@ int wsrep_check_opts()
(!strcasecmp(my_bind_addr_str, "127.0.0.1") ||
!strcasecmp(my_bind_addr_str, "localhost")))
{
WSREP_ERROR("wsrep_sst_method is set to 'mysqldump' yet "
WSREP_WARN("wsrep_sst_method is set to 'mysqldump' yet "
"mysqld bind_address is set to '%s', which makes it "
"impossible to receive state transfer from another "
"node, since mysqld won't accept such connections. "
"If you wish to use mysqldump state transfer method, "
"set bind_address to allow mysql client connections "
"from other cluster members (e.g. 0.0.0.0).",
my_bind_addr_str);
return 1;
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion sql/wsrep_mysqld.cc
Expand Up @@ -369,7 +369,7 @@ wsrep_view_handler_cb (void* app_ctx,
if (!wsrep_before_SE())
{
WSREP_DEBUG("[debug]: closing client connections for PRIM");
wsrep_close_client_connections(TRUE);
wsrep_close_client_connections(FALSE);
}

ssize_t const req_len= wsrep_sst_prepare (sst_req);
Expand Down
23 changes: 0 additions & 23 deletions sql/wsrep_sst.cc
Expand Up @@ -85,37 +85,14 @@ static void make_wsrep_defaults_file()
}


// TODO: Improve address verification.
static bool sst_receive_address_check (const char* str)
{
if (!strncasecmp(str, "127.0.0.1", strlen("127.0.0.1")) ||
!strncasecmp(str, "localhost", strlen("localhost")))
{
return 1;
}

return 0;
}

bool wsrep_sst_receive_address_check (sys_var *self, THD* thd, set_var* var)
{
char addr_buf[FN_REFLEN];

if ((! var->save_result.string_value.str) ||
(var->save_result.string_value.length > (FN_REFLEN - 1))) // safety
{
goto err;
}

memcpy(addr_buf, var->save_result.string_value.str,
var->save_result.string_value.length);
addr_buf[var->save_result.string_value.length]= 0;

if (sst_receive_address_check(addr_buf))
{
goto err;
}

return 0;

err:
Expand Down

0 comments on commit 8f1014e

Please sign in to comment.