Bug #86288 mysqlbinlog read-from-remote-server not honoring rewrite_db filtering
Submitted: 11 May 2017 20:34 Modified: 6 Jul 2017 9:44
Reporter: Julie Hergert Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S1 (Critical)
Version:5.7.18 OS:Any
Assigned to:

[11 May 2017 20:34] Julie Hergert
Description:
When running mysqlbinlog with the --read-from-remote-server option, the processing of the binlog entries accepts rewrite_db as an argument, but ignores the rewrite rule.  Therefore no filtering is done on the binlog entries, resulting in failures to write data in the target DB.

How to repeat:
The two commands below produce different results:

mysqlbinlog --database=bar --rewrite-db='foo->bar' --read-from-remote-server —host=<dbsvr> —user=root —password=xxx replicatelogs.000013

mysqlbinlog --database=bar --rewrite-db='foo->bar’ /mysql/binlogs/replicatelogs.000013

Suggested fix:
The commands as listed in the 'How to repeat' field should behave the same.
[19 May 2017 19:12] Sven Sandberg
Thank you for the bug report. I confirm that rewrite-db is not implemented when dumping from a remote server.

Note that there is a simple workaround: use --raw (which dumps a remote binlog in binary form), and pipe it to another mysqlbinlog process that reads from stdin and rewrites the database. The other mysqlbinlog process reads locally so it will honor --rewrite-db. Here is how to do it for the command line in this bug report:

mysqlbinlog --database=bar --read-from-remote-server --host=<dbsvr> --user=root --password=xxx replicatelogs.000013 --raw | mysqlbinlog - --rewrite-db='foo->bar'
[6 Jul 2017 9:41] Margaret Fisher
Posted by developer:
 
Added changelog entry for MySQL 5.7.20 and 8.0.3:
        When running <command>mysqlbinlog</command> with the --read-from-remote-server
        option, rewrite rules specified using the --rewrite-db option were ignored, 
        so data was not written to the target database.