summaryrefslogtreecommitdiff
path: root/sql/sql_repl.cc
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-08-21 22:04:22 +0300
committerunknown <monty@hundin.mysql.fi>2002-08-21 22:04:22 +0300
commit87f9ad3724a8644de4ba10f6247fe194a3d08457 (patch)
tree75f29bea26c7fd21a45f22fd906c7a1545aaee91 /sql/sql_repl.cc
parent457172d99256e68a93ab69eecbef23a3db7ef1c4 (diff)
downloadmariadb-git-87f9ad3724a8644de4ba10f6247fe194a3d08457.tar.gz
Use our version of RWLOCKS on UNIXWARE 7
More DBUG info for replication Better error messages from replication Fixed bug in replication code when connecting to 'localhost' (time was not released properly) Block ALARM signal on Linux for signal handler thread (Fixes problem with running mysqld with --debug) Removed warning when setting an AUTO_INCREMENT field to NULL Build-tools/Do-compile: Always run test with --warnings during build Docs/manual.texi: Changelog configure.in: Use our version of RWLOCKS on UNIXWARE 7 include/my_pthread.h: Use our version of RWLOCKS on UNIXWARE 7 include/mysql_version.h.in: Fixed warning when compiling embedded server include/mysqld_error.h: New error messages libmysql/libmysql.c: Give connect error message on reconnect if it fails. Fixed possible buffer overflow in expand_error() Added error messages for some error conditions. mysql-test/mysql-test-run.sh: Portability fixes: - Search after 'time' in path. - Search after mysqld in libexec - Remove end / when doing rm -r (fix for BSD) Clean up skip_test handling. mysql-test/r/rpl_empty_master_crash.result: New results mysql-test/t/rpl_empty_master_crash.test: Extended test mysys/mf_iocache.c: Remember file position on failed read. mysys/mf_iocache2.c: Fixed bug in filelength() call. mysys/thr_alarm.c: Made alarm handling more threadsafe when use with DBUG. mysys/thr_mutex.c: More debug info sql/log_event.cc: More DBUG_PRINT statements. sql/mini_client.cc: Better error reporting on failures. Return connect error on reconnect failure (instead of SERVER_GONE_ERROR) Fixed critical bug in alarm handling on connect (could leave an alarm event on indefinitely) sql/mysql_priv.h: Fixed arguments to mysql_binlog_send() sql/mysqld.cc: Block ALARM signal on Linux for signal handler thread (Fixes problem with running mysqld with --debug) sql/net_pkg.cc: Removed dead code sql/net_serv.cc: Ensure that last_errno is set in net_real_write() sql/repl_failsafe.cc: Code cleanup. Better error handling. sql/share/czech/errmsg.txt: New error messages. sql/share/danish/errmsg.txt: New error messages. sql/share/dutch/errmsg.txt: New error messages. sql/share/english/errmsg.txt: New error messages. sql/share/estonian/errmsg.txt: New error messages. sql/share/french/errmsg.txt: New error messages. sql/share/german/errmsg.txt: New error messages. sql/share/greek/errmsg.txt: New error messages. sql/share/hungarian/errmsg.txt: New error messages. sql/share/italian/errmsg.txt: New error messages. sql/share/japanese/errmsg.txt: New error messages. sql/share/korean/errmsg.txt: New error messages. sql/share/norwegian-ny/errmsg.txt: New error messages. sql/share/norwegian/errmsg.txt: New error messages. sql/share/polish/errmsg.txt: New error messages. sql/share/portuguese/errmsg.txt: New error messages. mysql-test/r/rpl_log_pos.result: Updated results mysql-test/t/rpl_log_pos.test: Added 'sleep' commands to make tests repeatable. sql/share/romanian/errmsg.txt: New error messages. sql/share/russian/errmsg.txt: New error messages. sql/share/slovak/errmsg.txt: New error messages. sql/share/spanish/errmsg.txt: New error messages. sql/share/swedish/errmsg.txt: New error messages. sql/share/ukrainian/errmsg.txt: New error messages. sql/slave.cc: Code optimization and cleanup. More DBUG statements. Better cleanup if start slave fails. Better error messages from 'fetch_master_table' Thread safer handling of 'wait_for_pos' sql/slave.h: Better handling of wait_for_pos sql/sql_load.cc: Removed warning when setting an AUTO_INCREMENT field to NULL sql/sql_parse.cc: Fixed calling of function that has changed. sql/sql_repl.cc: More DBUG statements Give a proper error number from mysql_binlog_send() so that we know when we have to abort slaves.
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r--sql/sql_repl.cc46
1 files changed, 38 insertions, 8 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 8975a05ac3a..379f76640b3 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -291,8 +291,12 @@ binlog purge"; break;
return 0;
}
+/*
+ TODO: Clean up loop to only have one call to send_file()
+*/
-void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
+void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
+ ushort flags)
{
LOG_INFO linfo;
char *log_file_name = linfo.log_file_name;
@@ -307,12 +311,15 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
int left_events = max_binlog_dump_events;
#endif
DBUG_ENTER("mysql_binlog_send");
+ DBUG_PRINT("enter",("log_ident: '%s' pos: %ld", log_ident, (long) pos));
+
bzero((char*) &log,sizeof(log));
#ifndef DBUG_OFF
if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
{
errmsg = "Master failed COM_BINLOG_DUMP to test if slave can recover";
+ my_errno= ER_UNKNOWN_ERROR;
goto err;
}
#endif
@@ -320,11 +327,13 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
if (!mysql_bin_log.is_open())
{
errmsg = "Binary log is not open";
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
}
if (!server_id_supplied)
{
errmsg = "Misconfigured master - server id was not set";
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
}
@@ -340,16 +349,20 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
if (mysql_bin_log.find_log_pos(&linfo, name))
{
errmsg = "Could not find first log file name in binary log index file";
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
}
if ((file=open_binlog(&log, log_file_name, &errmsg)) < 0)
+ {
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
-
- if (pos < 4)
+ }
+ if (pos < BIN_LOG_HEADER_SIZE || pos > my_b_filelength(&log))
{
errmsg= "Client requested master to start replication from \
impossible position";
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
}
@@ -365,7 +378,10 @@ impossible position";
{
// tell the client log name with a fake rotate_event
if (fake_rotate_event(net, packet, log_file_name, &errmsg))
+ {
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
+ }
packet->set("\0", 1);
}
@@ -380,12 +396,14 @@ impossible position";
{
net_flush(net);
errmsg = "Debugging binlog dump abort";
+ my_errno= ER_UNKNOWN_ERROR;
goto err;
}
#endif
if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
{
errmsg = "Failed on my_net_write()";
+ my_errno= ER_UNKNOWN_ERROR;
goto err;
}
DBUG_PRINT("info", ("log event code %d",
@@ -395,6 +413,7 @@ impossible position";
if (send_file(thd))
{
errmsg = "failed in send_file()";
+ my_errno= ER_UNKNOWN_ERROR;
goto err;
}
}
@@ -406,6 +425,7 @@ impossible position";
*/
if (error != LOG_READ_EOF)
{
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
switch (error) {
case LOG_READ_BOGUS:
errmsg = "bogus data in log event";
@@ -439,6 +459,7 @@ Increase max_allowed_packet on master";
if (net_flush(net))
{
errmsg = "failed on net_flush()";
+ my_errno= ER_UNKNOWN_ERROR;
goto err;
}
@@ -455,8 +476,8 @@ Increase max_allowed_packet on master";
#ifndef DBUG_OFF
if (max_binlog_dump_events && !left_events--)
{
- net_flush(net);
errmsg = "Debugging binlog dump abort";
+ my_errno= ER_UNKNOWN_ERROR;
goto err;
}
#endif
@@ -465,9 +486,12 @@ Increase max_allowed_packet on master";
No one will update the log while we are reading
now, but we'll be quick and just read one record
- To be able to handle EOF properly, we have to have the
- pthread_mutex_unlock() statements in the case statements.
+ TODO:
+ Add an counter that is incremented for each time we update
+ the binary log. We can avoid the following read if the counter
+ has not been updated since last read.
*/
+
pthread_mutex_lock(log_lock);
switch (Log_event::read_log_event(&log, packet, (pthread_mutex_t*)0)) {
case 0:
@@ -494,6 +518,7 @@ Increase max_allowed_packet on master";
if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
{
errmsg = "Failed on my_net_write()";
+ my_errno= ER_UNKNOWN_ERROR;
goto err;
}
@@ -502,6 +527,7 @@ Increase max_allowed_packet on master";
if (send_file(thd))
{
errmsg = "failed in send_file()";
+ my_errno= ER_UNKNOWN_ERROR;
goto err;
}
}
@@ -515,6 +541,7 @@ Increase max_allowed_packet on master";
if (fatal_error)
{
errmsg = "error reading log entry";
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
}
log.error=0;
@@ -533,6 +560,7 @@ Increase max_allowed_packet on master";
break;
default:
errmsg = "could not find next log";
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
}
@@ -546,8 +574,10 @@ Increase max_allowed_packet on master";
// otherwise the slave make get confused about the offset
if ((file=open_binlog(&log, log_file_name, &errmsg)) < 0 ||
fake_rotate_event(net, packet, log_file_name, &errmsg))
+ {
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
-
+ }
packet->length(0);
packet->append("\0",1);
}
@@ -836,7 +866,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
mi->rli.master_log_pos=0;
pthread_mutex_lock(&mi->rli.data_lock);
- mi->rli.abort_pos_wait = 1;
+ mi->rli.abort_pos_wait++;
pthread_cond_broadcast(&mi->data_cond);
pthread_mutex_unlock(&mi->rli.data_lock);