[MDEV-18405] Add Mariabackup option to set gtid_slave_pos to original server's gtid_current_pos during prepare Created: 2019-01-28 Updated: 2021-11-18 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Backup, mariabackup, Replication |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
Many users use Mariabackup to build slaves using the process outlined in the following documentation page: https://mariadb.com/kb/en/library/setting-up-a-replication-slave-with-mariabackup/ One problem with this process is that Mariabackup doesn't back up and restore the original server's entire GTID state, which can be considered to be the value of gtid_current_pos. https://mariadb.com/kb/en/library/gtid/#gtid_current_pos The value of gtid_current_pos is constructed from the values of two other system variables--gtid_slave_pos and gtid_binlog_pos. https://mariadb.com/kb/en/library/gtid/#gtid_slave_pos https://mariadb.com/kb/en/library/gtid/#gtid_binlog_pos Mariabackup does back up and restores the original server's value for gtid_slave_pos, because that information is stored in mysql.gtid_slave_pos, which is an InnoDB table. https://mariadb.com/kb/en/library/mysqlgtid_slave_pos-table/ Mariabackup does not currently back up and restore the original server's gtid_binlog_pos, because that information is stored in the binary logs, which are not backed up. This means that a server restored from a backup is missing some GTID state by default. Mariabackup does back up the original server's value of gtid_current_pos in the xtrabackup_binlog_info file. https://mariadb.com/kb/en/library/files-created-by-mariabackup/#xtrabackup_binlog_info This means that if a user wants to build a slave using a backup, then they can restore the backup, and then they can extract the original server's gtid_current_pos from xtrabackup_binlog_info:
And then the user would need to use this value to set the value of gtid_slave_pos, and then they could set up replication:
Some users would prefer if the value of gtid_slave_pos would automatically be set to the original server's gtid_current_pos when a backup was prepared. That way, users would not have to worry about manually fixing the GTID state, and they could just set up replication from a slave created from a backup by doing something like this:
And the slave would automatically know where to start replicating from. |
| Comments |
| Comment by Vladislav Vaintroub [ 2019-02-11 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
GeoffMontee, I think you overestimate what "prepare" does. It does Innodb recovery. It does not execute arbitrary SQL commands. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2019-02-11 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi wlad,
I wasn't sure if prepare would be capable of running SET GLOBAL gtid_binlog_state/gtid_slave_pos, but I did know that Mariabackup runs FLUSH TABLES FOR EXPORT during the prepare when the --export option is provided: So it didn't seem like a stretch to think that Mariabackup would also be able run SET GLOBAL gtid_binlog_state/gtid_slave_pos during the prepare if some other option were provided.
That would probably work. For gtid_binlog_state, there is also another option. The documentation says the following about this variable:
https://mariadb.com/kb/en/library/gtid/#gtid_binlog_state So Mariabackup could also create this MASTER-BIN.state file during the prepare. For example:
So that's a relatively easy way to set gtid_binlog_state without actually running SET GLOBAL gtid_binlog_state. What do you think about that? As for gtid_slave_pos, I just noticed that Mariabackup doesn't need to do anything to restore that. The documentation says that:
https://mariadb.com/kb/en/library/gtid/#gtid_slave_pos And this table is an InnoDB table, so Mariabackup should already back up the consistent slave position with the data. I confirmed that it does:
So gtid_slave_pos doesn't need to be set. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2019-02-11 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I definitely do not want to repeat "FLUSH TABLES FOR EXPORT" hack . I actually would prefer it the way it was before, in 10.1, where mariabackup did not act as full server, with bootstrap. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2019-02-11 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
That's understandable. It looks like the server writes the MASTER-BIN.state file with MYSQL_BIN_LOG::write_state_to_file() in sql/log.cc: https://github.com/MariaDB/server/blob/c2318291be7458238729ed80233ea71f1e6a62b8/sql/log.cc#L6057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrei Elkin [ 2019-02-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Took for myself having spoken with Wlad about the issue previously. In-progress status is dropped though as I am having two tickets in the way. ETA to resume with this one is Feb 19th. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2019-07-15 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
If the backup is going to be restored to a new slave with a different server_id value than the original server, then rather than restoring the GTIDs from gtid_binlog_pos to the new server's gtid_binlog_pos, it might make more sense to add the GTIDs from gtid_binlog_pos to the existing GTIDs in the new server's gtid_slave_pos. This is because GTIDs from gtid_binlog_pos in which the server_id of the GTID is not equal to the server's own server_id are effectively ignored. See the comment from knielsen on | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nicolas [ 2021-02-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi, any updates on this? In 10.5 what is the easiest way to restore, start a node from a backup when using mariabackup? This still being required?:
Mainly asking because I am trying to automating the process but wondering if maybe a flag when using `mariabackup --move-back ` could include the GTID. |