Bug #44188 STOP SLAVE should flush info files and relay logs.
Submitted: 9 Apr 2009 14:49 Modified: 7 Mar 2010 12:48
Reporter: Mikiya Okuno Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S4 (Feature request)
Version:5.1.33 OS:Any
Assigned to: Luis Soares CPU Architecture:Any

[9 Apr 2009 14:49] Mikiya Okuno
Description:
Currently, master.info and relay-log.info are not flushed when slave threads are stopped. This means that these files may corrupt when the server crashes. In such case, we should restore the slave from other slaves or the master. mysqldump is stable, but it's slow. As a backup method, instant snapshot is fairly popular amongst many people. However, snapshot taken from a slave doesn't include correct master.info, relay-log.info and relay-logs. We should take a backup from other slave like below:

1. STOP SLAVE
2. SHOW SLAVE STATUS
3. Take a snapshot
4. START SLAVE

I assume that slave is not updated other clients than its SQL thread. After restoring the slave from this backup, we should start the server with --skip-slave option and issue CHANGE MASTER TO command manually. This is a little bit messy. If the replication slave files are flushed when STOP SLAVE is executed, we can start the slave without --skip-slave option and CHANGE MASTER TO command.

How to repeat:
n/a

Suggested fix:
Flush three files in stop_slave() function:
o master.info
o relay-log.info
o the current relay log

A sample patch is available.
[9 Apr 2009 14:50] MySQL Verification Team
A sample patch for MySQL 5.1.33

Attachment: rep-info-flush.patch (application/octet-stream, text), 985 bytes.

[13 Oct 2009 0:24] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/86615

3143 Luis Soares	2009-10-13
      BUG#44188: STOP SLAVE should flush info files and relay logs.
      
      Replication info files are not being flushed and synced when the
      command 'STOP SLAVE' is issued. This means that one cannot just
      rely on existing values on those files when the slave has been
      stopped. Having consistent, uncorrupted and up-to-date info files
      when stopping the slave would be most useful, for instance, for
      snapshotting purposes (a procedure that is often used for
      restoring slaves).
      
      This patch addresses this by instrumenting the
      terminate_slave_threads function so that it also flushes and
      syncs the *info files as well as the relay log whenever it gets
      called, ie, on 'STOP SLAVE'. Although this imposes a performance
      trade-off (specifically when stopping the slave), it should have
      no negative influence on overall replication performance (impact
      is only noticeable on 'STOP SLAVE').
[13 Nov 2009 18:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/90388

3121 Luis Soares	2009-11-13
      BUG#44188: STOP SLAVE should flush info files and relay logs.
            
      Replication info files are not being flushed and synced when the
      command 'STOP SLAVE' is issued. This means that one cannot just
      rely on existing values on those files when the slave has been
      stopped. Having consistent, uncorrupted and up-to-date info files
      when stopping the slave would be most useful, for instance, for
      snapshotting purposes (a procedure that is often used for
      restoring slaves).
            
      This patch addresses this by instrumenting the
      terminate_slave_threads function so that it also flushes and
      syncs the *info files as well as the relay log whenever it gets
      called, ie, on 'STOP SLAVE'.  Although this imposes a performance
      trade-off (specifically when stopping the slave), it should have
      no negative influence on overall replication performance (impact
      is only noticeable on 'STOP SLAVE').
[18 Jan 2010 12:06] Bugs System
Pushed into 6.0.14-alpha (revid:alik@ibmvm-20100118120357-hnzhgadkpzqfnvsc) (version source revid:alik@ibmvm-20100118115413-kd3klpine09yyktw) (merge vers: 6.0.14-alpha) (pib:16)
[18 Jan 2010 12:07] Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100118120111-73dulkgc893it4r9) (version source revid:alik@ibmvm-20100118115335-0stecyzftqm7bqx6) (pib:16)
[23 Jan 2010 0:38] Paul DuBois
Noted in 6.0.14 changelog.

STOP SLAVE did not flush the relay log or the master.info or
relay-log.info files, which could lead to corruption if the server
crashed. 

Setting report to NDI pending push to Celosia.
[6 Mar 2010 10:55] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@linux-rbsx-20100118220048-5vnyqi5ghsbgmdsd) (merge vers: 5.5.99-m3) (pib:16)
[7 Mar 2010 12:48] Paul DuBois
Noted in 5.5.3 changelog.