innobackupex --slave-info executes the following code to get the master binlog coordinates for CHANGE MASTER TO written xtrabackup_slave_info:
mysql_send 'SHOW SLAVE STATUS\G';
# get output of the "show slave status" command from mysql output
# and extract binlog position of the master server
file_to_array($mysql_stdout, \@lines);
for (@lines) {
$master = $1 if /Master_Host:\s*(\S*)\s*$/;
$filename = $1 if /Master_Log_File:\s*(\S*)\s*$/;
$position = $1 if /Master_Log_Pos:\s*(\S*)\s*$/;
}
That code works, but there's a couple of problems with it, making it dependent on specific SHOW SLAVE STATUS output format:
- we actually want to read Relay_Master_Log_File rather than Master_Log_File. And we do read it, but only because Relay_Master_Log_File happens to be after Master_Log_File in the SHOW SLAVE STATUS output, so the previously read Master_Log_File (incorrect) is later overwritten by the Relay_Master_Log_File value (i.e. the correct one)
- there's not column in the SHOW SLAVE STATUS output named "Master_Log_Pos", but there are "Read_Master_Log_Pos" and "Exec_Master_Log_Pos". Again, we need the latter value for --slave-info, and we are just lucky it goes after Read_Master_Log_Pos.
The fix is to change the column names in the above code to not depend on specific order and other column naming in SHOW SLAVE STATUS.
innobackupex --slave-info executes the following code to get the master binlog coordinates for CHANGE MASTER TO written xtrabackup_ slave_info:
mysql_send 'SHOW SLAVE STATUS\G';
# get output of the "show slave status" command from mysql output to_array( $mysql_ stdout, \@lines); Host:\s* (\S*)\s* $/; Log_File: \s*(\S* )\s*$/; Log_Pos: \s*(\S* )\s*$/;
# and extract binlog position of the master server
file_
for (@lines) {
$master = $1 if /Master_
$filename = $1 if /Master_
$position = $1 if /Master_
}
That code works, but there's a couple of problems with it, making it dependent on specific SHOW SLAVE STATUS output format:
- we actually want to read Relay_Master_ Log_File rather than Master_Log_File. And we do read it, but only because Relay_Master_ Log_File happens to be after Master_Log_File in the SHOW SLAVE STATUS output, so the previously read Master_Log_File (incorrect) is later overwritten by the Relay_Master_ Log_File value (i.e. the correct one)
- there's not column in the SHOW SLAVE STATUS output named "Master_Log_Pos", but there are "Read_Master_ Log_Pos" and "Exec_Master_ Log_Pos" . Again, we need the latter value for --slave-info, and we are just lucky it goes after Read_Master_ Log_Pos.
The fix is to change the column names in the above code to not depend on specific order and other column naming in SHOW SLAVE STATUS.