From d8b2d4a0694156848db0862a230d248653f8ebe5 Mon Sep 17 00:00:00 2001 From: Rohit Kalhans Date: Tue, 29 May 2012 12:11:30 +0530 Subject: Bug#11762667: MYSQLBINLOG IGNORES ERRORS WHILE WRITING OUTPUT Problem: mysqlbinlog exits without any error code in case of file write error. It is because of the fact that the calls to Log_event::print() method does not return a value and the thus any error were being ignored. Resolution: We resolve this problem by checking for the IO_CACHE::error == -1 after every call to Log_event:: print() and terminating the further execution. client/mysqlbinlog.cc: - handled error conditions during event->print() calls - added check for error in end_io_cache() mysys/my_write.c: Added debug code to simulate file write error. error returned will be ENOSPC=> error no space on the disk sql/log_event.cc: Added debug code to simulate file write error, by reducing the size of io cache. --- mysys/my_write.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'mysys') diff --git a/mysys/my_write.c b/mysys/my_write.c index f261c768dcb..b545ab776b0 100644 --- a/mysys/my_write.c +++ b/mysys/my_write.c @@ -38,7 +38,17 @@ size_t my_write(int Filedes, const uchar *Buffer, size_t Count, myf MyFlags) for (;;) { - if ((writenbytes= write(Filedes, Buffer, Count)) == Count) + writenbytes= write(Filedes, Buffer, Count); + /** + To simulate the write error set the errno = error code + and the number pf written bytes to -1. + */ + DBUG_EXECUTE_IF ("simulate_file_write_error", + { + errno= ENOSPC; + writenbytes= (size_t) -1; + }); + if (writenbytes == Count) break; if (writenbytes != (size_t) -1) { /* Safeguard */ -- cgit v1.2.1