Skip to content

Commit

Permalink
Track out of order hlc value during slave apply
Browse files Browse the repository at this point in the history
Summary: Add a counter to track how many out of order hlc has been updated/commit during secondary instances

Reviewed By: abhinav04sharma

Differential Revision: D28632395

fbshipit-source-id: a81aff66649
  • Loading branch information
luqun authored and facebook-github-bot committed Jun 7, 2021
1 parent 1a7a8ce commit c9c2dbe
Show file tree
Hide file tree
Showing 8 changed files with 283 additions and 107 deletions.
1 change: 1 addition & 0 deletions mysql-test/r/information_schema_cs.result
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,7 @@ COLLATIONS information_schema.COLLATIONS 1
COLUMNS information_schema.COLUMNS 1
COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
COLUMN_STATISTICS information_schema.COLUMN_STATISTICS 1
DATABASE_APPLIED_HLC information_schema.DATABASE_APPLIED_HLC 1
ENABLED_ROLES information_schema.ENABLED_ROLES 1
ENGINES information_schema.ENGINES 1
EVENTS information_schema.EVENTS 1
Expand Down
104 changes: 52 additions & 52 deletions mysql-test/suite/rpl_gtid/r/rpl_maintain_database_hlc_rbr.result
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ a b
1 a
2 b
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000002
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000002 0
include/sync_slave_sql_with_master.inc
[connection slave]
include/show_binlog_events.inc
Expand Down Expand Up @@ -84,8 +84,8 @@ a b
1 a
2 b
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000002
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000002 0
Case 2: Multi statement txn
[connection master]
SET autocommit = OFF;
Expand Down Expand Up @@ -127,8 +127,8 @@ a b
3 c
4 d
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000003
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000003 0
include/sync_slave_sql_with_master.inc
[connection slave]
include/show_binlog_events.inc
Expand Down Expand Up @@ -165,8 +165,8 @@ a b
3 c
4 d
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000003
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000003 0
Case 3: Multi statement txn spanning multiple database
[connection master]
SET autocommit = OFF;
Expand Down Expand Up @@ -218,9 +218,9 @@ SELECT * FROM test2.t1;
a b
5 e
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000004
test2 2538630000000000004
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000004 0
test2 2538630000000000004 0
include/sync_slave_sql_with_master.inc
[connection slave]
include/show_binlog_events.inc
Expand Down Expand Up @@ -268,9 +268,9 @@ SELECT * FROM test2.t1;
a b
5 e
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000004
test2 2538630000000000004
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000004 0
test2 2538630000000000004 0
Case 4: Multiple single stmt txns txn spanning multiple database
[connection master]
SET autocommit = OFF;
Expand Down Expand Up @@ -335,9 +335,9 @@ a b
5 e
8 g
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000005
test2 2538630000000000006
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000005 0
test2 2538630000000000006 0
include/sync_slave_sql_with_master.inc
[connection slave]
include/show_binlog_events.inc
Expand Down Expand Up @@ -397,70 +397,70 @@ a b
5 e
8 g
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000005
test2 2538630000000000006
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000005 0
test2 2538630000000000006 0
Case 5: Pure DDL should also update and maintain per database HLC
[connection master]
SET autocommit = OFF;
CREATE TABLE test1.t2(a INT);
CREATE TABLE test2.t2(a INT);
CREATE DATABASE test3;
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000007
test2 2538630000000000008
test3 2538630000000000009
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000007 0
test2 2538630000000000008 0
test3 2538630000000000009 0
include/sync_slave_sql_with_master.inc
[connection slave]
SELECT * FROM information_schema.database_applied_hlc ORDER BY 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000007
test2 2538630000000000008
test3 2538630000000000009
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000007 0
test2 2538630000000000008 0
test3 2538630000000000009 0
Case 6: Duplicate enabling of maintain_database_hlc should not clear the map
[connection master]
SET @@global.maintain_database_hlc = ON;
SET @@global.maintain_database_hlc = ON;
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000007
test2 2538630000000000008
test3 2538630000000000009
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000007 0
test2 2538630000000000008 0
test3 2538630000000000009 0
[connection slave]
SET @@global.maintain_database_hlc = ON;
SET @@global.maintain_database_hlc = ON;
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000007
test2 2538630000000000008
test3 2538630000000000009
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000007 0
test2 2538630000000000008 0
test3 2538630000000000009 0
Case 7: Duplicate enabling of binlog_hlc should not clear the map
[connection master]
SET @@global.enable_binlog_hlc = ON;
SET @@global.enable_binlog_hlc = ON;
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000007
test2 2538630000000000008
test3 2538630000000000009
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000007 0
test2 2538630000000000008 0
test3 2538630000000000009 0
[connection slave]
SET @@global.enable_binlog_hlc = ON;
SET @@global.enable_binlog_hlc = ON;
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000007
test2 2538630000000000008
test3 2538630000000000009
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000007 0
test2 2538630000000000008 0
test3 2538630000000000009 0
Case 8: Disabling maintain_database_hlc should clear the map
[connection master]
SET @@global.maintain_database_hlc = OFF;
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
[connection slave]
SET @@global.maintain_database_hlc = OFF;
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
Case 9: Disabling enable_binlog_hlc should clear the map
[connection master]
SET @@global.maintain_database_hlc = ON;
Expand All @@ -470,19 +470,19 @@ SET @@global.maintain_database_hlc = ON;
insert into test1.t2 values(100);
commit;
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000010
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000010 0
SET @@global.enable_binlog_hlc = OFF;
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
include/sync_slave_sql_with_master.inc
[connection slave]
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
test1 2538630000000000010
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
test1 2538630000000000010 0
SET @@global.enable_binlog_hlc = OFF;
select * from information_schema.database_applied_hlc order by 2, 1;
DATABASE_NAME APPLIED_HLC
DATABASE_NAME APPLIED_HLC NUM_OUT_OF_ORDER_HLC
[connection master]
DROP TABLE test1.t1;
DROP TABLE test2.t1;
Expand Down

0 comments on commit c9c2dbe

Please sign in to comment.