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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
0fd577d0
Commit
0fd577d0
authored
Aug 24, 2002
by
monty@mashka.mysql.fi
Browse files
Options
Browse Files
Download
Plain Diff
Merge work:/my/mysql-4.0 into mashka.mysql.fi:/home/my/mysql-4.0
parents
6b6a024e
04723cf7
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
208 additions
and
100 deletions
+208
-100
.bzrignore
.bzrignore
+9
-9
Docs/manual.texi
Docs/manual.texi
+16
-2
client/mysql.cc
client/mysql.cc
+7
-1
client/mysqladmin.c
client/mysqladmin.c
+3
-0
client/mysqlimport.c
client/mysqlimport.c
+6
-0
client/mysqltest.c
client/mysqltest.c
+11
-10
libmysql/libmysql.c
libmysql/libmysql.c
+18
-11
mysql-test/r/rpl_rotate_logs.result
mysql-test/r/rpl_rotate_logs.result
+18
-7
mysql-test/t/rpl000018.test
mysql-test/t/rpl000018.test
+5
-0
mysql-test/t/rpl_log_pos.test
mysql-test/t/rpl_log_pos.test
+2
-1
mysql-test/t/rpl_rotate_logs-master.opt
mysql-test/t/rpl_rotate_logs-master.opt
+0
-0
mysql-test/t/rpl_rotate_logs-slave-master-info.opt
mysql-test/t/rpl_rotate_logs-slave-master-info.opt
+0
-0
mysql-test/t/rpl_rotate_logs-slave.sh
mysql-test/t/rpl_rotate_logs-slave.sh
+0
-0
mysql-test/t/rpl_rotate_logs.test
mysql-test/t/rpl_rotate_logs.test
+48
-9
scripts/mysql_zap.sh
scripts/mysql_zap.sh
+1
-1
sql/log.cc
sql/log.cc
+0
-1
sql/mini_client.cc
sql/mini_client.cc
+5
-8
sql/slave.cc
sql/slave.cc
+49
-33
sql/slave.h
sql/slave.h
+9
-5
sql/sql_class.h
sql/sql_class.h
+1
-2
No files found.
.bzrignore
View file @
0fd577d0
...
...
@@ -284,6 +284,7 @@ libmysqld/password.c
libmysqld/procedure.cc
libmysqld/records.cc
libmysqld/repl_failsafe.cc
libmysqld/set_var.cc
libmysqld/simple-test
libmysqld/slave.cc
libmysqld/sql_acl.cc
...
...
@@ -357,6 +358,8 @@ myisam/myisamlog
myisam/myisampack
myisam/test1.MYD
myisam/test1.MYI
myisam/test2.MYD
myisam/test2.MYI
mysql-4.0.2-alpha-pc-linux-gnu-i686.tar.gz
mysql-4.0.2-alpha.tar.gz
mysql-max-4.0.2-alpha-pc-linux-gnu-i686.tar.gz
...
...
@@ -424,6 +427,12 @@ sql-bench/copy-db
sql-bench/crash-me
sql-bench/gif/*
sql-bench/graph-compare-results
sql-bench/innotest1
sql-bench/innotest1a
sql-bench/innotest1b
sql-bench/innotest2
sql-bench/innotest2a
sql-bench/innotest2b
sql-bench/output/*
sql-bench/run-all-tests
sql-bench/server-cfg
...
...
@@ -485,12 +494,3 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
sql-bench/innotest1
sql-bench/innotest1a
sql-bench/innotest1b
sql-bench/innotest2
sql-bench/innotest2a
sql-bench/innotest2b
myisam/test2.MYD
myisam/test2.MYI
libmysqld/set_var.cc
Docs/manual.texi
View file @
0fd577d0
...
...
@@ -14373,6 +14373,10 @@ If this is enabled, a user can't create new users with the GRANT
command, if the user doesn't have @code{INSERT} privilege to the
@code{mysql.user} table or any column in this table.
@item --skip-bdb
Disable usage of BDB tables. This will save memory and may speed up some
things.
@item --skip-concurrent-insert
Turn off the ability to select and insert at the same time on @code{MyISAM}
tables. (This is only to be used if you think you have found a bug in this
...
...
@@ -14392,6 +14396,10 @@ flush-privileges} or @code{mysqladmin reload}.)
Never use host name cache for faster name-ip resolution, but query DNS server
on every connect instead. @xref{DNS}.
@item --skip-innodb
Disable usage of Innodb tables. This will save memory and disk space and
speed up some things.
@item --skip-external-locking (was --skip-locking)
Don't use system locking. To use @code{isamchk} or @code{myisamchk} you must
shut down the server. @xref{Stability}. Note that in MySQL Version
...
...
@@ -38620,6 +38628,9 @@ an auto-extending 10 MB file @file{ibdata1} to the @code{datadir}
of MySQL. (In MySQL-4.0.0 and 4.0.1 the datafile is 64 MB and not
auto-extending.)
If you don't want to use @code{InnoDB} tables, you can add the
@code{skip-innodb} option to your MySQL option file.
But to get good performance you MUST explicitly set the InnoDB parameters
listed in the following examples.
...
...
@@ -40571,13 +40582,14 @@ BDB tables:
@item @code{--bdb-no-recover} @tab Don't start Berkeley DB in recover mode.
@item @code{--bdb-shared-data} @tab Start Berkeley DB in multi-process mode (Don't use @code{DB_PRIVATE} when initialising Berkeley DB)
@item @code{--bdb-tmpdir=directory} @tab Berkeley DB tempfile name.
@item @code{--skip-bdb} @tab D
on't use berkeley db
.
@item @code{--skip-bdb} @tab D
isable usage of BDB tables
.
@item @code{-O bdb_max_lock=1000} @tab Set the maximum number of locks possible. @xref{SHOW VARIABLES}.
@end multitable
If you use @code{--skip-bdb}, MySQL will not initialise the
Berkeley DB library and this will save a lot of memory. Of course,
you cannot use @code{BDB} tables if you are using this option.
you cannot use @code{BDB} tables if you are using this option. If you try
to create an BDB table, MySQL will instead create a MyISAM table.
Normally you should start @code{mysqld} without @code{--bdb-no-recover} if you
intend to use BDB tables. This may, however, give you problems when you
...
...
@@ -50368,6 +50380,8 @@ 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
Fixed hang in @code{CHANGE MASTER TO} if the slave thread died very quickly.
@item
Big cleanup in replication code (less logging, better error messages, etc..)
@item
If the @code{--code-file} option is specified, the server calls
client/mysql.cc
View file @
0fd577d0
...
...
@@ -112,6 +112,7 @@ typedef struct st_status
static
HashTable
ht
;
static
char
**
defaults_argv
;
enum
enum_info_type
{
INFO_INFO
,
INFO_ERROR
,
INFO_RESULT
};
typedef
enum
enum_info_type
INFO_TYPE
;
...
...
@@ -317,15 +318,19 @@ int main(int argc,char *argv[])
status
.
add_to_history
=
1
;
status
.
exit_status
=
1
;
load_defaults
(
"my"
,
load_default_groups
,
&
argc
,
&
argv
);
defaults_argv
=
argv
;
if
(
get_options
(
argc
,
(
char
**
)
argv
))
{
free_defaults
(
defaults_argv
);
my_end
(
0
);
exit
(
1
);
}
free_defaults
(
argv
);
if
(
status
.
batch
&&
!
status
.
line_buff
&&
!
(
status
.
line_buff
=
batch_readline_init
(
max_allowed_packet
+
512
,
stdin
)))
{
free_defaults
(
defaults_argv
);
exit
(
1
);
}
glob_buffer
.
realloc
(
512
);
mysql_server_init
(
0
,
NULL
,
(
char
**
)
server_default_groups
);
completion_hash_init
(
&
ht
,
128
);
...
...
@@ -420,6 +425,7 @@ sig_handler mysql_end(int sig)
my_free
(
default_prompt
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
current_prompt
,
MYF
(
MY_ALLOW_ZERO_PTR
));
mysql_server_end
();
free_defaults
(
defaults_argv
);
my_end
(
info_flag
?
MY_CHECK_ERROR
|
MY_GIVE_INFO
:
0
);
exit
(
status
.
exit_status
);
}
...
...
client/mysqladmin.c
View file @
0fd577d0
...
...
@@ -254,7 +254,10 @@ int main(int argc,char *argv[])
load_defaults
(
"my"
,
load_default_groups
,
&
argc
,
&
argv
);
save_argv
=
argv
;
/* Save for free_defaults */
if
((
ho_error
=
handle_options
(
&
argc
,
&
argv
,
my_long_options
,
get_one_option
)))
{
free_defaults
(
save_argv
);
exit
(
ho_error
);
}
if
(
argc
==
0
)
{
...
...
client/mysqlimport.c
View file @
0fd577d0
...
...
@@ -471,9 +471,15 @@ int main(int argc, char **argv)
/* argv is changed in the program */
argv_to_free
=
argv
;
if
(
get_options
(
&
argc
,
&
argv
))
{
free_defaults
(
argv_to_free
);
return
(
1
);
}
if
(
!
(
sock
=
db_connect
(
current_host
,
current_db
,
current_user
,
opt_password
)))
{
free_defaults
(
argv_to_free
);
return
(
1
);
/* purecov: deadcode */
}
if
(
lock_tables
)
lock_table
(
sock
,
argc
,
argv
);
for
(;
*
argv
!=
NULL
;
argv
++
)
...
...
client/mysqltest.c
View file @
0fd577d0
...
...
@@ -1042,11 +1042,11 @@ int do_let(struct st_query* q)
if
(
!*
p
)
die
(
"Missing variable name in let
\n
"
);
var_name
=
p
;
while
(
*
p
&&
(
*
p
!=
'='
||
isspace
(
*
p
)))
while
(
*
p
&&
(
*
p
!=
'='
||
isspace
(
*
p
)))
p
++
;
var_name_end
=
p
;
if
(
*
p
==
'='
)
p
++
;
while
(
*
p
&&
isspace
(
*
p
))
while
(
*
p
&&
isspace
(
*
p
))
p
++
;
var_val_start
=
p
;
return
var_set
(
var_name
,
var_name_end
,
var_val_start
,
q
->
end
);
...
...
@@ -1054,9 +1054,10 @@ int do_let(struct st_query* q)
int
do_rpl_probe
(
struct
st_query
*
q
__attribute__
((
unused
)))
{
DBUG_ENTER
(
"do_rpl_probe"
);
if
(
mysql_rpl_probe
(
&
cur_con
->
mysql
))
die
(
"Failed in mysql_rpl_probe():
%s
"
,
mysql_error
(
&
cur_con
->
mysql
));
return
0
;
die
(
"Failed in mysql_rpl_probe():
'%s'
"
,
mysql_error
(
&
cur_con
->
mysql
));
DBUG_RETURN
(
0
)
;
}
int
do_enable_rpl_parse
(
struct
st_query
*
q
__attribute__
((
unused
)))
...
...
@@ -1077,7 +1078,7 @@ int do_sleep(struct st_query* q, my_bool real_sleep)
char
*
p
=
q
->
first_argument
;
struct
timeval
t
;
int
dec_mul
=
1000000
;
while
(
*
p
&&
isspace
(
*
p
))
p
++
;
while
(
*
p
&&
isspace
(
*
p
))
p
++
;
if
(
!*
p
)
die
(
"Missing argument in sleep
\n
"
);
t
.
tv_usec
=
0
;
...
...
@@ -1097,7 +1098,7 @@ int do_sleep(struct st_query* q, my_bool real_sleep)
else
{
t
.
tv_sec
=
atoi
(
p
);
while
(
*
p
&&
*
p
!=
'.'
&&
!
isspace
(
*
p
))
while
(
*
p
&&
*
p
!=
'.'
&&
!
isspace
(
*
p
))
p
++
;
if
(
*
p
==
'.'
)
{
...
...
@@ -1308,7 +1309,7 @@ int select_connection(struct st_query* q)
if
(
!*
p
)
die
(
"Missing connection name in connect
\n
"
);
name
=
p
;
while
(
*
p
&&
!
isspace
(
*
p
))
while
(
*
p
&&
!
isspace
(
*
p
))
p
++
;
*
p
=
0
;
...
...
@@ -1334,7 +1335,7 @@ int close_connection(struct st_query* q)
if
(
!*
p
)
die
(
"Missing connection name in connect
\n
"
);
name
=
p
;
while
(
*
p
&&
!
isspace
(
*
p
))
while
(
*
p
&&
!
isspace
(
*
p
))
p
++
;
*
p
=
0
;
...
...
@@ -1790,7 +1791,7 @@ int read_query(struct st_query** q_ptr)
}
}
while
(
*
p
&&
isspace
(
*
p
))
p
++
;
while
(
*
p
&&
isspace
(
*
p
))
p
++
;
if
(
*
p
==
'@'
)
{
p
++
;
...
...
@@ -2503,7 +2504,7 @@ int main(int argc, char** argv)
if
(
!
processed
)
{
current_line_inc
=
0
;
switch
(
q
->
type
)
{
switch
(
q
->
type
)
{
case
Q_WHILE
:
do_while
(
q
);
break
;
case
Q_END_BLOCK
:
do_done
(
q
);
break
;
default:
current_line_inc
=
1
;
break
;
...
...
libmysql/libmysql.c
View file @
0fd577d0
...
...
@@ -1160,14 +1160,15 @@ static void expand_error(MYSQL* mysql, int error)
static
int
get_master
(
MYSQL
*
mysql
,
MYSQL_RES
*
res
,
MYSQL_ROW
row
)
{
MYSQL
*
master
;
DBUG_ENTER
(
"get_master"
);
if
(
mysql_num_fields
(
res
)
<
3
)
return
1
;
/* safety */
DBUG_RETURN
(
1
)
;
/* safety */
/* use the same username and password as the original connection */
if
(
!
(
master
=
spawn_init
(
mysql
,
row
[
0
],
atoi
(
row
[
2
]),
0
,
0
)))
return
1
;
DBUG_RETURN
(
1
)
;
mysql
->
master
=
master
;
return
0
;
DBUG_RETURN
(
0
)
;
}
...
...
@@ -1183,18 +1184,19 @@ static int get_slaves_from_master(MYSQL* mysql)
int
error
=
1
;
int
has_auth_info
;
int
port_ind
;
DBUG_ENTER
(
"get_slaves_from_master"
);
if
(
!
mysql
->
net
.
vio
&&
!
mysql_real_connect
(
mysql
,
0
,
0
,
0
,
0
,
0
,
0
,
0
))
{
expand_error
(
mysql
,
CR_PROBE_MASTER_CONNECT
);
return
1
;
DBUG_RETURN
(
1
)
;
}
if
(
mysql_query
(
mysql
,
"SHOW SLAVE HOSTS"
)
||
!
(
res
=
mysql_store_result
(
mysql
)))
{
expand_error
(
mysql
,
CR_PROBE_SLAVE_HOSTS
);
return
1
;
DBUG_RETURN
(
1
)
;
}
switch
(
mysql_num_fields
(
res
))
{
...
...
@@ -1238,15 +1240,17 @@ static int get_slaves_from_master(MYSQL* mysql)
err:
if
(
res
)
mysql_free_result
(
res
);
return
error
;
DBUG_RETURN
(
error
)
;
}
int
STDCALL
mysql_rpl_probe
(
MYSQL
*
mysql
)
{
MYSQL_RES
*
res
=
0
;
MYSQL_RES
*
res
=
0
;
MYSQL_ROW
row
;
int
error
=
1
;
DBUG_ENTER
(
"mysql_rpl_probe"
);
/*
First determine the replication role of the server we connected to
the most reliable way to do this is to run SHOW SLAVE STATUS and see
...
...
@@ -1259,7 +1263,7 @@ int STDCALL mysql_rpl_probe(MYSQL* mysql)
!
(
res
=
mysql_store_result
(
mysql
)))
{
expand_error
(
mysql
,
CR_PROBE_SLAVE_STATUS
);
return
1
;
DBUG_RETURN
(
1
)
;
}
row
=
mysql_fetch_row
(
res
);
...
...
@@ -1284,7 +1288,7 @@ int STDCALL mysql_rpl_probe(MYSQL* mysql)
err:
if
(
res
)
mysql_free_result
(
res
);
return
error
;
DBUG_RETURN
(
error
)
;
}
...
...
@@ -1979,7 +1983,11 @@ static my_bool mysql_reconnect(MYSQL *mysql)
if
(
!
mysql_real_connect
(
&
tmp_mysql
,
mysql
->
host
,
mysql
->
user
,
mysql
->
passwd
,
mysql
->
db
,
mysql
->
port
,
mysql
->
unix_socket
,
mysql
->
client_flag
))
{
mysql
->
net
.
last_errno
=
tmp_mysql
.
net
.
last_errno
;
strmov
(
mysql
->
net
.
last_error
,
tmp_mysql
.
net
.
last_error
);
DBUG_RETURN
(
1
);
}
tmp_mysql
.
free_me
=
mysql
->
free_me
;
mysql
->
free_me
=
0
;
mysql_close
(
mysql
);
...
...
@@ -2060,7 +2068,7 @@ mysql_close(MYSQL *mysql)
mysql
->
status
=
MYSQL_STATUS_READY
;
/* Force command */
mysql
->
reconnect
=
0
;
simple_command
(
mysql
,
COM_QUIT
,
NullS
,
0
,
1
);
end_server
(
mysql
);
end_server
(
mysql
);
/* Sets mysql->net.vio= 0 */
}
my_free
((
gptr
)
mysql
->
host_info
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
mysql
->
user
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
@@ -2082,7 +2090,6 @@ mysql_close(MYSQL *mysql)
/* Clear pointers for better safety */
mysql
->
host_info
=
mysql
->
user
=
mysql
->
passwd
=
mysql
->
db
=
0
;
bzero
((
char
*
)
&
mysql
->
options
,
sizeof
(
mysql
->
options
));
mysql
->
net
.
vio
=
0
;
/* free/close slave list */
if
(
mysql
->
rpl_pivot
)
...
...
mysql-test/r/rpl
000016
.result
→
mysql-test/r/rpl
_rotate_logs
.result
View file @
0fd577d0
...
...
@@ -10,12 +10,14 @@ change master to master_host='127.0.0.1',master_port=MASTER_PORT,
master_user='root';
reset master;
slave start;
drop table if exists t1;
drop table if exists t1, t2, t3, t4;
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables");
create table t1 (s text);
insert into t1 values('Could not break slave'),('Tried hard');
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 60 master-bin.001
234 slave-relay-bin.001 275 master-bin.001 Yes Yes 0 0 234 275
127.0.0.1 root MASTER_PORT 60 master-bin.001
417 slave-relay-bin.001 458 master-bin.001 Yes Yes 0 0 417 458
select * from t1;
s
Could not break slave
...
...
@@ -30,6 +32,11 @@ Log_name
master-bin.001
master-bin.002
master-bin.003
create table t3 select * from temp_table;
select * from t3;
a
testing temporary tables
drop table temp_table, t3;
insert into t2 values(1234);
set insert_id=1234;
insert into t2 values(NULL);
...
...
@@ -42,7 +49,7 @@ master-bin.003
insert into t2 values (65);
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 60 master-bin.003
155 slave-relay-bin.001 755 master-bin.003 Yes Yes 0 0 155 755
127.0.0.1 root MASTER_PORT 60 master-bin.003
290 slave-relay-bin.001 1073 master-bin.003 Yes Yes 0 0 290 1073
select * from t2;
m
34
...
...
@@ -50,8 +57,11 @@ m
67
123
1234
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables part 2");
drop table if exists t3;
create table t3 (n int);
create table t4 select * from temp_table;
show master logs;
Log_name
master-bin.003
...
...
@@ -60,12 +70,13 @@ master-bin.005
master-bin.006
show master status;
File Position Binlog_do_db Binlog_ignore_db
master-bin.006 445
slave stop;
slave start;
master-bin.006 838
select * from t4;
a
testing temporary tables part 2
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 60 master-bin.006
445 slave-relay-bin.004 1229 master-bin.006 Yes Yes 0 0 445 1229
127.0.0.1 root MASTER_PORT 60 master-bin.006
838 slave-relay-bin.001 8034 master-bin.006 Yes Yes 0 0 838 8034
lock tables t3 read;
select count(*) from t3 where n >= 4;
count(*)
...
...
mysql-test/t/rpl000018.test
View file @
0fd577d0
#
# Running test with abort-slave-event-count=1
# This will force slave to reconnect after every event
#
require_manager
;
connect
(
master
,
localhost
,
root
,,
test
,
0
,
master
.
sock
);
connect
(
slave
,
localhost
,
root
,,
test
,
0
,
slave
.
sock
);
...
...
mysql-test/t/rpl_log_pos.test
View file @
0fd577d0
...
...
@@ -9,13 +9,14 @@ sync_with_master;
--
replace_result
3306
MASTER_PORT
9306
MASTER_PORT
3334
MASTER_PORT
3336
MASTER_PORT
show
slave
status
;
change
master
to
master_log_pos
=
73
;
sleep
5
;
slave
stop
;
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
;
sleep
5
;
--
replace_result
3306
MASTER_PORT
9306
MASTER_PORT
3334
MASTER_PORT
3336
MASTER_PORT
show
slave
status
;
change
master
to
master_log_pos
=
173
;
...
...
mysql-test/t/rpl
000016
-master.opt
→
mysql-test/t/rpl
_rotate_logs
-master.opt
View file @
0fd577d0
File moved
mysql-test/t/rpl
000016
-slave-master-info.opt
→
mysql-test/t/rpl
_rotate_logs
-slave-master-info.opt
View file @
0fd577d0
File moved
mysql-test/t/rpl
000016
-slave.sh
→
mysql-test/t/rpl
_rotate_logs
-slave.sh
View file @
0fd577d0
File moved
mysql-test/t/rpl
000016
.test
→
mysql-test/t/rpl
_rotate_logs
.test
View file @
0fd577d0
#
# Test are run with max_binlog_size=2048 to force automatic rotation of the
# binary log
# Tests done:
# - Check that slaves reports correct failures if master.info has strange
# modes/information
# - Automatic binary log rotation
# - Ensure that temporary tables works over flush logs and binary log
# changes
# - Test creating a duplicate key error and recover from it
#
connect
(
master
,
localhost
,
root
,,
test
,
0
,
master
.
sock
);
connect
(
slave
,
localhost
,
root
,,
test
,
0
,
slave
.
sock
);
system
cat
/
dev
/
null
>
var
/
slave
-
data
/
master
.
info
;
system
chmod
000
var
/
slave
-
data
/
master
.
info
;
connection
slave
;
!
slave
start
;
--
error
1201
slave
start
;
system
chmod
600
var
/
slave
-
data
/
master
.
info
;
!
slave
start
;
--
error
1201
slave
start
;
--
replace_result
3306
MASTER_PORT
9306
MASTER_PORT
3334
MASTER_PORT
3336
MASTER_PORT
!
eval
change
master
to
master_host
=
'127.0.0.1'
,
master_port
=
$MASTER_MYPORT
,
master_user
=
'root'
;
...
...
@@ -18,7 +31,14 @@ reset master;
connection
slave
;
slave
start
;
connection
master
;
drop
table
if
exists
t1
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
;
#
# Test FLUSH LOGS
#
create
temporary
table
temp_table
(
a
char
(
80
)
not
null
);
insert
into
temp_table
values
(
"testing temporary tables"
);
create
table
t1
(
s
text
);
insert
into
t1
values
(
'Could not break slave'
),(
'Tried hard'
);
save_master_pos
;
...
...
@@ -32,15 +52,24 @@ flush logs;
drop
table
if
exists
t2
;
create
table
t2
(
m
int
not
null
auto_increment
primary
key
);
insert
into
t2
values
(
34
),(
67
),(
123
);
save_master_pos
;
flush
logs
;
show
master
logs
;
create
table
t3
select
*
from
temp_table
;
#now lets make some duplicate key mess and see if we can recover from it
#first insert a value on the slave
save_master_pos
;
connection
slave
;
sync_with_master
;
select
*
from
t3
;
connection
master
;
drop
table
temp_table
,
t3
;
#
# Now lets make some duplicate key mess and see if we can recover from it
#
# First insert a value on the slave
connection
slave
;
insert
into
t2
values
(
1234
);
#same value on the master
...
...
@@ -73,7 +102,14 @@ sync_with_master;
--
replace_result
3306
MASTER_PORT
9306
MASTER_PORT
3334
MASTER_PORT
3336
MASTER_PORT
show
slave
status
;
select
*
from
t2
;
#
# Test forcing the replication log to rotate
#
connection
master
;
create
temporary
table
temp_table
(
a
char
(
80
)
not
null
);
insert
into
temp_table
values
(
"testing temporary tables part 2"
);
let
$
1
=
100
;
drop
table
if
exists
t3
;
create
table
t3
(
n
int
);
...
...
@@ -85,13 +121,16 @@ while ($1)
dec
$
1
;
}
enable_query_log
;
create
table
t4
select
*
from
temp_table
;
show
master
logs
;
show
master
status
;
save_master_pos
;
connection
slave
;
slave
stop
;
slave
start
;
#
slave stop;
#
slave start;
sync_with_master
;
select
*
from
t4
;
--
replace_result
3306
MASTER_PORT
9306
MASTER_PORT
3334
MASTER_PORT
3336
MASTER_PORT
show
slave
status
;
# because of concurrent insert, the table may not be up to date
...
...
scripts/mysql_zap.sh
View file @
0fd577d0
...
...
@@ -12,7 +12,7 @@ $opt_f= 0;
$opt_t
=
0
;
$opt_a
=
""
;
$BSD
=
-f
'/vmunix'
||
$ENV
{
"OS"
}
eq
"SunOS4"
;
$BSD
=
-f
'/vmunix'
||
$ENV
{
"OS"
}
eq
"SunOS4"
||
$^
O eq
'darwin'
;
$LINUX
=
$^
O eq
'linux'
;
$pscmd
=
$BSD
?
"/bin/ps -auxww"
:
$LINUX
?
"/bin/ps axuw"
:
"/bin/ps -ef"
;
...
...
sql/log.cc
View file @
0fd577d0
...
...
@@ -33,7 +33,6 @@
MYSQL_LOG
mysql_log
,
mysql_update_log
,
mysql_slow_log
,
mysql_bin_log
;
extern
I_List
<
i_string
>
binlog_do_db
,
binlog_ignore_db
;
extern
ulong
max_binlog_size
;
static
bool
test_if_number
(
const
char
*
str
,
long
*
res
,
bool
allow_wildcards
);
...
...
sql/mini_client.cc
View file @
0fd577d0
...
...
@@ -414,10 +414,8 @@ my_bool mc_mysql_reconnect(MYSQL *mysql)
mysql
->
db
,
mysql
->
port
,
mysql
->
unix_socket
,
mysql
->
client_flag
,
mysql
->
net
.
read_timeout
))
{
#ifdef NOT_USED
mysql
->
net
.
last_errno
=
CR_RECONNECT_FAILED
;
strmov
(
mysql
->
net
.
last_error
,
ER
(
mysql
->
net
.
last_errno
));
#endif
mysql
->
net
.
last_errno
=
tmp_mysql
.
net
.
last_errno
;
strmov
(
mysql
->
net
.
last_error
,
tmp_mysql
.
net
.
last_error
);
DBUG_RETURN
(
1
);
}
tmp_mysql
.
free_me
=
mysql
->
free_me
;
...
...
@@ -888,7 +886,6 @@ mc_mysql_close(MYSQL *mysql)
/* Clear pointers for better safety */
mysql
->
host_info
=
mysql
->
user
=
mysql
->
passwd
=
mysql
->
db
=
0
;
bzero
((
char
*
)
&
mysql
->
options
,
sizeof
(
mysql
->
options
));
mysql
->
net
.
vio
=
0
;
#ifdef HAVE_OPENSSL
mysql_ssl_clear
(
mysql
);
#endif
/* HAVE_OPENSSL */
...
...
@@ -976,12 +973,12 @@ mc_unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
DBUG_RETURN
(
result
);
}
int
mc_mysql_send_query
(
MYSQL
*
mysql
,
const
char
*
query
,
uint
length
)
int
mc_mysql_send_query
(
MYSQL
*
mysql
,
const
char
*
query
,
uint
length
)
{
return
mc_simple_command
(
mysql
,
COM_QUERY
,
query
,
length
,
1
);
}
int
mc_mysql_read_query_result
(
MYSQL
*
mysql
)
{
uchar
*
pos
;
...
...
sql/slave.cc
View file @
0fd577d0
...
...
@@ -443,14 +443,18 @@ int terminate_slave_thread(THD* thd, pthread_mutex_t* term_lock,
}
int
start_slave_thread
(
pthread_handler
h_func
,
pthread_mutex_t
*
start_lock
,
int
start_slave_thread
(
pthread_handler
h_func
,
pthread_mutex_t
*
start_lock
,
pthread_mutex_t
*
cond_lock
,
pthread_cond_t
*
start_cond
,
volatile
bool
*
slave_running
,
pthread_cond_t
*
start_cond
,
volatile
bool
*
slave_running
,
volatile
ulong
*
slave_run_id
,
MASTER_INFO
*
mi
)
{
pthread_t
th
;
ulong
start_id
;
DBUG_ASSERT
(
mi
->
inited
);
DBUG_ENTER
(
"start_slave_thread"
);
if
(
start_lock
)
pthread_mutex_lock
(
start_lock
);
if
(
!
server_id
)
...
...
@@ -460,7 +464,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock,
if
(
start_lock
)
pthread_mutex_unlock
(
start_lock
);
sql_print_error
(
"Server id not set, will not start slave"
);
return
ER_BAD_SLAVE
;
DBUG_RETURN
(
ER_BAD_SLAVE
)
;
}
if
(
*
slave_running
)
...
...
@@ -469,39 +473,36 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock,
pthread_cond_broadcast
(
start_cond
);
if
(
start_lock
)
pthread_mutex_unlock
(
start_lock
);
return
ER_SLAVE_MUST_STOP
;
DBUG_RETURN
(
ER_SLAVE_MUST_STOP
)
;
}
start_id
=
*
slave_run_id
;
DBUG_PRINT
(
"info"
,(
"Creating new slave thread"
));
if
(
pthread_create
(
&
th
,
&
connection_attrib
,
h_func
,
(
void
*
)
mi
))
{
if
(
start_lock
)
pthread_mutex_unlock
(
start_lock
);
return
ER_SLAVE_THREAD
;
DBUG_RETURN
(
ER_SLAVE_THREAD
)
;
}
if
(
start_cond
&&
cond_lock
)
{
THD
*
thd
=
current_thd
;
while
(
!*
slave_running
)
while
(
start_id
==
*
slave_run_id
)
{
DBUG_PRINT
(
"sleep"
,(
"Waiting for slave thread to start"
));
const
char
*
old_msg
=
thd
->
enter_cond
(
start_cond
,
cond_lock
,
"Waiting for slave thread to start"
);
pthread_cond_wait
(
start_cond
,
cond_lock
);
thd
->
exit_cond
(
old_msg
);
/*
TODO: in a very rare case of init_slave_thread failing, it is
possible that we can get stuck here since slave_running will not
be set. We need to change slave_running to int and have -1 as
error code.
*/
if
(
thd
->
killed
)
{
pthread_mutex_unlock
(
cond_lock
);
return
ER_SERVER_SHUTDOWN
;
DBUG_RETURN
(
ER_SERVER_SHUTDOWN
)
;
}
}
}
if
(
start_lock
)
pthread_mutex_unlock
(
start_lock
);
return
0
;
DBUG_RETURN
(
0
)
;
}
...
...
@@ -535,13 +536,15 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
if
(
thread_mask
&
SLAVE_IO
)
error
=
start_slave_thread
(
handle_slave_io
,
lock_io
,
lock_cond_io
,
cond_io
,
&
mi
->
slave_running
,
cond_io
,
&
mi
->
slave_running
,
&
mi
->
slave_run_id
,
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
);
&
mi
->
rli
.
slave_running
,
&
mi
->
rli
.
slave_run_id
,
mi
);
if
(
error
)
terminate_slave_threads
(
mi
,
thread_mask
&
SLAVE_IO
,
0
);
}
...
...
@@ -1807,23 +1810,30 @@ This may also be a network problem, or just a bug in the master or slave code.\
/* slave I/O thread */
pthread_handler_decl
(
handle_slave_io
,
arg
)
{
THD
*
thd
;
// needs to be first for thread_stack
MYSQL
*
mysql
;
MASTER_INFO
*
mi
=
(
MASTER_INFO
*
)
arg
;
char
llbuff
[
22
];
uint
retry_count
;
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init
();
#ifndef DBUG_OFF
slave_begin:
#endif
THD
*
thd
;
// needs to be first for thread_stack
MYSQL
*
mysql
=
NULL
;
MASTER_INFO
*
mi
=
(
MASTER_INFO
*
)
arg
;
char
llbuff
[
22
];
uint
retry_count
=
0
;
DBUG_ASSERT
(
mi
->
inited
);
mysql
=
NULL
;
retry_count
=
0
;
pthread_mutex_lock
(
&
mi
->
run_lock
);
/* Inform waiting threads that slave has started */
mi
->
slave_run_id
++
;
#ifndef DBUG_OFF
mi
->
events_till_abort
=
abort_slave_event_count
;
#endif
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init
();
thd
=
new
THD
;
// note that contructor of THD uses DBUG_ !
DBUG_ENTER
(
"handle_slave_io"
);
THD_CHECK_SENTRY
(
thd
);
...
...
@@ -2071,26 +2081,32 @@ log space");
pthread_handler_decl
(
handle_slave_sql
,
arg
)
{
#ifndef DBUG_OFF
slave_begin:
#endif
THD
*
thd
;
/* needs to be first for thread_stack */
char
llbuff
[
22
],
llbuff1
[
22
];
RELAY_LOG_INFO
*
rli
=
&
((
MASTER_INFO
*
)
arg
)
->
rli
;
const
char
*
errmsg
=
0
;
const
char
*
errmsg
;
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init
();
#ifndef DBUG_OFF
slave_begin:
#endif
DBUG_ASSERT
(
rli
->
inited
);
pthread_mutex_lock
(
&
rli
->
run_lock
);
DBUG_ASSERT
(
!
rli
->
slave_running
);
errmsg
=
0
;
#ifndef DBUG_OFF
rli
->
events_till_abort
=
abort_slave_event_count
;
#endif
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init
();
thd
=
new
THD
;
// note that contructor of THD uses DBUG_ !
DBUG_ENTER
(
"handle_slave_sql"
);
thd
=
new
THD
;
// note that contructor of THD uses DBUG_ !
THD_CHECK_SENTRY
(
thd
);
/* Inform waiting threads that slave has started */
rli
->
slave_run_id
++
;
pthread_detach_this_thread
();
if
(
init_slave_thread
(
thd
,
SLAVE_THD_SQL
))
{
...
...
sql/slave.h
View file @
0fd577d0
...
...
@@ -154,6 +154,7 @@ typedef struct st_relay_log_info
*/
volatile
uint32
slave_skip_counter
;
volatile
ulong
abort_pos_wait
;
/* Incremented on change master */
volatile
ulong
slave_run_id
;
/* Incremented on slave start */
pthread_mutex_t
log_space_lock
;
pthread_cond_t
log_space_cond
;
THD
*
sql_thd
;
...
...
@@ -171,8 +172,8 @@ typedef struct st_relay_log_info
st_relay_log_info
()
:
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
),
skip_log_purge
(
0
)
slave_run_id
(
0
),
inited
(
0
),
abort_slave
(
0
),
slave_running
(
0
),
log_pos_current
(
0
),
skip_log_purge
(
0
)
{
relay_log_name
[
0
]
=
master_log_name
[
0
]
=
0
;
bzero
(
&
info_file
,
sizeof
(
info_file
));
...
...
@@ -283,11 +284,13 @@ typedef struct st_master_info
bool
inited
;
bool
old_format
;
/* master binlog is in 3.23 format */
volatile
bool
abort_slave
,
slave_running
;
volatile
ulong
slave_run_id
;
bool
ignore_stop_event
;
st_master_info
()
:
fd
(
-
1
),
io_thd
(
0
),
inited
(
0
),
old_format
(
0
),
abort_slave
(
0
),
slave_running
(
0
)
st_master_info
()
:
fd
(
-
1
),
io_thd
(
0
),
inited
(
0
),
old_format
(
0
),
abort_slave
(
0
),
slave_running
(
0
),
slave_run_id
(
0
)
{
host
[
0
]
=
0
;
user
[
0
]
=
0
;
password
[
0
]
=
0
;
bzero
(
&
file
,
sizeof
(
file
));
...
...
@@ -360,7 +363,8 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
int
start_slave_thread
(
pthread_handler
h_func
,
pthread_mutex_t
*
start_lock
,
pthread_mutex_t
*
cond_lock
,
pthread_cond_t
*
start_cond
,
volatile
bool
*
slave_running
,
volatile
bool
*
slave_running
,
volatile
ulong
*
slave_run_id
,
MASTER_INFO
*
mi
);
/* If fd is -1, dump to NET */
...
...
sql/sql_class.h
View file @
0fd577d0
...
...
@@ -477,13 +477,12 @@ class THD :public ilink {
}
inline
void
close_active_vio
()
{
pthread_mutex_lock
(
&
LOCK_delete
);
safe_mutex_assert_owner
(
&
LOCK_delete
);
if
(
active_vio
)
{
vio_close
(
active_vio
);
active_vio
=
0
;
}
pthread_mutex_unlock
(
&
LOCK_delete
);
}
#endif
void
awake
(
bool
prepare_to_die
);
...
...
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