Repository navigation
[8.4]PXC-5203: Cluster disruption or deadlock with LOCK TABLES/INSTANCE FO… #2318
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
Merged
Merged
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
33 changes: 33 additions & 0 deletions
33
mysql-test/suite/galera/r/pxc_backup_lock_toi_reject.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,33 @@ | ||
| # | ||
| # 1. Create table t1 on node_1, wait for it on node_2. | ||
| # | ||
| CREATE TABLE t1 (id INT PRIMARY KEY, a INT, KEY k_a (a)) ENGINE=InnoDB; | ||
| INSERT INTO t1 VALUES (1, 10), (2, 20), (3, 30); | ||
| # | ||
| # 2. LOCK TABLES FOR BACKUP, ALTER TABLE will fail, | ||
| # Assert transaction is not replicated. | ||
| # | ||
| LOCK TABLES FOR BACKUP; | ||
| ALTER TABLE t1 DROP KEY k_a; | ||
| ERROR HY000: Can't execute the query because you have a conflicting backup lock | ||
| include/assert.inc [k_a index must still exist on node_1 (statement rejected locally)] | ||
| include/assert.inc [wsrep_last_committed must not advance on node_1 -- ALTER was not replicated] | ||
| include/assert.inc [k_a index must still exist on node_2 -- nothing was replicated] | ||
| include/assert.inc [Cluster must still have both nodes (no inconsistency vote / node eviction)] | ||
| UNLOCK TABLES; | ||
| # | ||
| # 3. After UNLOCK, the same ALTER TABLE succeeds and replicates normally. | ||
| # | ||
| ALTER TABLE t1 DROP KEY k_a; | ||
| # | ||
| # 4. LOCK INSTANCE FOR BACKUP with same-session DDL is replicated. | ||
| # | ||
| ALTER TABLE t1 ADD KEY k_a (a); | ||
| LOCK INSTANCE FOR BACKUP; | ||
| ALTER TABLE t1 DROP KEY k_a; | ||
| UNLOCK INSTANCE; | ||
| include/assert.inc [k_a index must be dropped on node_1 -- LOCK INSTANCE FOR BACKUP allows same-session DDL] | ||
| # | ||
| # 5. Cleanup. | ||
| # | ||
| DROP TABLE t1; |
115 changes: 115 additions & 0 deletions
115
mysql-test/suite/galera/t/pxc_backup_lock_toi_reject.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,115 @@ | ||
| ################################################################################ | ||
| # | ||
| # PXC-5203: A session holding LOCK TABLES FOR BACKUP that then runs its own | ||
| # DDL used to have the DDL replicated via Galera TOI *before* the local | ||
| # backup-lock check rejected it. Peers applied the DDL successfully while the | ||
| # originating node failed the statement locally -- a certification-vs-local | ||
| # result divergence that made Galera raise an "Inconsistency detected" vote | ||
| # and kick the node out of the cluster. | ||
| # | ||
| # This test proves the DDL is now rejected immediately, before it ever | ||
| # reaches TOI/replication, so peers never see it and no divergence occurs. | ||
| # It also proves LOCK INSTANCE FOR BACKUP (the ticket's "no problem" case) | ||
| # keeps working exactly as before: same-session DDL still succeeds and | ||
| # still replicates normally. | ||
| # | ||
| ################################################################################ | ||
| # 1. Create table t1 on node_1, wait for it on node_2. | ||
| # 2. LOCK TABLES FOR BACKUP + same-session ALTER TABLE fails immediately with | ||
| # ER_CANT_EXECUTE_WITH_BACKUP_LOCK; the index change never reaches node_2. | ||
| # 3. After UNLOCK, the same ALTER TABLE succeeds and replicates normally. | ||
| # 4. LOCK INSTANCE FOR BACKUP with same-session DDL is replicated. | ||
| # 5. Cleanup. | ||
| ################################################################################ | ||
| --source include/galera_cluster.inc | ||
|
|
||
| --echo # | ||
| --echo # 1. Create table t1 on node_1, wait for it on node_2. | ||
| --echo # | ||
|
|
||
| --connection node_1 | ||
| CREATE TABLE t1 (id INT PRIMARY KEY, a INT, KEY k_a (a)) ENGINE=InnoDB; | ||
| INSERT INTO t1 VALUES (1, 10), (2, 20), (3, 30); | ||
|
|
||
| --connection node_2 | ||
| --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1' | ||
| --source include/wait_condition.inc | ||
|
|
||
| --echo # | ||
| --echo # 2. LOCK TABLES FOR BACKUP, ALTER TABLE will fail, | ||
| --echo # Assert transaction is not replicated. | ||
| --echo # | ||
|
|
||
| --connection node_1 | ||
| --let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_last_committed'` | ||
|
|
||
| LOCK TABLES FOR BACKUP; | ||
| --error ER_CANT_EXECUTE_WITH_BACKUP_LOCK | ||
| ALTER TABLE t1 DROP KEY k_a; | ||
|
|
||
| --let $assert_text = k_a index must still exist on node_1 (statement rejected locally) | ||
| --let $assert_cond = COUNT(*) = 1 FROM information_schema.statistics WHERE TABLE_NAME="t1" AND INDEX_NAME="k_a" AND TABLE_SCHEMA=DATABASE() | ||
| --source include/assert.inc | ||
|
|
||
| # A TOI-replicated DDL is assigned a seqno before it returns, even if it then | ||
| # fails, so an unchanged wsrep_last_committed proves the ALTER never reached TOI. | ||
| --let $assert_text = wsrep_last_committed must not advance on node_1 -- ALTER was not replicated | ||
| --let $assert_cond = (SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME = "wsrep_last_committed") = $wsrep_last_committed_before | ||
| --source include/assert.inc | ||
|
|
||
| # Make sure node_2 has applied everything node_1 has committed before checking it. | ||
| --connection node_2 | ||
| --let $wait_condition = SELECT VARIABLE_VALUE >= $wsrep_last_committed_before FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_last_committed' | ||
| --source include/wait_condition.inc | ||
|
|
||
| --let $assert_text = k_a index must still exist on node_2 -- nothing was replicated | ||
| --let $assert_cond = COUNT(*) = 1 FROM information_schema.statistics WHERE TABLE_NAME="t1" AND INDEX_NAME="k_a" AND TABLE_SCHEMA=DATABASE() | ||
| --source include/assert.inc | ||
|
|
||
| --let $assert_text = Cluster must still have both nodes (no inconsistency vote / node eviction) | ||
| --let $assert_cond = (SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME="wsrep_cluster_size") = 2 | ||
| --source include/assert.inc | ||
|
|
||
| --connection node_1 | ||
| UNLOCK TABLES; | ||
|
|
||
| --echo # | ||
| --echo # 3. After UNLOCK, the same ALTER TABLE succeeds and replicates normally. | ||
| --echo # | ||
|
|
||
| ALTER TABLE t1 DROP KEY k_a; | ||
|
|
||
| --connection node_2 | ||
| --let $wait_condition = SELECT COUNT(*) = 0 FROM information_schema.statistics WHERE TABLE_NAME="t1" AND INDEX_NAME="k_a" AND TABLE_SCHEMA=DATABASE() | ||
| --source include/wait_condition.inc | ||
|
|
||
| --echo # | ||
| --echo # 4. LOCK INSTANCE FOR BACKUP with same-session DDL is replicated. | ||
| --echo # | ||
|
|
||
| --connection node_1 | ||
| ALTER TABLE t1 ADD KEY k_a (a); | ||
|
|
||
| --connection node_2 | ||
| --let $wait_condition = SELECT COUNT(*) = 1 FROM information_schema.statistics WHERE TABLE_NAME="t1" AND INDEX_NAME="k_a" AND TABLE_SCHEMA=DATABASE() | ||
| --source include/wait_condition.inc | ||
|
|
||
| --connection node_1 | ||
| LOCK INSTANCE FOR BACKUP; | ||
| ALTER TABLE t1 DROP KEY k_a; | ||
| UNLOCK INSTANCE; | ||
|
|
||
| --let $assert_text = k_a index must be dropped on node_1 -- LOCK INSTANCE FOR BACKUP allows same-session DDL | ||
| --let $assert_cond = COUNT(*) = 0 FROM information_schema.statistics WHERE TABLE_NAME="t1" AND INDEX_NAME="k_a" AND TABLE_SCHEMA=DATABASE() | ||
| --source include/assert.inc | ||
|
|
||
| --connection node_2 | ||
| --let $wait_condition = SELECT COUNT(*) = 0 FROM information_schema.statistics WHERE TABLE_NAME="t1" AND INDEX_NAME="k_a" AND TABLE_SCHEMA=DATABASE() | ||
| --source include/wait_condition.inc | ||
|
|
||
| --echo # | ||
| --echo # 5. Cleanup. | ||
| --echo # | ||
|
|
||
| --connection node_1 | ||
| DROP TABLE t1; | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.