Skip to content

Commit

Permalink
MDEV-9044 : Binlog corruption in Galera
Browse files Browse the repository at this point in the history
While refreshing the IO_CACHE, do not update its parameters (read_pos,
read_end & pos_in_file) if there is nothing left to read.
  • Loading branch information
Nirbhay Choubey committed Dec 18, 2015
1 parent 428e09a commit 58b54b7
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
30 changes: 30 additions & 0 deletions mysql-test/suite/galera/r/galera_as_master_large.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# MDEV-9044 : Getting binlog corruption on my Galera cluster (10.1.8)
# making it impossible to async slave.
#
START SLAVE;
SELECT @@GLOBAL.BINLOG_CACHE_SIZE;
@@GLOBAL.BINLOG_CACHE_SIZE
8192
CREATE TABLE t1 (c1 INTEGER PRIMARY KEY, c2 VARCHAR(12000)) ENGINE=INNODB;
CREATE TABLE t2 (c1 INTEGER PRIMARY KEY) ENGINE=INNODB;
START TRANSACTION;
INSERT INTO t1 VALUES(1, REPEAT('-', 10000));
COMMIT;
INSERT INTO t2 VALUES(1);
SELECT c1, LENGTH(c2) FROM t1;
c1 LENGTH(c2)
1 10000
SELECT * FROM t2;
c1
1
SELECT c1, LENGTH(c2) FROM t1;
c1 LENGTH(c2)
1 10000
SELECT * FROM t2;
c1
1
# Cleanup
DROP TABLE t1, t2;
STOP SLAVE;
RESET SLAVE ALL;
4 changes: 4 additions & 0 deletions mysql-test/suite/galera/t/galera_as_master_large.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
!include ../galera_2nodes_as_master.cnf

[mysqld.1]
binlog-cache-size=8192
46 changes: 46 additions & 0 deletions mysql-test/suite/galera/t/galera_as_master_large.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
--echo #
--echo # MDEV-9044 : Getting binlog corruption on my Galera cluster (10.1.8)
--echo # making it impossible to async slave.
--echo #

--source include/have_innodb.inc
--source include/galera_cluster.inc

--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
--disable_query_log
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1;
--enable_query_log
START SLAVE;

--connection node_1

SELECT @@GLOBAL.BINLOG_CACHE_SIZE;
CREATE TABLE t1 (c1 INTEGER PRIMARY KEY, c2 VARCHAR(12000)) ENGINE=INNODB;
CREATE TABLE t2 (c1 INTEGER PRIMARY KEY) ENGINE=INNODB;

START TRANSACTION;
INSERT INTO t1 VALUES(1, REPEAT('-', 10000));
COMMIT;
INSERT INTO t2 VALUES(1);
save_master_pos;

--connection node_2
SELECT c1, LENGTH(c2) FROM t1;
SELECT * FROM t2;

--connection node_3
sync_with_master;

SELECT c1, LENGTH(c2) FROM t1;
SELECT * FROM t2;

--echo # Cleanup
--connection node_1
DROP TABLE t1, t2;
save_master_pos;

--connection node_3
sync_with_master;

STOP SLAVE;
RESET SLAVE ALL;
6 changes: 5 additions & 1 deletion mysys/mf_iocache.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,11 @@ int _my_b_cache_read(IO_CACHE *info, uchar *Buffer, size_t Count)
info->error= (int) left_length;
DBUG_RETURN(1);
}
length=0; /* Didn't read any chars */
else
{
info->error= 0;
DBUG_RETURN(0); /* EOF */
}
}
else if ((length= mysql_file_read(info->file,info->buffer, max_length,
info->myflags)) < Count ||
Expand Down

0 comments on commit 58b54b7

Please sign in to comment.