Affects Version/s: 8.0.x, Not 5.6.x, Not 5.7.x
Fix Version/s: 8.0.12-2rc1
Consistent state of the MySQL binary log and storage engines can be obtained by querying the p_s.log_status table. It provides the following information:
- InnoDB's current LSN
- current binary log filename and position along with the executed GTID set
- replication info for each channel:
- channel name
- relay log name
- relay log position
This information is sufficient to provision new slave from the backup taken from the master.
There are cases when we need to provision the new slave from the backup taken from another slave.
When GTID mode is ON and the slave is using auto-positioning, all we need to do is to set gtid_purged (executed GTID set from log_status), point the new slave to the same master, and enable auto-positioning.
When GTID mode is OFF or auto-positioning is disabled, we need to save the current master binary log file and the position in it to which the SQL thread has read and executed.
With PS 5.7 xtrabackup did the following:
- LOCK BINLOG FOR BACKUP
- if -slave-info is specified run SHOW SLAVE STATUS, save Relay_Master_Log_File, Exec_Master_Log_Pos for each replication channel
- run SHOW MASTER STATUS, save current binary log file name, position and executed GTID set
- stop InnoDB log copying
- UNLOCK BINLOG
With PS 8.0 xtrabackup will:
- query p_s.log_status, save current binary log file name, position, executed GTID set and LSN
- stop InnoDB log copying at LSN taken at previous step
However p_s.log_status lacks Relay_Master_Log_File and Exec_Master_Log_Pos and xtrabackup will have to fallback to FTWRL when -slave-info is specified.
This feature will be useful. It seems easy to implement as well. By briefly looking at the log_resource.cc and comparing it with the show_slave_status_send_data in the rpl_slave.cc I found that we just need to take additional lock (mi->rli->data_lock) and serialize mi->rli->get_group_master_log_pos() and mi->rli->get_group_master_log_name() into JSON.
REPLICATION field of the p_s.log_status is a JSON array which looks like following:
relay_master_log_file and exec_master_log_position properties will be added to each channel and it will look like:
These properties will have the same meaning as the Relay_Master_Log_File and Exec_Master_Log_Pos fields of the SHOW SLAVE STATUS.