Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1551634: xtrabackup --slave-info does not handle multi-master replication #362

Merged
merged 1 commit into from May 2, 2017

Conversation

VasilyNemkov
Copy link
Contributor

Writing master info for every channel to xtrabackup_slave_info;
Added a test case that verifies multi-source replication for both binlog and gtid mode.

https://bugs.launchpad.net/percona-xtrabackup/+bug/1551634

@VasilyNemkov
Copy link
Contributor Author

Copy link
Contributor

@gl-sergei gl-sergei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address test regressions as well.

@@ -265,6 +276,18 @@ free_mysql_variables(mysql_variable *vars)
}
}

static
void
free_and_zero_mysql_variables(mysql_variable *vars)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add new function instead of making free_mysql_variables to zero values?

{NULL, NULL}
};

mysql_variable variables[] = {
{"gtid_slave_pos", &gtid_slave_pos},
{NULL, NULL}
};

read_mysql_variables(connection, "SHOW SLAVE STATUS", status, false);
// read_mysql_variables(connection, "SHOW SLAVE STATUS", status, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this line

"SHOW SLAVE STATUS", true, true);
int masters_count = 0;
while (read_mysql_variables_from_result(slave_status_res, status,
false) && ++masters_count) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incrementing counter inside of the loop body looks more straightforward to me

ut_a(asprintf(&mysql_slave_position,
"master host '%s', filename '%s', position '%s'",
master, filename, position) != -1);
if (mysql_slave_position) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably C++ strings will be easier to use and I see no reason not to...

"CHANGE MASTER TO MASTER_LOG_FILE='%s', "
"MASTER_LOG_POS=%s %s;\n",
filename, position, channel_info);
ut_a(asprintf(&tmp_mysql_slave_position,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include channel_name as well?

"CHANGE MASTER TO MASTER_AUTO_POSITION=1 %s;\n",
channel_info);

ut_a(asprintf(&tmp_mysql_slave_position,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include channel_name as well?

START SLAVE
MASTER_PORT=${SRV_MYSQLD_PORT[$master_id_arg]}
$extra
FOR CHANNEL 'master-$master_id_arg';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work on older servers, we need to make sure they are treated well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, now one have to explicitly specify USE_CHANNELS as an argument to the setup_slave in order to get named channels in CHANGE MASTER statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added explicit argument USE_CHANNELS to the setup_slave.

vlog "Backing up slave"
switch_server $slave_id

innobackupex --no-timestamp --slave-info --safe-slave-backup $topdir/backup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets replace with xtrabackup. innobackupex is deprecated and should be removed in future major releases.

multi_row_insert test.m2 \({1..13}\)

start_server_with_id $slave_id \
--master-info-repository=TABLE \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to set master-info-repository and relay-info-repository for this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is required to have multiple channels on slave. If we start slave server without both --master-info-repository=TABLE and --relay-log-info-repository=TABLE \, then setting up server as slave with CHANGE MASTER ... FOR CHANNEL '...' fails with:
ERROR 3077 (HY000) at line 1: To have multiple channels, repository cannot be of type FILE; Please check the repository configuration and convert them to TABLE.

…lication

Fixed xtrabackup_slave_info for multi-source replication: providing
master info and channel name for each channel.
Added a test case.
@VasilyNemkov
Copy link
Contributor Author

@gl-sergei
Copy link
Contributor

Thanks. Looks good to me.

@VasilyNemkov VasilyNemkov merged commit aee657c into percona:2.4 May 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants