From 18e4978edc13991e5c424084ef7e1a5c717b86a6 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 17 Mar 2023 16:41:27 +0530 Subject: MDEV-29975 InnoDB fails to release savepoint during bulk insert - InnoDB does rollback the whole transaction and discards the savepoint when there is a failure happens during bulk insert operation. When server request to release the savepoint, InnoDB should return DB_SUCCESS when it deals with bulk insert operation --- mysql-test/suite/innodb/r/insert_into_empty.result | 15 +++++++++++++++ mysql-test/suite/innodb/t/insert_into_empty.test | 14 ++++++++++++++ storage/innobase/trx/trx0roll.cc | 6 +++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index e7f051d3e56..25cc489bdab 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -214,4 +214,19 @@ WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test'; TABLE_ROWS AVG_ROW_LENGTH>0 3 1 DROP TABLE t1; +# +# MDEV-29975 InnoDB fails to release savepoint during bulk insert +# +CREATE TABLE t (c INT KEY) ENGINE=InnoDB; +begin; +INSERT INTO t VALUES (0,0); +ERROR 21S01: Column count doesn't match value count at row 1 +SAVEPOINT a; +INSERT INTO t VALUES (0),(0); +ERROR 23000: Duplicate entry '0' for key 'PRIMARY' +SAVEPOINT a; +commit; +SELECT * FROM t; +c +DROP TABLE t; # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index af8ed8be90d..932ab4c2a23 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -233,4 +233,18 @@ SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test'; DROP TABLE t1; +--echo # +--echo # MDEV-29975 InnoDB fails to release savepoint during bulk insert +--echo # +CREATE TABLE t (c INT KEY) ENGINE=InnoDB; +begin; +--error ER_WRONG_VALUE_COUNT_ON_ROW +INSERT INTO t VALUES (0,0); +SAVEPOINT a; +--error ER_DUP_ENTRY +INSERT INTO t VALUES (0),(0); +SAVEPOINT a; +commit; +SELECT * FROM t; +DROP TABLE t; --echo # End of 10.6 tests diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 59c9a319330..4de7ab29243 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -558,9 +558,13 @@ trx_release_savepoint_for_mysql( if (savep != NULL) { trx_roll_savepoint_free(trx, savep); + return DB_SUCCESS; + } else if (trx->last_sql_stat_start.least_undo_no == 0) { + /* Bulk insert could have discarded savepoints */ + return DB_SUCCESS; } - return(savep != NULL ? DB_SUCCESS : DB_NO_SAVEPOINT); + return DB_NO_SAVEPOINT; } /*******************************************************************//** -- cgit v1.2.1 From e8e0559ed213db0fffcfd9e2108eedaeb451f7f4 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 17 Mar 2023 17:17:35 +0530 Subject: MDEV-30870 Undo tablespace name displays wrongly for I_S queries - INNODB_SYS_TABLESPACES in information schema should display innodb_undo001, innodb_undo002 etc as tablespace name for undo tablespaces --- mysql-test/suite/innodb/r/undo_truncate.result | 5 +++++ mysql-test/suite/innodb/t/undo_truncate.opt | 1 + mysql-test/suite/innodb/t/undo_truncate.test | 3 +++ storage/innobase/handler/i_s.cc | 9 +++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/undo_truncate.result b/mysql-test/suite/innodb/r/undo_truncate.result index 5be1e5c3426..48b184f07c7 100644 --- a/mysql-test/suite/innodb/r/undo_truncate.result +++ b/mysql-test/suite/innodb/r/undo_truncate.result @@ -1,5 +1,10 @@ SET GLOBAL innodb_undo_log_truncate = 0; SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; +=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles === +Space_Name Page_Size Zip_Size Path +innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001 +innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002 +innodb_temporary DEFAULT DEFAULT MYSQLD_DATADIR/ibtmp1 create table t1(keyc int primary key, c char(100)) engine = innodb; create table t2(keyc int primary key, c char(100)) engine = innodb; connect con1,localhost,root,,; diff --git a/mysql-test/suite/innodb/t/undo_truncate.opt b/mysql-test/suite/innodb/t/undo_truncate.opt index 1459ec5db74..5e331e832fd 100644 --- a/mysql-test/suite/innodb/t/undo_truncate.opt +++ b/mysql-test/suite/innodb/t/undo_truncate.opt @@ -1,2 +1,3 @@ --innodb-buffer-pool-size=24M --innodb-immediate-scrub-data-uncompressed=ON +--loose-innodb-sys-tablespaces diff --git a/mysql-test/suite/innodb/t/undo_truncate.test b/mysql-test/suite/innodb/t/undo_truncate.test index 19829ce21e7..496eccb002e 100644 --- a/mysql-test/suite/innodb/t/undo_truncate.test +++ b/mysql-test/suite/innodb/t/undo_truncate.test @@ -15,6 +15,9 @@ call mtr.add_suppression("InnoDB: Trying to delete tablespace.*pending operation SET GLOBAL innodb_undo_log_truncate = 0; SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; +LET $MYSQLD_DATADIR = `select @@datadir`; +LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`; +--source suite/innodb/include/show_i_s_tablespaces.inc #----------------------------------------------------------------------------- # # Perform DML action using multiple clients and multiple undo tablespace. diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 063462a12b9..366ef38cc07 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -6436,8 +6436,13 @@ static int i_s_sys_tablespaces_fill(THD *thd, const fil_space_t &s, TABLE *t) OK(f->store(name.data(), name.size(), system_charset_info)); f->set_notnull(); } - else - f->set_notnull(); + else if (srv_is_undo_tablespace(s.id)) + { + char name[15]; + snprintf(name, sizeof name, "innodb_undo%03zu", + (s.id - srv_undo_space_id_start + 1)); + OK(f->store(name, strlen(name), system_charset_info)); + } else f->set_notnull(); } fields[SYS_TABLESPACES_NAME]->set_null(); -- cgit v1.2.1