MySQL Proxy meets: binlogs - sneak peek II

The logfiles look like:

$ mysqlbinlog binlog-merge-1.log -s
SET TIMESTAMP=1240066015/*!*/;
INSERT INTO tbl VALUES ( 1 )
/*!*/;
SET TIMESTAMP=1240066017/*!*/;
INSERT INTO tbl VALUES ( 3 )
/*!*/;
# End of log file
ROLLBACK /* added by mysqlbinlog */;

and

$ mysqlbinlog binlog-merge-2.log -s
SET TIMESTAMP=1240066016/*!*/;
INSERT INTO tbl VALUES ( 2 )
/*!*/;
SET TIMESTAMP=1240066018/*!*/;
INSERT INTO tbl VALUES ( 4 )
/*!*/;
# End of log file
ROLLBACK /* added by mysqlbinlog */;

As the two binlogs are independent and can't contain collisions we can just merge the two binlogs based on the timestamp:

$ mysqlbinlog binlog-merged.log -s
SET TIMESTAMP=1240066015/*!*/;
INSERT INTO tbl VALUES ( 1 )
/*!*/;
SET TIMESTAMP=1240066016/*!*/;
INSERT INTO tbl VALUES ( 2 )
/*!*/;
SET TIMESTAMP=1240066017/*!*/;
INSERT INTO tbl VALUES ( 3 )
/*!*/;
SET TIMESTAMP=1240066018/*!*/;
INSERT INTO tbl VALUES ( 4 )
/*!*/;
# End of log file
ROLLBACK /* added by mysqlbinlog */;

In my session I'll show you what is going in the background to merge any number of binlogs into one binlog. It is less than 50 lines of lua-code.

Just add a network-interface to it and another problem to make MySQL "sharding-complete" is solved.