Bug #77155 mtr rpl includes do not support default channel as $rpl_channel_name
Submitted: 26 May 2015 9:57 Modified: 4 Oct 2016 14:27
Reporter: João Gramacho Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[26 May 2015 9:57] João Gramacho
Description:
When writing test cases for replication we often use replication include files.

After WL#1697 (Multisource replication) was pushed, almost all replication include files support a parameter ($rpl_channel_name) that will be used when the test case needs to deal with a single replication channel other than the default channel.

Unfortunately, the current design does not allow that the default channel ('') be passed as a parameter, as almost all of the branches inside the include files are checking if ($rpl_channel_name != '') to use the FOR CHANNEL clause.

So, when other channels than the default channel are configured, we are not able to use the replication include files only for the default channel. We can use the includes for each other channel but the default one, or for all channels.

How to repeat:
Check the replication mtr include files.

This is an example at 'mysql-test/include/stop_slave.inc':

if ($rpl_channel_name != '')
{
  --let $_for_channel_clause= FOR CHANNEL  '$rpl_channel_name'
}

Suggested fix:
Two things should be done:

1) Pass the channel name with quotes in the test cases instead of passing only the channel name.

Use:
--let $rpl_channel_name= 'channel_1'
--source include/start_slave.inc

Instead of:
--let $rpl_channel_name= channel_1
--source include/start_slave.inc

This will allow to pass '' as the default channel.

2) Change the branching inside replication include files to check if $rpl_channel_name is set instead of checking if it is an empty string (as a default channel is):

Use like this:
if ($rpl_channel_name)
{
  --let $_for_channel_clause= FOR CHANNEL $rpl_channel_name
}

This will make the test case to enter the branch also for the default channel.

When wanting to execute a replication include file for all channels, the test case must clear the $rpl_channel_name variable:
--let $rpl_channel_name=
--source include/start_slave.inc
[4 Oct 2016 14:27] David Moss
This seems to be related to testing only and not require a change log entry.
[27 Dec 2016 8:42] David Moss
Posted by developer:
 
Seems to have been reopened, nothing user relevant here so reclosing.