Commit 2c005261 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-26753 Assertion state == TRX_STATE_PREPARED ||... failed

dict_stats_save(): Do not attempt to commit an already committed
transaction.
parent 2ca11234
...@@ -13,3 +13,17 @@ a ...@@ -13,3 +13,17 @@ a
drop table t1; drop table t1;
rename table mysql.table_stats_save to mysql.table_stats; rename table mysql.table_stats_save to mysql.table_stats;
flush tables; flush tables;
#
# MDEV-26753 Assertion state == TRX_STATE_PREPARED ||... failed
#
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
XA START 'test';
SELECT COUNT(*)>0 FROM mysql.innodb_index_stats LOCK IN SHARE MODE;
COUNT(*)>0
1
INSERT INTO t1 VALUES (1),(2);
UPDATE mysql.innodb_table_stats SET last_update=NULL WHERE table_name='t1';
XA END 'test';
XA ROLLBACK 'test';
DROP TABLE t1;
# End of 10.6 tests
...@@ -15,3 +15,17 @@ select * from t1; ...@@ -15,3 +15,17 @@ select * from t1;
drop table t1; drop table t1;
rename table mysql.table_stats_save to mysql.table_stats; rename table mysql.table_stats_save to mysql.table_stats;
flush tables; flush tables;
--echo #
--echo # MDEV-26753 Assertion state == TRX_STATE_PREPARED ||... failed
--echo #
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
XA START 'test';
SELECT COUNT(*)>0 FROM mysql.innodb_index_stats LOCK IN SHARE MODE;
INSERT INTO t1 VALUES (1),(2);
UPDATE mysql.innodb_table_stats SET last_update=NULL WHERE table_name='t1';
XA END 'test';
XA ROLLBACK 'test';
DROP TABLE t1;
--echo # End of 10.6 tests
/***************************************************************************** /*****************************************************************************
Copyright (c) 2009, 2019, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2021, MariaDB Corporation. Copyright (c) 2015, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -3115,7 +3115,9 @@ dict_stats_save( ...@@ -3115,7 +3115,9 @@ dict_stats_save(
ret = lock_table_for_trx(index_stats, trx, LOCK_X); ret = lock_table_for_trx(index_stats, trx, LOCK_X);
} }
if (ret != DB_SUCCESS) { if (ret != DB_SUCCESS) {
if (trx->state != TRX_STATE_NOT_STARTED) {
trx->commit(); trx->commit();
}
goto unlocked_free_and_exit; goto unlocked_free_and_exit;
} }
......
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