Skip to content

MDEV-31949 III. Innodb flush_log_later for XA commit,rollback #4054

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
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mysql-test/include/have_spider.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'SPIDER' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
{
--skip Test requires Spider engine
}
1 change: 1 addition & 0 deletions mysql-test/include/have_spider.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--plugin-load-add=$HA_SPIDER_SO
8 changes: 8 additions & 0 deletions mysql-test/include/show_binlog_events2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
# $regexp_replace
# A user's custom addon to standard preexisting list.
#
# $filter_cid
# boolean whether to filer out commit id (0) or not (1)
#

if ($binlog_start)
{
--let $_binlog_start=$binlog_start
}
if (!$binlog_start)
{
# consider instead ./binlog_start_pos.inc
--let $_binlog_start=256
}
if ($binlog_file)
Expand All @@ -36,4 +40,8 @@ if ($binlog_file)
--replace_result "$_from_binlog_start" "from <binlog_start>" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/ $replace_regexp
if ($filter_cid)
{
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/ / cid=[0-9]+// $replace_regexp
}
--eval show binlog events $_in_binlog_file from $_binlog_start
13 changes: 10 additions & 3 deletions mysql-test/include/wait_for_binlog_event.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
#
# USAGE
#
# let $wait_binlog_file= 'master-bin.000001', defaults to the current log
# let $wait_binlog_event= DROP;
# OR
# let $wait_binlog_event= ;pos=4 # as Rotate event signature in the SBE Info

# --source include/wait_for_binlog_event.inc

let $_loop_count= 300;
let $_last_event= ;
let $_event_pos= 1;

if (!$wait_binlog_file)
{
let $wait_binlog_file=query_get_value(SHOW MASTER STATUS, File, 1);
}
while (`SELECT INSTR("$_last_event","$wait_binlog_event") = 0`)
{
dec $_loop_count;
Expand All @@ -22,12 +29,12 @@ while (`SELECT INSTR("$_last_event","$wait_binlog_event") = 0`)
--die ERROR: failed while waiting for $wait_binlog_event in binlog
}
real_sleep 0.1;
let $_event= query_get_value(SHOW BINLOG EVENTS, Info, $_event_pos);
let $_event= query_get_value(SHOW BINLOG EVENTS IN '$wait_binlog_file', Info, $_event_pos);
let $_last_event= $_event;
while ($_event != "No such row")
{
inc $_event_pos;
let $_last_event= $_event;
let $_event= query_get_value(SHOW BINLOG EVENTS, Info, $_event_pos);
let $_event= query_get_value(SHOW BINLOG EVENTS IN '$wait_binlog_file', Info, $_event_pos);
}
}
4 changes: 4 additions & 0 deletions mysql-test/main/alter_table_online_debug.result
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,8 @@ update t set a = 0;
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
xa end 'xid';
xa prepare 'xid';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
xa commit 'xid';
set debug_sync= 'now signal go';
connection default;
Expand All @@ -1707,6 +1709,8 @@ update t set a = 0;
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
xa end 'xid';
xa prepare 'xid';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
xa rollback 'xid';
set debug_sync= 'now signal go';
connection default;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/binary_to_hex.result
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ c9: 0x000000000101000000000000000000F03F000000000000F03F
#Print the table contents in html format

<TABLE BORDER=1><TR><TH>c1</TH><TH>c2</TH><TH>c3</TH><TH>c4</TH><TH>c5</TH><TH>c6</TH><TH>c7</TH><TH>c8</TH><TH>c9</TH></TR><TR><TD>0x74696E79626C6F622D74657874207265616461626C65</TD><TD>0x626C6F622D74657874207265616461626C65</TD><TD>0x6D656469756D626C6F622D74657874207265616461626C65</TD><TD>0x6C6F6E67626C6F622D74657874207265616461626C65</TD><TD>0x74657874207265616461626C65</TD><TD>0x01</TD><TD>0x63</TD><TD>0x7661726961626C65</TD><TD>0x000000000101000000000000000000F03F000000000000F03F</TD></TR></TABLE><TABLE BORDER=1><TR><TH>id</TH><TH>col1</TH><TH>col2</TH></TR><TR><TD>1</TD><TD>0xAB123400000000000000</TD><TD>0x123ABC</TD></TR><TR><TD>2</TD><TD>0xDE123400000000000000</TD><TD>0x123DEF</TD></TR></TABLE>DROP TABLE t1, t2;
create table t1 (a int);
create table t1 (a int) engine=innodb;
formatID gtrid_length bqual_length data
1 3 2 0x7472316271
DROP TABLE t1;
3 changes: 2 additions & 1 deletion mysql-test/main/binary_to_hex.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#

# Save the initial number of concurrent sessions
--source include/have_innodb.inc
--source include/count_sessions.inc
--source include/not_embedded.inc

Expand Down Expand Up @@ -74,7 +75,7 @@ DROP TABLE t1, t2;

# MDEV-14593 human-readable XA RECOVER

create table t1 (a int);
create table t1 (a int) engine=innodb;

--write_file $MYSQLTEST_VARDIR/tmp/mdev-14593.sql
DELIMITER /
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/main/commit.result
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ DELETE FROM t1;
ERROR 25006: Cannot execute statement in a READ ONLY transaction
XA END 'test1';
XA PREPARE 'test1';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
XA COMMIT 'test1';
DROP TABLE t1;
#
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/main/flush_read_lock.result
Original file line number Diff line number Diff line change
Expand Up @@ -1308,10 +1308,14 @@ flush tables with read lock;
xa start 'test1';
xa end 'test1';
xa prepare 'test1';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
xa rollback 'test1';
xa start 'test1';
xa end 'test1';
xa prepare 'test1';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
xa commit 'test1';
xa recover;
unlock tables;
Expand Down
34 changes: 27 additions & 7 deletions mysql-test/main/xa.result
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,14 @@ xa rollback 'a';
xa start 'a';
xa end 'a';
xa prepare 'a';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
xa commit 'a';
xa start 'a';
xa end 'a';
xa prepare 'a';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
xa commit 'a';
CREATE TABLE t1(a INT, KEY(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1),(2);
Expand Down Expand Up @@ -222,8 +226,10 @@ XA END 'x';
XA END 'x';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
XA PREPARE 'x';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
XA PREPARE 'x';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ROLLBACK ONLY state
XA ROLLBACK 'x';
#
# Bug#59986 Assert in Diagnostics_area::set_ok_status() for XA COMMIT
Expand Down Expand Up @@ -324,6 +330,8 @@ connection con2;
XA START 'xid1';
XA END 'xid1';
XA PREPARE 'xid1';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
XA ROLLBACK 'xid1';
connection default;
DROP TABLE t1, t2;
Expand Down Expand Up @@ -396,6 +404,8 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
XA BEGIN 'Я_упaлa_c_сеновала_тормозила_головой';
XA END 'Я_упaлa_c_сеновала_тормозила_головой';
XA PREPARE 'Я_упaлa_c_сеновала_тормозила_головой';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
XA ROLLBACK 'Я_упaлa_c_сеновала_тормозила_головой';
SET NAMES default;
DROP TABLE t1;
Expand All @@ -422,9 +432,11 @@ XA ROLLBACK 'unknown';
ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction
XA END 'xid1';
XA PREPARE 'xid1';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
XA COMMIT 'xid1' ONE PHASE;
ERROR XAE05: XAER_INVAL: Invalid arguments (or unsupported command)
XA ROLLBACK 'xid1';
ERROR XAE04: XAER_NOTA: Unknown XID
#
# MDEV-21856 - xid_t::formatID has to be constrained to 4 byte size
#
Expand Down Expand Up @@ -463,8 +475,10 @@ SELECT * FROM t;
a
XA END '0';
XA PREPARE '0';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
HANDLER t READ NEXT;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ROLLBACK ONLY state
# Cleanup
XA COMMIT '0';
DROP TABLE t;
Expand Down Expand Up @@ -555,13 +569,17 @@ select 0;
0
xa end '1';
xa prepare '1';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
xa commit '1';
xa start '2';
select 0;
0
0
xa end '2';
xa prepare '2';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
xa rollback '2';
# Read-only disconnect case
connect con1_ro,localhost,root,,;
Expand All @@ -571,27 +589,29 @@ select 0;
0
xa end '3';
xa prepare '3';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
disconnect con1_ro;
connection default;
xa recover;
formatID gtrid_length bqual_length data
1 1 0 3
xa commit '3';
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
ERROR XAE04: XAER_NOTA: Unknown XID
connect con2_ro,localhost,root,,;
xa start '4';
select 0;
0
0
xa end '4';
xa prepare '4';
Warnings:
Note 4226 Found to be read-only XA transaction is rolled back
disconnect con2_ro;
connection default;
xa recover;
formatID gtrid_length bqual_length data
1 1 0 4
xa rollback '4';
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
ERROR XAE04: XAER_NOTA: Unknown XID
set @@global.read_only=@sav_read_only;
#
# End of 10.5 tests
Expand Down
8 changes: 5 additions & 3 deletions mysql-test/main/xa.test
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,10 @@ XA COMMIT 'unknown' ONE PHASE;
XA ROLLBACK 'unknown';
XA END 'xid1';
XA PREPARE 'xid1';
--error ER_XAER_INVAL
# marked to rollback at prepare does not warn (maybe it should)
--error 0
XA COMMIT 'xid1' ONE PHASE;
--error ER_XAER_NOTA
XA ROLLBACK 'xid1';


Expand Down Expand Up @@ -731,7 +733,7 @@ disconnect con1_ro;
connection default;
--source include/wait_until_count_sessions.inc
xa recover;
--error ER_XA_RBROLLBACK
--error ER_XAER_NOTA
xa commit '3';

--source include/count_sessions.inc
Expand All @@ -745,7 +747,7 @@ disconnect con2_ro;
connection default;
--source include/wait_until_count_sessions.inc
xa recover;
--error ER_XA_RBROLLBACK
--error ER_XAER_NOTA
xa rollback '4';

set @@global.read_only=@sav_read_only;
Expand Down
14 changes: 4 additions & 10 deletions mysql-test/main/xa_binlog.result
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ XA END 'x';
XA PREPARE 'x';
Warnings:
Warning 1030 Got error 131 "Command not supported by the engine" from storage engine Aria
Note 4226 Found to be read-only XA transaction is rolled back
XA COMMIT 'x';
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
SELECT * from t1;
a
XA BEGIN 'x';
Expand All @@ -36,6 +39,7 @@ XA END 'x';
XA PREPARE 'x';
Warnings:
Warning 1030 Got error 131 "Command not supported by the engine" from storage engine Aria
Note 4226 Found to be read-only XA transaction is rolled back
XA ROLLBACK 'x';
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
Expand Down Expand Up @@ -68,18 +72,8 @@ master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Gtid 1 # BEGIN GTID #-#-#
master-bin.000001 # Query 1 # use `test`; DELETE FROM t1
master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Gtid 1 # XA START X'78',X'',1 GTID #-#-#
master-bin.000001 # Query 1 # XA END X'78',X'',1
master-bin.000001 # XA_prepare 1 # XA PREPARE X'78',X'',1
master-bin.000001 # Gtid 1 # GTID #-#-#
master-bin.000001 # Query 1 # XA COMMIT X'78',X'',1
master-bin.000001 # Gtid 1 # BEGIN GTID #-#-#
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (3),(4)
master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Gtid 1 # XA START X'78',X'',1 GTID #-#-#
master-bin.000001 # Query 1 # XA END X'78',X'',1
master-bin.000001 # XA_prepare 1 # XA PREPARE X'78',X'',1
master-bin.000001 # Gtid 1 # GTID #-#-#
master-bin.000001 # Query 1 # XA ROLLBACK X'78',X'',1
master-bin.000001 # Gtid 1 # GTID #-#-#
master-bin.000001 # Query 1 # use `test`; DROP TABLE `t1` /* generated by server */
Loading