Skip to content

Commit 0058593

Browse files
author
guilhem@mysql.com
committed
Test for bug 578. And a comment in slave.cc.
1 parent e6cdc81 commit 0058593

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
drop table if exists t1;
2+
create table t1(a int) type=innodb;
3+
lock tables t1 write;
4+
insert into t1 values(10);
5+
select * from t1;
6+
a
7+
10
8+
drop table t1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--binlog-ignore-db=test innodb
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This is a test for bug 578
2+
3+
connect (con1,localhost,root,,);
4+
connect (con2,localhost,root,,);
5+
6+
connection con1;
7+
drop table if exists t1;
8+
create table t1(a int) type=innodb;
9+
lock tables t1 write;
10+
insert into t1 values(10);
11+
disconnect con1;
12+
13+
connection con2;
14+
# The bug was that, because of the LOCK TABLES, the handler "forgot" to commit,
15+
# and the other commit when we write to the binlog was not done because of
16+
# binlog-ignore-db
17+
select * from t1;
18+
drop table t1;

sql/slave.cc

+20
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,26 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
11861186
strmov(strcend(tmp,'.'),"-relay-bin");
11871187
opt_relay_logname=my_strdup(tmp,MYF(MY_WME));
11881188
}
1189+
1190+
/*
1191+
The relay log will now be opened, as a SEQ_READ_APPEND IO_CACHE. It is
1192+
notable that the last kilobytes of it (8 kB for example) may live in memory,
1193+
not on disk (depending on what the thread using it does). While this is
1194+
efficient, it has a side-effect one must know:
1195+
the size of the relay log on disk (displayed by 'ls -l' on Unix) can be a
1196+
few kilobytes less than one would expect by doing SHOW SLAVE STATUS; this
1197+
happens when only the IO thread is started (not the SQL thread). The
1198+
"missing" kilobytes are in memory, are preserved during 'STOP SLAVE; START
1199+
SLAVE IO_THREAD', and are flushed to disk when the slave's mysqld stops. So
1200+
this does not cause any bug. Example of how disk size grows by leaps:
1201+
1202+
Read_Master_Log_Pos: 7811 -rw-rw---- 1 guilhem qq 4 Jun 5 16:19 gbichot2-relay-bin.002
1203+
...later...
1204+
Read_Master_Log_Pos: 9744 -rw-rw---- 1 guilhem qq 8192 Jun 5 16:27 gbichot2-relay-bin.002
1205+
1206+
See how 4 is less than 7811 and 8192 is less than 9744.
1207+
*/
1208+
11891209
if (open_log(&rli->relay_log, glob_hostname, opt_relay_logname,
11901210
"-relay-bin", opt_relaylog_index_name,
11911211
LOG_BIN, 1 /* read_append cache */,

0 commit comments

Comments
 (0)