From db188083c38a9aeba146c9d591e3ed12cce0b200 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 26 May 2025 11:48:07 +0530 Subject: [PATCH] MDEV-36771 Assertion 'bulk_insert == TRX_NO_BULK' failed in trx_t::assert_freed - InnoDB fails to reset bulk_insert of a transaction while freeing the transaction during shutting down of a server. --- .../suite/innodb/r/insert_into_empty.result | 16 ++++++++++++++++ mysql-test/suite/innodb/t/insert_into_empty.test | 15 +++++++++++++++ storage/innobase/trx/trx0trx.cc | 1 + 3 files changed, 32 insertions(+) diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index b9cfe965c13..19e5267a1b7 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -580,4 +580,20 @@ WHERE variable_name = 'innodb_bulk_operations'; bulk_operations 1 DROP TABLE t1; +call mtr.add_suppression("Found 1 prepared XA transactions"); +# +# MDEV-36771 Assertion `bulk_insert == TRX_NO_BULK' failed +# in trx_t::assert_freed from innodb_shutdown +# +CREATE TABLE t1(f1 INT)ENGINE=InnoDB; +XA START 'a'; +INSERT INTO t1 VALUES(1); +XA END 'a'; +XA PREPARE 'a'; +# restart +XA COMMIT 'a'; +SELECT * FROM t1; +f1 +1 +DROP TABLE t1; # End of 10.11 tests diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index de36ccdb85f..e31b680ebe8 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -638,4 +638,19 @@ SELECT variable_value-@old_bulk_op bulk_operations FROM information_schema.global_status WHERE variable_name = 'innodb_bulk_operations'; DROP TABLE t1; + +call mtr.add_suppression("Found 1 prepared XA transactions"); +--echo # +--echo # MDEV-36771 Assertion `bulk_insert == TRX_NO_BULK' failed +--echo # in trx_t::assert_freed from innodb_shutdown +--echo # +CREATE TABLE t1(f1 INT)ENGINE=InnoDB; +XA START 'a'; +INSERT INTO t1 VALUES(1); +XA END 'a'; +XA PREPARE 'a'; +--source include/restart_mysqld.inc +XA COMMIT 'a'; +SELECT * FROM t1; +DROP TABLE t1; --echo # End of 10.11 tests diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 28b7fed90cd..725a6d95a0f 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -515,6 +515,7 @@ TRANSACTIONAL_TARGET void trx_free_at_shutdown(trx_t *trx) ut_a(trx->magic_n == TRX_MAGIC_N); ut_d(trx->apply_online_log = false); + trx->bulk_insert = 0; trx->commit_state(); trx->release_locks(); trx->mod_tables.clear();