Bug #41390 mysqlbinlog doesn't properly handle local slow IO
Submitted: 11 Dec 2008 10:55 Modified: 11 Dec 2008 13:33
Reporter: N Tucker Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:3.2, 4.1, 5.0, 5.1, 6.0 bzr OS:Linux (pc-linux-gnu i486)
Assigned to: CPU Architecture:Any

[11 Dec 2008 10:55] N Tucker
Description:
when reading from stdin (or, say, a pipe), mysqlbinlog doesn't properly block waiting for data to come in on the fd.  It looks in the io cache, sees that there is no data, and returns 0.  This means, for example, that this always fails:

cat mybinlog | mysqlbinlog -

whereas this works:

mysqlbinlog - < mybinlog

How to repeat:
run 'mysqlbinlog -'
expected result: it should block waiting for the log header to be read.
actual result: it exits immediately, claiming the log is empty.

Suggested fix:
use regular blocking IO instead of IO cache for local files?
[11 Dec 2008 10:58] N Tucker
Note: why this would be useful:  because then you could casually watch your binlog by doing:  tail -f -n +0 mybinlog | mysqlbinlog -

...which would be fun.  Seriously: fun.
[11 Dec 2008 13:33] Sveta Smirnova
Thank you for the report.

Verified as described. Problem exists in all current versions.

$cat ./data511/mysqld511-shella-bin.001104 | ./bin/mysqlbinlog -
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
mysqlbinlog: mf_iocache.c:492: _my_b_read: Assertion `my_errno != 29' failed.
Aborted

$ ./bin/mysqlbinlog - < ./data511/mysqld511-shella-bin.001104
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#070716 19:08:22 server id 511  end_log_pos 106         Start: binlog v 4, server v 5.1.21-beta-debug-log created 070716 19:08:22 at startup
# Warning: this binlog was not closed properly. Most probably mysqld crashed writing it.
ROLLBACK/*!*/;
BINLOG '
BqabRg//AQAAZgAAAGoAAAABAAQANS4xLjIxLWJldGEtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAGpptGEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;