Skip to content

Commit 4102f15

Browse files
committed
Aria will now register it's transactions
MDEV-22531 Remove maria::implicit_commit() MDEV-22607 Assertion `ha_info->ht() != binlog_hton' failed in MYSQL_BIN_LOG::unlog_xa_prepare From the handler point of view, Aria now looks like a transactional engine. One effect of this is that we don't need to call maria::implicit_commit() anymore. This change also forces the server to call trans_commit_stmt() after doing any read or writes to system tables. This work will also make it easier to later allow users to have system tables in other engines than Aria. To handle the case that Aria doesn't support rollback, a new handlerton flag, HTON_NO_ROLLBACK, was added to engines that has transactions without rollback (for the moment only binlog and Aria). Other things - Moved freeing of MARIA_SHARE to a separate function as the MARIA_SHARE can be still part of a transaction even if the table has closed. - Changed Aria checkpoint to use the new MARIA_SHARE free function. This fixes a possible memory leak when using S3 tables - Changed testing of binlog_hton to instead test for HTON_NO_ROLLBACK - Removed checking of has_transaction_manager() in handler.cc as we can assume that as the transaction was started by the engine, it does support transactions. - Added new class 'start_new_trans' that can be used to start indepdendent sub transactions, for example while reading mysql.proc, using help or status tables etc. - open_system_tables...() and open_proc_table_for_Read() doesn't anymore take a Open_tables_backup list. This is now handled by 'start_new_trans'. - Split thd::has_transactions() to thd::has_transactions() and thd::has_transactions_and_rollback() - Added handlerton code to free cached transactions objects. Needed by InnoDB. squash! 2ed3599
1 parent d1d4726 commit 4102f15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3910
-3678
lines changed

mysql-test/include/commit.inc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ end|
405405
delimiter ;|
406406
--echo # Reset Handler_commit and Handler_prepare counters
407407
flush status;
408+
409+
--echo #
410+
--echo # Count of reading of p_verify_status_increment() from mysql.proc
411+
call p_verify_status_increment(2, 0, 2, 0);
412+
408413
--echo #
409414
--echo # 1. Read-only statement: SELECT
410415
--echo #
@@ -562,7 +567,7 @@ begin
562567
return 2;
563568
end|
564569
delimiter ;|
565-
call p_verify_status_increment(0, 0, 0, 0);
570+
call p_verify_status_increment(4, 0, 4, 0);
566571

567572
--echo # 16. A function changes non-trans-table.
568573
--echo #
@@ -571,7 +576,7 @@ call p_verify_status_increment(0, 0, 0, 0);
571576
--echo # the binary log.
572577
--echo #
573578
select f1();
574-
call p_verify_status_increment(1, 0, 1, 0);
579+
call p_verify_status_increment(3, 0, 3, 0);
575580
commit;
576581
call p_verify_status_increment(1, 0, 1, 0);
577582

@@ -650,7 +655,7 @@ call p_verify_status_increment(0, 0, 0, 0);
650655
--echo # 24. DDL: TRUNCATE TEMPORARY TABLE
651656
--echo
652657
truncate table t2;
653-
call p_verify_status_increment(4, 0, 4, 0);
658+
call p_verify_status_increment(2, 0, 2, 0);
654659
commit;
655660
--echo # There is nothing left to commit
656661
call p_verify_status_increment(0, 0, 0, 0);
@@ -763,7 +768,7 @@ call p_verify_status_increment(0, 0, 0, 0);
763768
truncate table t3;
764769
call p_verify_status_increment(2, 0, 2, 0);
765770
create view v1 as select * from t2;
766-
call p_verify_status_increment(2, 0, 2, 0);
771+
call p_verify_status_increment(4, 0, 4, 0);
767772
check table t1;
768773
call p_verify_status_increment(2, 0, 2, 0);
769774
--echo # Sic: after this bug is fixed, CHECK leaves no pending transaction
@@ -774,7 +779,7 @@ call p_verify_status_increment(6, 0, 6, 0);
774779
commit;
775780
call p_verify_status_increment(0, 0, 0, 0);
776781
drop view v1;
777-
call p_verify_status_increment(0, 0, 0, 0);
782+
call p_verify_status_increment(2, 0, 2, 0);
778783

779784
--echo #
780785
--echo # Cleanup

mysql-test/main/backup_lock.result

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,23 +193,51 @@ SET GLOBAL lock_wait_timeout=0;
193193
CREATE TABLE t_permanent_innodb (col1 INT) ENGINE = InnoDB;
194194
CREATE TABLE t_permanent_myisam (col1 INT) ENGINE = MyISAM;
195195
CREATE TABLE t_permanent_aria (col1 INT) ENGINE = Aria transactional=1;
196+
CREATE TABLE t_permanent_aria2 (col1 INT) ENGINE = Aria transactional=0;
196197
INSERT INTO t_permanent_innodb SET col1 = 1;
197198
INSERT INTO t_permanent_myisam SET col1 = 1;
198199
INSERT INTO t_permanent_aria SET col1 = 1;
200+
INSERT INTO t_permanent_aria2 SET col1 = 1;
199201
CREATE TABLE t_con1_innodb (col1 INT) ENGINE = InnoDB;
200202
CREATE TABLE t_con1_myisam (col1 INT) ENGINE = MyISAM;
201203
connect con1,localhost,root,,;
202-
SET AUTOCOMMIT = 0;
203204
connection default;
204205
BACKUP STAGE START;
205206
BACKUP STAGE FLUSH;
206207
BACKUP STAGE BLOCK_DDL;
207208
BACKUP STAGE BLOCK_COMMIT;
208209
connection con1;
210+
SET AUTOCOMMIT = 1;
211+
UPDATE t_permanent_aria SET col1 = 1;
212+
UPDATE t_permanent_innodb SET col1 = 1;
213+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
209214
UPDATE t_permanent_innodb SET col1 = 8;
215+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
210216
UPDATE t_permanent_myisam SET col1 = 8;
211217
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
212218
UPDATE t_permanent_aria SET col1 = 8;
219+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
220+
UPDATE t_permanent_aria2 SET col1 = 8;
221+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
222+
select * from t_permanent_innodb;
223+
col1
224+
1
225+
select * from t_permanent_myisam;
226+
col1
227+
1
228+
select * from t_permanent_aria;
229+
col1
230+
8
231+
select * from t_permanent_aria2;
232+
col1
233+
1
234+
SET AUTOCOMMIT = 0;
235+
UPDATE t_permanent_innodb SET col1 = 9;
236+
UPDATE t_permanent_aria SET col1 = 9;
237+
UPDATE t_permanent_myisam SET col1 = 9;
238+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
239+
UPDATE t_permanent_aria2 SET col1 = 9;
240+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
213241
DROP TABLE t_con1_innodb;
214242
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
215243
DROP TABLE t_con1_myisam;
@@ -224,8 +252,11 @@ col1
224252
1
225253
select * from t_permanent_aria;
226254
col1
227-
8
228-
DROP TABLE t_permanent_myisam, t_permanent_innodb, t_permanent_aria;
255+
9
256+
select * from t_permanent_aria2;
257+
col1
258+
1
259+
DROP TABLE t_permanent_myisam, t_permanent_innodb, t_permanent_aria, t_permanent_aria2;
229260
DROP TABLE t_con1_innodb, t_con1_myisam;
230261
disconnect con1;
231262
set global lock_wait_timeout=default;

mysql-test/main/backup_lock.test

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,16 @@ SET GLOBAL lock_wait_timeout=0;
252252
CREATE TABLE t_permanent_innodb (col1 INT) ENGINE = InnoDB;
253253
CREATE TABLE t_permanent_myisam (col1 INT) ENGINE = MyISAM;
254254
CREATE TABLE t_permanent_aria (col1 INT) ENGINE = Aria transactional=1;
255+
CREATE TABLE t_permanent_aria2 (col1 INT) ENGINE = Aria transactional=0;
255256
INSERT INTO t_permanent_innodb SET col1 = 1;
256257
INSERT INTO t_permanent_myisam SET col1 = 1;
257258
INSERT INTO t_permanent_aria SET col1 = 1;
259+
INSERT INTO t_permanent_aria2 SET col1 = 1;
258260

259261
CREATE TABLE t_con1_innodb (col1 INT) ENGINE = InnoDB;
260262
CREATE TABLE t_con1_myisam (col1 INT) ENGINE = MyISAM;
261263

262264
--connect(con1,localhost,root,,)
263-
SET AUTOCOMMIT = 0;
264265

265266
--connection default
266267
BACKUP STAGE START;
@@ -269,10 +270,34 @@ BACKUP STAGE BLOCK_DDL;
269270
BACKUP STAGE BLOCK_COMMIT;
270271

271272
--connection con1
273+
SET AUTOCOMMIT = 1;
274+
275+
# These should work as values are not changed
276+
UPDATE t_permanent_aria SET col1 = 1;
277+
--error ER_LOCK_WAIT_TIMEOUT
278+
UPDATE t_permanent_innodb SET col1 = 1;
279+
280+
--error ER_LOCK_WAIT_TIMEOUT
272281
UPDATE t_permanent_innodb SET col1 = 8;
273282
--error ER_LOCK_WAIT_TIMEOUT
274283
UPDATE t_permanent_myisam SET col1 = 8;
284+
--error ER_LOCK_WAIT_TIMEOUT
275285
UPDATE t_permanent_aria SET col1 = 8;
286+
--error ER_LOCK_WAIT_TIMEOUT
287+
UPDATE t_permanent_aria2 SET col1 = 8;
288+
289+
select * from t_permanent_innodb;
290+
select * from t_permanent_myisam;
291+
select * from t_permanent_aria;
292+
select * from t_permanent_aria2;
293+
294+
SET AUTOCOMMIT = 0;
295+
UPDATE t_permanent_innodb SET col1 = 9;
296+
UPDATE t_permanent_aria SET col1 = 9;
297+
--error ER_LOCK_WAIT_TIMEOUT
298+
UPDATE t_permanent_myisam SET col1 = 9;
299+
--error ER_LOCK_WAIT_TIMEOUT
300+
UPDATE t_permanent_aria2 SET col1 = 9;
276301

277302
--error ER_LOCK_WAIT_TIMEOUT
278303
DROP TABLE t_con1_innodb;
@@ -286,8 +311,9 @@ BACKUP STAGE END;
286311
select * from t_permanent_innodb;
287312
select * from t_permanent_myisam;
288313
select * from t_permanent_aria;
314+
select * from t_permanent_aria2;
289315

290-
DROP TABLE t_permanent_myisam, t_permanent_innodb, t_permanent_aria;
316+
DROP TABLE t_permanent_myisam, t_permanent_innodb, t_permanent_aria, t_permanent_aria2;
291317
DROP TABLE t_con1_innodb, t_con1_myisam;
292318
--disconnect con1
293319
set global lock_wait_timeout=default;

mysql-test/main/commit_1innodb.result

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ end if;
385385
end|
386386
# Reset Handler_commit and Handler_prepare counters
387387
flush status;
388+
#
389+
# Count of reading of p_verify_status_increment() from mysql.proc
390+
call p_verify_status_increment(2, 0, 2, 0);
391+
SUCCESS
392+
388393
#
389394
# 1. Read-only statement: SELECT
390395
#
@@ -568,7 +573,7 @@ begin
568573
insert t2 set a=2;
569574
return 2;
570575
end|
571-
call p_verify_status_increment(0, 0, 0, 0);
576+
call p_verify_status_increment(4, 0, 4, 0);
572577
SUCCESS
573578

574579
# 16. A function changes non-trans-table.
@@ -580,7 +585,7 @@ SUCCESS
580585
select f1();
581586
f1()
582587
2
583-
call p_verify_status_increment(1, 0, 1, 0);
588+
call p_verify_status_increment(3, 0, 3, 0);
584589
SUCCESS
585590

586591
commit;
@@ -688,9 +693,9 @@ SUCCESS
688693
# 24. DDL: TRUNCATE TEMPORARY TABLE
689694

690695
truncate table t2;
691-
call p_verify_status_increment(4, 0, 4, 0);
692-
ERROR
693-
Expected commit increment: 4 actual: 2
696+
call p_verify_status_increment(2, 0, 2, 0);
697+
SUCCESS
698+
694699
commit;
695700
# There is nothing left to commit
696701
call p_verify_status_increment(0, 0, 0, 0);
@@ -855,7 +860,7 @@ call p_verify_status_increment(2, 0, 2, 0);
855860
SUCCESS
856861

857862
create view v1 as select * from t2;
858-
call p_verify_status_increment(2, 0, 2, 0);
863+
call p_verify_status_increment(4, 0, 4, 0);
859864
SUCCESS
860865

861866
check table t1;
@@ -882,7 +887,7 @@ call p_verify_status_increment(0, 0, 0, 0);
882887
SUCCESS
883888

884889
drop view v1;
885-
call p_verify_status_increment(0, 0, 0, 0);
890+
call p_verify_status_increment(2, 0, 2, 0);
886891
SUCCESS
887892

888893
#

mysql-test/main/warnings_debug.result

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ SET SESSION debug_dbug="+d,warn_during_ha_commit_trans";
55
INSERT INTO t1 VALUES (1);
66
Warnings:
77
Warning 1196 Some non-transactional changed tables couldn't be rolled back
8+
Warning 1196 Some non-transactional changed tables couldn't be rolled back
9+
Warning 1196 Some non-transactional changed tables couldn't be rolled back
810
SHOW WARNINGS;
911
Level Code Message
1012
Warning 1196 Some non-transactional changed tables couldn't be rolled back
11-
drop table t1;
13+
Warning 1196 Some non-transactional changed tables couldn't be rolled back
14+
Warning 1196 Some non-transactional changed tables couldn't be rolled back
1215
SET debug_dbug= @saved_dbug;
16+
drop table t1;

mysql-test/main/warnings_debug.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ INSERT INTO t1 VALUES (1);
1717
# packet. Show the warnings manually also.
1818
SHOW WARNINGS;
1919

20-
drop table t1;
2120
SET debug_dbug= @saved_dbug;
21+
drop table t1;

mysql-test/main/xa_binlog.result

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,33 @@ a
1818
1
1919
2
2020
3
21-
SHOW BINLOG EVENTS LIMIT 3,12;
21+
DROP TABLE t1;
22+
CREATE TABLE t1 (a INT) ENGINE=Aria;
23+
INSERT INTO t1 VALUES (1),(2);
24+
XA BEGIN 'x';
25+
DELETE FROM t1;
26+
XA END 'x';
27+
XA PREPARE 'x';
28+
Warnings:
29+
Warning 1030 Got error 131 "Command not supported by the engine" from storage engine Aria
30+
XA COMMIT 'x';
31+
SELECT * from t1;
32+
a
33+
XA BEGIN 'x';
34+
INSERT INTO t1 VALUES (3),(4);
35+
XA END 'x';
36+
XA PREPARE 'x';
37+
Warnings:
38+
Warning 1030 Got error 131 "Command not supported by the engine" from storage engine Aria
39+
XA ROLLBACK 'x';
40+
Warnings:
41+
Warning 1196 Some non-transactional changed tables couldn't be rolled back
42+
SELECT * from t1;
43+
a
44+
3
45+
4
46+
DROP TABLE t1;
47+
SHOW BINLOG EVENTS LIMIT 3,100;
2248
Log_name Pos Event_type Server_id End_log_pos Info
2349
master-bin.000001 # Gtid 1 # XA START X'786174657374',X'',1 GTID #-#-#
2450
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (1)
@@ -32,4 +58,28 @@ master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
3258
master-bin.000001 # Gtid 1 # BEGIN GTID #-#-#
3359
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (3)
3460
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
35-
DROP TABLE t1;
61+
master-bin.000001 # Gtid 1 # GTID #-#-#
62+
master-bin.000001 # Query 1 # use `test`; DROP TABLE `t1` /* generated by server */
63+
master-bin.000001 # Gtid 1 # GTID #-#-#
64+
master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1 (a INT) ENGINE=Aria
65+
master-bin.000001 # Gtid 1 # BEGIN GTID #-#-#
66+
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (1),(2)
67+
master-bin.000001 # Query 1 # COMMIT
68+
master-bin.000001 # Gtid 1 # BEGIN GTID #-#-#
69+
master-bin.000001 # Query 1 # use `test`; DELETE FROM t1
70+
master-bin.000001 # Query 1 # COMMIT
71+
master-bin.000001 # Gtid 1 # XA START X'78',X'',1 GTID #-#-#
72+
master-bin.000001 # Query 1 # XA END X'78',X'',1
73+
master-bin.000001 # XA_prepare 1 # XA PREPARE X'78',X'',1
74+
master-bin.000001 # Gtid 1 # GTID #-#-#
75+
master-bin.000001 # Query 1 # XA COMMIT X'78',X'',1
76+
master-bin.000001 # Gtid 1 # BEGIN GTID #-#-#
77+
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (3),(4)
78+
master-bin.000001 # Query 1 # COMMIT
79+
master-bin.000001 # Gtid 1 # XA START X'78',X'',1 GTID #-#-#
80+
master-bin.000001 # Query 1 # XA END X'78',X'',1
81+
master-bin.000001 # XA_prepare 1 # XA PREPARE X'78',X'',1
82+
master-bin.000001 # Gtid 1 # GTID #-#-#
83+
master-bin.000001 # Query 1 # XA ROLLBACK X'78',X'',1
84+
master-bin.000001 # Gtid 1 # GTID #-#-#
85+
master-bin.000001 # Query 1 # use `test`; DROP TABLE `t1` /* generated by server */

mysql-test/main/xa_binlog.test

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,38 @@ INSERT INTO t1 VALUES (3);
2424
COMMIT;
2525

2626
SELECT * FROM t1 ORDER BY a;
27+
DROP TABLE t1;
2728

28-
--replace_column 2 # 5 #
29-
--replace_regex /xid=[0-9]+/xid=XX/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/
30-
SHOW BINLOG EVENTS LIMIT 3,12;
29+
#
30+
# MDEV-22607 Assertion `ha_info->ht() != binlog_hton' failed in
31+
# MYSQL_BIN_LOG::unlog_xa_prepare
32+
#
33+
34+
CREATE TABLE t1 (a INT) ENGINE=Aria;
35+
INSERT INTO t1 VALUES (1),(2);
36+
XA BEGIN 'x';
37+
DELETE FROM t1;
38+
XA END 'x';
39+
XA PREPARE 'x';
40+
41+
# Cleanup
42+
XA COMMIT 'x';
43+
44+
SELECT * from t1;
3145

46+
XA BEGIN 'x';
47+
INSERT INTO t1 VALUES (3),(4);
48+
XA END 'x';
49+
XA PREPARE 'x';
50+
XA ROLLBACK 'x';
51+
52+
SELECT * from t1;
3253
DROP TABLE t1;
54+
55+
#
56+
# Time to check the log
57+
#
58+
59+
--replace_column 2 # 5 #
60+
--replace_regex /xid=[0-9]+/xid=XX/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/
61+
SHOW BINLOG EVENTS LIMIT 3,100;

0 commit comments

Comments
 (0)