Skip to content

Commit c78c1fe

Browse files
author
Sujatha Sivakumar
committed
Bug#14324766:PARTIALLY WRITTEN INSERT STATEMENT IN BINLOG
NO ERRORS REPORTED Problem: ======= Errors from my_b_fill are ignored. MYSQL_BIN_LOG::write_cache code assumes that 0 returned from my_b_fill always means end-of-cache, but that is incorrect. It can result in error and the error is ignored. Other callers of my_b_fill don't check for error: my_b_copy_to_file, maybe my_b_gets. Fix: === An error handler is already present to check the "cache" error that is reported during "MYSQL_BIN_LOG::write_cache" call. Hence error handlers are added for "my_b_copy_to_file" and "my_b_gets". During my_b_fill() function call, when the cache read fails info->error= -1 is set. Hence a check for "info->error" is added for the above to callers upon their return.
1 parent 9d7f333 commit c78c1fe

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

mysys/mf_iocache2.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -66,6 +66,8 @@ my_b_copy_to_file(IO_CACHE *cache, FILE *file)
6666
DBUG_RETURN(1);
6767
cache->read_pos= cache->read_end;
6868
} while ((bytes_in_cache= my_b_fill(cache)));
69+
if(cache->error == -1)
70+
DBUG_RETURN(1);
6971
DBUG_RETURN(0);
7072
}
7173

@@ -215,6 +217,8 @@ size_t my_b_fill(IO_CACHE *info)
215217
info->error= 0;
216218
return 0; /* EOF */
217219
}
220+
DBUG_EXECUTE_IF ("simulate_my_b_fill_error",
221+
{DBUG_SET("+d,simulate_file_read_error");});
218222
if ((length= my_read(info->file,info->buffer,max_length,
219223
info->myflags)) == (size_t) -1)
220224
{

mysys/my_read.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000-2002, 2004, 2006, 2007 MySQL AB
1+
/* Copyright (c) 2000-2002, 2004, 2006, 2007, 2013 MySQL AB
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -44,8 +44,18 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
4444
for (;;)
4545
{
4646
errno= 0; /* Linux doesn't reset this */
47-
if ((readbytes= read(Filedes, Buffer, (uint) Count)) != Count)
47+
if (DBUG_EVALUATE_IF("simulate_file_read_error", 1, 0) ||
48+
(readbytes= read(Filedes, Buffer, (uint) Count)) != Count)
4849
{
50+
DBUG_EXECUTE_IF ("simulate_file_read_error",
51+
{
52+
errno= ENOSPC;
53+
readbytes= (size_t) -1;
54+
DBUG_SET("-d,simulate_file_read_error");
55+
DBUG_SET("-d,simulate_my_b_fill_error");
56+
});
57+
58+
4959
my_errno= errno ? errno : -1;
5060
DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d",
5161
(int) readbytes, (ulong) Count, Filedes,

sql/log_event.cc

+2
Original file line numberDiff line numberDiff line change
@@ -9196,6 +9196,8 @@ Write_rows_log_event::do_exec_row(const Relay_log_info *const rli)
91969196
#ifdef MYSQL_CLIENT
91979197
void Write_rows_log_event::print(FILE *file, PRINT_EVENT_INFO* print_event_info)
91989198
{
9199+
DBUG_EXECUTE_IF("simulate_cache_read_error",
9200+
{DBUG_SET("+d,simulate_my_b_fill_error");});
91999201
Rows_log_event::print_helper(file, print_event_info, "Write_rows");
92009202
}
92019203
#endif

sql/sql_repl.cc

+2
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,8 @@ bool show_binlogs(THD* thd)
17321732
if (protocol->write())
17331733
goto err;
17341734
}
1735+
if(index_file->error == -1)
1736+
goto err;
17351737
mysql_bin_log.unlock_index();
17361738
my_eof(thd);
17371739
DBUG_RETURN(FALSE);

0 commit comments

Comments
 (0)