Skip to content

Commit 5943f6c

Browse files
dtcpatriciodahlerlend
authored andcommitted
Bug#36313793 --ndb-log-apply-status fails to work with no replica changes [3/3]
Problem: The NDB table, ndb_apply_status, tracks the replica applier state. If replicated changes were applied but are not visible in the Binlog Injector (log-replica-updates=OFF) - because NDB data nodes filtered those - then the epoch, from the Binlog Injector point-of-view, is deemed to be empty. But, ndb_apply_status did have an update because those changes were replicated in the cluster. This breaks the flow of apply status information in a chain/circular replication deployment. Analysis: Running some chain/circular replication scenarios, it is possible to observe, in the binlog injector handling of data events, that the ndb_apply_status table updates are written into the binlog transaction, thus not filtered (system tables do not have skip-log-replica-updates data node filter). If only ndb_apply_status updates are written, then it's considered an empty epoch, as there's no actual table data to write to the binlog. Therefore, the binlog transaction will be rolled back, in case logging of empty epochs is off. But, due to the nature of the `skip-log-replica-updates` filter in the NDB data nodes, some data might have been replicated even if not received by the binlog thread. Solution: The usage of ndb-log-apply-status=ON with circular replication is a complex case. Requires the understanding that even for a server that has skip-log-replica-updates, ndb_apply_status updates are still logged (and thus continue to propagate through the chain). With the above, this patch does not enable the replica updates filter in the NDB data nodes for the cases that ndb-log-apply-status or ndb-log-orig are ON. If log-replica-updates is OFF (filter might be enabled and in operation) then ndb-log-apply-status and ndb-log-orig cannot be toggled. Tests adapted to this new behavior. Change-Id: I48944c536142b87d361e73eacf0f7a699616fa66
1 parent c84e77c commit 5943f6c

13 files changed

+270
-203
lines changed

mysql-test/suite/ndb_rpl/my.cnf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ ndb-wait-connected=30
2525
ndb-wait-setup=120
2626
ndb-cluster-connection-pool=3
2727
replica-allow-batching
28-
ndb-log-orig
2928
ndb-log-bin=1
3029

3130
# Enable load data local functionality

mysql-test/suite/ndb_rpl/r/ndb_rpl_circular.result

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
77
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
88
include/rpl/connect.inc [creating master]
99
include/rpl/connect.inc [creating slave]
10+
# create the table on the "slave"
1011
CREATE TABLE t1 (a int key, b int) ENGINE=ndb;
12+
# now we should have a table on the master as well
1113
SHOW TABLES;
1214
Tables_in_test
1315
t1
@@ -70,70 +72,4 @@ master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
7072
master-bin.000001 # Query # # COMMIT
7173
STOP REPLICA;
7274
DROP TABLE t1;
73-
START REPLICA;
74-
create table t1 (a int primary key, b int) engine=ndb;
75-
show variables like '%log_orig%';
76-
Variable_name Value
77-
ndb_log_orig ON
78-
'Master' has only slave's serverid entry
79-
select server_id, log_name from mysql.ndb_apply_status order by server_id;
80-
server_id log_name
81-
2 slave-bin.000001
82-
set global ndb_log_apply_status=On;
83-
show variables like 'ndb_log_apply_status';
84-
Variable_name Value
85-
ndb_log_apply_status ON
86-
'Slave' has only Master's serverid entry
87-
select server_id, log_name from mysql.ndb_apply_status order by server_id;
88-
server_id log_name
89-
1 master-bin.000001
90-
'Slave' has following ndb_binlog_index entries
91-
select inserts, updates, deletes, schemaops, orig_server_id from mysql.ndb_binlog_index order by position,orig_epoch;
92-
inserts updates deletes schemaops orig_server_id
93-
1 0 0 0 1
94-
1 0 0 0 2
95-
set global ndb_log_apply_status=On;
96-
show variables like 'ndb_log_apply_status';
97-
Variable_name Value
98-
ndb_log_apply_status ON
99-
STOP REPLICA;
100-
insert into t1 values (1,1);
101-
'Slave' still has only Master's serverid entry
102-
select server_id, log_name from mysql.ndb_apply_status order by server_id;
103-
server_id log_name
104-
1 master-bin.000001
105-
'Slave' has following ndb_binlog_index entries
106-
select inserts, updates, deletes, schemaops, orig_server_id from mysql.ndb_binlog_index order by position,orig_epoch;
107-
inserts updates deletes schemaops orig_server_id
108-
1 0 0 0 1
109-
1 0 0 0 2
110-
0 0 0 0 2
111-
1 0 0 0 1
112-
'Master' still has only Slave's serverid entry
113-
select server_id, log_name from mysql.ndb_apply_status order by server_id;
114-
server_id log_name
115-
2 slave-bin.000001
116-
START REPLICA;
117-
'Master' now has own serverid entry as well.
118-
select server_id, log_name from mysql.ndb_apply_status order by server_id;
119-
server_id log_name
120-
1 master-bin.000001
121-
2 slave-bin.000001
122-
'Slave' still only has 'Master''s serverid entry
123-
select server_id, log_name from mysql.ndb_apply_status order by server_id;
124-
server_id log_name
125-
1 master-bin.000001
126-
Now create event originating at Slave
127-
insert into t1 values (2,2);
128-
'Slave' now also has its own serverid entry
129-
select server_id, log_name from mysql.ndb_apply_status order by server_id;
130-
server_id log_name
131-
1 master-bin.000001
132-
2 slave-bin.000001
133-
STOP REPLICA;
134-
set global ndb_log_apply_status=off;
135-
set global ndb_log_apply_status=off;
136-
STOP REPLICA;
137-
drop table t1;
138-
drop table t1;
13975
include/rpl/deinit.inc
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
include/rpl/init.inc [topology=1->2->1]
2+
Warnings:
3+
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
4+
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
5+
Warnings:
6+
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
7+
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
8+
include/rpl/connect.inc [creating source]
9+
include/rpl/connect.inc [creating replica]
10+
# Validating servers setup
11+
[connection source]
12+
SELECT @@log_replica_updates;
13+
@@log_replica_updates
14+
0
15+
SELECT @@ndb_log_orig;
16+
@@ndb_log_orig
17+
1
18+
SELECT @@ndb_log_apply_status;
19+
@@ndb_log_apply_status
20+
1
21+
# Since server has log-replica-updates=OFF, it cannot set following variables
22+
SET GLOBAL ndb_log_orig=ON;
23+
SHOW WARNINGS;
24+
Level Code Message
25+
Warning 1231 Variable 'ndb_log_orig' can't be changed when 'log_replica_updates' is OFF
26+
Error 1231 Variable 'ndb_log_orig' can't be set to the value of 'ON'
27+
SET GLOBAL ndb_log_orig=OFF;
28+
SHOW WARNINGS;
29+
Level Code Message
30+
Warning 1231 Variable 'ndb_log_orig' can't be changed when 'log_replica_updates' is OFF
31+
Error 1231 Variable 'ndb_log_orig' can't be set to the value of 'OFF'
32+
SET GLOBAL ndb_log_apply_status=ON;
33+
SHOW WARNINGS;
34+
Level Code Message
35+
Warning 1231 Variable 'ndb_log_apply_status' can't be changed when 'log_replica_updates' is OFF
36+
Error 1231 Variable 'ndb_log_apply_status' can't be set to the value of 'ON'
37+
SET GLOBAL ndb_log_apply_status=OFF;
38+
SHOW WARNINGS;
39+
Level Code Message
40+
Warning 1231 Variable 'ndb_log_apply_status' can't be changed when 'log_replica_updates' is OFF
41+
Error 1231 Variable 'ndb_log_apply_status' can't be set to the value of 'OFF'
42+
[connection replica]
43+
SELECT @@log_replica_updates;
44+
@@log_replica_updates
45+
1
46+
SELECT @@ndb_log_orig;
47+
@@ndb_log_orig
48+
1
49+
SELECT @@ndb_log_apply_status;
50+
@@ndb_log_apply_status
51+
1
52+
# Since server has log-replica-updates=ON, it can toggle following variables
53+
SET GLOBAL ndb_log_orig=OFF;
54+
SET GLOBAL ndb_log_orig=ON;
55+
SET GLOBAL ndb_log_apply_status=OFF;
56+
SET GLOBAL ndb_log_apply_status=ON;
57+
# Now create table
58+
[connection source]
59+
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE = NDB;
60+
include/rpl/stop_replica.inc
61+
INSERT INTO t1 VALUES (1,1);
62+
[connection replica]
63+
# Replica has only source's serverid entry
64+
select server_id, log_name from mysql.ndb_apply_status order by server_id;
65+
server_id log_name
66+
1 master-bin.000001
67+
# Replica has following ndb_binlog_index entries
68+
select inserts, updates, deletes, schemaops, orig_server_id from mysql.ndb_binlog_index order by position,orig_epoch;
69+
inserts updates deletes schemaops orig_server_id
70+
0 0 0 0 2
71+
1 0 0 0 1
72+
[connection source]
73+
include/rpl/start_replica.inc
74+
# Source now has own serverid entry as well
75+
select server_id, log_name from mysql.ndb_apply_status order by server_id;
76+
server_id log_name
77+
1 master-bin.000001
78+
2 slave-bin.000001
79+
[connection replica]
80+
# Replica still only has source's serverid entry
81+
select server_id, log_name from mysql.ndb_apply_status order by server_id;
82+
server_id log_name
83+
1 master-bin.000001
84+
# Now create event originating at replica
85+
INSERT INTO t1 VALUES (2,2);
86+
# Replica now also has its own serverid entry
87+
select server_id, log_name from mysql.ndb_apply_status order by server_id;
88+
server_id log_name
89+
1 master-bin.000001
90+
2 slave-bin.000001
91+
# Cleanup
92+
DROP TABLE t1;
93+
include/rpl/deinit.inc

mysql-test/suite/ndb_rpl/r/ndb_rpl_slave_lsu_anyval.result

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ CREATE TABLE bug_45756_slave_logged_1 (a int) engine = NDB;
1919
INSERT INTO bug_45756_slave_logged_1 VALUES (1);
2020
DROP TABLE bug_45756_slave_logged_1;
2121
CREATE TABLE bug_45756_slave_logged_2 (a int) engine = NDB;
22-
Warnings:
23-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
2422
INSERT INTO bug_45756_slave_logged_2 VALUES (1);
2523
DROP TABLE bug_45756_slave_logged_2;
2624
CREATE TABLE bug_45756_slave_logged_3 (a int) engine = NDB;
@@ -34,8 +32,6 @@ DROP TABLE bug_45756_slave_not_logged_1;
3432
SET SQL_LOG_BIN= 1;
3533
SET SQL_LOG_BIN= 0;
3634
CREATE TABLE bug_45756_slave_not_logged_2 (a int) engine = NDB;
37-
Warnings:
38-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
3935
INSERT INTO bug_45756_slave_not_logged_2 VALUES (1);
4036
DROP TABLE bug_45756_slave_not_logged_2;
4137
SET SQL_LOG_BIN= 1;
@@ -46,23 +42,17 @@ DROP TABLE bug_45756_slave_not_logged_3;
4642
SET SQL_LOG_BIN= 1;
4743
*** Generating data to be replicated ***
4844
CREATE TABLE bug45756_master_logged_1 (a int) engine = NDB;
49-
Warnings:
50-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
5145
INSERT INTO bug45756_master_logged_1 VALUES (1);
5246
DROP TABLE bug45756_master_logged_1;
5347
CREATE TABLE bug45756_master_logged_2 (a int) engine = NDB;
5448
INSERT INTO bug45756_master_logged_2 VALUES (1);
5549
DROP TABLE bug45756_master_logged_2;
5650
CREATE TABLE bug45756_master_logged_3 (a int) engine = NDB;
57-
Warnings:
58-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
5951
INSERT INTO bug45756_master_logged_3 VALUES (1);
6052
DROP TABLE bug45756_master_logged_3;
6153
*** Generating changes not to be replicated ***
6254
SET SQL_LOG_BIN= 0;
6355
CREATE TABLE bug45756_master_not_logged_1 (a int) engine = NDB;
64-
Warnings:
65-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
6656
INSERT INTO bug45756_master_not_logged_1 VALUES (1);
6757
DROP TABLE bug45756_master_not_logged_1;
6858
SET SQL_LOG_BIN= 1;
@@ -73,8 +63,6 @@ DROP TABLE bug45756_master_not_logged_2;
7363
SET SQL_LOG_BIN= 1;
7464
SET SQL_LOG_BIN= 0;
7565
CREATE TABLE bug45756_master_not_logged_3 (a int) engine = NDB;
76-
Warnings:
77-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
7866
INSERT INTO bug45756_master_not_logged_3 VALUES (1);
7967
DROP TABLE bug45756_master_not_logged_3;
8068
SET SQL_LOG_BIN= 1;
@@ -430,8 +418,6 @@ CREATE TABLE bug_45756_slave_logged_1 (a int) engine = NDB;
430418
INSERT INTO bug_45756_slave_logged_1 VALUES (1);
431419
DROP TABLE bug_45756_slave_logged_1;
432420
CREATE TABLE bug_45756_slave_logged_2 (a int) engine = NDB;
433-
Warnings:
434-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
435421
INSERT INTO bug_45756_slave_logged_2 VALUES (1);
436422
DROP TABLE bug_45756_slave_logged_2;
437423
CREATE TABLE bug_45756_slave_logged_3 (a int) engine = NDB;
@@ -445,8 +431,6 @@ DROP TABLE bug_45756_slave_not_logged_1;
445431
SET SQL_LOG_BIN= 1;
446432
SET SQL_LOG_BIN= 0;
447433
CREATE TABLE bug_45756_slave_not_logged_2 (a int) engine = NDB;
448-
Warnings:
449-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
450434
INSERT INTO bug_45756_slave_not_logged_2 VALUES (1);
451435
DROP TABLE bug_45756_slave_not_logged_2;
452436
SET SQL_LOG_BIN= 1;
@@ -457,23 +441,17 @@ DROP TABLE bug_45756_slave_not_logged_3;
457441
SET SQL_LOG_BIN= 1;
458442
*** Generating data to be replicated ***
459443
CREATE TABLE bug45756_master_logged_1 (a int) engine = NDB;
460-
Warnings:
461-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
462444
INSERT INTO bug45756_master_logged_1 VALUES (1);
463445
DROP TABLE bug45756_master_logged_1;
464446
CREATE TABLE bug45756_master_logged_2 (a int) engine = NDB;
465447
INSERT INTO bug45756_master_logged_2 VALUES (1);
466448
DROP TABLE bug45756_master_logged_2;
467449
CREATE TABLE bug45756_master_logged_3 (a int) engine = NDB;
468-
Warnings:
469-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
470450
INSERT INTO bug45756_master_logged_3 VALUES (1);
471451
DROP TABLE bug45756_master_logged_3;
472452
*** Generating changes not to be replicated ***
473453
SET SQL_LOG_BIN= 0;
474454
CREATE TABLE bug45756_master_not_logged_1 (a int) engine = NDB;
475-
Warnings:
476-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
477455
INSERT INTO bug45756_master_not_logged_1 VALUES (1);
478456
DROP TABLE bug45756_master_not_logged_1;
479457
SET SQL_LOG_BIN= 1;
@@ -484,8 +462,6 @@ DROP TABLE bug45756_master_not_logged_2;
484462
SET SQL_LOG_BIN= 1;
485463
SET SQL_LOG_BIN= 0;
486464
CREATE TABLE bug45756_master_not_logged_3 (a int) engine = NDB;
487-
Warnings:
488-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
489465
INSERT INTO bug45756_master_not_logged_3 VALUES (1);
490466
DROP TABLE bug45756_master_not_logged_3;
491467
SET SQL_LOG_BIN= 1;
@@ -841,8 +817,6 @@ CREATE TABLE bug_45756_slave_logged_1 (a int) engine = NDB;
841817
INSERT INTO bug_45756_slave_logged_1 VALUES (1);
842818
DROP TABLE bug_45756_slave_logged_1;
843819
CREATE TABLE bug_45756_slave_logged_2 (a int) engine = NDB;
844-
Warnings:
845-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
846820
INSERT INTO bug_45756_slave_logged_2 VALUES (1);
847821
DROP TABLE bug_45756_slave_logged_2;
848822
CREATE TABLE bug_45756_slave_logged_3 (a int) engine = NDB;
@@ -856,8 +830,6 @@ DROP TABLE bug_45756_slave_not_logged_1;
856830
SET SQL_LOG_BIN= 1;
857831
SET SQL_LOG_BIN= 0;
858832
CREATE TABLE bug_45756_slave_not_logged_2 (a int) engine = NDB;
859-
Warnings:
860-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
861833
INSERT INTO bug_45756_slave_not_logged_2 VALUES (1);
862834
DROP TABLE bug_45756_slave_not_logged_2;
863835
SET SQL_LOG_BIN= 1;
@@ -868,23 +840,17 @@ DROP TABLE bug_45756_slave_not_logged_3;
868840
SET SQL_LOG_BIN= 1;
869841
*** Generating data to be replicated ***
870842
CREATE TABLE bug45756_master_logged_1 (a int) engine = NDB;
871-
Warnings:
872-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
873843
INSERT INTO bug45756_master_logged_1 VALUES (1);
874844
DROP TABLE bug45756_master_logged_1;
875845
CREATE TABLE bug45756_master_logged_2 (a int) engine = NDB;
876846
INSERT INTO bug45756_master_logged_2 VALUES (1);
877847
DROP TABLE bug45756_master_logged_2;
878848
CREATE TABLE bug45756_master_logged_3 (a int) engine = NDB;
879-
Warnings:
880-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
881849
INSERT INTO bug45756_master_logged_3 VALUES (1);
882850
DROP TABLE bug45756_master_logged_3;
883851
*** Generating changes not to be replicated ***
884852
SET SQL_LOG_BIN= 0;
885853
CREATE TABLE bug45756_master_not_logged_1 (a int) engine = NDB;
886-
Warnings:
887-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
888854
INSERT INTO bug45756_master_not_logged_1 VALUES (1);
889855
DROP TABLE bug45756_master_not_logged_1;
890856
SET SQL_LOG_BIN= 1;
@@ -895,8 +861,6 @@ DROP TABLE bug45756_master_not_logged_2;
895861
SET SQL_LOG_BIN= 1;
896862
SET SQL_LOG_BIN= 0;
897863
CREATE TABLE bug45756_master_not_logged_3 (a int) engine = NDB;
898-
Warnings:
899-
Warning 1296 Replica updates are only filtered in NDB when using --server-id-bits=32
900864
INSERT INTO bug45756_master_not_logged_3 VALUES (1);
901865
DROP TABLE bug45756_master_not_logged_3;
902866
SET SQL_LOG_BIN= 1;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
!include suite/ndb_rpl/my.cnf
2+
3+
[mysqld]
4+
ndb-log-orig=1

0 commit comments

Comments
 (0)