[Commits] 0b0d341: MDEV-9044 : Binlog corruption in Galera

Nirbhay Choubey nirbhay at mariadb.com
Mon Dec 7 21:01:53 EET 2015


revision-id: 0b0d34138300b891ccbec58e01f3ab5bebe24d71
parent(s): 3c0e9d31b3e6494931deb09f5c93b05a96df8471
committer: Nirbhay Choubey
branch nick: 10.1.b9044
timestamp: 2015-12-07 14:01:52 -0500
message:

MDEV-9044 : Binlog corruption in Galera

While refreshing the IO_CACHE, do not update its parameters (read_pos,
read_end & pos_in_file) if there is nothing left to read.

---
 .../suite/galera/r/galera_as_master_large.result   | 30 ++++++++++++++
 .../suite/galera/t/galera_as_master_large.cnf      |  4 ++
 .../suite/galera/t/galera_as_master_large.test     | 46 ++++++++++++++++++++++
 mysys/mf_iocache.c                                 |  6 ++-
 4 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/mysql-test/suite/galera/r/galera_as_master_large.result b/mysql-test/suite/galera/r/galera_as_master_large.result
new file mode 100644
index 0000000..4d55338
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_as_master_large.result
@@ -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;
diff --git a/mysql-test/suite/galera/t/galera_as_master_large.cnf b/mysql-test/suite/galera/t/galera_as_master_large.cnf
new file mode 100644
index 0000000..bd8f381
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_as_master_large.cnf
@@ -0,0 +1,4 @@
+!include ../galera_2nodes_as_master.cnf
+
+[mysqld.1]
+binlog-cache-size=8192
diff --git a/mysql-test/suite/galera/t/galera_as_master_large.test b/mysql-test/suite/galera/t/galera_as_master_large.test
new file mode 100644
index 0000000..fa343cd
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_as_master_large.test
@@ -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;
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 28e5e72..db8d0b5 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -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 ||


More information about the commits mailing list