-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MDEV-37541 Race of rolling back and committing transaction to binlog #4301
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
+101
−2
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
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,41 @@ | ||
| create table t1 (a int primary key, b text) engine=innodb; | ||
| connect trx1_rollback,localhost,root,,; | ||
| CREATE TABLE t_x (a int) engine=MEMORY; | ||
| SET binlog_format=row; | ||
| CREATE TEMPORARY TABLE tt_tmp ( id INT ) ENGINE = Memory; | ||
| BEGIN; | ||
| insert into t_x values (1); | ||
| drop temporary table tt_tmp; | ||
| insert into t1 values (99, "gotta log first"); | ||
| SET DEBUG_SYNC= 'reset'; | ||
| SET DEBUG_SYNC= "before_group_commit_queue SIGNAL trx1_at_log WAIT_FOR trx1_go"; | ||
| ROLLBACK; | ||
| connect trx2_commit,localhost,root,,; | ||
| insert into t1 values (99, "second best in binlog"); | ||
| connection default; | ||
| SET DEBUG_SYNC= "now WAIT_FOR trx1_at_log"; | ||
| SET DEBUG_SYNC= "now SIGNAL trx1_go"; | ||
| connection trx2_commit; | ||
| select * from t1; | ||
| a b | ||
| 99 second best in binlog | ||
| # Prove the logging order is Trx1, Trx2 | ||
| include/show_binlog_events.inc | ||
| Log_name Pos Event_type Server_id End_log_pos Info | ||
| master-bin.000001 # Gtid # # BEGIN GTID #-#-# | ||
| master-bin.000001 # Annotate_rows # # insert into t_x values (1) | ||
| master-bin.000001 # Table_map # # table_id: # (test.t_x) | ||
| master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F | ||
| master-bin.000001 # Query # # COMMIT | ||
| master-bin.000001 # Gtid # # BEGIN GTID #-#-# | ||
| master-bin.000001 # Annotate_rows # # insert into t1 values (99, "gotta log first") | ||
| master-bin.000001 # Table_map # # table_id: # (test.t1) | ||
| master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F | ||
| master-bin.000001 # Query # # ROLLBACK | ||
| master-bin.000001 # Gtid # # BEGIN GTID #-#-# | ||
| master-bin.000001 # Query # # use `test`; insert into t1 values (99, "second best in binlog") | ||
| master-bin.000001 # Xid # # COMMIT /* XID */ | ||
| drop table t_x, t1; | ||
| disconnect trx1_rollback; | ||
| disconnect trx2_commit; | ||
| # end of the tests |
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,50 @@ | ||
| --source include/have_debug_sync.inc | ||
| --source include/have_innodb.inc | ||
| --source include/have_binlog_format_mixed.inc | ||
|
|
||
| create table t1 (a int primary key, b text) engine=innodb; | ||
|
|
||
| connect(trx1_rollback,localhost,root,,); | ||
| CREATE TABLE t_x (a int) engine=MEMORY; | ||
|
|
||
| --let $master_file= query_get_value(SHOW MASTER STATUS, File, 1) | ||
| --let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1) | ||
| SET binlog_format=row; | ||
| CREATE TEMPORARY TABLE tt_tmp ( id INT ) ENGINE = Memory; | ||
| BEGIN; | ||
| insert into t_x values (1); | ||
| drop temporary table tt_tmp; | ||
| insert into t1 values (99, "gotta log first"); | ||
|
|
||
| SET DEBUG_SYNC= 'reset'; | ||
| SET DEBUG_SYNC= "before_group_commit_queue SIGNAL trx1_at_log WAIT_FOR trx1_go"; | ||
|
|
||
| --send ROLLBACK | ||
|
|
||
| connect(trx2_commit,localhost,root,,); | ||
| --send insert into t1 values (99, "second best in binlog") | ||
|
|
||
| connection default; | ||
|
|
||
| # Make sure ROLLBACK is in the binlogging phase .. | ||
| SET DEBUG_SYNC= "now WAIT_FOR trx1_at_log"; | ||
| # .. and the contender trx2 in the locking phase .. | ||
| let $wait_condition= | ||
| select count(*) = 1 from information_schema.innodb_trx | ||
| where trx_state = "LOCK WAIT" and trx_query like "%insert into t1 values%"; | ||
| source include/wait_condition.inc; | ||
| # .. when both provided unfreeze the trx:s .. | ||
| SET DEBUG_SYNC= "now SIGNAL trx1_go"; | ||
|
|
||
| connection trx2_commit; | ||
| reap; | ||
| select * from t1; | ||
|
|
||
| # .. to observe proper binlogging. | ||
| --echo # Prove the logging order is Trx1, Trx2 | ||
| --source include/show_binlog_events.inc | ||
|
|
||
| drop table t_x, t1; | ||
| disconnect trx1_rollback; | ||
| disconnect trx2_commit; | ||
| --echo # end of the tests |
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
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.
I haven't had time to fully investigate some of my questions/concerns before I leave for vacation, but I figured I'd at least voice them before I leave.
@knielsen mentions on JIRA
Which I interpret as supporting your solution. But to me it looks a bit unconventional:
Otherwise, it seems we may run other opposite binlog-order problems when rollback is
BINLOG->ENGINEand commit can beENGINE->BINLOGfor direct writes.Uh oh!
There was an error while loading. Please reload this page.
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.
I am somewhat lost with the question.. Let me make it fully clear, the matter at hand is about the engine rollback
runs ahead of its order in the 2pc protocol. The engine completes (a similar would be with COMMIT, but it does not exist that thanks to the same measure as in the patch) the trx before binlog (as coordinator) gets informed.