~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to mysql-test/extra/rpl_tests/rpl_log.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Requires statement logging
 
2
 
 
3
# Clean up old slave's binlogs.
 
4
# The slave is started with --log-slave-updates
 
5
# and this test does SHOW BINLOG EVENTS on the slave's
 
6
# binlog. But previous tests can influence the current test's
 
7
# binlog (e.g. a temporary table in the previous test has not
 
8
# been explicitly deleted, and at the beginning of the current
 
9
# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
 
10
# We wait for the slave to have written all he wants to the binlog
 
11
# (otherwise RESET MASTER may come too early).
 
12
save_master_pos;
 
13
connection slave;
 
14
sync_with_master;
 
15
stop slave;
 
16
reset master;
 
17
reset slave;
 
18
# We are going to read the slave's binlog which contains file_id (for some LOAD
 
19
# DATA INFILE); to make it repeatable (not influenced by other tests), we need
 
20
# to stop and start the slave, to be sure file_id will start from 1.
 
21
#  This can be done with 'server_stop slave', but
 
22
# this would require the manager, so most of the time the test will be skipped
 
23
# :(
 
24
# To workaround this, I (Guilhem) add a (empty) rpl_log-slave.opt (because when
 
25
# mysql-test-run finds such a file it restarts the slave before doing the
 
26
# test). That's not very elegant but I could find no better way, sorry.
 
27
 
 
28
let $VERSION=`select version()`;
 
29
 
 
30
connection master;
 
31
reset master;
 
32
eval create table t1(n int not null auto_increment primary key)ENGINE=$engine_type;
 
33
insert into t1 values (NULL);
 
34
drop table t1;
 
35
eval create table t1 (word char(20) not null)ENGINE=$engine_type;
 
36
load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines;
 
37
select count(*) from t1;
 
38
--replace_result $VERSION VERSION
 
39
--replace_column 2 # 5 #
 
40
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 
41
show binlog events;
 
42
--replace_column 2 # 5 #
 
43
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 
44
show binlog events from 107 limit 1;
 
45
--replace_column 2 # 5 #
 
46
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 
47
show binlog events from 107 limit 2;
 
48
--replace_column 2 # 5 #
 
49
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 
50
show binlog events from 107 limit 2,1;
 
51
flush logs;
 
52
 
 
53
# We need an extra update before doing save_master_pos.
 
54
# Otherwise, an unlikely scenario may occur:
 
55
# * When the master's binlog_dump thread reads the end of master-bin.001,
 
56
# it send the rotate event which is at this end, plus a fake rotate event
 
57
# because it's starting to read a new binlog.
 
58
# save_master_pos will record the position of the first of the two rotate
 
59
# (because the fake one is not in the master's binlog anyway).
 
60
# * Later the slave waits for the position of the first rotate event,
 
61
# and it may quickly stop (in 'slave stop') without having received the fake
 
62
# one.
 
63
# So, depending on a few milliseconds, we end up with 2 rotate events in the
 
64
# relay log or one, which influences the output of SHOW SLAVE STATUS, making
 
65
# it not predictable and causing random test failures.
 
66
# To make it predictable, we do a useless update now, but which has the
 
67
# interest of making the slave catch both rotate events.
 
68
 
 
69
eval create table t3 (a int)ENGINE=$engine_type;
 
70
 
 
71
# Sync slave and force it to start on another binary log
 
72
 
 
73
#show rows of t1 on master
 
74
connection master;
 
75
select * from t1 order by 1 asc;
 
76
 
 
77
save_master_pos;
 
78
connection slave;
 
79
# Note that the above 'slave start' will cause a 3rd rotate event (a fake one)
 
80
# to go into the relay log (the master always sends a fake one when replication
 
81
# starts). 
 
82
start slave;
 
83
let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%';
 
84
--source include/wait_slave_status.inc
 
85
sync_with_master;
 
86
#check t1 on slave to ensure whether it's identical with on master
 
87
select * from t1 order by 1 asc;
 
88
flush logs;
 
89
stop slave;
 
90
connection master;
 
91
 
 
92
# Create some entries for second log
 
93
 
 
94
eval create table t2 (n int)ENGINE=$engine_type;
 
95
insert into t2 values (1);
 
96
source include/show_binlog_events.inc;
 
97
--replace_result $VERSION VERSION
 
98
--replace_column 2 # 5 #
 
99
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 
100
show binlog events in 'master-bin.000002';
 
101
show binary logs;
 
102
save_master_pos;
 
103
connection slave;
 
104
start slave;
 
105
sync_with_master;
 
106
show binary logs;
 
107
--replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
 
108
--replace_column 2 # 5 #
 
109
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 
110
show binlog events in 'slave-bin.000001' from 4;
 
111
--replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
 
112
--replace_column 2 # 5 #
 
113
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 
114
show binlog events in 'slave-bin.000002' from 4;
 
115
source include/show_slave_status.inc;
 
116
 
 
117
# Need to recode the following
 
118
 
 
119
#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=4 and  master_server_id=1;
 
120
#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=79 and master_server_id=1;
 
121
#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=311 and master_server_id=1;
 
122
#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=4 and master_server_id=1;
 
123
#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=122 and master_server_id=1;
 
124
 
 
125
--error 1220
 
126
show binlog events in 'slave-bin.000005' from 4;
 
127
 
 
128
connection master;
 
129
 
 
130
# The table drops caused Cluster Replication wrapper to fail as event ID would never be the same.# Moving drops here.
 
131
 
 
132
DROP TABLE t1;
 
133
DROP TABLE t2;
 
134
DROP TABLE t3;
 
135
 
 
136
#
 
137
# Bug #6880: LAST_INSERT_ID() within a statement
 
138
#
 
139
 
 
140
create table t1(a int auto_increment primary key, b int);
 
141
insert into t1 values (NULL, 1);
 
142
reset master;
 
143
set insert_id=5;
 
144
insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
 
145
source include/show_binlog_events.inc;
 
146
select * from t1;
 
147
drop table t1;
 
148
 
 
149
# End of 4.1 tests
 
150
 
 
151
sync_slave_with_master;
 
152