-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-37977 InnoDB deadlock report incorrectly reports rolled back transaction number #4679
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
arcivanov
wants to merge
1
commit into
MariaDB:10.11
Choose a base branch
from
arcivanov:MDEV-37977
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
Some comments aren't visible on the classic Files Changed page.
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,36 @@ | ||
| # | ||
| # MDEV-37977 InnoDB deadlock report incorrectly reports | ||
| # rolled back transaction number | ||
| # | ||
| SET @save_print_all_deadlocks= @@GLOBAL.innodb_print_all_deadlocks; | ||
| SET GLOBAL innodb_print_all_deadlocks= ON; | ||
| CREATE TABLE t1 (id INT PRIMARY KEY, val INT) ENGINE=InnoDB; | ||
| INSERT INTO t1 VALUES (1, 10), (2, 20); | ||
| # | ||
| # Classic deadlock: con1 locks row 1 then tries row 2; | ||
| # default locks row 2 then tries row 1. | ||
| # The requesting transaction (default) is always the preferred | ||
| # victim due to bit 0 in calc_victim_weight(). In a 2-transaction | ||
| # cycle, find_cycle() returns the other transaction, so the | ||
| # requesting transaction is displayed as "(1) TRANSACTION". | ||
| # The rollback message must say "WE ROLL BACK TRANSACTION (1)". | ||
| # | ||
| connect con1,localhost,root,,; | ||
| BEGIN; | ||
| UPDATE t1 SET val= 11 WHERE id= 1; | ||
| connection default; | ||
| BEGIN; | ||
| UPDATE t1 SET val= 22 WHERE id= 2; | ||
| connection con1; | ||
| UPDATE t1 SET val= 12 WHERE id= 2; | ||
| connection default; | ||
| UPDATE t1 SET val= 21 WHERE id= 1; | ||
| ERROR 40001: Deadlock found when trying to get lock; try restarting transaction | ||
| ROLLBACK; | ||
| connection con1; | ||
| ROLLBACK; | ||
| connection default; | ||
| FOUND 1 /WE ROLL BACK TRANSACTION \(1\)/ in mysqld.1.err | ||
| disconnect con1; | ||
| SET GLOBAL innodb_print_all_deadlocks= @save_print_all_deadlocks; | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| --echo # | ||
| --echo # MDEV-37977 InnoDB deadlock report incorrectly reports | ||
| --echo # rolled back transaction number | ||
| --echo # | ||
|
|
||
| --source include/not_embedded.inc | ||
| --source include/have_innodb.inc | ||
| --source include/count_sessions.inc | ||
|
|
||
| SET @save_print_all_deadlocks= @@GLOBAL.innodb_print_all_deadlocks; | ||
| SET GLOBAL innodb_print_all_deadlocks= ON; | ||
|
|
||
| CREATE TABLE t1 (id INT PRIMARY KEY, val INT) ENGINE=InnoDB; | ||
| INSERT INTO t1 VALUES (1, 10), (2, 20); | ||
|
|
||
| --echo # | ||
| --echo # Classic deadlock: con1 locks row 1 then tries row 2; | ||
| --echo # default locks row 2 then tries row 1. | ||
| --echo # The requesting transaction (default) is always the preferred | ||
| --echo # victim due to bit 0 in calc_victim_weight(). In a 2-transaction | ||
| --echo # cycle, find_cycle() returns the other transaction, so the | ||
| --echo # requesting transaction is displayed as "(1) TRANSACTION". | ||
| --echo # The rollback message must say "WE ROLL BACK TRANSACTION (1)". | ||
| --echo # | ||
|
|
||
| --connect (con1,localhost,root,,) | ||
| BEGIN; | ||
| UPDATE t1 SET val= 11 WHERE id= 1; | ||
|
|
||
| --connection default | ||
| BEGIN; | ||
| UPDATE t1 SET val= 22 WHERE id= 2; | ||
|
|
||
| --connection con1 | ||
| --send UPDATE t1 SET val= 12 WHERE id= 2 | ||
|
|
||
| --connection default | ||
| let $wait_condition= | ||
| SELECT COUNT(*) >= 2 FROM INFORMATION_SCHEMA.INNODB_LOCKS | ||
| WHERE lock_table LIKE '%t1%'; | ||
| --source include/wait_condition.inc | ||
|
|
||
| --error ER_LOCK_DEADLOCK | ||
| UPDATE t1 SET val= 21 WHERE id= 1; | ||
| ROLLBACK; | ||
|
|
||
| --connection con1 | ||
| --reap | ||
| ROLLBACK; | ||
|
|
||
| --connection default | ||
| let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; | ||
| let SEARCH_PATTERN= WE ROLL BACK TRANSACTION \(1\); | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| --disconnect con1 | ||
| SET GLOBAL innodb_print_all_deadlocks= @save_print_all_deadlocks; | ||
| DROP TABLE t1; | ||
| --source include/wait_until_count_sessions.inc | ||
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
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.
We could move the
--disconnect con1right after theROLLBACK, to reduce the wait time at the end.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.
So would you prefer a descriptive name with a standalone test or integration into an existing one?