Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
9b6df03c
Commit
9b6df03c
authored
Jun 08, 2002
by
monty@bitch.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a lot of DBUG_xxx statements to be able to find replication bug.
Fixed critical bug on 64 bit systems. Cleanups
parent
23e9db94
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
134 additions
and
75 deletions
+134
-75
BUILD/compile-solaris-sparc-purify
BUILD/compile-solaris-sparc-purify
+16
-3
sql/log_event.cc
sql/log_event.cc
+17
-9
sql/opt_range.h
sql/opt_range.h
+9
-1
sql/repl_failsafe.cc
sql/repl_failsafe.cc
+3
-2
sql/slave.cc
sql/slave.cc
+77
-50
sql/sql_repl.cc
sql/sql_repl.cc
+12
-10
No files found.
BUILD/compile-solaris-sparc-purify
View file @
9b6df03c
#! /bin/sh
#! /bin/sh
while
test
$#
-gt
0
do
case
"
$1
"
in
--debug
)
EXTRA_CONFIG_FLAGS
=
--with-debug
;
shift
;;
-h
|
--help
)
cat
<<
EOF
; exit 0 ;;
Usage:
$0
[-h|-n] [configure-options]
--debug Compile with DBUG enabled
EOF
*
)
echo
"No such option '
$1
'"
;
exit
;;
esac
done
gmake
-k
clean
||
true
gmake
-k
clean
||
true
/bin/rm
-f
*
/.deps/
*
.P config.cache
/bin/rm
-f
*
/.deps/
*
.P config.cache
aclocal
&&
autoheader
&&
aclocal
&&
automake
&&
autoconf
aclocal
&&
autoheader
&&
aclocal
&&
automake
&&
autoconf
(
cd
bdb/dist
&&
sh s_all
)
(
cd
bdb/dist
&&
sh s_all
)
(
cd
innobase
&&
aclocal
&&
autoheader
&&
aclocal
&&
automake
&&
autoconf
)
(
cd
innobase
&&
aclocal
&&
autoheader
&&
aclocal
&&
automake
&&
autoconf
)
CFLAGS
=
"-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -DHAVE_purify -DEXTRA_DEBUG -O2"
CXX
=
gcc
CXXLD
=
g++
CXXFLAGS
=
"-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -DHAVE_purify -DEXTRA_DEBUG -O2"
./configure
--prefix
=
/usr/local/mysql
--enable-assembler
--with-extra-charsets
=
complex
--enable-thread-safe-client
--with-berkeley-db
--with-innodb
CFLAGS
=
"-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -DHAVE_purify -DEXTRA_DEBUG -O2"
CXX
=
gcc
CXXLD
=
g++
CXXFLAGS
=
"-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -DHAVE_purify -DEXTRA_DEBUG -O2"
./configure
--prefix
=
/usr/local/mysql
--enable-assembler
--with-extra-charsets
=
complex
--enable-thread-safe-client
--with-berkeley-db
--with-innodb
$EXTRA_CONFIG_FLAGS
gmake
-j
4
gmake
-j
4
cd
sql
;
rm
mysqld
;
cd
sql
;
mv
mysqld mysqld-org
;
make
CXXLD
=
"purify -best-effort g++"
mysqld
;
mv
mysqld mysqld-purify
make
CXXLD
=
"purify -best-effort g++"
mysqld
;
mv
mysqld mysqld-purify
make
CXXLD
=
"quantify -best-effort g++"
mysqld
;
mv
mysqld mysqld-quantify
make
CXXLD
=
"quantify -best-effort g++"
mysqld
;
mv
mysqld mysqld-quantify
make
CXXLD
=
"purecov -best-effort g++"
mysqld
;
mv
mysqld mysqld-purecov
make
CXXLD
=
"purecov -best-effort g++"
mysqld
;
mv
mysqld mysqld-purecov
mv
mysqld-org mysqld
sql/log_event.cc
View file @
9b6df03c
...
@@ -1240,8 +1240,9 @@ Slave_log_event::Slave_log_event(THD* thd_arg,
...
@@ -1240,8 +1240,9 @@ Slave_log_event::Slave_log_event(THD* thd_arg,
struct
st_relay_log_info
*
rli
)
:
struct
st_relay_log_info
*
rli
)
:
Log_event
(
thd_arg
),
mem_pool
(
0
),
master_host
(
0
)
Log_event
(
thd_arg
),
mem_pool
(
0
),
master_host
(
0
)
{
{
DBUG_ENTER
(
"Slave_log_event"
);
if
(
!
rli
->
inited
)
if
(
!
rli
->
inited
)
return
;
DBUG_VOID_RETURN
;
MASTER_INFO
*
mi
=
rli
->
mi
;
MASTER_INFO
*
mi
=
rli
->
mi
;
// TODO: re-write this better without holding both locks at the same time
// TODO: re-write this better without holding both locks at the same time
...
@@ -1259,11 +1260,14 @@ Slave_log_event::Slave_log_event(THD* thd_arg,
...
@@ -1259,11 +1260,14 @@ Slave_log_event::Slave_log_event(THD* thd_arg,
memcpy
(
master_log
,
rli
->
master_log_name
,
master_log_len
+
1
);
memcpy
(
master_log
,
rli
->
master_log_name
,
master_log_len
+
1
);
master_port
=
mi
->
port
;
master_port
=
mi
->
port
;
master_pos
=
rli
->
master_log_pos
;
master_pos
=
rli
->
master_log_pos
;
DBUG_PRINT
(
"info"
,
(
"master_log: %s pos: %d"
,
master_log
,
(
ulong
)
master_pos
));
}
}
else
else
sql_print_error
(
"Out of memory while recording slave event"
);
sql_print_error
(
"Out of memory while recording slave event"
);
pthread_mutex_unlock
(
&
rli
->
data_lock
);
pthread_mutex_unlock
(
&
rli
->
data_lock
);
pthread_mutex_unlock
(
&
mi
->
data_lock
);
pthread_mutex_unlock
(
&
mi
->
data_lock
);
DBUG_VOID_RETURN
;
}
}
...
@@ -1284,8 +1288,8 @@ void Slave_log_event::print(FILE* file, bool short_form, char* last_db)
...
@@ -1284,8 +1288,8 @@ void Slave_log_event::print(FILE* file, bool short_form, char* last_db)
return
;
return
;
print_header
(
file
);
print_header
(
file
);
fputc
(
'\n'
,
file
);
fputc
(
'\n'
,
file
);
fprintf
(
file
,
"Slave: master_host
='%s' master_port=%d
\
fprintf
(
file
,
"Slave: master_host
: '%s' master_port: %d
\
master_log=%s master_pos=
%s
\n
"
,
master_log: '%s' master_pos:
%s
\n
"
,
master_host
,
master_port
,
master_log
,
llstr
(
master_pos
,
llbuff
));
master_host
,
master_port
,
master_log
,
llstr
(
master_pos
,
llbuff
));
}
}
...
@@ -1791,9 +1795,13 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
...
@@ -1791,9 +1795,13 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
{
{
bool
rotate_binlog
=
0
,
write_slave_event
=
0
;
bool
rotate_binlog
=
0
,
write_slave_event
=
0
;
char
*
log_name
=
rli
->
master_log_name
;
char
*
log_name
=
rli
->
master_log_name
;
DBUG_ENTER
(
"Rotate_log_event::exec_event"
);
pthread_mutex_lock
(
&
rli
->
data_lock
);
pthread_mutex_lock
(
&
rli
->
data_lock
);
// TODO: probably needs re-write
/*
// rotate local binlog only if the name of remote has changed
TODO: probably needs re-write
rotate local binlog only if the name of remote has changed
*/
if
(
!*
log_name
||
!
(
log_name
[
ident_len
]
==
0
&&
if
(
!*
log_name
||
!
(
log_name
[
ident_len
]
==
0
&&
!
memcmp
(
log_name
,
new_log_ident
,
ident_len
)))
!
memcmp
(
log_name
,
new_log_ident
,
ident_len
)))
{
{
...
@@ -1801,7 +1809,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
...
@@ -1801,7 +1809,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
&&
mysql_bin_log
.
is_open
());
&&
mysql_bin_log
.
is_open
());
rotate_binlog
=
(
*
log_name
&&
write_slave_event
);
rotate_binlog
=
(
*
log_name
&&
write_slave_event
);
if
(
ident_len
>=
sizeof
(
rli
->
master_log_name
))
if
(
ident_len
>=
sizeof
(
rli
->
master_log_name
))
return
1
;
DBUG_RETURN
(
1
)
;
memcpy
(
log_name
,
new_log_ident
,
ident_len
);
memcpy
(
log_name
,
new_log_ident
,
ident_len
);
log_name
[
ident_len
]
=
0
;
log_name
[
ident_len
]
=
0
;
}
}
...
@@ -1812,6 +1820,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
...
@@ -1812,6 +1820,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
mysql_bin_log
.
new_file
();
mysql_bin_log
.
new_file
();
rli
->
master_log_pos
=
4
;
rli
->
master_log_pos
=
4
;
}
}
DBUG_PRINT
(
"info"
,
(
"master_log_pos: %d"
,
(
ulong
)
rli
->
master_log_pos
));
pthread_cond_broadcast
(
&
rli
->
data_cond
);
pthread_cond_broadcast
(
&
rli
->
data_cond
);
pthread_mutex_unlock
(
&
rli
->
data_lock
);
pthread_mutex_unlock
(
&
rli
->
data_lock
);
flush_relay_log_info
(
rli
);
flush_relay_log_info
(
rli
);
...
@@ -1826,13 +1835,12 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
...
@@ -1826,13 +1835,12 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
mysql_bin_log
.
write
(
&
s
);
mysql_bin_log
.
write
(
&
s
);
}
}
}
}
return
0
;
DBUG_RETURN
(
0
)
;
}
}
int
Intvar_log_event
::
exec_event
(
struct
st_relay_log_info
*
rli
)
int
Intvar_log_event
::
exec_event
(
struct
st_relay_log_info
*
rli
)
{
{
switch
(
type
)
switch
(
type
)
{
{
case
LAST_INSERT_ID_EVENT
:
case
LAST_INSERT_ID_EVENT
:
thd
->
last_insert_id_used
=
1
;
thd
->
last_insert_id_used
=
1
;
thd
->
last_insert_id
=
val
;
thd
->
last_insert_id
=
val
;
...
...
sql/opt_range.h
View file @
9b6df03c
...
@@ -38,10 +38,14 @@ typedef struct st_key_part {
...
@@ -38,10 +38,14 @@ typedef struct st_key_part {
Field
*
field
;
Field
*
field
;
}
KEY_PART
;
}
KEY_PART
;
class
QUICK_RANGE
:
public
Sql_alloc
{
class
QUICK_RANGE
:
public
Sql_alloc
{
public:
public:
char
*
min_key
,
*
max_key
;
char
*
min_key
,
*
max_key
;
uint16
min_length
,
max_length
,
flag
;
uint16
min_length
,
max_length
,
flag
;
#ifdef HAVE_purify
uint16
dummy
;
/* Avoid warnings on 'flag' */
#endif
QUICK_RANGE
();
/* Full range */
QUICK_RANGE
();
/* Full range */
QUICK_RANGE
(
const
char
*
min_key_arg
,
uint
min_length_arg
,
QUICK_RANGE
(
const
char
*
min_key_arg
,
uint
min_length_arg
,
const
char
*
max_key_arg
,
uint
max_length_arg
,
const
char
*
max_key_arg
,
uint
max_length_arg
,
...
@@ -51,7 +55,11 @@ class QUICK_RANGE :public Sql_alloc {
...
@@ -51,7 +55,11 @@ class QUICK_RANGE :public Sql_alloc {
min_length
((
uint16
)
min_length_arg
),
min_length
((
uint16
)
min_length_arg
),
max_length
((
uint16
)
max_length_arg
),
max_length
((
uint16
)
max_length_arg
),
flag
((
uint16
)
flag_arg
)
flag
((
uint16
)
flag_arg
)
{}
{
#ifdef HAVE_purify
dummy
=
0
;
#endif
}
};
};
...
...
sql/repl_failsafe.cc
View file @
9b6df03c
...
@@ -811,8 +811,9 @@ int load_master_data(THD* thd)
...
@@ -811,8 +811,9 @@ int load_master_data(THD* thd)
strmake
(
active_mi
->
master_log_name
,
row
[
0
],
strmake
(
active_mi
->
master_log_name
,
row
[
0
],
sizeof
(
active_mi
->
master_log_name
));
sizeof
(
active_mi
->
master_log_name
));
active_mi
->
master_log_pos
=
strtoull
(
row
[
1
],
(
char
**
)
0
,
10
);
active_mi
->
master_log_pos
=
strtoull
(
row
[
1
],
(
char
**
)
0
,
10
);
if
(
active_mi
->
master_log_pos
<
4
)
// don't hit the magic number
active_mi
->
master_log_pos
=
4
;
// don't hit the magic number
if
(
active_mi
->
master_log_pos
<
BIN_LOG_HEADER_SIZE
)
active_mi
->
master_log_pos
=
BIN_LOG_HEADER_SIZE
;
active_mi
->
rli
.
pending
=
0
;
active_mi
->
rli
.
pending
=
0
;
flush_master_info
(
active_mi
);
flush_master_info
(
active_mi
);
}
}
...
...
sql/slave.cc
View file @
9b6df03c
...
@@ -119,6 +119,7 @@ void unlock_slave_threads(MASTER_INFO* mi)
...
@@ -119,6 +119,7 @@ void unlock_slave_threads(MASTER_INFO* mi)
int
init_slave
()
int
init_slave
()
{
{
DBUG_ENTER
(
"init_slave"
);
// TODO (multi-master): replace this with list initialization
// TODO (multi-master): replace this with list initialization
active_mi
=
&
main_mi
;
active_mi
=
&
main_mi
;
...
@@ -129,8 +130,10 @@ int init_slave()
...
@@ -129,8 +130,10 @@ int init_slave()
*/
*/
if
(
server_id
&&
!
master_host
)
if
(
server_id
&&
!
master_host
)
{
{
// TODO: re-write this to interate through the list of files
/*
// for multi-master
TODO: re-write this to interate through the list of files
for multi-master
*/
char
fname
[
FN_REFLEN
+
128
];
char
fname
[
FN_REFLEN
+
128
];
MY_STAT
stat_area
;
MY_STAT
stat_area
;
fn_format
(
fname
,
master_info_file
,
mysql_data_home
,
""
,
4
+
16
+
32
);
fn_format
(
fname
,
master_info_file
,
mysql_data_home
,
""
,
4
+
16
+
32
);
...
@@ -141,21 +144,24 @@ int init_slave()
...
@@ -141,21 +144,24 @@ int init_slave()
// slave thread
// slave thread
if
(
master_host
)
if
(
master_host
)
{
{
if
(
!
opt_skip_slave_start
&&
start_slave_threads
(
1
/* need mutex */
,
if
(
!
opt_skip_slave_start
)
{
if
(
start_slave_threads
(
1
/* need mutex */
,
0
/* no wait for start*/
,
0
/* no wait for start*/
,
active_mi
,
active_mi
,
master_info_file
,
master_info_file
,
relay_log_info_file
,
relay_log_info_file
,
SLAVE_IO
|
SLAVE_SQL
SLAVE_IO
|
SLAVE_SQL
))
))
sql_print_error
(
"Warning: Can't create threads to handle slave"
);
sql_print_error
(
"Warning: Can't create threads to handle slave"
);
else
if
(
opt_skip_slave_start
)
}
if
(
init_master_info
(
active_mi
,
master_info_file
,
relay_log_info_file
))
else
if
(
init_master_info
(
active_mi
,
master_info_file
,
relay_log_info_file
))
sql_print_error
(
"Warning: failed to initialized master info"
);
sql_print_error
(
"Warning: failed to initialized master info"
);
}
}
return
0
;
DBUG_RETURN
(
0
)
;
}
}
static
void
free_table_ent
(
TABLE_RULE_ENT
*
e
)
static
void
free_table_ent
(
TABLE_RULE_ENT
*
e
)
{
{
my_free
((
gptr
)
e
,
MYF
(
0
));
my_free
((
gptr
)
e
,
MYF
(
0
));
...
@@ -495,6 +501,7 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
...
@@ -495,6 +501,7 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
pthread_mutex_t
*
lock_io
=
0
,
*
lock_sql
=
0
,
*
lock_cond_io
=
0
,
*
lock_cond_sql
=
0
;
pthread_mutex_t
*
lock_io
=
0
,
*
lock_sql
=
0
,
*
lock_cond_io
=
0
,
*
lock_cond_sql
=
0
;
pthread_cond_t
*
cond_io
=
0
,
*
cond_sql
=
0
;
pthread_cond_t
*
cond_io
=
0
,
*
cond_sql
=
0
;
int
error
=
0
;
int
error
=
0
;
DBUG_ENTER
(
"start_slave_threads"
);
if
(
need_slave_mutex
)
if
(
need_slave_mutex
)
{
{
...
@@ -509,21 +516,20 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
...
@@ -509,21 +516,20 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
lock_cond_sql
=
&
mi
->
rli
.
run_lock
;
lock_cond_sql
=
&
mi
->
rli
.
run_lock
;
}
}
if
(
init_master_info
(
mi
,
master_info_fname
,
slave_info_fname
))
if
(
init_master_info
(
mi
,
master_info_fname
,
slave_info_fname
))
return
ER_MASTER_INFO
;
DBUG_RETURN
(
ER_MASTER_INFO
)
;
if
(
(
thread_mask
&
SLAVE_IO
)
&&
if
(
thread_mask
&
SLAVE_IO
)
(
error
=
start_slave_thread
(
handle_slave_io
,
lock_io
,
lock_cond_io
,
error
=
start_slave_thread
(
handle_slave_io
,
lock_io
,
lock_cond_io
,
cond_io
,
&
mi
->
slave_running
,
cond_io
,
&
mi
->
slave_running
,
mi
)))
mi
);
return
error
;
if
(
!
error
&&
(
thread_mask
&
SLAVE_SQL
))
if
((
thread_mask
&
SLAVE_SQL
)
&&
error
=
start_slave_thread
(
handle_slave_sql
,
lock_sql
,
lock_cond_sql
,
(
error
=
start_slave_thread
(
handle_slave_sql
,
lock_sql
,
lock_cond_sql
,
cond_sql
,
cond_sql
,
&
mi
->
rli
.
slave_running
,
mi
)))
&
mi
->
rli
.
slave_running
,
mi
);
return
error
;
DBUG_RETURN
(
error
);
return
0
;
}
}
void
init_table_rule_hash
(
HASH
*
h
,
bool
*
h_inited
)
void
init_table_rule_hash
(
HASH
*
h
,
bool
*
h_inited
)
{
{
hash_init
(
h
,
TABLE_RULE_HASH_SIZE
,
0
,
0
,
hash_init
(
h
,
TABLE_RULE_HASH_SIZE
,
0
,
0
,
...
@@ -1083,20 +1089,23 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
...
@@ -1083,20 +1089,23 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
}
}
rli
->
info_fd
=
info_fd
;
rli
->
info_fd
=
info_fd
;
int
relay_log_pos
,
master_log_pos
;
if
(
init_strvar_from_file
(
rli
->
relay_log_name
,
if
(
init_strvar_from_file
(
rli
->
relay_log_name
,
sizeof
(
rli
->
relay_log_name
),
&
rli
->
info_file
,
sizeof
(
rli
->
relay_log_name
),
&
rli
->
info_file
,
""
)
||
""
)
||
init_intvar_from_file
(
(
int
*
)
&
rli
->
relay_log_pos
,
init_intvar_from_file
(
&
relay_log_pos
,
&
rli
->
info_file
,
BIN_LOG_HEADER_SIZE
)
||
&
rli
->
info_file
,
BIN_LOG_HEADER_SIZE
)
||
init_strvar_from_file
(
rli
->
master_log_name
,
init_strvar_from_file
(
rli
->
master_log_name
,
sizeof
(
rli
->
master_log_name
),
&
rli
->
info_file
,
sizeof
(
rli
->
master_log_name
),
&
rli
->
info_file
,
""
)
||
""
)
||
init_intvar_from_file
((
int
*
)
&
rli
->
master_log_pos
,
init_intvar_from_file
(
&
master_log_pos
,
&
rli
->
info_file
,
0
))
&
rli
->
info_file
,
0
))
{
{
msg
=
"Error reading slave log configuration"
;
msg
=
"Error reading slave log configuration"
;
goto
err
;
goto
err
;
}
}
rli
->
relay_log_pos
=
relay_log_pos
;
rli
->
master_log_pos
=
master_log_pos
;
if
(
init_relay_log_pos
(
rli
,
0
/* log already inited */
,
if
(
init_relay_log_pos
(
rli
,
0
/* log already inited */
,
0
/* pos already inited */
,
0
/* pos already inited */
,
0
/* no data lock*/
,
0
/* no data lock*/
,
...
@@ -1252,25 +1261,36 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
...
@@ -1252,25 +1261,36 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
goto
err
;
goto
err
;
mi
->
fd
=
fd
;
mi
->
fd
=
fd
;
int
port
,
connect_retry
,
master_log_pos
;
if
(
init_strvar_from_file
(
mi
->
master_log_name
,
if
(
init_strvar_from_file
(
mi
->
master_log_name
,
sizeof
(
mi
->
master_log_name
),
&
mi
->
file
,
sizeof
(
mi
->
master_log_name
),
&
mi
->
file
,
""
)
||
""
)
||
init_intvar_from_file
(
(
int
*
)
&
mi
->
master_log_pos
,
&
mi
->
file
,
4
)
||
init_intvar_from_file
(
&
master_log_pos
,
&
mi
->
file
,
4
)
||
init_strvar_from_file
(
mi
->
host
,
sizeof
(
mi
->
host
),
&
mi
->
file
,
init_strvar_from_file
(
mi
->
host
,
sizeof
(
mi
->
host
),
&
mi
->
file
,
master_host
)
||
master_host
)
||
init_strvar_from_file
(
mi
->
user
,
sizeof
(
mi
->
user
),
&
mi
->
file
,
init_strvar_from_file
(
mi
->
user
,
sizeof
(
mi
->
user
),
&
mi
->
file
,
master_user
)
||
master_user
)
||
init_strvar_from_file
(
mi
->
password
,
HASH_PASSWORD_LENGTH
+
1
,
&
mi
->
file
,
init_strvar_from_file
(
mi
->
password
,
HASH_PASSWORD_LENGTH
+
1
,
&
mi
->
file
,
master_password
)
||
master_password
)
||
init_intvar_from_file
(
(
int
*
)
&
mi
->
port
,
&
mi
->
file
,
master_port
)
||
init_intvar_from_file
(
&
port
,
&
mi
->
file
,
master_port
)
||
init_intvar_from_file
(
(
int
*
)
&
mi
->
connect_retry
,
&
mi
->
file
,
init_intvar_from_file
(
&
connect_retry
,
&
mi
->
file
,
master_connect_retry
))
master_connect_retry
))
{
{
sql_print_error
(
"Error reading master configuration"
);
sql_print_error
(
"Error reading master configuration"
);
goto
err
;
goto
err
;
}
}
/*
This has to be handled here as init_intvar_from_file can't handle
my_off_t types
*/
mi
->
master_log_pos
=
(
my_off_t
)
master_log_pos
;
mi
->
port
=
(
uint
)
port
;
mi
->
connect_retry
=
(
uint
)
connect_retry
;
}
}
DBUG_PRINT
(
"master_info"
,(
"log_file_name: %s position: %ld"
,
mi
->
master_log_name
,
(
ulong
)
mi
->
master_log_pos
));
mi
->
inited
=
1
;
mi
->
inited
=
1
;
// now change cache READ -> WRITE - must do this before flush_master_info
// now change cache READ -> WRITE - must do this before flush_master_info
reinit_io_cache
(
&
mi
->
file
,
WRITE_CACHE
,
0L
,
0
,
1
);
reinit_io_cache
(
&
mi
->
file
,
WRITE_CACHE
,
0L
,
0
,
1
);
...
@@ -1399,6 +1419,8 @@ int flush_master_info(MASTER_INFO* mi)
...
@@ -1399,6 +1419,8 @@ int flush_master_info(MASTER_INFO* mi)
{
{
IO_CACHE
*
file
=
&
mi
->
file
;
IO_CACHE
*
file
=
&
mi
->
file
;
char
lbuf
[
22
];
char
lbuf
[
22
];
DBUG_ENTER
(
"flush_master_info"
);
DBUG_PRINT
(
"enter"
,(
"master_pos: %ld"
,
(
long
)
mi
->
master_log_pos
));
my_b_seek
(
file
,
0L
);
my_b_seek
(
file
,
0L
);
my_b_printf
(
file
,
"%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
%d
\n
%d
\n
%d
\n
"
,
my_b_printf
(
file
,
"%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
%d
\n
%d
\n
%d
\n
"
,
...
@@ -1407,7 +1429,7 @@ int flush_master_info(MASTER_INFO* mi)
...
@@ -1407,7 +1429,7 @@ int flush_master_info(MASTER_INFO* mi)
mi
->
password
,
mi
->
port
,
mi
->
connect_retry
mi
->
password
,
mi
->
port
,
mi
->
connect_retry
);
);
flush_io_cache
(
file
);
flush_io_cache
(
file
);
return
0
;
DBUG_RETURN
(
0
)
;
}
}
int
st_relay_log_info
::
wait_for_pos
(
THD
*
thd
,
String
*
log_name
,
int
st_relay_log_info
::
wait_for_pos
(
THD
*
thd
,
String
*
log_name
,
...
@@ -1496,13 +1518,9 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
...
@@ -1496,13 +1518,9 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
thd
->
options
|=
OPTION_BIG_SELECTS
;
thd
->
options
|=
OPTION_BIG_SELECTS
;
if
(
thd_type
==
SLAVE_THD_SQL
)
if
(
thd_type
==
SLAVE_THD_SQL
)
{
thd
->
proc_info
=
"Waiting for the next event in slave queue"
;
thd
->
proc_info
=
"Waiting for the next event in slave queue"
;
}
else
else
{
thd
->
proc_info
=
"Waiting for master update"
;
thd
->
proc_info
=
"Waiting for master update"
;
}
thd
->
version
=
refresh_version
;
thd
->
version
=
refresh_version
;
thd
->
set_time
();
thd
->
set_time
();
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
@@ -1751,8 +1769,9 @@ slave_begin:
...
@@ -1751,8 +1769,9 @@ slave_begin:
pthread_cond_broadcast
(
&
mi
->
start_cond
);
pthread_cond_broadcast
(
&
mi
->
start_cond
);
pthread_mutex_unlock
(
&
mi
->
run_lock
);
pthread_mutex_unlock
(
&
mi
->
run_lock
);
DBUG_PRINT
(
"info"
,(
"master info: log_file_name='%s', position=%s"
,
DBUG_PRINT
(
"master_info"
,(
"log_file_name: '%s' position: %s"
,
mi
->
master_log_name
,
llstr
(
mi
->
master_log_pos
,
llbuff
)));
mi
->
master_log_name
,
llstr
(
mi
->
master_log_pos
,
llbuff
)));
if
(
!
(
mi
->
mysql
=
mysql
=
mc_mysql_init
(
NULL
)))
if
(
!
(
mi
->
mysql
=
mysql
=
mc_mysql_init
(
NULL
)))
{
{
...
@@ -2013,10 +2032,12 @@ slave_begin:
...
@@ -2013,10 +2032,12 @@ slave_begin:
}
}
DBUG_ASSERT
(
rli
->
relay_log_pos
>=
BIN_LOG_HEADER_SIZE
);
DBUG_ASSERT
(
rli
->
relay_log_pos
>=
BIN_LOG_HEADER_SIZE
);
DBUG_ASSERT
(
my_b_tell
(
rli
->
cur_log
)
==
rli
->
relay_log_pos
);
DBUG_ASSERT
(
my_b_tell
(
rli
->
cur_log
)
==
rli
->
relay_log_pos
);
DBUG_PRINT
(
"info"
,(
"master info: log_file_name: %s, position: %s"
,
rli
->
master_log_name
,
llstr
(
rli
->
master_log_pos
,
llbuff
)));
DBUG_ASSERT
(
rli
->
sql_thd
==
thd
);
DBUG_ASSERT
(
rli
->
sql_thd
==
thd
);
DBUG_PRINT
(
"master_info"
,(
"log_file_name: %s position: %s"
,
rli
->
master_log_name
,
llstr
(
rli
->
master_log_pos
,
llbuff
)));
sql_print_error
(
"Slave SQL thread initialized, starting replication in \
sql_print_error
(
"Slave SQL thread initialized, starting replication in \
log '%s' at position %s, relay log '%s' position: %s"
,
RPL_LOG_NAME
,
log '%s' at position %s, relay log '%s' position: %s"
,
RPL_LOG_NAME
,
llstr
(
rli
->
master_log_pos
,
llbuff
),
rli
->
relay_log_name
,
llstr
(
rli
->
master_log_pos
,
llbuff
),
rli
->
relay_log_name
,
...
@@ -2180,13 +2201,16 @@ err:
...
@@ -2180,13 +2201,16 @@ err:
static
int
process_io_rotate
(
MASTER_INFO
*
mi
,
Rotate_log_event
*
rev
)
static
int
process_io_rotate
(
MASTER_INFO
*
mi
,
Rotate_log_event
*
rev
)
{
{
DBUG_ENTER
(
"process_io_rotate"
);
if
(
unlikely
(
!
rev
->
is_valid
()))
if
(
unlikely
(
!
rev
->
is_valid
()))
return
1
;
DBUG_RETURN
(
1
)
;
DBUG_ASSERT
(
rev
->
ident_len
<
sizeof
(
mi
->
master_log_name
));
DBUG_ASSERT
(
rev
->
ident_len
<
sizeof
(
mi
->
master_log_name
));
memcpy
(
mi
->
master_log_name
,
rev
->
new_log_ident
,
memcpy
(
mi
->
master_log_name
,
rev
->
new_log_ident
,
rev
->
ident_len
);
rev
->
ident_len
);
mi
->
master_log_name
[
rev
->
ident_len
]
=
0
;
mi
->
master_log_name
[
rev
->
ident_len
]
=
0
;
mi
->
master_log_pos
=
rev
->
pos
;
mi
->
master_log_pos
=
rev
->
pos
;
DBUG_PRINT
(
"info"
,
(
"master_log_pos: %d"
,
(
ulong
)
mi
->
master_log_pos
));
#ifndef DBUG_OFF
#ifndef DBUG_OFF
/*
/*
If we do not do this, we will be getting the first
If we do not do this, we will be getting the first
...
@@ -2195,7 +2219,7 @@ static int process_io_rotate(MASTER_INFO* mi, Rotate_log_event* rev)
...
@@ -2195,7 +2219,7 @@ static int process_io_rotate(MASTER_INFO* mi, Rotate_log_event* rev)
if
(
disconnect_slave_event_count
)
if
(
disconnect_slave_event_count
)
events_till_disconnect
++
;
events_till_disconnect
++
;
#endif
#endif
return
0
;
DBUG_RETURN
(
0
)
;
}
}
/*
/*
...
@@ -2260,6 +2284,7 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf,
...
@@ -2260,6 +2284,7 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf,
int
error
=
process_io_create_file
(
mi
,(
Create_file_log_event
*
)
ev
);
int
error
=
process_io_create_file
(
mi
,(
Create_file_log_event
*
)
ev
);
delete
ev
;
delete
ev
;
mi
->
master_log_pos
+=
event_len
;
mi
->
master_log_pos
+=
event_len
;
DBUG_PRINT
(
"info"
,
(
"master_log_pos: %d"
,
(
ulong
)
mi
->
master_log_pos
));
pthread_mutex_unlock
(
&
mi
->
data_lock
);
pthread_mutex_unlock
(
&
mi
->
data_lock
);
DBUG_ASSERT
(
tmp_buf
);
DBUG_ASSERT
(
tmp_buf
);
my_free
((
char
*
)
tmp_buf
,
MYF
(
0
));
my_free
((
char
*
)
tmp_buf
,
MYF
(
0
));
...
@@ -2283,6 +2308,7 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf,
...
@@ -2283,6 +2308,7 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf,
delete
ev
;
delete
ev
;
if
(
likely
(
inc_pos
))
if
(
likely
(
inc_pos
))
mi
->
master_log_pos
+=
event_len
;
mi
->
master_log_pos
+=
event_len
;
DBUG_PRINT
(
"info"
,
(
"master_log_pos: %d"
,
(
ulong
)
mi
->
master_log_pos
));
if
(
unlikely
(
processed_stop_event
))
if
(
unlikely
(
processed_stop_event
))
mi
->
ignore_stop_event
=
1
;
mi
->
ignore_stop_event
=
1
;
pthread_mutex_unlock
(
&
mi
->
data_lock
);
pthread_mutex_unlock
(
&
mi
->
data_lock
);
...
@@ -2334,6 +2360,7 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len)
...
@@ -2334,6 +2360,7 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len)
{
{
if
(
likely
(
inc_pos
))
if
(
likely
(
inc_pos
))
mi
->
master_log_pos
+=
event_len
;
mi
->
master_log_pos
+=
event_len
;
DBUG_PRINT
(
"info"
,
(
"master_log_pos: %d"
,
(
ulong
)
mi
->
master_log_pos
));
mi
->
rli
.
relay_log
.
harvest_bytes_written
(
&
mi
->
rli
.
log_space_total
);
mi
->
rli
.
relay_log
.
harvest_bytes_written
(
&
mi
->
rli
.
log_space_total
);
}
}
if
(
unlikely
(
processed_stop_event
))
if
(
unlikely
(
processed_stop_event
))
...
...
sql/sql_repl.cc
View file @
9b6df03c
...
@@ -323,7 +323,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
...
@@ -323,7 +323,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
if
(
pos
<
4
)
if
(
pos
<
4
)
{
{
errmsg
=
"Client requested master to start replic
tion from \
errmsg
=
"Client requested master to start replica
tion from \
impossible position"
;
impossible position"
;
goto
err
;
goto
err
;
}
}
...
@@ -691,6 +691,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
...
@@ -691,6 +691,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
int
error
=
0
,
restart_thread_mask
;
int
error
=
0
,
restart_thread_mask
;
const
char
*
errmsg
=
0
;
const
char
*
errmsg
=
0
;
bool
need_relay_log_purge
=
1
;
bool
need_relay_log_purge
=
1
;
DBUG_ENTER
(
"change_master"
);
// kill slave thread
// kill slave thread
lock_slave_threads
(
mi
);
lock_slave_threads
(
mi
);
...
@@ -702,7 +703,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
...
@@ -702,7 +703,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
{
{
send_error
(
&
thd
->
net
,
error
);
send_error
(
&
thd
->
net
,
error
);
unlock_slave_threads
(
mi
);
unlock_slave_threads
(
mi
);
return
1
;
DBUG_RETURN
(
1
)
;
}
}
thd
->
proc_info
=
"changing master"
;
thd
->
proc_info
=
"changing master"
;
LEX_MASTER_INFO
*
lex_mi
=
&
thd
->
lex
.
mi
;
LEX_MASTER_INFO
*
lex_mi
=
&
thd
->
lex
.
mi
;
...
@@ -711,7 +712,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
...
@@ -711,7 +712,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
{
{
send_error
(
&
thd
->
net
,
0
,
"Could not initialize master info"
);
send_error
(
&
thd
->
net
,
0
,
"Could not initialize master info"
);
unlock_slave_threads
(
mi
);
unlock_slave_threads
(
mi
);
return
1
;
DBUG_RETURN
(
1
)
;
}
}
/* data lock not needed since we have already stopped the running threads,
/* data lock not needed since we have already stopped the running threads,
...
@@ -722,7 +723,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
...
@@ -722,7 +723,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
{
{
// if we change host or port, we must reset the postion
// if we change host or port, we must reset the postion
mi
->
master_log_name
[
0
]
=
0
;
mi
->
master_log_name
[
0
]
=
0
;
mi
->
master_log_pos
=
4
;
// skip magic number
mi
->
master_log_pos
=
BIN_LOG_HEADER_SIZE
;
mi
->
rli
.
pending
=
0
;
mi
->
rli
.
pending
=
0
;
}
}
...
@@ -731,9 +732,10 @@ int change_master(THD* thd, MASTER_INFO* mi)
...
@@ -731,9 +732,10 @@ int change_master(THD* thd, MASTER_INFO* mi)
sizeof
(
mi
->
master_log_name
));
sizeof
(
mi
->
master_log_name
));
if
(
lex_mi
->
pos
)
if
(
lex_mi
->
pos
)
{
{
mi
->
master_log_pos
=
lex_mi
->
pos
;
mi
->
master_log_pos
=
lex_mi
->
pos
;
mi
->
rli
.
pending
=
0
;
mi
->
rli
.
pending
=
0
;
}
}
DBUG_PRINT
(
"info"
,
(
"master_log_pos: %d"
,
(
ulong
)
mi
->
master_log_pos
));
if
(
lex_mi
->
host
)
if
(
lex_mi
->
host
)
strmake
(
mi
->
host
,
lex_mi
->
host
,
sizeof
(
mi
->
host
));
strmake
(
mi
->
host
,
lex_mi
->
host
,
sizeof
(
mi
->
host
));
...
@@ -769,7 +771,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
...
@@ -769,7 +771,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
&
errmsg
))
&
errmsg
))
{
{
net_printf
(
&
thd
->
net
,
0
,
"Failed purging old relay logs: %s"
,
errmsg
);
net_printf
(
&
thd
->
net
,
0
,
"Failed purging old relay logs: %s"
,
errmsg
);
return
1
;
DBUG_RETURN
(
1
)
;
}
}
}
}
else
else
...
@@ -783,11 +785,11 @@ int change_master(THD* thd, MASTER_INFO* mi)
...
@@ -783,11 +785,11 @@ int change_master(THD* thd, MASTER_INFO* mi)
//Sasha: note that I had to change net_printf() to make this work
//Sasha: note that I had to change net_printf() to make this work
net_printf
(
&
thd
->
net
,
0
,
"Failed initializing relay log position: %s"
,
msg
);
net_printf
(
&
thd
->
net
,
0
,
"Failed initializing relay log position: %s"
,
msg
);
unlock_slave_threads
(
mi
);
unlock_slave_threads
(
mi
);
return
1
;
DBUG_RETURN
(
1
)
;
}
}
}
}
mi
->
rli
.
master_log_pos
=
mi
->
master_log_pos
;
mi
->
rli
.
master_log_pos
=
mi
->
master_log_pos
;
DBUG_PRINT
(
"info"
,
(
"master_log_pos: %d"
,
(
ulong
)
mi
->
master_log_pos
));
strnmov
(
mi
->
rli
.
master_log_name
,
mi
->
master_log_name
,
strnmov
(
mi
->
rli
.
master_log_name
,
mi
->
master_log_name
,
sizeof
(
mi
->
rli
.
master_log_name
));
sizeof
(
mi
->
rli
.
master_log_name
));
if
(
!
mi
->
rli
.
master_log_name
[
0
])
// uninitialized case
if
(
!
mi
->
rli
.
master_log_name
[
0
])
// uninitialized case
...
@@ -810,7 +812,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
...
@@ -810,7 +812,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
send_error
(
&
thd
->
net
,
error
);
send_error
(
&
thd
->
net
,
error
);
else
else
send_ok
(
&
thd
->
net
);
send_ok
(
&
thd
->
net
);
return
0
;
DBUG_RETURN
(
0
)
;
}
}
int
reset_master
(
THD
*
thd
)
int
reset_master
(
THD
*
thd
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment