# Xtrabackup of replica - relay log not backed up - Slave failed to initialize relay log

**URL:** <https://forums.percona.com/t/xtrabackup-of-replica-relay-log-not-backed-up-slave-failed-to-initialize-relay-log/8890>\
**Category:** Percona XtraBackup\
**Created:** [January 22, 2021, 12:08pm UTC](https://forums.percona.com/t/xtrabackup-of-replica-relay-log-not-backed-up-slave-failed-to-initialize-relay-log/8890 "2021-01-22T12:08:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aviddavid](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@aviddavid](https://forums.percona.com/u/aviddavid)\
**Post date:** [January 22, 2021, 12:08pm UTC](https://forums.percona.com/t/xtrabackup-of-replica-relay-log-not-backed-up-slave-failed-to-initialize-relay-log/8890/1 "2021-01-22T12:08:26Z")

</div>

Hello. I’m using xtrabackup 8.0.22-15 with MySQL Server 8.0.22 to take full backups from a replica with options `--slave-info` and `--safe-slave-backup`.

I’m using binary log file position based replication with MIXED `binlog-format`  
Using default `relay-log` and `relay-log-index` settings. (uses hostname).

Replication fails to start with this error after restoring the backup for a new replica:

> ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository

The corresponding errors from the mysql error log:

> [ERROR] [MY-010544] [Repl] Failed to open the relay log ‘./hostname-relay-bin.000002’ (relay\_log\_pos 224567).
> 
> [ERROR] [MY-011059] [Repl] Could not find target log file mentioned in relay log info in the index file ‘./hostname-relay-bin.index’ during relay log initialization.
> 
> [ERROR] [MY-010426] [Repl] Slave: Failed to initialize the master info structure for channel ‘’; its record may still be present in ‘mysql.slave\_master\_info’ table, consider deleting it.

Table `mysql.slave_relay_log_info` refers to `hostname-relay-bin.000002` but this file isn’t present because xtrabackup isn’t backing it up (and not restoring it).

I can resolve this by running `RESET SLAVE ALL` and then setting up replication again using the `MASTER_LOG_FILE` and `MASTER_LOG_POS` settings from the `xtrabackup_slave_info` file, but:

Could this result in some lost transactions? I’m considering a situation that there are some statements in the relay log when xtrabackup runs, and so the MASTER\_LOG\_POS is ahead of what the slave has committed. Since xtrabackup isn’t backing up the relay log and needs a `RESET SLAVE ALL` to start replication after a restore, it seems that any such statements in the relay log might be lost.

Does xtrabackup ensure that the replica has fully performed all events in the relay log during backup? Option `--safe-slave-backup` says that it temporary stops the slave SQL thread so perhaps this helps, and so is this option definitely needed to ensure that the replica has an empty relay log?

I restore the backup by:

1. Stop MySQL
2. Run xtrabackup with `--prepare`
3. Run xtrabackup with `--copy-back`
4. Start MySQL
5. Run the `CHANGE MASTER` command per `xtrabackup_slave_info` file: `CHANGE MASTER TO MASTER_LOG_FILE='binlog.000002', MASTER_LOG_POS=1234;`
6. Run `START SLAVE;`

Example `mysql.slave_relay_log_info` after the steps:

> mysql\> select \* from mysql.slave\_relay\_log\_info\G  
> Number\_of\_lines: 12  
> Relay\_log\_name: ./hostname-relay-bin.000002  
> Relay\_log\_pos: 224567  
> Master\_log\_name: binlog.000002  
> Master\_log\_pos: 1234  
> Sql\_delay: 0  
> Number\_of\_workers: 0  
> Id: 1  
> Channel\_name:  
> Privilege\_checks\_username: NULL  
> Privilege\_checks\_hostname: NULL  
> Require\_row\_format: 0  
> Require\_table\_primary\_key\_check: STREAM

---

<div class="post-metadata">

**Author:** ![lalit.choudhary](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lalit.choudhary/32/51_2.png) [@lalit.choudhary](https://forums.percona.com/u/lalit.choudhary)\
**Post date:** [January 22, 2021, 12:51pm UTC](https://forums.percona.com/t/xtrabackup-of-replica-relay-log-not-backed-up-slave-failed-to-initialize-relay-log/8890/2 "2021-01-22T12:51:17Z")

</div>

@aviddavid  
Could you please report this to [https://jira.percona.com/](https://jira.percona.com/) as a bug for the product Percona Xtrabackup and I will check it.

---

<div class="post-metadata">

**Author:** ![aviddavid](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@aviddavid](https://forums.percona.com/u/aviddavid)\
**Post date:** [January 22, 2021, 1:10pm UTC](https://forums.percona.com/t/xtrabackup-of-replica-relay-log-not-backed-up-slave-failed-to-initialize-relay-log/8890/3 "2021-01-22T13:10:33Z")

</div>

Thanks @lalit.choudhary - I’ve opened [[PXB-2413] Replication fails after a replica backup is restored - Slave failed to initialize relay log - Percona JIRA](https://jira.percona.com/browse/PXB-2413)

---

<div class="post-metadata">

**Author:** ![lalit.choudhary](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lalit.choudhary/32/51_2.png) [@lalit.choudhary](https://forums.percona.com/u/lalit.choudhary)\
**Post date:** [January 27, 2021, 9:11am UTC](https://forums.percona.com/t/xtrabackup-of-replica-relay-log-not-backed-up-slave-failed-to-initialize-relay-log/8890/4 "2021-01-27T09:11:28Z")

</div>

@aviddavid  
Thank you. I verified and updated Jira bug PXB-2413 with a test case.

---

<div class="post-metadata">

**Author:** ![turnon2003](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@turnon2003](https://forums.percona.com/u/turnon2003)\
**Post date:** [March 27, 2023, 12:07pm UTC](https://forums.percona.com/t/xtrabackup-of-replica-relay-log-not-backed-up-slave-failed-to-initialize-relay-log/8890/6 "2023-03-27T12:07:47Z")

</div>

Hi, has this issue been resolved? because i got the same problem in xtrabackup-8.0.32-25-1 and mysql 8.0.32

---

<div class="post-metadata">

**Author:** ![lalit.choudhary](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lalit.choudhary/32/51_2.png) [@lalit.choudhary](https://forums.percona.com/u/lalit.choudhary)\
**Post date:** [March 28, 2023, 5:14am UTC](https://forums.percona.com/t/xtrabackup-of-replica-relay-log-not-backed-up-slave-failed-to-initialize-relay-log/8890/7 "2023-03-28T05:14:44Z")

</div>

Hello @turnon2003

[[PXB-2413] Replication fails after a replica backup is restored - Slave failed to initialize relay log - Percona JIRA](https://jira.percona.com/browse/PXB-2413) Is Still Open state. Please Login to JIra, go to PXB-2413 report, and click on “Vote for this issue” as it’s affected you. More Votes will prioritize the issue.
