1
0
mirror of https://github.com/MariaDB/server.git synced 2025-05-29 21:42:28 +03:00

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

dict_stats_save(): Do not attempt to commit an already committed
transaction.
This commit is contained in:
Marko Mäkelä 2022-04-26 18:09:14 +03:00
parent 2ca1123464
commit 2c005261cb
3 changed files with 32 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
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 @@ release_and_exit:
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) {
trx->commit(); if (trx->state != TRX_STATE_NOT_STARTED) {
trx->commit();
}
goto unlocked_free_and_exit; goto unlocked_free_and_exit;
} }