summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2020-12-04 13:59:02 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2020-12-04 13:59:02 +0530
commit7176e09f8a02ae0a1cc95dcbab66b0156e08ac80 (patch)
tree44cc1f09d7de59273031e7a168403b77f0d0e3ac
parent98baf80753943ff08fe502f62e91e50e04f6baf0 (diff)
downloadmariadb-git-bb-10.5-MDEV-515.tar.gz
MDEV-515 Addressed marko's review comments.bb-10.5-MDEV-515
-rw-r--r--mysql-test/main/innodb_mysql_lock.test2
-rw-r--r--mysql-test/suite/binlog/t/binlog_xa_prepared.inc2
-rw-r--r--mysql-test/suite/innodb/disabled.def2
-rw-r--r--mysql-test/suite/innodb/r/ddl_purge.result1
-rw-r--r--mysql-test/suite/innodb/r/innodb-bug-14084530.result3
-rw-r--r--mysql-test/suite/innodb/t/ddl_purge.test4
-rw-r--r--mysql-test/suite/innodb/t/innodb-bug-14084530.test7
-rw-r--r--storage/innobase/dict/dict0mem.cc27
-rw-r--r--storage/innobase/handler/ha_innodb.cc5
-rw-r--r--storage/innobase/include/dict0mem.h2
10 files changed, 29 insertions, 26 deletions
diff --git a/mysql-test/main/innodb_mysql_lock.test b/mysql-test/main/innodb_mysql_lock.test
index 501bd49a8f0..1285dc4c241 100644
--- a/mysql-test/main/innodb_mysql_lock.test
+++ b/mysql-test/main/innodb_mysql_lock.test
@@ -25,6 +25,8 @@ connect (con3,localhost,root,,);
connection con1;
set @@autocommit=0;
CREATE TABLE t1(s1 INT UNIQUE) ENGINE=innodb;
+# MDEV-515 takes X-lock on the table for the first insert.
+# So Concurrent DML blocked
INSERT INTO t1 VALUES(100);
COMMIT;
INSERT INTO t1 VALUES (1);
diff --git a/mysql-test/suite/binlog/t/binlog_xa_prepared.inc b/mysql-test/suite/binlog/t/binlog_xa_prepared.inc
index 76e394f28d2..1c6a9fe0ced 100644
--- a/mysql-test/suite/binlog/t/binlog_xa_prepared.inc
+++ b/mysql-test/suite/binlog/t/binlog_xa_prepared.inc
@@ -53,6 +53,8 @@ CREATE VIEW v_processlist as SELECT * FROM performance_schema.threads where typ
--eval call mtr.add_suppression("Found $prepared_at_server_restart prepared XA transactions")
CREATE TABLE t (a INT) ENGINE=innodb;
+# First insert in the table takes X-lock
+# So concurrent DML could be blocked
INSERT INTO t VALUES(100);
# Counter is incremented at the end of post restart to
# reflect number of loops done in correctness computation.
diff --git a/mysql-test/suite/innodb/disabled.def b/mysql-test/suite/innodb/disabled.def
index 89208966015..35c941f8af7 100644
--- a/mysql-test/suite/innodb/disabled.def
+++ b/mysql-test/suite/innodb/disabled.def
@@ -11,5 +11,3 @@
##############################################################################
create-index-debug : MDEV-13680 InnoDB may crash when btr_page_alloc() fails
-innodb.ddl_purge: MDEV-515
-innodb.blob-crash: MDEV-515
diff --git a/mysql-test/suite/innodb/r/ddl_purge.result b/mysql-test/suite/innodb/r/ddl_purge.result
index 45f4c99e97b..a1d96de24ca 100644
--- a/mysql-test/suite/innodb/r/ddl_purge.result
+++ b/mysql-test/suite/innodb/r/ddl_purge.result
@@ -1,5 +1,6 @@
CREATE TABLE t0 (pk INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t1 (pk INT PRIMARY KEY, b INT) ENGINE=InnoDB;
+INSERT INTO t0 VALUES(100);
connect con1,localhost,root,,test;
BEGIN;
INSERT INTO t0 SET pk=1;
diff --git a/mysql-test/suite/innodb/r/innodb-bug-14084530.result b/mysql-test/suite/innodb/r/innodb-bug-14084530.result
index 58cab531e2f..b8e0e3a579d 100644
--- a/mysql-test/suite/innodb/r/innodb-bug-14084530.result
+++ b/mysql-test/suite/innodb/r/innodb-bug-14084530.result
@@ -1,6 +1,9 @@
SET AUTOCOMMIT = 0;
CREATE DATABASE testdb_wl5522;
CREATE TABLE testdb_wl5522.t1 (c1 int ) engine = Innodb;
+BEGIN;
+INSERT INTO testdb_wl5522.t1 VALUES (1),(123),(331);
+ROLLBACK;
SELECT c1 FROM testdb_wl5522.t1;
c1
FLUSH TABLES testdb_wl5522.t1 FOR EXPORT;
diff --git a/mysql-test/suite/innodb/t/ddl_purge.test b/mysql-test/suite/innodb/t/ddl_purge.test
index 60d17acead8..43a64b2d73c 100644
--- a/mysql-test/suite/innodb/t/ddl_purge.test
+++ b/mysql-test/suite/innodb/t/ddl_purge.test
@@ -5,6 +5,10 @@
CREATE TABLE t0 (pk INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t1 (pk INT PRIMARY KEY, b INT) ENGINE=InnoDB;
+# First insert in the table takes X-lock
+# So concurrent DML could be blocked
+INSERT INTO t0 VALUES(100);
+
--connect (con1,localhost,root,,test)
BEGIN;
INSERT INTO t0 SET pk=1;
diff --git a/mysql-test/suite/innodb/t/innodb-bug-14084530.test b/mysql-test/suite/innodb/t/innodb-bug-14084530.test
index 0db10678193..f27fbbe31d7 100644
--- a/mysql-test/suite/innodb/t/innodb-bug-14084530.test
+++ b/mysql-test/suite/innodb/t/innodb-bug-14084530.test
@@ -8,10 +8,9 @@ SET AUTOCOMMIT = 0;
CREATE DATABASE testdb_wl5522;
CREATE TABLE testdb_wl5522.t1 (c1 int ) engine = Innodb;
-# MDEV-515 could reset the clustered index LSN
-#BEGIN;
-#INSERT INTO testdb_wl5522.t1 VALUES (1),(123),(331);
-#ROLLBACK;
+BEGIN;
+INSERT INTO testdb_wl5522.t1 VALUES (1),(123),(331);
+ROLLBACK;
SELECT c1 FROM testdb_wl5522.t1;
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index 58d23ed11d1..f4024c9fedb 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -1407,7 +1407,7 @@ void dict_table_t::empty_table()
|| index->online_status == ONLINE_INDEX_ABORTED_DROPPED)
continue;
- if (index->page == FIL_NULL && index->type & DICT_FTS)
+ if (index->type & DICT_FTS)
continue;
if (index->online_status == ONLINE_INDEX_CREATION)
@@ -1432,9 +1432,9 @@ void dict_table_t::empty_table()
remove_bulk_trx();
}
-void dict_table_t::assign_stat_n_rows()
+void dict_table_t::assign_non_empty()
{
- if (!space || !is_readable())
+ if (!space || !is_readable() || non_empty)
return;
dict_index_t* clust_index= dict_table_get_first_index(this);
@@ -1451,17 +1451,18 @@ void dict_table_t::assign_stat_n_rows()
if (!is_readable())
{
mtr.commit();
- return ;
+ return;
}
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
if (!rec_is_metadata(btr_pcur_get_rec(&pcur), *clust_index))
btr_pcur_move_to_prev_on_page(&pcur);
else if (rec_is_alter_metadata(btr_pcur_get_rec(&pcur),
*clust_index))
+ {
non_empty= true;
-
- ulint n_rows= 0;
-scan_leaf:
+ mtr.commit();
+ return;
+ }
cur= btr_pcur_get_page_cur(&pcur);
page_cur_move_to_next(cur);
next_page:
@@ -1471,9 +1472,6 @@ next_page:
if (next_page_no == FIL_NULL)
{
mtr.commit();
- stat_n_rows= n_rows;
- if (n_rows)
- non_empty= true;
return;
}
@@ -1492,13 +1490,12 @@ next_page:
}
rec= page_cur_get_rec(cur);
- if (rec_get_deleted_flag(rec, dict_table_is_comp(this)));
- else if (!page_rec_is_supremum(rec))
- n_rows++;
- else
+ if (page_rec_is_supremum(rec))
{
next_page= true;
goto next_page;
}
- goto scan_leaf;
+ non_empty= true;
+ mtr.commit();
+ return;
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index e4d513419bf..6841eb8706f 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -5737,9 +5737,7 @@ ha_innobase::open(const char* name, int, uint)
}
}
- if (!ib_table->non_empty) {
- ib_table->assign_stat_n_rows();
- }
+ ib_table->assign_non_empty();
m_prebuilt = row_create_prebuilt(ib_table, table->s->reclength);
@@ -7515,7 +7513,6 @@ ha_innobase::write_row(
if (m_prebuilt->table->can_bulk_op()
&& lock_table_has(trx, m_prebuilt->table, LOCK_X)) {
- // bulk index code
m_prebuilt->table->bulk_trx_id = trx->id;
}
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index b786999e2c0..cfdb479753e 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -1954,7 +1954,7 @@ struct dict_table_t {
size_t *db_name_len, size_t *tbl_name_len) const;
/** Assign n_stat_rows in dict_table_t */
- void assign_stat_n_rows();
+ void assign_non_empty();
/** Empty the table */
void empty_table();