Skip to content

Commit

Permalink
MDEV-26753 Assertion state == TRX_STATE_PREPARED ||... failed
Browse files Browse the repository at this point in the history
dict_stats_save(): Do not attempt to commit an already committed
transaction.
  • Loading branch information
dr-m committed Apr 26, 2022
1 parent 2ca1123 commit 2c00526
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
14 changes: 14 additions & 0 deletions mysql-test/suite/innodb/r/stat_tables.result
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ a
drop table t1;
rename table mysql.table_stats_save to mysql.table_stats;
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
14 changes: 14 additions & 0 deletions mysql-test/suite/innodb/t/stat_tables.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,17 @@ select * from t1;
drop table t1;
rename table mysql.table_stats_save to mysql.table_stats;
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
6 changes: 4 additions & 2 deletions storage/innobase/dict/dict0stats.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************
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
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -3115,7 +3115,9 @@ dict_stats_save(
ret = lock_table_for_trx(index_stats, trx, LOCK_X);
}
if (ret != DB_SUCCESS) {
trx->commit();
if (trx->state != TRX_STATE_NOT_STARTED) {
trx->commit();
}
goto unlocked_free_and_exit;
}

Expand Down

0 comments on commit 2c00526

Please sign in to comment.