summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-04-21 11:33:59 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2022-04-21 11:33:59 +0300
commit394784095eeedb3a2915249fe14a9d2e1f91a23a (patch)
tree0a2e7ad98bfa382744d87c6af6eb91f4bfc3858d /storage
parentd7189fbcb4dadf23d615a5f3a26aba1d4e37178f (diff)
parent4730314a70119ae5857edffe2d1bec86960ef22b (diff)
downloadmariadb-git-394784095eeedb3a2915249fe14a9d2e1f91a23a.tar.gz
Merge 10.3 into 10.4
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/handler/ha_innodb.cc11
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc33
-rw-r--r--storage/innobase/include/sync0sync.h3
-rw-r--r--storage/innobase/include/sync0types.h4
-rw-r--r--storage/innobase/sync/sync0debug.cc18
-rw-r--r--storage/innobase/sync/sync0sync.cc3
-rw-r--r--storage/maria/ma_write.c3
-rw-r--r--storage/maria/maria_def.h3
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/mdev_25116.result33
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_25116.cnf3
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_25116.test37
-rw-r--r--storage/spider/mysql-test/spider/r/spider3_fixes.result8
-rw-r--r--storage/spider/mysql-test/spider/t/spider3_fixes.test10
-rw-r--r--storage/spider/spd_db_conn.cc3
-rw-r--r--storage/spider/spd_table.cc2
15 files changed, 118 insertions, 56 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 86069f61c31..972c2a0731a 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -615,7 +615,6 @@ static PSI_mutex_info all_innodb_mutexes[] = {
PSI_KEY(fts_doc_id_mutex),
PSI_KEY(log_flush_order_mutex),
PSI_KEY(hash_table_mutex),
- PSI_KEY(ibuf_bitmap_mutex),
PSI_KEY(ibuf_mutex),
PSI_KEY(ibuf_pessimistic_insert_mutex),
PSI_KEY(index_online_log),
@@ -1904,7 +1903,9 @@ static void sst_enable_innodb_writes()
ut_d(recv_no_log_write= false);
purge_sys.resume();
wsrep_sst_disable_writes= false;
- fil_crypt_set_thread_cnt(srv_n_fil_crypt_threads);
+ const uint old_count= srv_n_fil_crypt_threads;
+ srv_n_fil_crypt_threads= 0;
+ fil_crypt_set_thread_cnt(old_count);
}
static void innodb_disable_internal_writes(bool disable)
@@ -12659,7 +12660,6 @@ bool create_table_info_t::row_size_is_acceptable(
return true;
}
-/* FIXME: row size check has some flaws and should be improved */
dict_index_t::record_size_info_t dict_index_t::record_size_info() const
{
ut_ad(!(type & DICT_FTS));
@@ -12749,6 +12749,8 @@ dict_index_t::record_size_info_t dict_index_t::record_size_info() const
{
/* dict_index_add_col() should guarantee this */
ut_ad(!f.prefix_len || f.fixed_len == f.prefix_len);
+ if (f.prefix_len)
+ field_max_size= f.prefix_len;
/* Fixed lengths are not encoded
in ROW_FORMAT=COMPACT. */
goto add_field_size;
@@ -12802,7 +12804,8 @@ dict_index_t::record_size_info_t dict_index_t::record_size_info() const
unique columns, result.shortest_size equals the size of the
node pointer record minus the node pointer column. */
if (i + 1 == dict_index_get_n_unique_in_tree(this) &&
- result.shortest_size + REC_NODE_PTR_SIZE >= page_ptr_max)
+ result.shortest_size + REC_NODE_PTR_SIZE + (comp ? 0 : 2) >=
+ page_ptr_max)
{
result.set_too_big(i);
}
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index 8022205dc7e..dbb19bec7a0 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -251,9 +251,6 @@ static ib_mutex_t ibuf_pessimistic_insert_mutex;
/** The mutex protecting the insert buffer structs */
static ib_mutex_t ibuf_mutex;
-/** The mutex protecting the insert buffer bitmaps */
-static ib_mutex_t ibuf_bitmap_mutex;
-
/** The area in pages from which contract looks for page numbers for merge */
const ulint IBUF_MERGE_AREA = 8;
@@ -400,8 +397,6 @@ ibuf_close(void)
mutex_free(&ibuf_mutex);
- mutex_free(&ibuf_bitmap_mutex);
-
dict_table_t* ibuf_table = ibuf->index->table;
rw_lock_free(&ibuf->index->lock);
dict_mem_index_free(ibuf->index);
@@ -457,8 +452,6 @@ ibuf_init_at_db_start(void)
mutex_create(LATCH_ID_IBUF, &ibuf_mutex);
- mutex_create(LATCH_ID_IBUF_BITMAP, &ibuf_bitmap_mutex);
-
mutex_create(LATCH_ID_IBUF_PESSIMISTIC_INSERT,
&ibuf_pessimistic_insert_mutex);
@@ -997,26 +990,16 @@ ibuf_update_free_bits_for_two_pages_low(
buf_block_t* block2, /*!< in: index page */
mtr_t* mtr) /*!< in: mtr */
{
- ulint state;
-
- ut_ad(mtr->is_named_space(block1->page.id.space()));
- ut_ad(block1->page.id.space() == block2->page.id.space());
-
- /* As we have to x-latch two random bitmap pages, we have to acquire
- the bitmap mutex to prevent a deadlock with a similar operation
- performed by another OS thread. */
-
- mutex_enter(&ibuf_bitmap_mutex);
-
- state = ibuf_index_page_calc_free(block1);
-
- ibuf_set_free_bits_low(block1, state, mtr);
-
- state = ibuf_index_page_calc_free(block2);
+ ut_ad(mtr->is_named_space(block1->page.id.space()));
+ ut_ad(block1->page.id.space() == block2->page.id.space());
- ibuf_set_free_bits_low(block2, state, mtr);
+ /* Avoid deadlocks by acquiring multiple bitmap page latches in
+ a consistent order (smaller pointer first). */
+ if (block1 > block2)
+ std::swap(block1, block2);
- mutex_exit(&ibuf_bitmap_mutex);
+ ibuf_set_free_bits_low(block1, ibuf_index_page_calc_free(block1), mtr);
+ ibuf_set_free_bits_low(block2, ibuf_index_page_calc_free(block2), mtr);
}
/** Returns TRUE if the page is one of the fixed address ibuf pages.
diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h
index c9cf963b840..0cd41a807c6 100644
--- a/storage/innobase/include/sync0sync.h
+++ b/storage/innobase/include/sync0sync.h
@@ -3,7 +3,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2020, MariaDB Corporation.
+Copyright (c) 2020, 2022, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -61,7 +61,6 @@ extern mysql_pfs_key_t fts_delete_mutex_key;
extern mysql_pfs_key_t fts_doc_id_mutex_key;
extern mysql_pfs_key_t fts_pll_tokenize_mutex_key;
extern mysql_pfs_key_t hash_table_mutex_key;
-extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
extern mysql_pfs_key_t ibuf_mutex_key;
extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
extern mysql_pfs_key_t log_sys_mutex_key;
diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h
index 1bd52547d93..b0510e82524 100644
--- a/storage/innobase/include/sync0types.h
+++ b/storage/innobase/include/sync0types.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2020, MariaDB Corporation.
+Copyright (c) 2017, 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
@@ -226,7 +226,6 @@ enum latch_level_t {
SYNC_INDEX_ONLINE_LOG,
SYNC_IBUF_BITMAP,
- SYNC_IBUF_BITMAP_MUTEX,
SYNC_IBUF_TREE_NODE,
SYNC_IBUF_TREE_NODE_NEW,
SYNC_IBUF_INDEX_TREE,
@@ -289,7 +288,6 @@ enum latch_id_t {
LATCH_ID_FTS_DOC_ID,
LATCH_ID_FTS_PLL_TOKENIZE,
LATCH_ID_HASH_TABLE_MUTEX,
- LATCH_ID_IBUF_BITMAP,
LATCH_ID_IBUF,
LATCH_ID_IBUF_PESSIMISTIC_INSERT,
LATCH_ID_LOG_SYS,
diff --git a/storage/innobase/sync/sync0debug.cc b/storage/innobase/sync/sync0debug.cc
index 377adc5b009..6f99eec8c07 100644
--- a/storage/innobase/sync/sync0debug.cc
+++ b/storage/innobase/sync/sync0debug.cc
@@ -473,7 +473,6 @@ LatchDebug::LatchDebug()
LEVEL_MAP_INSERT(SYNC_LOCK_WAIT_SYS);
LEVEL_MAP_INSERT(SYNC_INDEX_ONLINE_LOG);
LEVEL_MAP_INSERT(SYNC_IBUF_BITMAP);
- LEVEL_MAP_INSERT(SYNC_IBUF_BITMAP_MUTEX);
LEVEL_MAP_INSERT(SYNC_IBUF_TREE_NODE);
LEVEL_MAP_INSERT(SYNC_IBUF_TREE_NODE_NEW);
LEVEL_MAP_INSERT(SYNC_IBUF_INDEX_TREE);
@@ -747,7 +746,6 @@ LatchDebug::check_order(
case SYNC_LOCK_WAIT_SYS:
case SYNC_RW_TRX_HASH_ELEMENT:
case SYNC_TRX_SYS:
- case SYNC_IBUF_BITMAP_MUTEX:
case SYNC_REDO_RSEG:
case SYNC_NOREDO_RSEG:
case SYNC_PURGE_LATCH:
@@ -830,22 +828,13 @@ LatchDebug::check_order(
break;
case SYNC_IBUF_BITMAP:
-
- /* Either the thread must own the master mutex to all
- the bitmap pages, or it is allowed to latch only ONE
- bitmap page. */
-
- if (find(latches, SYNC_IBUF_BITMAP_MUTEX) != 0) {
-
- basic_check(latches, level, SYNC_IBUF_BITMAP - 1);
-
- } else if (!srv_is_being_started) {
+ if (!srv_is_being_started) {
/* This is violated during trx_sys_create_rsegs()
when creating additional rollback segments during
upgrade. */
- basic_check(latches, level, SYNC_IBUF_BITMAP);
+ basic_check(latches, level, SYNC_IBUF_BITMAP - 1);
}
break;
@@ -1282,9 +1271,6 @@ sync_latch_meta_init()
LATCH_ADD_MUTEX(HASH_TABLE_MUTEX, SYNC_BUF_PAGE_HASH,
hash_table_mutex_key);
- LATCH_ADD_MUTEX(IBUF_BITMAP, SYNC_IBUF_BITMAP_MUTEX,
- ibuf_bitmap_mutex_key);
-
LATCH_ADD_MUTEX(IBUF, SYNC_IBUF_MUTEX, ibuf_mutex_key);
LATCH_ADD_MUTEX(IBUF_PESSIMISTIC_INSERT, SYNC_IBUF_PESS_INSERT_MUTEX,
diff --git a/storage/innobase/sync/sync0sync.cc b/storage/innobase/sync/sync0sync.cc
index e7be502632d..7ccde7373a7 100644
--- a/storage/innobase/sync/sync0sync.cc
+++ b/storage/innobase/sync/sync0sync.cc
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
-Copyright (c) 2020, MariaDB Corporation.
+Copyright (c) 2020, 2022, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -46,7 +46,6 @@ mysql_pfs_key_t fts_delete_mutex_key;
mysql_pfs_key_t fts_doc_id_mutex_key;
mysql_pfs_key_t fts_pll_tokenize_mutex_key;
mysql_pfs_key_t hash_table_mutex_key;
-mysql_pfs_key_t ibuf_bitmap_mutex_key;
mysql_pfs_key_t ibuf_mutex_key;
mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
mysql_pfs_key_t log_sys_mutex_key;
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index 86770749a45..88486bca246 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -728,7 +728,10 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key,
}
}
if (flag == MARIA_FOUND_WRONG_KEY)
+ {
+ my_errno= HA_ERR_CRASHED;
goto err;
+ }
if (!was_last_key)
insert_last=0;
next_page= _ma_kpos(page.node, keypos);
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index c51ae2b95f7..80c57ad9a0e 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -890,7 +890,8 @@ struct st_maria_handler
#define PACK_TYPE_SELECTED 1U /* Bits in field->pack_type */
#define PACK_TYPE_SPACE_FIELDS 2U
#define PACK_TYPE_ZERO_FILL 4U
-#define MARIA_FOUND_WRONG_KEY 32768U /* Impossible value from ha_key_cmp */
+
+#define MARIA_FOUND_WRONG_KEY INT_MAX32 /* Impossible value from ha_key_cmp */
#define MARIA_BLOCK_SIZE(key_length,data_pointer,key_pointer,block_size) (((((key_length)+(data_pointer)+(key_pointer))*4+(key_pointer)+2)/(block_size)+1)*(block_size))
#define MARIA_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */
diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_25116.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_25116.result
new file mode 100644
index 00000000000..cd2ca4b1635
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_25116.result
@@ -0,0 +1,33 @@
+#
+# MDEV-25116 Spider: IF(COUNT( trigger SQL Error (1054)_ Unknown column '' in field list
+#
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+connection child2_1;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+CREATE TABLE tbl_a (id INT);
+connection master_1;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+CREATE TABLE tbl_a (
+id INT
+) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"';
+connection master_1;
+SELECT IF(COUNT(id > 0),'Y','N') FROM tbl_a;
+IF(COUNT(id > 0),'Y','N')
+N
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_25116.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_25116.cnf
new file mode 100644
index 00000000000..05dfd8a0bce
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_25116.cnf
@@ -0,0 +1,3 @@
+!include include/default_mysqld.cnf
+!include ../my_1_1.cnf
+!include ../my_2_1.cnf
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_25116.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_25116.test
new file mode 100644
index 00000000000..70c2bcc51b7
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_25116.test
@@ -0,0 +1,37 @@
+--echo #
+--echo # MDEV-25116 Spider: IF(COUNT( trigger SQL Error (1054)_ Unknown column '' in field list
+--echo #
+
+--disable_query_log
+--disable_result_log
+--source ../../t/test_init.inc
+--enable_result_log
+--enable_query_log
+
+--connection child2_1
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+
+CREATE TABLE tbl_a (id INT);
+
+--connection master_1
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+
+eval CREATE TABLE tbl_a (
+ id INT
+) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"';
+
+--connection master_1
+SELECT IF(COUNT(id > 0),'Y','N') FROM tbl_a;
+
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+--connection child2_1
+DROP DATABASE IF EXISTS auto_test_remote;
+
+--disable_query_log
+--disable_result_log
+--source ../t/test_deinit.inc
+--enable_query_log
+--enable_result_log
diff --git a/storage/spider/mysql-test/spider/r/spider3_fixes.result b/storage/spider/mysql-test/spider/r/spider3_fixes.result
index d6aec25bfc1..7a80e102462 100644
--- a/storage/spider/mysql-test/spider/r/spider3_fixes.result
+++ b/storage/spider/mysql-test/spider/r/spider3_fixes.result
@@ -200,6 +200,14 @@ id
5000
10000
connection master_1;
+#
+# MDEV-28225 Disallow user to create Spider temporary table
+#
+connection master_1;
+CREATE TEMPORARY TABLE t1 (
+a INT
+) ENGINE=Spider;
+ERROR HY000: Table storage engine 'SPIDER' does not support the create option 'TEMPORARY'
deinit
connection master_1;
diff --git a/storage/spider/mysql-test/spider/t/spider3_fixes.test b/storage/spider/mysql-test/spider/t/spider3_fixes.test
index 13fa6f5fa39..73126d6d348 100644
--- a/storage/spider/mysql-test/spider/t/spider3_fixes.test
+++ b/storage/spider/mysql-test/spider/t/spider3_fixes.test
@@ -264,6 +264,16 @@ if ($USE_CHILD_GROUP2)
}
+--echo #
+--echo # MDEV-28225 Disallow user to create Spider temporary table
+--echo #
+--connection master_1
+--error ER_ILLEGAL_HA_CREATE_OPTION
+CREATE TEMPORARY TABLE t1 (
+ a INT
+) ENGINE=Spider;
+
+
--echo
--echo deinit
--disable_warnings
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index be9ee324ee1..38b9db56c58 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -9603,8 +9603,7 @@ int spider_db_open_item_ref(
}
DBUG_RETURN(0);
}
- DBUG_RETURN(spider_db_print_item_type(*(item_ref->ref), NULL, spider, str,
- alias, alias_length, dbton_id, use_fields, fields));
+ DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); // MDEV-25116
}
DBUG_RETURN(spider_db_open_item_ident((Item_ident *) item_ref, spider, str,
alias, alias_length, dbton_id, use_fields, fields));
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index 495e1483ee6..9d3846cb43b 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -6931,7 +6931,7 @@ int spider_db_init(
spider_hton_ptr = spider_hton;
spider_hton->state = SHOW_OPTION_YES;
- spider_hton->flags = HTON_NO_FLAGS;
+ spider_hton->flags = HTON_TEMPORARY_NOT_SUPPORTED;
#ifdef HTON_CAN_READ_CONNECT_STRING_IN_PARTITION
spider_hton->flags |= HTON_CAN_READ_CONNECT_STRING_IN_PARTITION;
#endif