Bug #71722 Dangerous mysqlbinlog usage in example
Submitted: 14 Feb 2014 14:09 Modified: 10 Oct 2014 0:30
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Backup Documentation Severity:S3 (Non-critical)
Version:3.9.0, 3.10 OS:Any
Assigned to: Daniel So CPU Architecture:Any

[14 Feb 2014 14:09] Daniël van Eeden
Description:
The MEB documentation suggests a usage pattern for mysqlbinlog which isn't safe according to the mysqlbinlog documentation.

How to repeat:
Page: http://dev.mysql.com/doc/mysql-enterprise-backup/3.9/en/advanced.master.html
------------------
$ mysqlbinlog --start-position=5585832 mysqldatadir/omnibook-bin.002 | mysql
$ mysqlbinlog /mysqldatadir/omnibook-bin.003 | mysql
$ mysqlbinlog /mysqldatadir/omnibook-bin.004 | mysql
------------------

Page: https://dev.mysql.com/doc/refman/5.6/en/mysqlbinlog.html
------------------
If you have more than one binary log to execute on the MySQL server, the safe method is to process them all using a single connection to the server. Here is an example that demonstrates what may be unsafe:

shell> mysqlbinlog binlog.000001 | mysql -u root -p # DANGER!!
shell> mysqlbinlog binlog.000002 | mysql -u root -p # DANGER!!
------------------

Suggested fix:
Use the safer methods described in the mysqlbinlog documentation
[17 Feb 2014 13:19] MySQL Verification Team
Hello Daniel,

Thank you for the bug report.
Verified as described.

Thanks,
Umesh
[18 Feb 2014 22:40] Daniel So
Corrected the command sample to read:

$ mysqlbinlog /mysqldatadir/omnibook-bin.003 /mysqldatadir/omnibook-bin.004 | mysql

Also added the explanation that both binlogs have to be piped by a single connection to the server.
[29 Jul 2014 8:07] Daniël van Eeden
From:
http://dev.mysql.com/doc/mysql-enterprise-backup/3.10/en/advanced.master.html

--------------------------------------------------
Pipe the remaining binlog files to the restored backup. For example, if there are two more binlog files, omnibook-bin.003 and omnibook-bin,004, pipe them with a single connection to the server:
           
$ mysqlbinlog --start-position=5585832 mysqldatadir/omnibook-bin.002 | mysql
$ mysqlbinlog /mysqldatadir/omnibook-bin.003 /mysqldatadir/omnibook-bin.004 | mysql

 The number of remaining binlog files varies depending on when the last backup was taken: the older the backup, the more remaining binlog files there may be.
--------------------------------------------------

This is still not correct. _ALL_ binlogs must be sent over a single connection.

So either combine both comands or use the method as used on http://dev.mysql.com/doc/mysql-enterprise-backup/3.10/en/advanced.point.html to create a file which is then sent over a single connection.

This is probably only a risk when using temporary tables, but it is a risk.
[10 Oct 2014 0:30] Daniel So
The MySQL Enterprise Backup 3.11 manual has been updated with the suggestion of combining the two commands into one. Also added more explanations. Changes will appear in the next build of the manual.