Commit 9c68cded authored by unknown's avatar unknown

Use my_b_append instead of my_b_write on a SEQ_READ_APPEND cache, when we write

the first 4 bytes of the relay log. Indeed comments in mysys/mf_iocache.c 
say we must always use my_b_append for such a cache.
This *could* avoid a very rare assertion failure which is: 
030524 19:32:38  Slave SQL thread initialized, starting replication in log 'FIRST' at position 0, relay log '/
users/gbichot/4.1.1/mysql-test/var/log/slave-relay-bin.000001' position: 4
030524 19:32:38  next log '/users/gbichot/4.1.1/mysql-test/var/log/slave-relay-bin.000002' is currently active
mysqld: mf_iocache.c:701: _my_b_seq_read: Assertion `pos_in_file == info->end_of_file' failed.
and which seemed to happen always when the SQL thread and/or the I/O thread
were at position 4 in a relay log.


include/my_sys.h:
  moving a function from log_event.cc so that it can be widely used
mysys/mf_iocache.c:
  moving a function from log_event.cc so that it can be widely used
sql/log.cc:
  my_b_write should not be used on a SEQ_READ_APPEND cache, one should use my_b_append
  (otherwise there could be some locking problems).
sql/log_event.cc:
  moved to mysys/mf_iocache.c for wider use.
  A typo.
parent ad68064c
...@@ -677,6 +677,8 @@ extern int _my_b_get(IO_CACHE *info); ...@@ -677,6 +677,8 @@ extern int _my_b_get(IO_CACHE *info);
extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count); extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count); extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count);
extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count); extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count);
extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count);
extern int my_block_write(IO_CACHE *info, const byte *Buffer, extern int my_block_write(IO_CACHE *info, const byte *Buffer,
uint Count, my_off_t pos); uint Count, my_off_t pos);
extern int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock); extern int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
......
...@@ -988,6 +988,20 @@ int my_b_append(register IO_CACHE *info, const byte *Buffer, uint Count) ...@@ -988,6 +988,20 @@ int my_b_append(register IO_CACHE *info, const byte *Buffer, uint Count)
} }
int my_b_safe_write(IO_CACHE *info, const byte *Buffer, uint Count)
{
/*
Sasha: We are not writing this with the ? operator to avoid hitting
a possible compiler bug. At least gcc 2.95 cannot deal with
several layers of ternary operators that evaluated comma(,) operator
expressions inside - I do have a test case if somebody wants it
*/
if (info->type == SEQ_READ_APPEND)
return my_b_append(info, Buffer, Count);
return my_b_write(info, Buffer, Count);
}
/* /*
Write a block to disk where part of the data may be inside the record Write a block to disk where part of the data may be inside the record
buffer. As all write calls to the data goes through the cache, buffer. As all write calls to the data goes through the cache,
......
...@@ -263,7 +263,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, ...@@ -263,7 +263,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
an extension for the binary log files. an extension for the binary log files.
In this case we write a standard header to it. In this case we write a standard header to it.
*/ */
if (my_b_write(&log_file, (byte*) BINLOG_MAGIC, BIN_LOG_HEADER_SIZE)) if (my_b_safe_write(&log_file, (byte*) BINLOG_MAGIC, BIN_LOG_HEADER_SIZE))
goto err; goto err;
bytes_written += BIN_LOG_HEADER_SIZE; bytes_written += BIN_LOG_HEADER_SIZE;
write_file_name_to_index_file=1; write_file_name_to_index_file=1;
......
...@@ -26,20 +26,6 @@ ...@@ -26,20 +26,6 @@
#include <assert.h> #include <assert.h>
inline int my_b_safe_write(IO_CACHE* file, const byte *buf,
int len)
{
/*
Sasha: We are not writing this with the ? operator to avoid hitting
a possible compiler bug. At least gcc 2.95 cannot deal with
several layers of ternary operators that evaluated comma(,) operator
expressions inside - I do have a test case if somebody wants it
*/
if (file->type == SEQ_READ_APPEND)
return my_b_append(file, buf,len);
return my_b_write(file, buf,len);
}
#ifdef MYSQL_CLIENT #ifdef MYSQL_CLIENT
static void pretty_print_str(FILE* file, char* str, int len) static void pretty_print_str(FILE* file, char* str, int len)
{ {
...@@ -2039,7 +2025,7 @@ Slave: load data infile on table '%s' at log position %s in log \ ...@@ -2039,7 +2025,7 @@ Slave: load data infile on table '%s' at log position %s in log \
err=ER(sql_errno); err=ER(sql_errno);
} }
slave_print_error(rli,sql_errno,"\ slave_print_error(rli,sql_errno,"\
Error '%s' running lOAD DATA INFILE on table '%s'. Default database: '%s'", Error '%s' running LOAD DATA INFILE on table '%s'. Default database: '%s'",
err, (char*)table_name, print_slave_db_safe(db)); err, (char*)table_name, print_slave_db_safe(db));
free_root(&thd->mem_root,0); free_root(&thd->mem_root,0);
return 1; return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment