1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

fixed mutex bug ( or lack of it) when reading log entries on COM_BINLOG_DUMP

added error_code to query event, and checking to see if we get the
expected error on the slave
removed obsolete code from slave.cc


sql/log_event.cc:
  added mutex as an argument to FILE read_log_event functions
sql/log_event.h:
  added error_code for the query event
sql/mysqlbinlog.cc:
  fix for new form of read_log_event
sql/slave.cc:
  removed obsolte code with fetch nx table
  added check to see if the query runs with the same error on the slave
  as it did on the master
sql/sql_repl.cc:
  fixed mutex problem around read_log_event
This commit is contained in:
unknown
2000-10-03 19:53:13 -06:00
parent ddae2009f5
commit cfc4a2e74e
5 changed files with 103 additions and 61 deletions

View File

@ -121,7 +121,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
errmsg = "Could not find first log";
goto err;
}
log = my_fopen(log_file_name, O_RDONLY, MYF(MY_WME));
log = my_fopen(log_file_name, O_RDONLY|O_BINARY, MYF(MY_WME));
if(!log)
{
@ -143,14 +143,17 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
while(!net->error && net->vio != 0 && !thd->killed)
{
while(!(error = Log_event::read_log_event(log, packet)))
pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
while(!(error = Log_event::read_log_event(log, packet, log_lock)))
{
if(my_net_write(net, (char*)packet->ptr(), packet->length()) )
{
errmsg = "Failed on my_net_write()";
goto err;
}
DBUG_PRINT("info", ("log event code %d",(*packet)[LOG_EVENT_OFFSET+1] ));
DBUG_PRINT("info", ("log event code %d",
(*packet)[LOG_EVENT_OFFSET+1] ));
if((*packet)[LOG_EVENT_OFFSET+1] == LOAD_EVENT)
{
if(send_file(thd))
@ -168,7 +171,8 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
goto err;
}
if(!(flags & BINLOG_DUMP_NON_BLOCK) && mysql_bin_log.is_active(log_file_name))
if(!(flags & BINLOG_DUMP_NON_BLOCK) &&
mysql_bin_log.is_active(log_file_name))
// block until there is more data in the log
// unless non-blocking mode requested
{
@ -183,7 +187,6 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
// if we did not miss anything, we just wait for other threads
// to signal us
{
pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
clearerr(log);
// tell the kill thread how to wake us up
@ -196,18 +199,19 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
bool read_packet = 0, fatal_error = 0;
pthread_mutex_lock(log_lock); // no one will update the log while we are reading
// no one will update the log while we are reading
// now, but we'll be quick and just read one record
switch(Log_event::read_log_event(log, packet))
switch(Log_event::read_log_event(log, packet, log_lock))
{
case 0:
read_packet = 1; // we read successfully, so we'll need to send it to the
read_packet = 1;
// we read successfully, so we'll need to send it to the
// slave
break;
case LOG_READ_EOF:
pthread_mutex_lock(log_lock);
pthread_cond_wait(&COND_binlog_update, log_lock);
pthread_mutex_unlock(log_lock);
break;
default:
@ -215,7 +219,6 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
break;
}
pthread_mutex_unlock(log_lock);
pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0;
@ -275,7 +278,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
break;
(void) my_fclose(log, MYF(MY_WME));
log = my_fopen(log_file_name, O_RDONLY, MYF(MY_WME));
log = my_fopen(log_file_name, O_RDONLY|O_BINARY, MYF(MY_WME));
if(!log)
goto err;
// fake Rotate_log event just in case it did not make it to the log