Below is the list of changes that have just been committed into a local
5.1 repository of elkin. When elkin does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-09-11 19:29:27+03:00, aelkin@stripped +15 -0
WL#342 heartbeat and associated bug#20435 Relay logs are rotated at slave_net_timeout when there's no activity.
The second changeset to be put over the first.
Augmenting slave's handling of the event with rejecting any mismatch of binlog names except when slave has not
not assigned its version at master_info.
Agreegating file name and position into a new coordinate struct.
Using the struct's instance as transport from read event to send routine.
Reading of file name is made even more safe as it's protected by LOCK_open.
Status of received events on slave side is added.
mysql-test/include/show_binlog_events2.inc@stripped, 2007-09-11 19:25:35+03:00, aelkin@stripped +1 -1
FD size increased by 1 byte
Heartbeat line in the status
mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result@stripped, 2007-09-11 19:25:35+03:00, aelkin@stripped +1 -0
FD size increased by 1 byte
Heartbeat line in the status
mysql-test/suite/rpl_ndb/r/rpl_ndb_circular.result@stripped, 2007-09-11 19:25:35+03:00, aelkin@stripped +2 -0
FD size increased by 1 byte
Heartbeat line in the status
mysql-test/suite/rpl_ndb/r/rpl_ndb_circular_simplex.result@stripped, 2007-09-11 19:25:36+03:00, aelkin@stripped +2 -0
FD size increased by 1 byte
Heartbeat line in the status
mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result@stripped, 2007-09-11 19:25:36+03:00, aelkin@stripped +9 -0
FD size increased by 1 byte
Heartbeat line in the status
mysql-test/suite/rpl_ndb/r/rpl_ndb_idempotent.result@stripped, 2007-09-11 19:25:36+03:00, aelkin@stripped +6 -6
FD size increased by 1 byte
Heartbeat line in the status
mysql-test/suite/rpl_ndb/r/rpl_ndb_multi.result@stripped, 2007-09-11 19:25:36+03:00, aelkin@stripped +2 -2
FD size increased by 1 byte
Heartbeat line in the status
mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result@stripped, 2007-09-11 19:25:36+03:00, aelkin@stripped +1 -0
FD size increased by 1 byte
Heartbeat line in the status
mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb.result@stripped, 2007-09-11 19:25:37+03:00, aelkin@stripped +34 -34
FD size increased by 1 byte
Heartbeat line in the status
sql/log_event.cc@stripped, 2007-09-11 19:25:37+03:00, aelkin@stripped +13 -1
binlog file name is safer to pick up at time LOCK_log is held by dump thread to avoid
its steeling by one that can rotate it.
::read_log_event() arglist extended to return the coordinates of the currenly read event.
sql/log_event.h@stripped, 2007-09-11 19:25:37+03:00, aelkin@stripped +11 -1
coordinates stuct, signature of the method.
sql/mysqld.cc@stripped, 2007-09-11 19:25:37+03:00, aelkin@stripped +19 -0
status of received heartbeats.
sql/rpl_mi.h@stripped, 2007-09-11 19:25:38+03:00, aelkin@stripped +1 -0
the type is chosen as ulonglong since the period can be as small as 0.001 second.
sql/slave.cc@stripped, 2007-09-11 19:25:38+03:00, aelkin@stripped +13 -3
Allowing binlog file name to be unknown with accepting such event. In other cases of inequality to reject it.
sql/sql_repl.cc@stripped, 2007-09-11 19:25:38+03:00, aelkin@stripped +26 -19
agreegating file name and pos into event_coordinates struct across master's code.
diff -Nrup a/mysql-test/include/show_binlog_events2.inc b/mysql-test/include/show_binlog_events2.inc
--- a/mysql-test/include/show_binlog_events2.inc 2007-04-19 00:08:53 +03:00
+++ b/mysql-test/include/show_binlog_events2.inc 2007-09-11 19:25:35 +03:00
@@ -2,7 +2,7 @@
# Differs slightly from show_binlog events in showing server_id
# which is important for some tests
#
---let $binlog_start=106
+--let $binlog_start=107
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result 2007-06-27 15:28:30 +03:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result 2007-09-11 19:25:35 +03:00
@@ -179,6 +179,7 @@ Last_IO_Errno <Last_IO_Errno>
Last_IO_Error <Last_IO_Error>
Last_SQL_Errno <Last_SQL_Errno>
Last_SQL_Error <Last_SQL_Error>
+Heartbeat_period 5.000
set GLOBAL slave_transaction_retries=10;
START SLAVE;
select * from t1 order by nid;
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_circular.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_circular.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_circular.result 2007-06-27 15:28:30 +03:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_circular.result 2007-09-11 19:25:35 +03:00
@@ -56,6 +56,7 @@ Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
+Heartbeat_period 5.000
SELECT * FROM t1 ORDER BY a;
a b
1 2
@@ -99,5 +100,6 @@ Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
+Heartbeat_period 1800.000
STOP SLAVE;
DROP TABLE t1;
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_circular_simplex.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_circular_simplex.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_circular_simplex.result 2007-07-27 16:06:40 +03:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_circular_simplex.result 2007-09-11 19:25:36 +03:00
@@ -53,6 +53,7 @@ Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
+Heartbeat_period 1800.000
SELECT * FROM t1 ORDER BY a;
a b
1 2
@@ -102,3 +103,4 @@ Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
+Heartbeat_period 5.000
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result 2007-08-16 18:26:29 +03:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result 2007-09-11 19:25:36 +03:00
@@ -92,6 +92,7 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 1533
Last_SQL_Error Table definition on master and slave does not match: Column 2 size mismatch - master has size 10, test.t2 on slave has size 6. Master's column size should be <= the slave's column size.
+Heartbeat_period 5.000
STOP SLAVE;
RESET SLAVE;
SELECT * FROM t2 ORDER BY a;
@@ -159,6 +160,7 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 1533
Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3
+Heartbeat_period 5.000
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
*** Drop t3 ***
@@ -221,6 +223,7 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 1533
Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3
+Heartbeat_period 5.000
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
*** Drop t4 ***
@@ -283,6 +286,7 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 1533
Last_SQL_Error Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246
+Heartbeat_period 5.000
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
*** Drop t5 ***
@@ -344,6 +348,7 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 1533
Last_SQL_Error Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3
+Heartbeat_period 5.000
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3;
*** Drop t6 ***
DROP TABLE t6;
@@ -456,6 +461,7 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 1533
Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5
+Heartbeat_period 5.000
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
*** Drop t10 ***
@@ -517,6 +523,7 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 1533
Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252
+Heartbeat_period 5.000
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
*** Drop t11 ***
@@ -707,6 +714,7 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 1060
Last_SQL_Error Error 'Duplicate column name 'c6'' on query. Default database: 'test'. Query: 'ALTER TABLE t15 ADD COLUMN c6 INT AFTER c5'
+Heartbeat_period 5.000
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
*** Try to insert in master ****
@@ -843,6 +851,7 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 1533
Last_SQL_Error Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2
+Heartbeat_period 5.000
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
** DROP table t17 ***
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_idempotent.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_idempotent.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_idempotent.result 2007-06-27 15:28:30 +03:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_idempotent.result 2007-09-11 19:25:36 +03:00
@@ -33,15 +33,15 @@ c1 c2 c3
row3 C 3
row4 D 4
SHOW SLAVE STATUS;
-Slave_IO_State 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 Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error
-<Slave_IO_State> 127.0.0.1 root MASTER_PORT 1 master-bin.000001 <Read_Master_Log_Pos> <Relay_Log_File> <Relay_Log_Pos> master-bin.000001 Yes Yes <Replicate_Ignore_Table> 0 0 <Exec_Master_Log_Pos> <Relay_Log_Space> None 0 No <Seconds_Behind_Master> No <Last_IO_Errno> <Last_IO_Error> 0
+Slave_IO_State 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 Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Heartbeat_period
+<Slave_IO_State> 127.0.0.1 root MASTER_PORT 1 master-bin.000001 <Read_Master_Log_Pos> <Relay_Log_File> <Relay_Log_Pos> master-bin.000001 Yes Yes <Replicate_Ignore_Table> 0 0 <Exec_Master_Log_Pos> <Relay_Log_Space> None 0 No <Seconds_Behind_Master> No <Last_IO_Errno> <Last_IO_Error> 0 5.000
STOP SLAVE;
CHANGE MASTER TO
master_log_file = 'master-bin.000001',
master_log_pos = <the_pos> ;
SHOW SLAVE STATUS;
-Slave_IO_State 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 Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error
-<Slave_IO_State> 127.0.0.1 root MASTER_PORT 1 master-bin.000001 <Read_Master_Log_Pos> <Relay_Log_File> <Relay_Log_Pos> master-bin.000001 No No <Replicate_Ignore_Table> 0 0 <Exec_Master_Log_Pos> <Relay_Log_Space> None 0 No <Seconds_Behind_Master> No <Last_IO_Errno> <Last_IO_Error> 0
+Slave_IO_State 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 Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Heartbeat_period
+<Slave_IO_State> 127.0.0.1 root MASTER_PORT 1 master-bin.000001 <Read_Master_Log_Pos> <Relay_Log_File> <Relay_Log_Pos> master-bin.000001 No No <Replicate_Ignore_Table> 0 0 <Exec_Master_Log_Pos> <Relay_Log_Space> None 0 No <Seconds_Behind_Master> No <Last_IO_Errno> <Last_IO_Error> 0 5.000
START SLAVE;
SELECT * FROM t1 ORDER BY c3;
c1 c2 c3
@@ -68,6 +68,6 @@ SELECT * FROM t1;
c1 c2 c3
row2 new on slave 2
SHOW SLAVE STATUS;
-Slave_IO_State 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 Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error
-<Slave_IO_State> 127.0.0.1 root MASTER_PORT 1 master-bin.000001 <Read_Master_Log_Pos> <Relay_Log_File> <Relay_Log_Pos> master-bin.000001 Yes Yes <Replicate_Ignore_Table> 0 0 <Exec_Master_Log_Pos> <Relay_Log_Space> None 0 No <Seconds_Behind_Master> <Last_IO_Errno> <Last_IO_Error> 0
+Slave_IO_State 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 Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Heartbeat_period
+<Slave_IO_State> 127.0.0.1 root MASTER_PORT 1 master-bin.000001 <Read_Master_Log_Pos> <Relay_Log_File> <Relay_Log_Pos> master-bin.000001 Yes Yes <Replicate_Ignore_Table> 0 0 <Exec_Master_Log_Pos> <Relay_Log_Space> None 0 No <Seconds_Behind_Master> <Last_IO_Errno> <Last_IO_Error> 0 5.000
DROP TABLE IF EXISTS t1;
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_multi.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_multi.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_multi.result 2007-06-27 15:27:26 +03:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_multi.result 2007-09-11 19:25:36 +03:00
@@ -26,11 +26,11 @@ stop slave;
SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
FROM mysql.ndb_binlog_index WHERE epoch = <the_epoch> ;
@the_pos:=Position @the_file:=SUBSTRING_INDEX(FILE, '/', -1)
-106 master-bin1.000001
+107 master-bin1.000001
CHANGE MASTER TO
master_port=<MASTER_PORT1>,
master_log_file = 'master-bin1.000001',
-master_log_pos = 106 ;
+master_log_pos = 107 ;
start slave;
INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4);
DELETE FROM t1 WHERE c3 = 1;
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result 2007-06-27 15:28:30 +03:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result 2007-09-11 19:25:36 +03:00
@@ -110,6 +110,7 @@ Last_IO_Errno <Last_IO_Errno>
Last_IO_Error <Last_IO_Error>
Last_SQL_Errno 0
Last_SQL_Error
+Heartbeat_period 5.000
SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
hex(c1) hex(c2) c3
1 1 row1
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb.result b/mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb.result 2007-07-30 01:10:22 +03:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb.result 2007-09-11 19:25:37 +03:00
@@ -29,16 +29,16 @@ a b
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 4 Format_desc 1 106 Server ver: SERVER_VERSION, Binlog ver: 4
-master-bin.000001 106 Query 1 223 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
-master-bin.000001 223 Query 1 287 BEGIN
-master-bin.000001 287 Table_map 1 330 table_id: # (test.t1)
-master-bin.000001 330 Table_map 1 392 table_id: # (mysql.ndb_apply_status)
-master-bin.000001 392 Write_rows 1 451 table_id: #
-master-bin.000001 451 Write_rows 1 498 table_id: # flags: STMT_END_F
-master-bin.000001 498 Query 1 563 COMMIT
-master-bin.000001 563 Query 1 643 use `test`; TRUNCATE TABLE t1
-master-bin.000001 643 Query 1 719 use `test`; DROP TABLE t1
+master-bin.000001 4 Format_desc 1 107 Server ver: SERVER_VERSION, Binlog ver: 4
+master-bin.000001 107 Query 1 224 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
+master-bin.000001 224 Query 1 288 BEGIN
+master-bin.000001 288 Table_map 1 331 table_id: # (test.t1)
+master-bin.000001 331 Table_map 1 393 table_id: # (mysql.ndb_apply_status)
+master-bin.000001 393 Write_rows 1 452 table_id: #
+master-bin.000001 452 Write_rows 1 499 table_id: # flags: STMT_END_F
+master-bin.000001 499 Query 1 564 COMMIT
+master-bin.000001 564 Query 1 644 use `test`; TRUNCATE TABLE t1
+master-bin.000001 644 Query 1 720 use `test`; DROP TABLE t1
**** On Master ****
CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
INSERT INTO t1 VALUES (1,1), (2,2);
@@ -65,27 +65,27 @@ a b
DROP TABLE t1;
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 4 Format_desc 1 106 Server ver: SERVER_VERSION, Binlog ver: 4
-master-bin.000001 106 Query 1 223 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
-master-bin.000001 223 Query 1 287 BEGIN
-master-bin.000001 287 Table_map 1 330 table_id: # (test.t1)
-master-bin.000001 330 Table_map 1 392 table_id: # (mysql.ndb_apply_status)
-master-bin.000001 392 Write_rows 1 451 table_id: #
-master-bin.000001 451 Write_rows 1 498 table_id: # flags: STMT_END_F
-master-bin.000001 498 Query 1 563 COMMIT
-master-bin.000001 563 Query 1 643 use `test`; TRUNCATE TABLE t1
-master-bin.000001 643 Query 1 719 use `test`; DROP TABLE t1
-master-bin.000001 719 Query 1 836 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
-master-bin.000001 836 Query 1 900 BEGIN
-master-bin.000001 900 Table_map 1 943 table_id: # (test.t1)
-master-bin.000001 943 Table_map 1 1005 table_id: # (mysql.ndb_apply_status)
-master-bin.000001 1005 Write_rows 1 1064 table_id: #
-master-bin.000001 1064 Write_rows 1 1111 table_id: # flags: STMT_END_F
-master-bin.000001 1111 Query 1 1176 COMMIT
-master-bin.000001 1176 Query 1 1240 BEGIN
-master-bin.000001 1240 Table_map 1 1283 table_id: # (test.t1)
-master-bin.000001 1283 Table_map 1 1345 table_id: # (mysql.ndb_apply_status)
-master-bin.000001 1345 Write_rows 1 1404 table_id: #
-master-bin.000001 1404 Delete_rows 1 1443 table_id: # flags: STMT_END_F
-master-bin.000001 1443 Query 1 1508 COMMIT
-master-bin.000001 1508 Query 1 1584 use `test`; DROP TABLE t1
+master-bin.000001 4 Format_desc 1 107 Server ver: SERVER_VERSION, Binlog ver: 4
+master-bin.000001 107 Query 1 224 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
+master-bin.000001 224 Query 1 288 BEGIN
+master-bin.000001 288 Table_map 1 331 table_id: # (test.t1)
+master-bin.000001 331 Table_map 1 393 table_id: # (mysql.ndb_apply_status)
+master-bin.000001 393 Write_rows 1 452 table_id: #
+master-bin.000001 452 Write_rows 1 499 table_id: # flags: STMT_END_F
+master-bin.000001 499 Query 1 564 COMMIT
+master-bin.000001 564 Query 1 644 use `test`; TRUNCATE TABLE t1
+master-bin.000001 644 Query 1 720 use `test`; DROP TABLE t1
+master-bin.000001 720 Query 1 837 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
+master-bin.000001 837 Query 1 901 BEGIN
+master-bin.000001 901 Table_map 1 944 table_id: # (test.t1)
+master-bin.000001 944 Table_map 1 1006 table_id: # (mysql.ndb_apply_status)
+master-bin.000001 1006 Write_rows 1 1065 table_id: #
+master-bin.000001 1065 Write_rows 1 1112 table_id: # flags: STMT_END_F
+master-bin.000001 1112 Query 1 1177 COMMIT
+master-bin.000001 1177 Query 1 1241 BEGIN
+master-bin.000001 1241 Table_map 1 1284 table_id: # (test.t1)
+master-bin.000001 1284 Table_map 1 1346 table_id: # (mysql.ndb_apply_status)
+master-bin.000001 1346 Write_rows 1 1405 table_id: #
+master-bin.000001 1405 Delete_rows 1 1444 table_id: # flags: STMT_END_F
+master-bin.000001 1444 Query 1 1509 COMMIT
+master-bin.000001 1509 Query 1 1585 use `test`; DROP TABLE t1
diff -Nrup a/sql/log_event.cc b/sql/log_event.cc
--- a/sql/log_event.cc 2007-09-10 19:29:19 +03:00
+++ b/sql/log_event.cc 2007-09-11 19:25:37 +03:00
@@ -715,13 +715,17 @@ bool Log_event::write_header(IO_CACHE* f
/*
Log_event::read_log_event()
+ event_coordinates * coord in/out: to return the coordinates
+ Returns: error code
+
This needn't be format-tolerant, because we only read
LOG_EVENT_MINIMAL_HEADER_LEN (we just want to read the event's length).
*/
int Log_event::read_log_event(IO_CACHE* file, String* packet,
- pthread_mutex_t* log_lock)
+ pthread_mutex_t* log_lock,
+ struct event_coordinates * coord)
{
ulong data_len;
int result=0;
@@ -783,6 +787,14 @@ int Log_event::read_log_event(IO_CACHE*
(file->error >= 0 ? LOG_READ_TRUNC: LOG_READ_IO));
/* Implicit goto end; */
}
+ }
+ if (coord != NULL)
+ {
+ /*
+ the last read event's coordinates are prepared to be send with heartbeat
+ */
+ coord->file_name= mysql_bin_log.get_log_fname();
+ coord->pos= uint4korr(packet->ptr() + 1 + LOG_POS_OFFSET);
}
end:
diff -Nrup a/sql/log_event.h b/sql/log_event.h
--- a/sql/log_event.h 2007-09-10 19:29:19 +03:00
+++ b/sql/log_event.h 2007-09-11 19:25:37 +03:00
@@ -608,6 +608,15 @@ typedef struct st_print_event_info
} PRINT_EVENT_INFO;
#endif
+/*
+ the struct aggregate the two paramenters uniquely identifying an event
+ in scope of one master/slave pair
+*/
+struct event_coordinates
+{
+ char * file_name;
+ ulong pos;
+};
/*****************************************************************************
@@ -719,7 +728,8 @@ public:
const Format_description_log_event
*description_event);
static int read_log_event(IO_CACHE* file, String* packet,
- pthread_mutex_t* log_lock);
+ pthread_mutex_t* log_lock,
+ struct event_coordinates * coord);
/*
init_show_field_list() prepares the column names and types for the
output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc 2007-08-27 14:43:58 +03:00
+++ b/sql/mysqld.cc 2007-09-11 19:25:37 +03:00
@@ -6435,6 +6435,24 @@ static int show_slave_retried_trans(THD
pthread_mutex_unlock(&LOCK_active_mi);
return 0;
}
+
+static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
+{
+ pthread_mutex_lock(&LOCK_active_mi);
+ if (active_mi)
+ {
+ var->type= SHOW_LONGLONG;
+ var->value= buff;
+ pthread_mutex_lock(&active_mi->rli.data_lock);
+ *((longlong *)buff)= active_mi->received_heartbeats;
+ pthread_mutex_unlock(&active_mi->rli.data_lock);
+ }
+ else
+ var->type= SHOW_UNDEF;
+ pthread_mutex_unlock(&LOCK_active_mi);
+ return 0;
+}
+
#endif /* HAVE_REPLICATION */
static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff)
@@ -6905,6 +6923,7 @@ SHOW_VAR status_vars[]= {
{"Slave_open_temp_tables", (char*) &slave_open_temp_tables, SHOW_LONG},
#ifdef HAVE_REPLICATION
{"Slave_retried_transactions",(char*) &show_slave_retried_trans, SHOW_FUNC},
+ {"Slave_received_heartbeats",(char*) &show_slave_received_heartbeats, SHOW_FUNC},
{"Slave_running", (char*) &show_slave_running, SHOW_FUNC},
#endif
{"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG},
diff -Nrup a/sql/rpl_mi.h b/sql/rpl_mi.h
--- a/sql/rpl_mi.h 2007-09-10 19:29:19 +03:00
+++ b/sql/rpl_mi.h 2007-09-11 19:25:38 +03:00
@@ -84,6 +84,7 @@ class Master_info : public Slave_reporti
uint port;
uint connect_retry;
float heartbeat_period;
+ ulonglong received_heartbeats; // counter of received heartbeat events
#ifndef DBUG_OFF
int events_till_disconnect;
#endif
diff -Nrup a/sql/slave.cc b/sql/slave.cc
--- a/sql/slave.cc 2007-09-10 19:29:20 +03:00
+++ b/sql/slave.cc 2007-09-11 19:25:38 +03:00
@@ -3171,12 +3171,22 @@ int queue_event(Master_info* mi,const ch
error_msg.append(buff, (uint) strlen(buff));
goto err;
}
+ mi->received_heartbeats++;
/*
- compare local and event's versions of log_file, log_pos
+ compare local and event's versions of log_file, log_pos.
+
+ Heartbeat is sent only after an event corresponding to the corrdinates
+ the heartbeat carries.
+ Slave can not have a difference in coordinates except in the only
+ special case when mi->master_log_name, master_log_pos have never
+ been updated by Rotate event i.e when slave does not have any history
+ with the master (and thereafter mi->master_log_pos is NULL).
+
TODO: handling `when' for SHOW SLAVE STATUS' snds behind
*/
- if (!memcmp(mi->master_log_name, hb.log_ident, hb.ident_len)
- && mi->master_log_pos != hb.log_pos)
+ if ((memcmp(mi->master_log_name, hb.log_ident, hb.ident_len)
+ && mi->master_log_name != NULL)
+ || mi->master_log_pos != hb.log_pos)
{
/* missed events of heartbeat from the past */
error= ER_SLAVE_HEARTBEAT_FAILURE;
diff -Nrup a/sql/sql_repl.cc b/sql/sql_repl.cc
--- a/sql/sql_repl.cc 2007-09-10 19:29:20 +03:00
+++ b/sql/sql_repl.cc 2007-09-11 19:25:38 +03:00
@@ -350,7 +350,7 @@ static ulonglong get_heartbeat_period(TH
the dump thread.
*/
static int send_heartbeat_event(NET* net, String* packet,
- char* log_file_name, ulong pos)
+ struct event_coordinates *coord)
{
DBUG_ENTER("send_heartbeat_event");
char header[LOG_EVENT_HEADER_LEN];
@@ -362,7 +362,7 @@ static int send_heartbeat_event(NET* net
header[EVENT_TYPE_OFFSET] = HEARTBEAT_LOG_EVENT;
- char* p= log_file_name + dirname_length(log_file_name);
+ char* p= coord->file_name + dirname_length(coord->file_name);
uint ident_len = (uint) strlen(p);
ulong event_len = ident_len + LOG_EVENT_HEADER_LEN;
@@ -370,7 +370,7 @@ static int send_heartbeat_event(NET* net
int4store(header + EVENT_LEN_OFFSET, event_len);
int2store(header + FLAGS_OFFSET, 0);
- int4store(header + LOG_POS_OFFSET, pos); // log_pos
+ int4store(header + LOG_POS_OFFSET, coord->pos); // log_pos
packet->append(header, sizeof(header));
packet->append(p, ident_len); // log_file_name
@@ -417,7 +417,13 @@ void mysql_binlog_send(THD* thd, char* l
struct timespec heartbeat_ts;
heartbeat_ts.tv_sec= 0;
heartbeat_ts.tv_nsec= 0;
-
+ struct event_coordinates *coord= NULL;
+ if (heartbeat_period != 0)
+ {
+ coord= new struct event_coordinates;
+ coord->file_name= log_ident; // initialization basing on what slave remembers
+ coord->pos= pos;
+ }
#ifndef DBUG_OFF
if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
{
@@ -533,7 +539,7 @@ impossible position";
Try to find a Format_description_log_event at the beginning of
the binlog
*/
- if (!(error = Log_event::read_log_event(&log, packet, log_lock)))
+ if (!(error = Log_event::read_log_event(&log, packet, log_lock, NULL)))
{
/*
The packet has offsets equal to the normal offsets in a binlog
@@ -594,16 +600,10 @@ impossible position";
/* seek to the requested position, to start the requested dump */
my_b_seek(&log, pos); // Seek will done on next read
-
while (!net->error && net->vio != 0 && !thd->killed)
{
- while (!(error = Log_event::read_log_event(&log, packet, log_lock)))
+ while (!(error = Log_event::read_log_event(&log, packet, log_lock, coord)))
{
- /*
- the last read event's log_pos is spared for possible preparing
- of a heartbeat event. Notice, there are two saving points.
- */
- master_last_event_log_pos= uint4korr(packet->ptr() + 1 + LOG_POS_OFFSET);
#ifndef DBUG_OFF
if (max_binlog_dump_events && !left_events--)
{
@@ -703,13 +703,13 @@ impossible position";
*/
pthread_mutex_lock(log_lock);
- switch (Log_event::read_log_event(&log, packet, (pthread_mutex_t*)0)) {
+ switch (Log_event::read_log_event(&log, packet, (pthread_mutex_t*) 0,
+ coord))
+ {
case 0:
/* we read successfully, so we'll need to send it to the slave */
pthread_mutex_unlock(log_lock);
read_packet = 1;
- master_last_event_log_pos= uint4korr(packet->ptr() + 1 +
- LOG_POS_OFFSET);
break;
case LOG_READ_EOF:
@@ -728,16 +728,19 @@ impossible position";
{
set_timespec_nsec(heartbeat_ts, heartbeat_period);
}
- /* Note that the following call unlocks lock_log */
+ else
+ {
+ DBUG_ASSERT(heartbeat_ts.tv_sec == 0 &&
+ heartbeat_ts.tv_nsec == 0);
+ }
+ /* Note that the following call unlocks lock_log if no heartbeat */
ret= mysql_bin_log.wait_for_update_bin_log(thd, &heartbeat_ts);
DBUG_ASSERT(ret == 0 || heartbeat_period != 0);
if (ret == ETIMEDOUT || ret == ETIME)
{
sql_print_information("master sends heartbeat message");
- if (send_heartbeat_event(net, packet,
- mysql_bin_log.get_log_fname(),
- master_last_event_log_pos))
+ if (send_heartbeat_event(net, packet, coord))
{
errmsg = "Failed on my_net_write()";
my_errno= ER_UNKNOWN_ERROR;
@@ -849,6 +852,8 @@ end:
pthread_mutex_lock(&LOCK_thread_count);
thd->current_linfo = 0;
pthread_mutex_unlock(&LOCK_thread_count);
+ if (heartbeat_period != 0ULL)
+ delete coord;
DBUG_VOID_RETURN;
err:
@@ -868,6 +873,8 @@ err:
(void) my_close(file, MYF(MY_WME));
my_message(my_errno, errmsg, MYF(0));
+ if (heartbeat_period != 0ULL)
+ delete coord;
DBUG_VOID_RETURN;
}
| Thread |
|---|
| • bk commit into 5.1 tree (aelkin:1.2570) BUG#20435 | Andrei Elkin | 11 Sep |