summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xBuild-tools/Do-compile2
-rw-r--r--Docs/manual.texi42
-rw-r--r--configure.in2
-rw-r--r--include/my_pthread.h6
-rw-r--r--include/mysql_version.h.in2
-rw-r--r--include/mysqld_error.h3
-rw-r--r--libmysql/libmysql.c56
-rw-r--r--mysql-test/mysql-test-run.sh38
-rw-r--r--mysql-test/r/rpl_empty_master_crash.result4
-rw-r--r--mysql-test/r/rpl_log_pos.result (renamed from mysql-test/r/rpl000014.result)18
-rw-r--r--mysql-test/t/rpl_empty_master_crash.test6
-rw-r--r--mysql-test/t/rpl_log_pos.test (renamed from mysql-test/t/rpl000014.test)19
-rw-r--r--mysys/mf_iocache.c5
-rw-r--r--mysys/mf_iocache2.c2
-rw-r--r--mysys/thr_alarm.c23
-rw-r--r--mysys/thr_mutex.c4
-rw-r--r--sql/log_event.cc12
-rw-r--r--sql/mini_client.cc55
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc12
-rw-r--r--sql/net_pkg.cc2
-rw-r--r--sql/net_serv.cc3
-rw-r--r--sql/repl_failsafe.cc74
-rw-r--r--sql/share/czech/errmsg.txt1
-rw-r--r--sql/share/danish/errmsg.txt1
-rw-r--r--sql/share/dutch/errmsg.txt1
-rw-r--r--sql/share/english/errmsg.txt1
-rw-r--r--sql/share/estonian/errmsg.txt1
-rw-r--r--sql/share/french/errmsg.txt1
-rw-r--r--sql/share/german/errmsg.txt1
-rw-r--r--sql/share/greek/errmsg.txt1
-rw-r--r--sql/share/hungarian/errmsg.txt1
-rw-r--r--sql/share/italian/errmsg.txt1
-rw-r--r--sql/share/japanese/errmsg.txt1
-rw-r--r--sql/share/korean/errmsg.txt1
-rw-r--r--sql/share/norwegian-ny/errmsg.txt1
-rw-r--r--sql/share/norwegian/errmsg.txt1
-rw-r--r--sql/share/polish/errmsg.txt1
-rw-r--r--sql/share/portuguese/errmsg.txt1
-rw-r--r--sql/share/romanian/errmsg.txt1
-rw-r--r--sql/share/russian/errmsg.txt1
-rw-r--r--sql/share/slovak/errmsg.txt1
-rw-r--r--sql/share/spanish/errmsg.txt1
-rw-r--r--sql/share/swedish/errmsg.txt1
-rw-r--r--sql/share/ukrainian/errmsg.txt1
-rw-r--r--sql/slave.cc159
-rw-r--r--sql/slave.h6
-rw-r--r--sql/sql_load.cc2
-rw-r--r--sql/sql_parse.cc7
-rw-r--r--sql/sql_repl.cc46
50 files changed, 406 insertions, 228 deletions
diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile
index d262fc82f94..04e905cb834 100755
--- a/Build-tools/Do-compile
+++ b/Build-tools/Do-compile
@@ -236,7 +236,7 @@ if ($opt_stage <= 5 && !$opt_no_test && !$opt_no_mysqltest)
{
system("mkdir $bench_tmpdir") if (! -d $bench_tmpdir);
safe_cd("${test_dir}/mysql-test");
- check_system("./mysql-test-run --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --manager-port=$manager_port --no-manager --sleep=10", "tests were successful");
+ check_system("./mysql-test-run --warnings --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --manager-port=$manager_port --no-manager --sleep=10", "tests were successful");
}
# Start the server if we are going to run any of the benchmarks
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 4d8ebb622b7..d19beb75896 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -8099,14 +8099,39 @@ dumping core after you upgrade MySQL.
@node Upgrading-from-3.23, Upgrading-from-3.22, Upgrade, Upgrade
@subsection Upgrading From Version 3.23 to Version 4.0
-You can use your old datafiles without any modification with Version 4.0.
-If you want to move your data from a MySQL 4.0 server to an older server,
-you have to use @code{mysqldump}.
+In general what you have to do when upgrading to 4.0 from an earlier
+MySQL version:
+
+@itemize
+@item
+Run the @code{mysql_fix_privilege_tables} to add new privileges and features
+to the MySQL privilege tables.
+@item
+Edit any MySQL startup scripts or configure files to not use any of the
+deprecated options listed below.
+@item
+Convert your old ISAM files to MyISAM files with the command:
+@code{mysql_convert_table_format database}. Note that this should only
+be run if all tables in the given database is ISAM or MyISAM tables. If
+this is not the case you should run @code{ALTER TABLE table_name TYPE=MyISAM}
+on all ISAM tables.
+@end itemize
+
+MySQL 4.0 will work even if you don't do the above, but you will not be
+able to use the new security privileges that MySQL 4.0 and you may run
+into problems when upgrading later to MySQL 4.1 or newer. The ISAM file
+format still works in MySQL 4.0 but it's deprecated and will be disabled
+in MySQL 5.0.
Old clients should work with a Version 4.0 server without any problems.
-The following lists tell what you have to watch out for when upgrading to
-version 4.0;
+Even if you do the above, you can still downgrade to MySQL 3.23.52 or newer
+if you run into problems with the MySQL 4.0 series. In this case you have
+to do a mysqldump of any tables using a fulltext index and restore these
+in 3.23 (because 4.0 uses a new format for fulltext index).
+
+The following is a more complete lists tell what you have to watch out
+for when upgrading to version 4.0;
@itemize @bullet
@item
@@ -8136,7 +8161,7 @@ before. In particular, you will need @code{REPLICATION SLAVE}
The startup parameters @code{myisam_max_extra_sort_file_size} and
@code{myisam_max_extra_sort_file_size} are now given in bytes
(was megabytes before 4.0.3).
-External system locking of MyISAM/ISAM files is now turned of by default.
+External system locking of MyISAM/ISAM files is now turned off by default.
One can turn this on by doing @code{--external-locking}. (For most users
this is never needed).
@item
@@ -50266,6 +50291,9 @@ each individual 4.0.x release.
@itemize @bullet
@item
+Don't increment warnings when setting @code{AUTO_INCREMENT} columns to
+@code{NULL} in @code{LOAD DATA INFILE}.
+@item
Fixed shutdown problem (SIGTERM signal handling) on Solaris. (Bug from 4.0.2).
@item
@code{SHOW MASTER STATUS} now returns an empty set if binary log is not
@@ -50299,7 +50327,7 @@ Fixed some problems with @code{CREATE TABLE ... SELECT function()}.
@code{mysqld} now has the option @code{--temp-pool} enabled by default as this
gives better performance with some operating systems.
@item
-Big cleanup in replication code.
+Big cleanup in replication code (less logging, better error messages, etc..)
@item
If the @code{--code-file} option is specified, the server calls
@code{setrlimit()} to set the maximum allowed core file size to unlimited,
diff --git a/configure.in b/configure.in
index d4ae062865d..5c6330c2672 100644
--- a/configure.in
+++ b/configure.in
@@ -1186,7 +1186,7 @@ then
else
# CC="$CC -Kthread -DOpenUNIX8";
# CXX="$CXX -Kthread -DOpenUNIX8";
- CC="$CC -Kthread -DUNIXWARE_7";
+ CC="$CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK";
CXX="$CXX -Kthread -DUNIXWARE_7";
fi
AC_MSG_RESULT("yes")
diff --git a/include/my_pthread.h b/include/my_pthread.h
index aac0222c136..9b7812b7cf2 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -487,6 +487,12 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
/* READ-WRITE thread locking */
+#ifdef HAVE_BROKEN_RWLOCK /* For OpenUnix */
+#undef HAVE_PTHREAD_RWLOCK_RDLOCK
+#undef HAVE_RWLOCK_INIT
+#undef HAVE_RWLOCK_T
+#endif
+
#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
/* use these defs for simple mutex locking */
#define rw_lock_t pthread_mutex_t
diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in
index 1eb6f253d74..793bf36e9fe 100644
--- a/include/mysql_version.h.in
+++ b/include/mysql_version.h.in
@@ -10,7 +10,9 @@
#else
#define PROTOCOL_VERSION @PROTOCOL_VERSION@
#define MYSQL_SERVER_VERSION "@VERSION@"
+#ifndef MYSQL_SERVER_SUFFIX
#define MYSQL_SERVER_SUFFIX "@MYSQL_SERVER_SUFFIX@"
+#endif
#define FRM_VER @DOT_FRM_VERSION@
#define MYSQL_VERSION_ID @MYSQL_VERSION_ID@
#define MYSQL_PORT @MYSQL_TCP_PORT@
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index 9f0ea9d7988..0898b3d576f 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -252,4 +252,5 @@
#define ER_VAR_CANT_BE_READ 1233
#define ER_CANT_USE_OPTION_HERE 1234
#define ER_NOT_SUPPORTED_YET 1235
-#define ER_ERROR_MESSAGES 236
+#define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
+#define ER_ERROR_MESSAGES 237
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index c6f88c1fb60..32148baf1d3 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -465,11 +465,7 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
if (mysql->net.vio == 0)
{ /* Do reconnect if possible */
if (mysql_reconnect(mysql))
- {
- net->last_errno=CR_SERVER_GONE_ERROR;
- strmov(net->last_error,ER(net->last_errno));
goto end;
- }
}
if (mysql->status != MYSQL_STATUS_READY)
{
@@ -490,8 +486,9 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
{
DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno));
end_server(mysql);
- if (mysql_reconnect(mysql) ||
- net_write_command(net,(uchar) command,arg,
+ if (mysql_reconnect(mysql))
+ goto end;
+ if (net_write_command(net,(uchar) command,arg,
length ? length : (ulong) strlen(arg)))
{
net->last_errno=CR_SERVER_GONE_ERROR;
@@ -1136,17 +1133,22 @@ int STDCALL mysql_reads_from_master_enabled(MYSQL* mysql)
return !(mysql->options.no_master_reads);
}
-/* We may get an error while doing replication internals.
- In this case, we add a special explanation to the original
- error
+
+/*
+ We may get an error while doing replication internals.
+ In this case, we add a special explanation to the original
+ error
*/
-static inline void expand_error(MYSQL* mysql, int error)
+
+static void expand_error(MYSQL* mysql, int error)
{
char tmp[MYSQL_ERRMSG_SIZE];
- char* p, *tmp_end;
- tmp_end = strnmov(tmp, mysql->net.last_error, MYSQL_ERRMSG_SIZE);
- p = strnmov(mysql->net.last_error, ER(error), MYSQL_ERRMSG_SIZE);
- memcpy(p, tmp, tmp_end - tmp);
+ char *p;
+ uint err_length;
+ strmake(tmp, mysql->net.last_error, MYSQL_ERRMSG_SIZE-1);
+ p = strmake(mysql->net.last_error, ER(error), MYSQL_ERRMSG_SIZE-1);
+ err_length= (uint) (p - mysql->net.last_error);
+ strmake(p, tmp, MYSQL_ERRMSG_SIZE-1 - err_length);
mysql->net.last_errno = error;
}
@@ -1155,7 +1157,7 @@ static inline void expand_error(MYSQL* mysql, int error)
read the given result and row
*/
-static inline int get_master(MYSQL* mysql, MYSQL_RES* res, MYSQL_ROW row)
+static int get_master(MYSQL* mysql, MYSQL_RES* res, MYSQL_ROW row)
{
MYSQL* master;
if (mysql_num_fields(res) < 3)
@@ -1174,7 +1176,7 @@ static inline int get_master(MYSQL* mysql, MYSQL_RES* res, MYSQL_ROW row)
retrieve all the slaves
*/
-static inline int get_slaves_from_master(MYSQL* mysql)
+static int get_slaves_from_master(MYSQL* mysql)
{
MYSQL_RES* res = 0;
MYSQL_ROW row;
@@ -1239,6 +1241,7 @@ err:
return error;
}
+
int STDCALL mysql_rpl_probe(MYSQL* mysql)
{
MYSQL_RES* res = 0;
@@ -1620,7 +1623,11 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (mysql->options.named_pipe ||
(host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) ||
(unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE)))
+ {
+ net->last_errno= CR_SERVER_LOST;
+ strmov(net->last_error,ER(net->last_errno));
goto error; /* User only requested named pipes */
+ }
/* Try also with TCP/IP */
}
else
@@ -1669,9 +1676,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
&tmp_errno);
if (!hp)
{
+ my_gethostbyname_r_free();
net->last_errno=CR_UNKNOWN_HOST;
sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, tmp_errno);
- my_gethostbyname_r_free();
goto error;
}
memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
@@ -1853,7 +1860,11 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (client_flag & CLIENT_SSL)
{
if (my_net_write(net,buff,(uint) (2)) || net_flush(net))
+ {
+ net->last_errno= CR_SERVER_LOST;
+ strmov(net->last_error,ER(net->last_errno));
goto error;
+ }
/* Do the SSL layering. */
DBUG_PRINT("info", ("IO layer change in progress..."));
DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context_));
@@ -1883,8 +1894,13 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
mysql->db=my_strdup(db,MYF(MY_WME));
db=0;
}
- if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net) ||
- net_safe_read(mysql) == packet_error)
+ if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net))
+ {
+ net->last_errno= CR_SERVER_LOST;
+ strmov(net->last_error,ER(net->last_errno));
+ goto error;
+ }
+ if (net_safe_read(mysql) == packet_error)
goto error;
if (client_flag & CLIENT_COMPRESS) /* We will use compression */
net->compress=1;
@@ -1952,6 +1968,8 @@ static my_bool mysql_reconnect(MYSQL *mysql)
{
/* Allow reconnect next time */
mysql->server_status&= ~SERVER_STATUS_IN_TRANS;
+ mysql->net.last_errno=CR_SERVER_GONE_ERROR;
+ strmov(mysql->net.last_error,ER(mysql->net.last_errno));
DBUG_RETURN(1);
}
mysql_init(&tmp_mysql);
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index a4e9b0ea08a..770a827f103 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -93,7 +93,7 @@ FIND=find
GCOV=`which gcov | $SED q`
PRINTF=printf
RM=rm
-TIME=time
+TIME=`which time | $SED q`
TR=tr
XARGS=`which xargs | $SED q`
@@ -391,7 +391,12 @@ if [ x$SOURCE_DIST = x1 ] ; then
CHARSETSDIR="$BASEDIR/sql/share/charsets"
INSTALL_DB="./install_test_db"
else
- MYSQLD="$BASEDIR/bin/mysqld"
+ if test -x "$BASEDIR/libexec/mysqld"
+ then
+ MYSQLD="$BASEDIR/libexec/mysqld"
+ else
+ MYSQLD="$BASEDIR/bin/mysqld"
+ fi
MYSQL_TEST="$BASEDIR/bin/mysqltest"
MYSQLADMIN="$BASEDIR/bin/mysqladmin"
MYSQL_MANAGER="$BASEDIR/bin/mysqlmanager"
@@ -530,6 +535,18 @@ total_inc () {
TOT_TEST=`$EXPR $TOT_TEST + 1`
}
+
+skip_test() {
+ USERT=" ...."
+ SYST=" ...."
+ REALT=" ...."
+ timestr="$USERT $SYST $REALT"
+ pname=`$ECHO "$1 "|$CUT -c 1-24`
+ RES="$pname $timestr"
+ skip_inc
+ $ECHO "$RES$RES_SPACE [ skipped ]"
+}
+
report_stats () {
if [ $TOT_FAIL = 0 ]; then
$ECHO "All $TOT_TEST tests were successful."
@@ -567,7 +584,7 @@ mysql_install_db () {
for slave_num in 1 2 ;
do
- $RM -rf var/slave$slave_num-data/
+ $RM -rf var/slave$slave_num-data
mkdir -p var/slave$slave_num-data/mysql
mkdir -p var/slave$slave_num-data/test
cp var/slave-data/mysql/* var/slave$slave_num-data/mysql
@@ -1026,7 +1043,8 @@ run_testcase ()
SKIP_THIS_TEST=`$EXPR \( $tname : "$SKIP_TEST" \) != 0`
if [ x$SKIP_THIS_TEST = x1 ] ;
then
- return;
+ skip_test $tname;
+ return;
fi
fi
@@ -1034,21 +1052,15 @@ run_testcase ()
DO_THIS_TEST=`$EXPR \( $tname : "$DO_TEST" \) != 0`
if [ x$DO_THIS_TEST = x0 ] ;
then
- return;
+ skip_test $tname;
+ return;
fi
fi
if [ x${NO_SLAVE}x$SKIP_SLAVE = x1x0 ] ;
then
- USERT=" ...."
- SYST=" ...."
- REALT=" ...."
- timestr="$USERT $SYST $REALT"
- pname=`$ECHO "$tname "|$CUT -c 1-24`
- RES="$pname $timestr"
- skip_inc
- $ECHO "$RES$RES_SPACE [ skipped ]"
+ skip_test $tname;
return
fi
diff --git a/mysql-test/r/rpl_empty_master_crash.result b/mysql-test/r/rpl_empty_master_crash.result
index 5a82df19ef5..19e2bf28dcd 100644
--- a/mysql-test/r/rpl_empty_master_crash.result
+++ b/mysql-test/r/rpl_empty_master_crash.result
@@ -8,4 +8,6 @@ drop table if exists t1;
show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
load table t1 from master;
-Error in fetch_master_table
+Error connecting to master: Master is not configured
+load table t1 from master;
+Error from master: 'Table 'test.t1' doesn't exist'
diff --git a/mysql-test/r/rpl000014.result b/mysql-test/r/rpl_log_pos.result
index 8e0dfc3a117..6883da76180 100644
--- a/mysql-test/r/rpl000014.result
+++ b/mysql-test/r/rpl_log_pos.result
@@ -19,22 +19,24 @@ Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Lo
slave start;
show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 73 slave-relay-bin.001 4 master-bin.001 Yes Yes 0 0 73 4
+127.0.0.1 root MASTER_PORT 1 master-bin.001 73 slave-relay-bin.001 4 master-bin.001 No Yes 0 0 73 4
change master to master_log_pos=173;
+slave start;
show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 173 slave-relay-bin.001 4 master-bin.001 Yes Yes 0 0 173 4
+127.0.0.1 root MASTER_PORT 1 master-bin.001 173 slave-relay-bin.001 4 master-bin.001 No Yes 0 0 173 4
show master status;
File Position Binlog_do_db Binlog_ignore_db
master-bin.001 79
-create table if not exists foo(n int);
-drop table if exists foo;
-create table foo (n int);
-insert into foo values (1),(2),(3);
+create table if not exists t1 (n int);
+drop table if exists t1;
+create table t1 (n int);
+insert into t1 values (1),(2),(3);
change master to master_log_pos=79;
-select * from foo;
+slave start;
+select * from t1;
n
1
2
3
-drop table foo;
+drop table t1;
diff --git a/mysql-test/t/rpl_empty_master_crash.test b/mysql-test/t/rpl_empty_master_crash.test
index 7923a29dcf1..afa76ce10bb 100644
--- a/mysql-test/t/rpl_empty_master_crash.test
+++ b/mysql-test/t/rpl_empty_master_crash.test
@@ -1,5 +1,11 @@
source include/master-slave.inc;
drop table if exists t1;
show slave status;
+#
+# Load table should not succeed on the master as this is not a slave
+#
--error 1218
load table t1 from master;
+connection slave;
+--error 1188
+load table t1 from master;
diff --git a/mysql-test/t/rpl000014.test b/mysql-test/t/rpl_log_pos.test
index 0b75314ee6a..cce52dc5daa 100644
--- a/mysql-test/t/rpl000014.test
+++ b/mysql-test/t/rpl_log_pos.test
@@ -1,3 +1,6 @@
+#
+# Testing of setting slave to wrong log position with master_log_pos
+#
source include/master-slave.inc;
show master status;
save_master_pos;
@@ -12,24 +15,28 @@ change master to master_log_pos=73;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
slave start;
+sleep 2;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
change master to master_log_pos=173;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+slave start;
+sleep 2;
show slave status;
connection master;
show master status;
-create table if not exists foo(n int);
-drop table if exists foo;
-create table foo (n int);
-insert into foo values (1),(2),(3);
+create table if not exists t1 (n int);
+drop table if exists t1;
+create table t1 (n int);
+insert into t1 values (1),(2),(3);
save_master_pos;
connection slave;
change master to master_log_pos=79;
+slave start;
sync_with_master;
-select * from foo;
+select * from t1;
connection master;
-drop table foo;
+drop table t1;
save_master_pos;
connection slave;
sync_with_master;
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 6f7fb907ad5..43b3d30915f 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -392,8 +392,8 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
if ((read_length=my_read(info->file,Buffer,(uint) length,info->myflags))
!= (uint) length)
{
- info->error= read_length == (uint) -1 ? -1 :
- (int) (read_length+left_length);
+ info->error= (read_length == (uint) -1 ? -1 :
+ (int) (read_length+left_length));
DBUG_RETURN(1);
}
Count-=length;
@@ -422,6 +422,7 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
{
if (length != (uint) -1)
memcpy(Buffer,info->buffer,(size_t) length);
+ info->pos_in_file= pos_in_file;
info->error= length == (uint) -1 ? -1 : (int) (length+left_length);
info->read_pos=info->read_end=info->buffer;
DBUG_RETURN(1);
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index 21979b99285..344b7ac2251 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -220,7 +220,7 @@ my_off_t my_b_filelength(IO_CACHE *info)
}
else
{
- info->seek_not_done=0;
+ info->seek_not_done=1;
return my_seek(info->file,0L,MY_SEEK_END,MYF(0));
}
}
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index c75b43ad0fc..902b8212cca 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -223,7 +223,8 @@ void thr_end_alarm(thr_alarm_t *alarmed)
printf("Warning: Didn't find alarm %lx in queue of %d alarms\n",
(long) *alarmed, alarm_queue.elements);
#endif
- DBUG_PRINT("warning",("Didn't find alarm %lx in queue\n",*alarmed));
+ DBUG_PRINT("warning",("Didn't find alarm %lx in queue\n",
+ (long) *alarmed));
}
if (alarm_aborted && !alarm_queue.elements)
delete_queue(&alarm_queue);
@@ -244,8 +245,10 @@ sig_handler process_alarm(int sig __attribute__((unused)))
{
sigset_t old_mask;
ALARM *alarm_data;
- DBUG_ENTER("process_alarm");
- DBUG_PRINT("info",("sig: %d active alarms: %d",sig,alarm_queue.elements));
+
+/*
+ This must be first as we can't call DBUG inside an alarm for a normal thread
+*/
#if THR_SERVER_ALARM == THR_CLIENT_ALARM
if (!pthread_equal(pthread_self(),alarm_thread))
@@ -256,17 +259,20 @@ sig_handler process_alarm(int sig __attribute__((unused)))
#ifdef DONT_REMEMBER_SIGNAL
sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */
#endif
- DBUG_VOID_RETURN;
+ return;
}
#endif
-
-#if defined(MAIN) && !defined(__bsdi__)
- printf("process_alarm\n"); fflush(stdout);
-#endif
+ {
#ifndef USE_ALARM_THREAD
pthread_sigmask(SIG_SETMASK,&full_signal_set,&old_mask);
pthread_mutex_lock(&LOCK_alarm);
#endif
+ DBUG_ENTER("process_alarm");
+ DBUG_PRINT("info",("sig: %d active alarms: %d",sig,alarm_queue.elements));
+
+#if defined(MAIN) && !defined(__bsdi__)
+ printf("process_alarm\n"); fflush(stdout);
+#endif
if (alarm_queue.elements)
{
if (alarm_aborted)
@@ -335,6 +341,7 @@ sig_handler process_alarm(int sig __attribute__((unused)))
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
#endif
DBUG_VOID_RETURN;
+ }
}
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 4493c54069f..6de96f0a24a 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -53,8 +53,8 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
pthread_mutex_lock(&mp->global);
if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread))
{
- fprintf(stderr,"safe_mutex: Trying to lock mutex at %s, line %d, when the mutex was already locked at %s, line %d\n",
- file,line,mp->file,mp->line);
+ fprintf(stderr,"safe_mutex: Trying to lock mutex at %s, line %d, when the mutex was already locked at %s, line %d in thread %s\n",
+ file,line,mp->file, mp->line, my_thread_name());
fflush(stderr);
abort();
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index afa821d0bb1..1f7a4013d80 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -437,6 +437,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
ulong data_len;
int result=0;
char buf[LOG_EVENT_HEADER_LEN];
+ DBUG_ENTER("read_log_event");
if (log_lock)
pthread_mutex_lock(log_lock);
@@ -447,17 +448,18 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
will know it can go into cond_wait to be woken up on the next
update to the log.
*/
+ DBUG_PRINT("error",("file->error: %d", file->error));
if (!file->error)
result= LOG_READ_EOF;
else
- result= (file->error > 0 ? LOG_READ_TRUNC: LOG_READ_IO);
+ result= (file->error > 0 ? LOG_READ_TRUNC : LOG_READ_IO);
goto end;
}
data_len= uint4korr(buf + EVENT_LEN_OFFSET);
if (data_len < LOG_EVENT_HEADER_LEN ||
data_len > current_thd->variables.max_allowed_packet)
{
-
+ DBUG_PRINT("error",("data_len: %ld", data_len));
result= ((data_len < LOG_EVENT_HEADER_LEN) ? LOG_READ_BOGUS :
LOG_READ_TOO_LARGE);
goto end;
@@ -469,8 +471,8 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
if (packet->append(file, data_len))
{
/*
- Here we should never hit eof in a non-error condtion
- eof means we are reading the event partially, which should
+ Here we should never hit EOF in a non-error condition.
+ EOF means we are reading the event partially, which should
never happen.
*/
result= file->error >= 0 ? LOG_READ_TRUNC: LOG_READ_IO;
@@ -481,7 +483,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
end:
if (log_lock)
pthread_mutex_unlock(log_lock);
- return result;
+ DBUG_RETURN(result);
}
#endif // MYSQL_CLIENT
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index cf5747b8160..e1a209ec0ec 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -407,20 +407,23 @@ my_bool mc_mysql_reconnect(MYSQL *mysql)
DBUG_ENTER("mc_mysql_reconnect");
if (!mysql->reconnect)
+ {
+ mysql->net.last_errno=CR_SERVER_GONE_ERROR;
+ strmov(mysql->net.last_error, ER(mysql->net.last_errno));
DBUG_RETURN(1);
-
+ }
mc_mysql_init(&tmp_mysql);
tmp_mysql.options=mysql->options;
if (!mc_mysql_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
mysql->db, mysql->port, mysql->unix_socket,
mysql->client_flag, mysql->net.read_timeout))
- {
- tmp_mysql.reconnect=0;
- mc_mysql_close(&tmp_mysql);
- mysql->net.last_errno=CR_SERVER_GONE_ERROR;
- strmov(mysql->net.last_error,ER(mysql->net.last_errno));
- DBUG_RETURN(1);
- }
+ {
+#ifdef NOT_USED
+ mysql->net.last_errno=CR_RECONNECT_FAILED;
+ strmov(mysql->net.last_error, ER(mysql->net.last_errno));
+#endif
+ DBUG_RETURN(1);
+ }
tmp_mysql.free_me=mysql->free_me;
mysql->free_me=0;
bzero((char*) &mysql->options,sizeof(&mysql->options));
@@ -443,11 +446,7 @@ mc_simple_command(MYSQL *mysql,enum enum_server_command command,
if (mysql->net.vio == 0)
{ /* Do reconnect if possible */
if (mc_mysql_reconnect(mysql))
- {
- net->last_errno=CR_SERVER_GONE_ERROR;
- strmov(net->last_error,ER(net->last_errno));
goto end;
- }
}
if (mysql->status != MYSQL_STATUS_READY)
{
@@ -468,8 +467,9 @@ mc_simple_command(MYSQL *mysql,enum enum_server_command command,
{
DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno));
mc_end_server(mysql);
- if (mc_mysql_reconnect(mysql) ||
- net_write_command(net,(uchar) command,arg,
+ if (mc_mysql_reconnect(mysql))
+ goto end;
+ if (net_write_command(net,(uchar) command,arg,
length ? length :(uint) strlen(arg)))
{
net->last_errno=CR_SERVER_GONE_ERROR;
@@ -515,8 +515,6 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
user ? user : "(Null)",
net_read_timeout,
(uint) slave_net_timeout));
- thr_alarm_init(&alarmed);
- thr_alarm(&alarmed, net_read_timeout, &alarm_buff);
net->vio = 0; /* If something goes wrong */
mysql->charset=default_charset_info; /* Set character set */
@@ -527,6 +525,8 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
mysql->reconnect=1; /* Reconnect as default */
mysql->server_status=SERVER_STATUS_AUTOCOMMIT;
+ if (!mysql->options.connect_timeout)
+ mysql->options.connect_timeout= net_read_timeout;
/*
** Grab a socket and connect it to the server
@@ -598,7 +598,11 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
host=LOCAL_HOST;
sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host);
DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port));
- if ((sock = (my_socket) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
+ thr_alarm_init(&alarmed);
+ thr_alarm(&alarmed, net_read_timeout, &alarm_buff);
+ sock = (my_socket) socket(AF_INET,SOCK_STREAM,0);
+ thr_end_alarm(&alarmed);
+ if (sock == SOCKET_ERROR)
{
net->last_errno=CR_IPSOCK_ERROR;
sprintf(net->last_error,ER(net->last_errno),socket_errno);
@@ -641,12 +645,8 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
socket_errno,host));
net->last_errno= CR_CONN_HOST_ERROR;
sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno);
- if (thr_alarm_in_use(&alarmed))
- thr_end_alarm(&alarmed);
goto error;
}
- if (thr_alarm_in_use(&alarmed))
- thr_end_alarm(&alarmed);
}
if (!net->vio || my_net_init(net, net->vio))
@@ -778,7 +778,11 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if (client_flag & CLIENT_SSL)
{
if (my_net_write(net,buff,(uint) (2)) || net_flush(net))
+ {
+ net->last_errno= CR_SERVER_LOST;
+ strmov(net->last_error,ER(net->last_errno));
goto error;
+ }
/* Do the SSL layering. */
DBUG_PRINT("info", ("IO layer change in progress..."));
DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context_));
@@ -808,8 +812,13 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
mysql->db=my_strdup(db,MYF(MY_WME));
db=0;
}
- if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net) ||
- mc_net_safe_read(mysql) == packet_error)
+ if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net))
+ {
+ net->last_errno= CR_SERVER_LOST;
+ strmov(net->last_error,ER(net->last_errno));
+ goto error;
+ }
+ if (mc_net_safe_read(mysql) == packet_error)
goto error;
if (client_flag & CLIENT_COMPRESS) /* We will use compression */
net->compress=1;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 7bd69055f5f..4eb2c24313c 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -293,7 +293,7 @@ inline THD *_current_thd(void)
int mysql_create_db(THD *thd, char *db, uint create_info, bool silent);
int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
-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);
int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists);
int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
bool log_query);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d086dda3e9f..986263bbb6b 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -787,9 +787,12 @@ static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
static sig_handler print_signal_warning(int sig)
{
- if (global_system_variables.log_warnings)
- sql_print_error("Warning: Got signal %d from thread %d",
- sig,my_thread_id());
+ if (!DBUG_IN_USE)
+ {
+ if (global_system_variables.log_warnings)
+ sql_print_error("Warning: Got signal %d from thread %d",
+ sig,my_thread_id());
+ }
#ifdef DONT_REMEMBER_SIGNAL
sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
@@ -1555,6 +1558,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
(void) pthread_cond_signal(&COND_thread_count);
(void) pthread_mutex_unlock(&LOCK_thread_count);
+ (void) pthread_sigmask(SIG_BLOCK,&set,NULL);
for (;;)
{
int error; // Used when debugging
@@ -1608,7 +1612,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
#endif
default:
#ifdef EXTRA_DEBUG
- sql_print_error("Warning: Got signal: %d, error: %d",sig,error); /* purecov: tested */
+ sql_print_error("Warning: Got signal: %d error: %d",sig,error); /* purecov: tested */
#endif
break; /* purecov: tested */
}
diff --git a/sql/net_pkg.cc b/sql/net_pkg.cc
index 52400e02d06..55c9bd3cfab 100644
--- a/sql/net_pkg.cc
+++ b/sql/net_pkg.cc
@@ -37,7 +37,7 @@ void send_error(NET *net, uint sql_errno, const char *err)
{
if (sql_errno)
err=ER(sql_errno);
- else if (!err)
+ else
{
if ((err=net->last_error)[0])
sql_errno=net->last_errno;
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 8c1792a6c8b..da4f75e74b5 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -392,6 +392,9 @@ net_real_write(NET *net,const char *packet,ulong len)
"%s: my_net_write: fcntl returned error %d, aborting thread\n",
my_progname,vio_errno(net->vio));
#endif /* EXTRA_DEBUG */
+#ifdef MYSQL_SERVER
+ net->last_errno=ER_NET_ERROR_ON_WRITE;
+#endif
net->error=2; /* Close socket */
goto end;
}
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 54843f1dfa4..af0628f729b 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -140,41 +140,54 @@ void unregister_slave(THD* thd, bool only_mine, bool need_mutex)
}
+/*
+ Register slave in 'slave_list' hash table
+
+ RETURN VALUES
+ 0 ok
+ 1 Error. Error message sent to client
+*/
+
int register_slave(THD* thd, uchar* packet, uint packet_length)
{
+ int res;
SLAVE_INFO *si;
- int res = 1;
- uchar* p = packet, *p_end = packet + packet_length;
+ uchar *p= packet, *p_end= packet + packet_length;
if (check_access(thd, REPL_SLAVE_ACL, any_db))
return 1;
if (!(si = (SLAVE_INFO*)my_malloc(sizeof(SLAVE_INFO), MYF(MY_WME))))
- goto err;
+ goto err2;
- thd->server_id = si->server_id = uint4korr(p);
- p += 4;
+ thd->server_id= si->server_id= uint4korr(p);
+ p+= 4;
get_object(p,si->host);
get_object(p,si->user);
get_object(p,si->password);
- si->port = uint2korr(p);
+ if (p+10 > p_end)
+ goto err;
+ si->port= uint2korr(p);
p += 2;
- si->rpl_recovery_rank = uint4korr(p);
+ si->rpl_recovery_rank= uint4korr(p);
p += 4;
- if (!(si->master_id = uint4korr(p)))
- si->master_id = server_id;
- si->thd = thd;
- pthread_mutex_lock(&LOCK_slave_list);
+ if (!(si->master_id= uint4korr(p)))
+ si->master_id= server_id;
+ si->thd= thd;
+ pthread_mutex_lock(&LOCK_slave_list);
unregister_slave(thd,0,0);
- res = hash_insert(&slave_list, (byte*) si);
+ res= hash_insert(&slave_list, (byte*) si);
pthread_mutex_unlock(&LOCK_slave_list);
return res;
err:
- if (si)
- my_free((gptr) si, MYF(MY_WME));
- return res;
+ my_free((gptr) si, MYF(MY_WME));
+ my_message(ER_UNKNOWN_ERROR, "Wrong parameters to function register_slave",
+ MYF(0));
+err2:
+ send_error(&thd->net);
+ return 1;
}
static uint32* slave_list_key(SLAVE_INFO* si, uint* len,
@@ -446,6 +459,7 @@ int update_slave_list(MYSQL* mysql)
const char* error=0;
bool have_auth_info;
int port_ind;
+ DBUG_ENTER("update_slave_list");
if (mc_mysql_query(mysql,"SHOW SLAVE HOSTS",0) ||
!(res = mc_mysql_store_result(mysql)))
@@ -506,10 +520,10 @@ err:
mc_mysql_free_result(res);
if (error)
{
- sql_print_error("Error updating slave list:",error);
- return 1;
+ sql_print_error("Error updating slave list: %s",error);
+ DBUG_RETURN(1);
}
- return 0;
+ DBUG_RETURN(0);
}
@@ -622,17 +636,13 @@ int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi)
if (!mi->host || !*mi->host) /* empty host */
{
- DBUG_PRINT("error",("empty hostname"));
+ strmov(mysql->net.last_error, "Master is not configured");
DBUG_RETURN(1);
}
if (!mc_mysql_connect(mysql, mi->host, mi->user, mi->password, 0,
mi->port, 0, 0,
slave_net_timeout))
- {
- sql_print_error("Connection to master failed: %s",
- mc_mysql_error(mysql));
DBUG_RETURN(1);
- }
DBUG_RETURN(0);
}
@@ -649,26 +659,26 @@ static inline void cleanup_mysql_results(MYSQL_RES* db_res,
}
-static inline int fetch_db_tables(THD* thd, MYSQL* mysql, const char* db,
- MYSQL_RES* table_res, MASTER_INFO* mi)
+static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db,
+ MYSQL_RES *table_res, MASTER_INFO *mi)
{
MYSQL_ROW row;
for (row = mc_mysql_fetch_row(table_res); row;
row = mc_mysql_fetch_row(table_res))
{
TABLE_LIST table;
- const char* table_name = row[0];
+ const char* table_name= row[0];
int error;
if (table_rules_on)
{
- table.next = 0;
- table.db = (char*)db;
- table.real_name = (char*)table_name;
- table.updating = 1;
+ table.next= 0;
+ table.db= (char*) db;
+ table.real_name= (char*) table_name;
+ table.updating= 1;
if (!tables_ok(thd, &table))
continue;
}
- if ((error = fetch_master_table(thd, db, table_name, mi, mysql)))
+ if ((error= fetch_master_table(thd, db, table_name, mi, mysql)))
return error;
}
return 0;
@@ -709,7 +719,7 @@ int load_master_data(THD* thd)
if (connect_to_master(thd, &mysql, active_mi))
{
- net_printf(&thd->net, error = ER_CONNECT_TO_MASTER,
+ net_printf(&thd->net, error= ER_CONNECT_TO_MASTER,
mc_mysql_error(&mysql));
goto err;
}
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index 4acb152a22b..18b32447dc9 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -246,3 +246,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index e017b0337c8..d6528753195 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -240,3 +240,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index 5348f96e463..5578ec28532 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -247,3 +247,4 @@
"Variabele '%-.64s' kan alleen worden gewijzigd, niet gelezen",
"Foutieve toepassing/plaatsing van '%s'",
"Deze versie van MySQL ondersteunt nog geen '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index 8a10d0351f5..450b3453b01 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -237,3 +237,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index 161310f05c9..f160be03e89 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -242,3 +242,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index 893a65747b8..c8d92d72b5f 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -237,3 +237,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index 5e886f9a2c9..6de6e911cd0 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -240,3 +240,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index 4f49e1b4e08..6a58bfb6ea8 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -237,3 +237,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index 8cd486b5f63..8da5eb6d8d6 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -239,3 +239,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index 5cd026db0ab..0aa2ce07545 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -237,3 +237,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index 70e4ca55c4c..e81feded9d7 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -239,3 +239,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index 1e659227e0a..45d049e2545 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -237,3 +237,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index 3b4efe7602b..6fd054fa5f2 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -239,3 +239,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index 535087320c6..a241a99b179 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -239,3 +239,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index 7aed210f6e4..7184acf2495 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -241,3 +241,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index 2a635558055..e5de0d85b03 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -237,3 +237,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index 59b913c0a1a..406c1ba3c70 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -241,3 +241,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index 4e8e9508b73..ec6f7d2818c 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -240,3 +240,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index 12b32da0f64..2e14be90bc0 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -245,3 +245,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index c8c33152cc0..fb1ab3c9b7d 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -238,3 +238,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 8c24be8f819..1a352f16225 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -237,3 +237,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt
index 2b54d1f6098..3a8a1abc429 100644
--- a/sql/share/ukrainian/errmsg.txt
+++ b/sql/share/ukrainian/errmsg.txt
@@ -242,3 +242,4 @@
"Variable '%-.64s' can only be set, not read",
"Wrong usage/placement of '%s'",
"This version of MySQL doesn't yet support '%s'",
+"Got fatal error %d: '%-.128s' from master when reading data from binary log",
diff --git a/sql/slave.cc b/sql/slave.cc
index c80b2090592..dc933114e28 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -88,25 +88,16 @@ char* rewrite_db(char* db);
restart these threads
*/
-
void init_thread_mask(int* mask,MASTER_INFO* mi,bool inverse)
{
bool set_io = mi->slave_running, set_sql = mi->rli.slave_running;
- if (inverse)
- {
- /*
- This makes me think of the Russian idiom "I am not I, and this is
- not my horse", which is used to deny reponsibility for
- one's actions.
- */
- set_io = !set_io;
- set_sql = !set_sql;
- }
register int tmp_mask=0;
if (set_io)
tmp_mask |= SLAVE_IO;
if (set_sql)
tmp_mask |= SLAVE_SQL;
+ if (inverse)
+ tmp_mask^= (SLAVE_IO | SLAVE_SQL);
*mask = tmp_mask;
}
@@ -380,6 +371,7 @@ int terminate_slave_threads(MASTER_INFO* mi,int thread_mask,bool skip_lock)
int error,force_all = (thread_mask & SLAVE_FORCE_ALL);
pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
pthread_mutex_t *sql_cond_lock,*io_cond_lock;
+ DBUG_ENTER("terminate_slave_threads");
sql_cond_lock=sql_lock;
io_cond_lock=io_lock;
@@ -396,7 +388,7 @@ int terminate_slave_threads(MASTER_INFO* mi,int thread_mask,bool skip_lock)
&mi->stop_cond,
&mi->slave_running)) &&
!force_all)
- return error;
+ DBUG_RETURN(error);
}
if ((thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL)) && mi->rli.slave_running)
{
@@ -407,9 +399,9 @@ int terminate_slave_threads(MASTER_INFO* mi,int thread_mask,bool skip_lock)
&mi->rli.stop_cond,
&mi->rli.slave_running)) &&
!force_all)
- return error;
+ DBUG_RETURN(error);
}
- return 0;
+ DBUG_RETURN(0);
}
@@ -552,9 +544,13 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
cond_io,&mi->slave_running,
mi);
if (!error && (thread_mask & SLAVE_SQL))
+ {
error=start_slave_thread(handle_slave_sql,lock_sql,lock_cond_sql,
cond_sql,
&mi->rli.slave_running,mi);
+ if (error)
+ terminate_slave_threads(mi, thread_mask & SLAVE_IO, 0);
+ }
DBUG_RETURN(error);
}
@@ -958,54 +954,51 @@ err:
return error;
}
-int fetch_master_table(THD* thd, const char* db_name, const char* table_name,
- MASTER_INFO* mi, MYSQL* mysql)
+int fetch_master_table(THD *thd, const char *db_name, const char *table_name,
+ MASTER_INFO *mi, MYSQL *mysql)
{
- int error = 1;
- int fetch_errno = 0;
- bool called_connected = (mysql != NULL);
- if (!called_connected && !(mysql = mc_mysql_init(NULL)))
- {
- sql_print_error("fetch_master_table: Error in mysql_init()");
- fetch_errno = ER_GET_ERRNO;
- goto err;
- }
+ int error= 1;
+ const char *errmsg=0;
+ bool called_connected= (mysql != NULL);
+ DBUG_ENTER("fetch_master_table");
+ DBUG_PRINT("enter", ("db_name: '%s' table_name: '%s'",
+ db_name,table_name));
if (!called_connected)
- {
+ {
+ if (!(mysql = mc_mysql_init(NULL)))
+ {
+ send_error(&thd->net); // EOM
+ DBUG_RETURN(1);
+ }
if (connect_to_master(thd, mysql, mi))
{
- sql_print_error("Could not connect to master while fetching table\
- '%-64s.%-64s'", db_name, table_name);
- fetch_errno = ER_CONNECT_TO_MASTER;
- goto err;
+ net_printf(&thd->net, ER_CONNECT_TO_MASTER, mc_mysql_error(mysql));
+ mc_mysql_close(mysql);
+ DBUG_RETURN(1);
}
+ if (thd->killed)
+ goto err;
}
- if (thd->killed)
- goto err;
if (request_table_dump(mysql, db_name, table_name))
{
- fetch_errno = ER_GET_ERRNO;
- sql_print_error("fetch_master_table: failed on table dump request ");
+ error= ER_UNKNOWN_ERROR;
+ errmsg= "Failed on table dump request";
goto err;
}
-
if (create_table_from_dump(thd, &mysql->net, db_name,
table_name))
- {
- // create_table_from_dump will have sent the error alread
- sql_print_error("fetch_master_table: failed on create table ");
- goto err;
- }
+ goto err; // create_table_from_dump will have sent the error already
error = 0;
+
err:
- if (mysql && !called_connected)
- mc_mysql_close(mysql);
- if (fetch_errno && thd->net.vio)
- send_error(&thd->net, fetch_errno, "Error in fetch_master_table");
thd->net.no_send_ok = 0; // Clear up garbage after create_table_from_dump
- return error;
+ if (!called_connected)
+ mc_mysql_close(mysql);
+ if (errmsg && thd->net.vio)
+ send_error(&thd->net, error, errmsg);
+ DBUG_RETURN(test(error)); // Return 1 on error
}
@@ -1372,7 +1365,8 @@ int register_slave_on_master(MYSQL* mysql)
if (mc_simple_command(mysql, COM_REGISTER_SLAVE, (char*)packet.ptr(),
packet.length(), 0))
{
- sql_print_error("Error on COM_REGISTER_SLAVE: '%s'",
+ sql_print_error("Error on COM_REGISTER_SLAVE: %d '%s'",
+ mc_mysql_errno(mysql),
mc_mysql_error(mysql));
return 1;
}
@@ -1471,22 +1465,21 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
{
if (!inited)
return -1;
- bool pos_reached = 0;
int event_count = 0;
+ ulong init_abort_pos_wait;
+ DBUG_ENTER("wait_for_pos");
+
pthread_mutex_lock(&data_lock);
- abort_pos_wait=0; // abort only if master info changes during wait
+ // abort only if master info changes during wait
+ init_abort_pos_wait= abort_pos_wait;
- while (!thd->killed || !abort_pos_wait)
+ while (!thd->killed &&
+ init_abort_pos_wait == abort_pos_wait &&
+ mi->slave_running)
{
- int cmp_result;
- if (abort_pos_wait)
- {
- abort_pos_wait=0;
- pthread_mutex_unlock(&data_lock);
- return -1;
- }
+ bool pos_reached;
+ int cmp_result= 0;
DBUG_ASSERT(*master_log_name || master_log_pos == 0);
- cmp_result = 0;
if (*master_log_name)
{
/*
@@ -1512,7 +1505,13 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
event_count++;
}
pthread_mutex_unlock(&data_lock);
- return thd->killed ? -1 : event_count;
+ DBUG_PRINT("exit",("killed: %d abort: %d slave_running: %d",
+ (int) thd->killed,
+ (int) (init_abort_pos_wait != abort_pos_wait),
+ (int) mi->slave_running));
+ DBUG_RETURN((thd->killed || init_abort_pos_wait != abort_pos_wait ||
+ !mi->slave_running) ?
+ -1 : event_count);
}
@@ -1564,28 +1563,23 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed,
void* thread_killed_arg)
{
+ int nap_time;
thr_alarm_t alarmed;
thr_alarm_init(&alarmed);
time_t start_time= time((time_t*) 0);
time_t end_time= start_time+sec;
- ALARM alarm_buff;
- while (start_time < end_time)
+ while ((nap_time= (int) (end_time - start_time)) > 0)
{
- int nap_time = (int) (end_time - start_time);
+ ALARM alarm_buff;
/*
The only reason we are asking for alarm is so that
we will be woken up in case of murder, so if we do not get killed,
set the alarm so it goes off after we wake up naturally
*/
- thr_alarm(&alarmed, 2 * nap_time,&alarm_buff);
+ thr_alarm(&alarmed, 2 * nap_time, &alarm_buff);
sleep(nap_time);
- /*
- If we wake up before the alarm goes off, hit the button
- so it will not wake up the wife and kids :-)
- */
- if (thr_alarm_in_use(&alarmed))
- thr_end_alarm(&alarmed);
+ thr_end_alarm(&alarmed);
if ((*thread_killed)(thd,thread_killed_arg))
return 1;
@@ -1594,6 +1588,7 @@ static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed,
return 0;
}
+
static int request_dump(MYSQL* mysql, MASTER_INFO* mi,
bool *suppress_warnings)
{
@@ -1601,6 +1596,8 @@ static int request_dump(MYSQL* mysql, MASTER_INFO* mi,
int len;
int binlog_flags = 0; // for now
char* logname = mi->master_log_name;
+ DBUG_ENTER("request_dump");
+
// TODO if big log files: Change next to int8store()
int4store(buf, (longlong) mi->master_log_pos);
int2store(buf + 4, binlog_flags);
@@ -1617,12 +1614,13 @@ static int request_dump(MYSQL* mysql, MASTER_INFO* mi,
if (mc_mysql_errno(mysql) == ER_NET_READ_INTERRUPTED)
*suppress_warnings= 1; // Suppress reconnect warning
else
- sql_print_error("Error on COM_BINLOG_DUMP: %s, will retry in %d secs",
- mc_mysql_error(mysql), master_connect_retry);
- return 1;
+ sql_print_error("Error on COM_BINLOG_DUMP: %d %s, will retry in %d secs",
+ mc_mysql_errno(mysql), mc_mysql_error(mysql),
+ master_connect_retry);
+ DBUG_RETURN(1);
}
- return 0;
+ DBUG_RETURN(0);
}
@@ -1895,6 +1893,7 @@ connected:
goto err;
}
+ DBUG_PRINT("info",("Starting reading binary log from master"));
while (!io_slave_killed(thd,mi))
{
bool suppress_warnings= 0;
@@ -1960,7 +1959,8 @@ after reconnect");
if (event_len == packet_error)
{
- if (mc_mysql_errno(mysql) == ER_NET_PACKET_TOO_LARGE)
+ uint mysql_error_number= mc_mysql_errno(mysql);
+ if (mysql_error_number == ER_NET_PACKET_TOO_LARGE)
{
sql_print_error("\
Log entry on master is longer than max_allowed_packet (%ld) on \
@@ -1969,7 +1969,12 @@ max_allowed_packet",
thd->variables.max_allowed_packet);
goto err;
}
-
+ if (mysql_error_number == ER_MASTER_FATAL_ERROR_READING_BINLOG)
+ {
+ sql_print_error(ER(mysql_error_number), mysql_error_number,
+ mc_mysql_error(mysql));
+ goto err;
+ }
thd->proc_info = "Waiting to reconnect after a failed read";
mc_end_server(mysql);
if (retry_count++)
@@ -2535,9 +2540,11 @@ static int connect_to_master(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
suppress_warnings= 0;
sql_print_error("Slave I/O thread: error connecting to master \
'%s@%s:%d': \
-Error: '%s' errno: %d retry-time: %d",mi->user,mi->host,mi->port,
+Error: '%s' errno: %d retry-time: %d retries: %d",
+ mi->user,mi->host,mi->port,
mc_mysql_error(mysql), last_errno,
- mi->connect_retry);
+ mi->connect_retry,
+ master_retry_count);
}
/*
By default we try forever. The reason is that failure will trigger
diff --git a/sql/slave.h b/sql/slave.h
index c59ab03c275..790205a1105 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -152,6 +152,7 @@ typedef struct st_relay_log_info
errors, and have been manually applied by DBA already.
*/
volatile uint32 slave_skip_counter;
+ volatile ulong abort_pos_wait; /* Incremented on change master */
pthread_mutex_t log_space_lock;
pthread_cond_t log_space_cond;
THD * sql_thd;
@@ -165,13 +166,12 @@ typedef struct st_relay_log_info
bool inited;
volatile bool abort_slave, slave_running;
bool log_pos_current;
- bool abort_pos_wait;
bool skip_log_purge;
st_relay_log_info()
- :info_fd(-1),cur_log_fd(-1), cur_log_old_open_count(0),
+ :info_fd(-1),cur_log_fd(-1), cur_log_old_open_count(0), abort_pos_wait(0),
inited(0), abort_slave(0), slave_running(0), log_pos_current(0),
- abort_pos_wait(0), skip_log_purge(0)
+ skip_log_purge(0)
{
relay_log_name[0] = master_log_name[0] = 0;
bzero(&info_file,sizeof(info_file));
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index e58c7493a0f..50e0ea9d5c8 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -430,7 +430,7 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
{
if (field->type() == FIELD_TYPE_TIMESTAMP)
((Field_timestamp*) field)->set_time();
- else
+ else if (field != table->next_number_field)
thd->cuted_fields++;
}
continue;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index fa6384d93a6..f93b12d0565 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -889,9 +889,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
case COM_REGISTER_SLAVE:
{
- if (register_slave(thd, (uchar*)packet, packet_length))
- send_error(&thd->net);
- else
+ if (!register_slave(thd, (uchar*)packet, packet_length))
send_ok(&thd->net);
break;
}
@@ -1077,6 +1075,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
ulong pos;
ushort flags;
uint32 slave_server_id;
+ /* TODO: The following has to be changed to an 8 byte integer */
pos = uint4korr(packet);
flags = uint2korr(packet + 4);
pthread_mutex_lock(&LOCK_server_id);
@@ -1084,7 +1083,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
kill_zombie_dump_threads(slave_server_id = uint4korr(packet+6));
thd->server_id = slave_server_id;
pthread_mutex_unlock(&LOCK_server_id);
- mysql_binlog_send(thd, thd->strdup(packet + 10), pos, flags);
+ mysql_binlog_send(thd, thd->strdup(packet + 10), (my_off_t) pos, flags);
unregister_slave(thd,1,1);
// fake COM_QUIT -- if we get here, the thread needs to terminate
error = TRUE;
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);