Skip to content

Commit 2e785b3

Browse files
Debarun BanerjeeHery Ramilison
authored andcommitted
BUG#25032066 PREPARED TRANSACTION SHOULD NOT BE ROLLED BACK
BY HIGH PRIORITY TRANSACTION Problem : --------- 1. delete_all_rows() and rnd_init() are not returning error after async rollback in 5.7. This results in assert in innodb in next call. 2. High priority transaction is rolling back prepared transaction. This is because TRX_FORCE_ROLLBACK_DISABLE is getting set only for first entry [TrxInInnoDB]. Solution : ---------- 1. return DB_FORCED_ABORT error after rollback. 2. check and disable rollback in TrxInInnodb::enter always. Reviewed-by: Sunny Bains <sunny.bains@oracle.com> RB: 13777 (cherry picked from commit 628f957a874dfcdc5431c52a39b5363c13a1fdba)
1 parent a568faf commit 2e785b3

22 files changed

+137
-57
lines changed

mysql-test/suite/innodb/r/high_prio_trx_debug.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,21 @@ select * from t1;
2525
c1
2626
2
2727
DROP TABLE t1;
28+
#
29+
# Bug #25032066: PREPARED TRANSACTION SHOULD NOT BE ROLLED BACK
30+
#
31+
CREATE TABLE t1(col1 int PRIMARY KEY, col2 int);
32+
INSERT INTO t1 VALUES(1, 10);
33+
XA START 'xid1';
34+
UPDATE t1 SET col2 = 20;
35+
XA END 'xid1';
36+
XA PREPARE 'xid1';
37+
include/start_transaction_high_prio.inc
38+
START TRANSACTION /* HIGH PRIORITY */;
39+
UPDATE t1 SET col2 = 30 WHERE col2 = 10;;
40+
XA COMMIT 'xid1';
41+
COMMIT;
42+
SELECT * FROM t1;
43+
col1 col2
44+
1 20
45+
DROP TABLE t1;

mysql-test/suite/innodb/t/high_prio_trx_debug.test

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ select * from t1;
3333
SET DEBUG_SYNC='trx_kill_blocking_enter SIGNAL enter_innodb';
3434
UPDATE t1 SET c1=2 WHERE c1=0;
3535
commit;
36-
--disconnect con1
3736

3837
--connection default
3938
--error ER_LOCK_DEADLOCK
@@ -42,4 +41,34 @@ commit;
4241
select * from t1;
4342
DROP TABLE t1;
4443

44+
--echo #
45+
--echo # Bug #25032066: PREPARED TRANSACTION SHOULD NOT BE ROLLED BACK
46+
--echo #
47+
48+
CREATE TABLE t1(col1 int PRIMARY KEY, col2 int);
49+
INSERT INTO t1 VALUES(1, 10);
50+
51+
XA START 'xid1';
52+
UPDATE t1 SET col2 = 20;
53+
XA END 'xid1';
54+
XA PREPARE 'xid1';
55+
56+
--connection con1
57+
--source include/start_transaction_high_prio.inc
58+
--send UPDATE t1 SET col2 = 30 WHERE col2 = 10;
59+
--sleep 1
60+
61+
--connection default
62+
XA COMMIT 'xid1';
63+
64+
--connection con1
65+
--reap
66+
COMMIT;
67+
68+
--connection default
69+
SELECT * FROM t1;
70+
71+
--disconnect con1
72+
DROP TABLE t1;
73+
4574
--source include/wait_until_count_sessions.inc

rapid/plugin/group_replication/tests/mtr/r/gr_multi_primary_foreign_key_conflict.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ COMMIT;
3535
# certification, since server_1 is blocked before broadcast.
3636
[connection server2]
3737
UPDATE t1 SET a=2 WHERE a=1;
38-
include/sync_slave_sql_with_master.inc
3938

4039
############################################################
4140
# 5. Signal the waiting thread on server_1 to resume.
@@ -47,6 +46,8 @@ SET @@GLOBAL.DEBUG= @debug_save;
4746
# 6. It will end up in an error stating that it was aborted,
4847
# since transactions are conflicting and server2 was
4948
# ordered first.
49+
[connection server2]
50+
include/sync_slave_sql_with_master.inc
5051
[connection server_1]
5152
ERROR HY000: Plugin instructed the server to rollback the current transaction.
5253

rapid/plugin/group_replication/tests/mtr/r/gr_multi_primary_key_conflict.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ COMMIT;
3232
# certification, since server_1 is blocked before broadcast.
3333
[connection server2]
3434
UPDATE t1 SET a=4 AND b=5 WHERE b=2;
35-
include/sync_slave_sql_with_master.inc
3635

3736
############################################################
3837
# 5. Signal the waiting thread on server_1 to resume.
@@ -44,6 +43,8 @@ SET @@GLOBAL.DEBUG= @debug_save;
4443
# 6. It will end up in an error stating that it was aborted,
4544
# since transactions are conflicting and server2 was
4645
# ordered first.
46+
[connection server2]
47+
include/sync_slave_sql_with_master.inc
4748
[connection server_1]
4849
ERROR HY000: Plugin instructed the server to rollback the current transaction.
4950

rapid/plugin/group_replication/tests/mtr/r/gr_multi_primary_unique_key_conflict.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ COMMIT;
3232
# certification, since server_1 is blocked before broadcast.
3333
[connection server2]
3434
UPDATE t1 SET b=6 WHERE c=4;
35-
include/sync_slave_sql_with_master.inc
3635

3736
############################################################
3837
# 5. Signal the waiting thread on server_1 to resume.
@@ -44,6 +43,8 @@ SET @@GLOBAL.DEBUG= @debug_save;
4443
# 6. It will end up in an error stating that it was aborted,
4544
# since transactions are conflicting and server2 was
4645
# ordered first.
46+
[connection server2]
47+
include/sync_slave_sql_with_master.inc
4748
[connection server_1]
4849
ERROR HY000: Plugin instructed the server to rollback the current transaction.
4950

rapid/plugin/group_replication/tests/mtr/r/gr_multi_unique_key_conflict.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ COMMIT;
3131
# certification, since server_1 is blocked before broadcast.
3232
[connection server2]
3333
INSERT INTO t1 VALUES(4, 2, 3);
34-
include/sync_slave_sql_with_master.inc
3534

3635
############################################################
3736
# 5. Signal the waiting thread on server_1 to resume.
@@ -43,6 +42,8 @@ SET @@GLOBAL.DEBUG= @debug_save;
4342
# 6. It will end up in an error stating that it was aborted,
4443
# since transactions are conflicting and server2 was
4544
# ordered first.
45+
[connection server2]
46+
include/sync_slave_sql_with_master.inc
4647
[connection server_1]
4748
ERROR HY000: Plugin instructed the server to rollback the current transaction.
4849

rapid/plugin/group_replication/tests/mtr/r/gr_primary_key_conflict.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ COMMIT;
3131
# certification, since server_1 is blocked before broadcast.
3232
[connection server2]
3333
INSERT INTO t1 VALUES (1);
34-
include/sync_slave_sql_with_master.inc
3534

3635
############################################################
3736
# 5. Signal the waiting thread on server_1 to resume.
@@ -43,6 +42,8 @@ SET @@GLOBAL.DEBUG= @debug_save;
4342
# 6. It will end up in an error stating that it was aborted,
4443
# since transactions are conflicting and server2 was
4544
# ordered first.
45+
[connection server2]
46+
include/sync_slave_sql_with_master.inc
4647
[connection server_1]
4748
ERROR HY000: Plugin instructed the server to rollback the current transaction.
4849

rapid/plugin/group_replication/tests/mtr/r/gr_read_committed_isolation.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ BEGIN;
4444
UPDATE t1 SET a=3 WHERE a=10;
4545
DELETE FROM t1 where a=20;
4646
COMMIT;
47-
include/sync_slave_sql_with_master.inc
4847

4948
## 3.4 Signal the waiting thread on server1 to resume.
5049
[connection server1]
@@ -53,6 +52,8 @@ SET @@GLOBAL.DEBUG= @debug_save;
5352

5453
## 3.5 It will end up in an error stating that it was aborted, since
5554
## transactions are conflicting and server2 was ordered first.
55+
[connection server2]
56+
include/sync_slave_sql_with_master.inc
5657
[connection server_1]
5758
ERROR HY000: Plugin instructed the server to rollback the current transaction.
5859

rapid/plugin/group_replication/tests/mtr/r/gr_read_uncommitted_isolation.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ BEGIN;
4444
UPDATE t1 SET a=3 WHERE a=10;
4545
DELETE FROM t1 where a=20;
4646
COMMIT;
47-
include/sync_slave_sql_with_master.inc
4847

4948
## 3.4 Signal the waiting thread on server1 to resume.
5049
[connection server1]
@@ -53,6 +52,8 @@ SET @@GLOBAL.DEBUG= @debug_save;
5352

5453
## 3.5 It will end up in an error stating that it was aborted, since
5554
## transactions are conflicting and server2 was ordered first.
55+
[connection server2]
56+
include/sync_slave_sql_with_master.inc
5657
[connection server_1]
5758
ERROR HY000: Plugin instructed the server to rollback the current transaction.
5859

rapid/plugin/group_replication/tests/mtr/r/gr_repeatable_read_isolation.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ BEGIN;
4444
UPDATE t1 SET a=3 WHERE a=10;
4545
DELETE FROM t1 where a=20;
4646
COMMIT;
47-
include/sync_slave_sql_with_master.inc
4847

4948
## 3.4 Signal the waiting thread on server1 to resume.
5049
[connection server1]
@@ -53,6 +52,8 @@ SET @@GLOBAL.DEBUG= @debug_save;
5352

5453
## 3.5 It will end up in an error stating that it was aborted, since
5554
## transactions are conflicting and server2 was ordered first.
55+
[connection server2]
56+
include/sync_slave_sql_with_master.inc
5657
[connection server_1]
5758
ERROR HY000: Plugin instructed the server to rollback the current transaction.
5859

0 commit comments

Comments
 (0)