-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-28213 Skip ignored domain IDs during GTID validation #4677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bodyhedia44
wants to merge
1
commit into
MariaDB:main
Choose a base branch
from
bodyhedia44:MDEV-28213-fix-ignored-domain-validation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
mysql-test/suite/rpl/r/rpl_gtid_ignored_domain_ids_validation.result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| include/rpl_init.inc [topology=1->2] | ||
| # | ||
| # Setup: Create tables in two GTID domains on master | ||
| # | ||
| connection server_1; | ||
| SET @@session.gtid_domain_id= 1; | ||
| CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| INSERT INTO t1 VALUES (1); | ||
| SET @@session.gtid_domain_id= 2; | ||
| CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| INSERT INTO t2 VALUES (100); | ||
| connection server_2; | ||
| SELECT * FROM t1; | ||
| a | ||
| 1 | ||
| SELECT * FROM t2; | ||
| a | ||
| 100 | ||
| # | ||
| # Test 1: IGNORE_DOMAIN_IDS with purged binlogs should not cause error 1236 | ||
| # | ||
| connection server_2; | ||
| include/stop_slave.inc | ||
| connection server_1; | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (200); | ||
| INSERT INTO t2 VALUES (201); | ||
| FLUSH LOGS; | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (202); | ||
| FLUSH LOGS; | ||
| include/wait_for_purge.inc "master-bin.000003" | ||
| show binary logs; | ||
| Log_name File_size | ||
| master-bin.000003 # | ||
| connection server_2; | ||
| CHANGE MASTER TO IGNORE_DOMAIN_IDS=(2), MASTER_USE_GTID=slave_pos; | ||
| include/start_slave.inc | ||
| connection server_1; | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (2); | ||
| connection server_2; | ||
| # Slave should have domain 1 data (the domain it cares about) | ||
| SELECT * FROM t1 ORDER BY a; | ||
| a | ||
| 1 | ||
| 2 | ||
| connection server_1; | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (250); | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (5); | ||
| connection server_2; | ||
| # Domain 1 row should arrive; domain 2 row should be filtered out | ||
| SELECT * FROM t1 ORDER BY a; | ||
| a | ||
| 1 | ||
| 2 | ||
| 5 | ||
| SELECT MAX(a) < 250 AS domain2_filtered FROM t2; | ||
| domain2_filtered | ||
| 1 | ||
| # | ||
| # Test 2: DO_DOMAIN_IDS with purged binlogs should not cause error 1236 | ||
| # | ||
| connection server_2; | ||
| include/stop_slave.inc | ||
| connection server_1; | ||
| connection server_2; | ||
| CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), DO_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; | ||
| include/start_slave.inc | ||
| connection server_1; | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (3); | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (300); | ||
| connection server_2; | ||
| include/stop_slave.inc | ||
| connection server_1; | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (400); | ||
| INSERT INTO t2 VALUES (401); | ||
| FLUSH LOGS; | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (402); | ||
| FLUSH LOGS; | ||
| include/wait_for_purge.inc "master-bin.000005" | ||
| show binary logs; | ||
| Log_name File_size | ||
| master-bin.000005 # | ||
| connection server_2; | ||
| CHANGE MASTER TO DO_DOMAIN_IDS=(1), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; | ||
| include/start_slave.inc | ||
| connection server_1; | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (4); | ||
| connection server_2; | ||
| # Slave should have all domain 1 data | ||
| SELECT * FROM t1 ORDER BY a; | ||
| a | ||
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| connection server_1; | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (500); | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (6); | ||
| connection server_2; | ||
| # Domain 1 row should arrive; domain 2 row should be filtered | ||
| SELECT * FROM t1 ORDER BY a; | ||
| a | ||
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| SELECT MAX(a) < 500 AS domain2_filtered FROM t2; | ||
| domain2_filtered | ||
| 1 | ||
| # | ||
| # Cleanup | ||
| # | ||
| connection server_2; | ||
| include/stop_slave.inc | ||
| connection server_1; | ||
| connection server_2; | ||
| CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; | ||
| include/start_slave.inc | ||
| connection server_1; | ||
| SET @@session.gtid_domain_id= 0; | ||
| DROP TABLE t1, t2; | ||
| connection server_2; | ||
| include/rpl_end.inc |
219 changes: 219 additions & 0 deletions
219
mysql-test/suite/rpl/t/rpl_gtid_ignored_domain_ids_validation.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,219 @@ | ||
| --source include/have_innodb.inc | ||
| --let $rpl_topology=1->2 | ||
| --source include/rpl_init.inc | ||
|
|
||
| # | ||
| # MDEV-28213: A slave's ignored domain ids should not be validated when | ||
| # connecting to a master. | ||
| # | ||
| # When a slave connects to a master using MASTER_USE_GTID=Slave_Pos and the | ||
| # master has purged old binlogs, the master validates the slave's GTID state | ||
| # against the oldest available binlog's Gtid_list event. If the master's | ||
| # Gtid_list contains domains that the slave is configured to ignore (via | ||
| # IGNORE_DOMAIN_IDS or DO_DOMAIN_IDS), those domains should NOT be validated. | ||
| # Previously this would cause error 1236. | ||
| # | ||
|
|
||
| --echo # | ||
| --echo # Setup: Create tables in two GTID domains on master | ||
| --echo # | ||
|
|
||
| --connection server_1 | ||
| SET @@session.gtid_domain_id= 1; | ||
| CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| INSERT INTO t1 VALUES (1); | ||
|
|
||
| SET @@session.gtid_domain_id= 2; | ||
| CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| INSERT INTO t2 VALUES (100); | ||
|
|
||
| # Sync slave with master for both domains | ||
| --save_master_pos | ||
|
|
||
| --connection server_2 | ||
| --sync_with_master | ||
|
|
||
| SELECT * FROM t1; | ||
| SELECT * FROM t2; | ||
|
|
||
| --echo # | ||
| --echo # Test 1: IGNORE_DOMAIN_IDS with purged binlogs should not cause error 1236 | ||
| --echo # | ||
|
|
||
| --connection server_2 | ||
| --source include/stop_slave.inc | ||
|
|
||
| --connection server_1 | ||
| # While slave is stopped, only advance domain 2 (which will be ignored). | ||
| # Domain 1 stays at the same position so the slave can still connect for it. | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (200); | ||
| INSERT INTO t2 VALUES (201); | ||
|
|
||
| # Flush logs to rotate the binlog file, then flush again so we have a newer | ||
| # file to purge up to. | ||
| FLUSH LOGS; | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (202); | ||
| FLUSH LOGS; | ||
|
|
||
| # Now purge all binlogs except the latest. | ||
| # The oldest remaining binlog's Gtid_list will reference both domains. | ||
| # Domain 1 will still be at the position the slave knows (up to date). | ||
| # Domain 2 will have advanced past the slave's position (stale for slave). | ||
| --let $purge_binlogs_to= query_get_value(SHOW MASTER STATUS, File, 1) | ||
| --source include/wait_for_purge.inc | ||
| --source include/show_binary_logs.inc | ||
|
|
||
| --connection server_2 | ||
| # Configure slave to ignore domain 2. The slave has no up-to-date position | ||
| # for domain 2 since it was stopped before the latest domain 2 transactions. | ||
| # Without the fix, connecting would fail with error 1236 because the master | ||
| # validates domain 2's position even though the slave doesn't care about it. | ||
| CHANGE MASTER TO IGNORE_DOMAIN_IDS=(2), MASTER_USE_GTID=slave_pos; | ||
| --source include/start_slave.inc | ||
|
|
||
| # Verify slave can connect and replicate domain 1 data | ||
| --connection server_1 | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (2); | ||
| --save_master_pos | ||
|
|
||
| --connection server_2 | ||
| --sync_with_master | ||
|
|
||
| --echo # Slave should have domain 1 data (the domain it cares about) | ||
| SELECT * FROM t1 ORDER BY a; | ||
|
|
||
| # Verify that new transactions in the ignored domain (2) do not break | ||
| # replication. Previously, the connection would never get this far because | ||
| # it would error at connect time. | ||
| --connection server_1 | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (250); | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (5); | ||
| --save_master_pos | ||
|
|
||
| --connection server_2 | ||
| --sync_with_master | ||
|
|
||
| --echo # Domain 1 row should arrive; domain 2 row should be filtered out | ||
| SELECT * FROM t1 ORDER BY a; | ||
| # t2 should NOT have the new row since domain 2 is ignored | ||
| SELECT MAX(a) < 250 AS domain2_filtered FROM t2; | ||
|
|
||
| --echo # | ||
| --echo # Test 2: DO_DOMAIN_IDS with purged binlogs should not cause error 1236 | ||
| --echo # | ||
|
|
||
| --connection server_2 | ||
| --source include/stop_slave.inc | ||
|
|
||
| # The slave ignored domain 2 during test 1, so its position for domain 2 | ||
| # is stale. We need to update it to match the master before we can start | ||
| # replication without the ignore filter. | ||
| --connection server_1 | ||
| --let $master_pos= `SELECT @@GLOBAL.gtid_binlog_pos` | ||
| --connection server_2 | ||
| --disable_query_log | ||
| --eval SET GLOBAL gtid_slave_pos='$master_pos' | ||
| --enable_query_log | ||
|
|
||
| # Reset domain filtering and sync up | ||
| CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), DO_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; | ||
| --source include/start_slave.inc | ||
|
|
||
| # Sync up everything | ||
| --connection server_1 | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (3); | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (300); | ||
| --save_master_pos | ||
|
|
||
| --connection server_2 | ||
| --sync_with_master | ||
| --source include/stop_slave.inc | ||
|
|
||
| --connection server_1 | ||
| # While slave is stopped, only advance domain 2 (which will NOT be in DO list). | ||
| # Domain 1 stays current so the slave can connect for it. | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (400); | ||
| INSERT INTO t2 VALUES (401); | ||
|
|
||
| # Create new binlog and purge old ones | ||
| FLUSH LOGS; | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (402); | ||
| FLUSH LOGS; | ||
|
|
||
| # Purge all old binlogs | ||
| --let $purge_binlogs_to= query_get_value(SHOW MASTER STATUS, File, 1) | ||
| --source include/wait_for_purge.inc | ||
| --source include/show_binary_logs.inc | ||
|
|
||
| --connection server_2 | ||
| # Configure slave with DO_DOMAIN_IDS=(1) -- only replicate domain 1. | ||
| # This means domain 2 should be ignored during validation. | ||
| # Without the fix, this would fail because the master's oldest binlog | ||
| # references domain 2 but slave may not have the latest position for it. | ||
| CHANGE MASTER TO DO_DOMAIN_IDS=(1), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; | ||
| --source include/start_slave.inc | ||
|
|
||
| --connection server_1 | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (4); | ||
| --save_master_pos | ||
|
|
||
| --connection server_2 | ||
| --sync_with_master | ||
|
|
||
| --echo # Slave should have all domain 1 data | ||
| SELECT * FROM t1 ORDER BY a; | ||
|
|
||
| # Verify that new transactions in the non-DO domain (2) do not break | ||
| # replication when DO_DOMAIN_IDS=(1) is active. | ||
| --connection server_1 | ||
| SET @@session.gtid_domain_id= 2; | ||
| INSERT INTO t2 VALUES (500); | ||
| SET @@session.gtid_domain_id= 1; | ||
| INSERT INTO t1 VALUES (6); | ||
| --save_master_pos | ||
|
|
||
| --connection server_2 | ||
| --sync_with_master | ||
|
|
||
| --echo # Domain 1 row should arrive; domain 2 row should be filtered | ||
| SELECT * FROM t1 ORDER BY a; | ||
| SELECT MAX(a) < 500 AS domain2_filtered FROM t2; | ||
|
|
||
| --echo # | ||
| --echo # Cleanup | ||
| --echo # | ||
|
|
||
| --connection server_2 | ||
| --source include/stop_slave.inc | ||
|
|
||
| # Update slave's GTID position to match master for all domains, | ||
| # since domain 2 was not replicated during test 2. | ||
| --connection server_1 | ||
| --let $master_pos= `SELECT @@GLOBAL.gtid_binlog_pos` | ||
| --connection server_2 | ||
| --disable_query_log | ||
| --eval SET GLOBAL gtid_slave_pos='$master_pos' | ||
| --enable_query_log | ||
|
|
||
| CHANGE MASTER TO DO_DOMAIN_IDS=(), IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; | ||
| --source include/start_slave.inc | ||
|
|
||
| --connection server_1 | ||
| SET @@session.gtid_domain_id= 0; | ||
| DROP TABLE t1, t2; | ||
| --save_master_pos | ||
|
|
||
| --connection server_2 | ||
| --sync_with_master | ||
|
|
||
| --source include/rpl_end.inc | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something that should also be tested here is what happens when new transactions arrive from
gtid_domain_id=2. They should be ignored, but we want to make sure it doesn't cause replication to break. Previously, the replication connection would never get this far b/c it would error at connection time.