-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-34784 unhandled FK dependency with DML vs DDL #5041
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
sjaakola
wants to merge
1
commit into
10.11
Choose a base branch
from
10.11-MDEV-34784
base: 10.11
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| connection node_2; | ||
| connection node_1; | ||
| CREATE TABLE parent ( | ||
| id INT PRIMARY KEY, | ||
| KEY (id) | ||
| ) ENGINE=InnoDB; | ||
| CREATE TABLE child ( | ||
| id INT PRIMARY KEY, | ||
| parent_id INT DEFAULT NULL, | ||
| FOREIGN KEY (parent_id) | ||
| REFERENCES parent(id) | ||
| ) ENGINE=InnoDB; | ||
| connection node_2; | ||
| SET SESSION wsrep_sync_wait = 0; | ||
| SET GLOBAL wsrep_slave_threads=2; | ||
| SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_toi"; | ||
| connection node_1; | ||
| ALTER TABLE parent ADD COLUMN (j INT); | ||
| connection node_2; | ||
| SET DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_toi_reached"; | ||
| connection node_1; | ||
| INSERT INTO child(id) values (1); | ||
| connection node_2; | ||
| SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_toi"; | ||
| SET SESSION wsrep_sync_wait = DEFAULT; | ||
| SET DEBUG_SYNC = "RESET"; | ||
| SET GLOBAL DEBUG_DBUG = ''; | ||
| SET GLOBAL wsrep_slave_threads = DEFAULT; | ||
| connection node_1; | ||
| DROP TABLE child; | ||
| DROP TABLE parent; |
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,71 @@ | ||
| # | ||
| # Testing that foreign key constraint dependencies are correctly | ||
| # recorded in write set preventing harmfull parallel applying. | ||
| # | ||
| # In this scenario foreign reference column in child table is left | ||
| # NULL in a DML, and therefore the FK parent table is not appended | ||
| # in the key set. DDL execution on parent table will require table | ||
| # lock on FK child table | ||
| # | ||
|
|
||
| --source include/galera_cluster.inc | ||
| --source include/have_debug.inc | ||
| --source include/have_debug_sync.inc | ||
| --source include/galera_have_debug_sync.inc | ||
|
|
||
| CREATE TABLE parent ( | ||
| id INT PRIMARY KEY, | ||
| KEY (id) | ||
| ) ENGINE=InnoDB; | ||
|
|
||
| CREATE TABLE child ( | ||
| id INT PRIMARY KEY, | ||
| parent_id INT DEFAULT NULL, | ||
| FOREIGN KEY (parent_id) | ||
| REFERENCES parent(id) | ||
| ) ENGINE=InnoDB; | ||
|
|
||
|
|
||
| # Set up sync point for TOI applying in node 2 | ||
| --connection node_2 | ||
| SET SESSION wsrep_sync_wait = 0; | ||
| SET GLOBAL wsrep_slave_threads=2; | ||
|
|
||
| SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_toi"; | ||
|
|
||
| # replicate ALTER | ||
| --connection node_1 | ||
| ALTER TABLE parent ADD COLUMN (j INT); | ||
|
|
||
| # wait for ALTER to reach applying state | ||
| --connection node_2 | ||
| SET DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_toi_reached"; | ||
|
|
||
| # | ||
| # Expect the INSERT to depend on the ALTER, | ||
| # therefore it should wait for the ALTER to | ||
| # finish before it can be applied. | ||
| # If bug is present, the wait condition will | ||
| # timeout | ||
| # | ||
| --let $expected_apply_waits = `SELECT VARIABLE_VALUE+1 FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_apply_waits'` | ||
|
|
||
| --connection node_1 | ||
| # note, the FK column will have NULL value | ||
| INSERT INTO child(id) values (1); | ||
|
|
||
| # check that the INSERT depends on ALTER and waits for ALTER to complete first | ||
| --connection node_2 | ||
| --let $wait_condition = SELECT VARIABLE_VALUE = $expected_apply_waits FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_apply_waits' | ||
| --source include/wait_condition.inc | ||
| SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_toi"; | ||
| SET SESSION wsrep_sync_wait = DEFAULT; | ||
|
|
||
| SET DEBUG_SYNC = "RESET"; | ||
| SET GLOBAL DEBUG_DBUG = ''; | ||
| SET GLOBAL wsrep_slave_threads = DEFAULT; | ||
|
|
||
| --connection node_1 | ||
| DROP TABLE child; | ||
| DROP TABLE parent; | ||
|
|
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
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 |
|---|---|---|
|
|
@@ -567,7 +567,11 @@ static void wsrep_assert_valid_bf_bf_wait(const lock_t *lock, const trx_t *trx, | |
| << " index: " | ||
| << lock->index->name() | ||
| << " that has lock "; | ||
| lock_rec_print(stderr, lock, mtr); | ||
| if (!lock->is_table()) { | ||
| lock_rec_print(stderr, lock, mtr); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this safe i.e. is page always latched? |
||
| } else { | ||
| lock_table_print(stderr, lock); | ||
| } | ||
|
|
||
| ib::error() << "WSREP state: "; | ||
|
|
||
|
|
@@ -1068,10 +1072,20 @@ void wsrep_report_error(const lock_t* victim_lock, const trx_t *bf_trx) | |
| // should not execute concurrently | ||
| mtr_t mtr; | ||
| WSREP_ERROR("BF request is not compatible with victim"); | ||
|
|
||
| auto print_lock_details = [&](const lock_t* lock) { | ||
| if (!lock->is_table()) { | ||
| lock_rec_print(stderr, lock, mtr); | ||
| } else { | ||
| lock_table_print(stderr, lock); | ||
| } | ||
| }; | ||
|
|
||
| WSREP_ERROR("BF requesting lock: "); | ||
| lock_rec_print(stderr, bf_trx->lock.wait_lock, mtr); | ||
| print_lock_details(bf_trx->lock.wait_lock); | ||
|
|
||
| WSREP_ERROR("victim holding lock: "); | ||
| lock_rec_print(stderr, victim_lock, mtr); | ||
| print_lock_details(victim_lock); | ||
| } | ||
| #endif /* WITH_DEBUG */ | ||
|
|
||
|
|
||
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.