diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-02-24 15:49:58 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-02-24 15:49:58 +0200 |
commit | 5c9229b96f44fd3d46dcf1dd6a1c4293af1523c8 (patch) | |
tree | 331379211126c77dd9c5c91a223e6845b6bd4695 | |
parent | 21987e5919afba29a7a7a537d3567909c7b4b9ff (diff) | |
download | mariadb-git-5c9229b96f44fd3d46dcf1dd6a1c4293af1523c8.tar.gz |
MDEV-24951 Assertion m.first->second.valid(trx->undo_no) failed
trx_t::commit_in_memory(): Invoke mod_tables.clear().
trx_free_at_shutdown(): Invoke mod_tables.clear() for transactions
that are discarded on shutdown.
Everywhere else, assert mod_tables.empty() on freed transaction objects.
-rw-r--r-- | mysql-test/suite/innodb/r/insert_into_empty.result | 16 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/insert_into_empty.test | 19 | ||||
-rw-r--r-- | storage/innobase/include/trx0trx.h | 1 | ||||
-rw-r--r-- | storage/innobase/trx/trx0roll.cc | 1 | ||||
-rw-r--r-- | storage/innobase/trx/trx0trx.cc | 6 |
5 files changed, 38 insertions, 5 deletions
diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index 2fd351c3f47..da352e4970b 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -34,3 +34,19 @@ INSERT INTO t1 SELECT * FROM seq_1_to_500; ROLLBACK; DROP TABLE t1; SET GLOBAL innodb_adaptive_hash_index = @save_ahi; +# +# MDEV-24951 Assertion m.first->second.valid(trx->undo_no) failed +# in trx_undo_report_row_operation +# +CREATE TEMPORARY TABLE t (c INT) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB; +SET tx_read_only=1; +BEGIN; +INSERT INTO t2 VALUES(0); +INSERT INTO t VALUES(0); +COMMIT; +INSERT INTO t VALUES(0); +DROP TEMPORARY TABLE t,t2; +ERROR 25006: Cannot execute statement in a READ ONLY transaction +SET tx_read_only=0; +DROP TEMPORARY TABLE t,t2; diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index 6d5cb2119a2..21387b08377 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -33,3 +33,22 @@ INSERT INTO t1 SELECT * FROM seq_1_to_500; ROLLBACK; DROP TABLE t1; SET GLOBAL innodb_adaptive_hash_index = @save_ahi; + +--echo # +--echo # MDEV-24951 Assertion m.first->second.valid(trx->undo_no) failed +--echo # in trx_undo_report_row_operation +--echo # + +CREATE TEMPORARY TABLE t (c INT) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB; +SET tx_read_only=1; +BEGIN; +INSERT INTO t2 VALUES(0); +INSERT INTO t VALUES(0); +COMMIT; +INSERT INTO t VALUES(0); + +--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION +DROP TEMPORARY TABLE t,t2; +SET tx_read_only=0; +DROP TEMPORARY TABLE t,t2; diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index c15180d190f..4cda7c9c31d 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1062,6 +1062,7 @@ public: ut_ad(!is_referenced()); ut_ad(!is_wsrep()); ut_ad(!lock.was_chosen_as_deadlock_victim); + ut_ad(mod_tables.empty()); ut_ad(!read_view.is_open()); ut_ad(!lock.wait_thr); ut_ad(!lock.wait_lock); diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index e79fbca2386..b53f092c675 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -59,7 +59,6 @@ const trx_t* trx_roll_crash_recv_trx; @retval false if the rollback was aborted by shutdown */ inline bool trx_t::rollback_finish() { - mod_tables.clear(); if (UNIV_LIKELY(error_state == DB_SUCCESS)) { commit(); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 461c80234e6..6e585921e20 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -397,8 +397,6 @@ void trx_t::free() autoinc_locks= NULL; } - mod_tables.clear(); - MEM_NOACCESS(&n_ref, sizeof n_ref); /* do not poison mutex */ MEM_NOACCESS(&id, sizeof id); @@ -522,6 +520,7 @@ trx_free_at_shutdown(trx_t *trx) trx->commit_state(); trx->release_locks(); + trx->mod_tables.clear(); trx_undo_free_at_shutdown(trx); ut_a(!trx->read_only); @@ -1270,8 +1269,6 @@ inline void trx_t::commit_tables() #endif } } - - mod_tables.clear(); } /** Evict a table definition due to the rollback of ALTER TABLE. @@ -1474,6 +1471,7 @@ inline void trx_t::commit_in_memory(const mtr_t *mtr) DBUG_LOG("trx", "Commit in memory: " << this); state= TRX_STATE_NOT_STARTED; + mod_tables.clear(); assert_freed(); trx_init(this); |