Commit 6d8794e5 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-21650 Non-empty statement transaction on global rollback after TRT update error

TRT opens statement transaction. Cleanup it in case of error.
parent 6b4f0d78
......@@ -528,3 +528,31 @@ drop table t;
uninstall plugin test_versioning;
select trt_begin_ts(0);
ERROR 42000: FUNCTION test.trt_begin_ts does not exist
#
# MDEV-21650 Non-empty statement transaction on global rollback after TRT update error
#
create table t1 (s date, e date, period for app(s,e)) engine=innodb;
alter table t1
add row_start bigint unsigned as row start,
add row_end bigint unsigned as row end,
add period for system_time(row_start,row_end),
with system versioning,
add period if not exists for app(x,y);
Warnings:
Note 1060 Duplicate column name 'app'
set transaction isolation level serializable;
start transaction;
insert into t1 (s,e) values ('2021-07-04','2024-08-18');
connect con1,localhost,root,,test;
start transaction;
insert into t1 (s,e) values ('2018-06-01','2021-09-15');
connection default;
select * from t1 for system_time as of now();
ERROR HY000: TRX_ID ... not found in `mysql.transaction_registry`
connection con1;
set innodb_lock_wait_timeout= 1, lock_wait_timeout= 1;
alter table xx;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
disconnect con1;
connection default;
drop table t1;
......@@ -401,7 +401,7 @@ a check_row(row_start, row_end)
drop tables t1, t2, t3;
#
# MDEV-24522 Assertion `inited==NONE' fails upon UPDATE on versioned table with unique blob
#
create table t1 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
insert into t1 values (1, 1, 'foo'), (2, 11, 'bar');
update t1 set a = 3 where b <= 9;
......
......@@ -540,3 +540,38 @@ drop table t;
uninstall plugin test_versioning;
--error ER_SP_DOES_NOT_EXIST
select trt_begin_ts(0);
--echo #
--echo # MDEV-21650 Non-empty statement transaction on global rollback after TRT update error
--echo #
create table t1 (s date, e date, period for app(s,e)) engine=innodb;
alter table t1
add row_start bigint unsigned as row start,
add row_end bigint unsigned as row end,
add period for system_time(row_start,row_end),
with system versioning,
add period if not exists for app(x,y);
set transaction isolation level serializable;
start transaction;
insert into t1 (s,e) values ('2021-07-04','2024-08-18');
--connect (con1,localhost,root,,test)
start transaction;
insert into t1 (s,e) values ('2018-06-01','2021-09-15');
--connection default
--replace_regex /TRX_ID \d+/TRX_ID .../
--error ER_VERS_NO_TRX_ID
select * from t1 for system_time as of now();
--connection con1
set innodb_lock_wait_timeout= 1, lock_wait_timeout= 1;
# can be existing or non-existing table, does not matter
--error ER_LOCK_WAIT_TIMEOUT
alter table xx;
# cleanup
--disconnect con1
--connection default
drop table t1;
......@@ -328,7 +328,7 @@ drop tables t1, t2, t3;
--echo #
--echo # MDEV-24522 Assertion `inited==NONE' fails upon UPDATE on versioned table with unique blob
--echo
--echo #
create table t1 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
insert into t1 values (1, 1, 'foo'), (2, 11, 'bar');
......
......@@ -1564,14 +1564,13 @@ int ha_commit_trans(THD *thd, bool all)
#endif
TR_table trt(thd, true);
if (trt.update(trx_start_id, trx_end_id))
#ifdef WITH_WSREP
{
#ifdef WITH_WSREP
thd->variables.wsrep_on= saved_wsrep_on;
#endif
(void) trans_rollback_stmt(thd);
goto err;
#ifdef WITH_WSREP
}
#endif
// Here, the call will not commit inside InnoDB. It is only working
// around closing thd->transaction.stmt open by TR_table::open().
if (all)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment