From d7ba72ea9bfc26b6b7172b4ad6c5a1eddbc386c1 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Sat, 6 Aug 2022 22:18:11 -0400 Subject: Remove Darwin CMake file The file is now empty and thus serves no purpose. --- cmake/os/Darwin.cmake | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 cmake/os/Darwin.cmake diff --git a/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake deleted file mode 100644 index 21e18360dfe..00000000000 --- a/cmake/os/Darwin.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. -# -# 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 Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA - -# This file includes OSX specific options and quirks, related to system checks -- cgit v1.2.1 From d48428e99aa7435ff72e2df7da05f35363e90ec3 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Mon, 1 Aug 2022 19:39:09 +0530 Subject: MDEV-27151: JSON_VALUE() does not parse NULL properties properly Analysis: JSON_VALUE() returns "null" string instead of NULL pointer. Fix: When the type is JSON_VALUE_NULL (which is also a scalar) set null_value to true and return 0 instead of returning string. --- mysql-test/main/func_json.result | 27 +++++++++++++++++++++++++++ mysql-test/main/func_json.test | 19 +++++++++++++++++++ sql/item_jsonfunc.cc | 7 ++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 8e3b47e322a..2c3cb2f1e72 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1016,5 +1016,32 @@ j {"ID": "4", "Name": "Betty", "Age": 19} drop table t1; # +# MDEV-27151: JSON_VALUE() does not parse NULL properties properly +# +# +# It is correct for JSON_EXTRACT() to give null instead of "NULL" because +# it returns the json literal that is put inside json. +# Hence it should return null as in 'null' string and not SQL NULL. +# JSON_VALUE() returns the "VALUE" so it is correct for it to return SQl NULL +# +SELECT NULL; +NULL +NULL +SELECT JSON_VALUE('{"nulltest": null}', '$.nulltest'); +JSON_VALUE('{"nulltest": null}', '$.nulltest') +NULL +SELECT 1 + NULL; +1 + NULL +NULL +SELECT 1 + JSON_VALUE('{"nulltest": null}', '$.nulltest'); +1 + JSON_VALUE('{"nulltest": null}', '$.nulltest') +NULL +SELECT NULL; +NULL +NULL +SELECT JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a'); +JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a') +null +# # End of 10.3 tests # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 16f323a9a56..51961c0406a 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -627,6 +627,25 @@ SELECT * FROM t1 WHERE JSON_EXTRACT(j, '$.Age')=19; drop table t1; +--echo # +--echo # MDEV-27151: JSON_VALUE() does not parse NULL properties properly +--echo # +--echo # +--echo # It is correct for JSON_EXTRACT() to give null instead of "NULL" because +--echo # it returns the json literal that is put inside json. +--echo # Hence it should return null as in 'null' string and not SQL NULL. +--echo # JSON_VALUE() returns the "VALUE" so it is correct for it to return SQl NULL +--echo # + +SELECT NULL; +SELECT JSON_VALUE('{"nulltest": null}', '$.nulltest'); +SELECT 1 + NULL; +SELECT 1 + JSON_VALUE('{"nulltest": null}', '$.nulltest'); + + +SELECT NULL; +SELECT JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a'); + --echo # --echo # End of 10.3 tests --echo # diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 011cfdc8fd0..abbff8c3e92 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -619,6 +619,12 @@ continue_search: if (json_read_value(&je)) goto err_return; + if (je.value_type == JSON_VALUE_NULL) + { + null_value= 1; + return NULL; + } + if (unlikely(check_and_get_value(&je, str, &error))) { if (error) @@ -1111,7 +1117,6 @@ my_decimal *Item_func_json_extract::val_decimal(my_decimal *to) case JSON_VALUE_OBJECT: case JSON_VALUE_ARRAY: case JSON_VALUE_FALSE: - // TODO: fix: NULL should be NULL case JSON_VALUE_NULL: int2my_decimal(E_DEC_FATAL_ERROR, 0, false/*unsigned_flag*/, to); return to; -- cgit v1.2.1 From 6d90d2ba7f86bf95823f74ca2da433193ae84b25 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Sun, 14 Aug 2022 21:45:05 -0400 Subject: bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b229b7f95f7..92848892dc8 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=3 -MYSQL_VERSION_PATCH=36 +MYSQL_VERSION_PATCH=37 SERVER_MATURITY=stable -- cgit v1.2.1 From a4a42f50f05c0f48fdc85bf8891755c809622d01 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Sun, 14 Aug 2022 22:19:37 -0400 Subject: bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index eb444d84828..ec02fb54be8 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=4 -MYSQL_VERSION_PATCH=26 +MYSQL_VERSION_PATCH=27 SERVER_MATURITY=stable -- cgit v1.2.1 From fd1e5f91d273315d5f08c4f11abe3446793c3979 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Sun, 14 Aug 2022 22:53:37 -0400 Subject: bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 526e94ebc5d..41ccccdc33f 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=17 +MYSQL_VERSION_PATCH=18 SERVER_MATURITY=stable -- cgit v1.2.1 From c2080060801342f46849423adf71515ae7a33e04 Mon Sep 17 00:00:00 2001 From: Nayuta Yanagisawa Date: Thu, 28 Jul 2022 21:24:57 +0900 Subject: MDEV-29008 Server crash or assertion `field' failed in spider_db_open_item_ident / group by handler ha_spider::field_exchange() returns NULL and that results in a crash or a assertion failure in spider_db_open_item_ident(). In the first place, there seems to be no need to call field_exchange() for printing an identity (column name with alias). Thus, we simply remove the call. --- .../mysql-test/spider/bugfix/r/mdev_29008.result | 38 +++++++++++++++++++++ .../mysql-test/spider/bugfix/t/mdev_29008.cnf | 3 ++ .../mysql-test/spider/bugfix/t/mdev_29008.test | 39 ++++++++++++++++++++++ storage/spider/spd_db_conn.cc | 2 -- 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_29008.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_29008.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29008.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29008.result new file mode 100644 index 00000000000..66e33f42a7e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29008.result @@ -0,0 +1,38 @@ +# +# MDEV-29008 Server crash or assertion `field' failed in spider_db_open_item_ident / group by handler +# +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 ( +a INT, +b INT +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +INSERT INTO tbl_a VALUES (1,2),(3,4); +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +CREATE TABLE tbl_a ( +a INT, +b INT +) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"'; +SELECT MIN(t2.a) AS f1, t1.b AS f2 FROM tbl_a AS t1 JOIN tbl_a AS t2 GROUP BY f2 ORDER BY f1, f2; +f1 f2 +1 2 +1 4 +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_29008.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.cnf new file mode 100644 index 00000000000..05dfd8a0bce --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.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_29008.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test new file mode 100644 index 00000000000..28d9a9244e3 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test @@ -0,0 +1,39 @@ +--echo # +--echo # MDEV-29008 Server crash or assertion `field' failed in spider_db_open_item_ident / group by handler +--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; +eval CREATE TABLE tbl_a ( + a INT, + b INT +) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +INSERT INTO tbl_a VALUES (1,2),(3,4); + +--connection master_1 +CREATE DATABASE auto_test_local; +USE auto_test_local; +eval CREATE TABLE tbl_a ( + a INT, + b INT +) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"'; + +SELECT MIN(t2.a) AS f1, t1.b AS f2 FROM tbl_a AS t1 JOIN tbl_a AS t2 GROUP BY f2 ORDER BY f1, f2; + +--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/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 2569574561e..1aafa175a7b 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -9115,8 +9115,6 @@ int spider_db_open_item_ident( SPIDER_FIELD_HOLDER *field_holder = field_chain->field_holder; spider = field_holder->spider; share = spider->share; - field = spider->field_exchange(field); - DBUG_ASSERT(field); if ((error_num = share->dbton_share[dbton_id]-> append_column_name_with_alias(str, field->field_index, field_holder->alias->ptr(), field_holder->alias->length()))) -- cgit v1.2.1 From 32167225c728c19ca478bce0529d549a8d056f87 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 16 Aug 2022 17:34:38 +0530 Subject: MDEV-13013 InnoDB unnecessarily extends data files - While creating a new InnoDB segment, allocates the extent before allocating the inode or page allocation even though the pages are present in fragment segment. This patch does reserve the extent when InnoDB ran out of fragment pages in the tablespace. --- .../suite/innodb/r/check_ibd_filesize,32k.rdiff | 12 +++---- .../suite/innodb/r/check_ibd_filesize,4k.rdiff | 12 +++---- .../suite/innodb/r/check_ibd_filesize,64k.rdiff | 12 +++---- .../suite/innodb/r/check_ibd_filesize,8k.rdiff | 12 +++---- .../suite/innodb/r/check_ibd_filesize.result | 4 +-- mysql-test/suite/innodb/t/temporary_table.test | 1 + .../suite/mariabackup/log_page_corruption.result | 24 +++++++------- storage/innobase/fsp/fsp0fsp.cc | 38 +++++++++++++++------- 8 files changed, 66 insertions(+), 49 deletions(-) diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff index 6cf0fdf4159..44446602b9f 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff @@ -1,18 +1,18 @@ ---- check_ibd_filesize.result -+++ check_ibd_filesize.result,32k +--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:29:25.129637040 +0530 @@ -3,18 +3,12 @@ # SPACE IN 5.7 THAN IN 5.6 # CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; --# bytes: 98304 -+# bytes: 196608 +-# bytes: 65536 ++# bytes: 131072 INSERT INTO t1 SELECT * FROM seq_1_to_25000; -# bytes: 9437184 +# bytes: 786432 DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; --# bytes: 98304 -+# bytes: 196608 +-# bytes: 65536 ++# bytes: 131072 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; -# bytes: 4194304 -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff index 52cd6832755..ef55ad971fe 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff @@ -1,17 +1,17 @@ ---- check_ibd_filesize.result -+++ check_ibd_filesize.result,4k +--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:39.288769153 +0530 @@ -3,18 +3,18 @@ # SPACE IN 5.7 THAN IN 5.6 # CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; --# bytes: 98304 -+# bytes: 24576 +-# bytes: 65536 ++# bytes: 16384 INSERT INTO t1 SELECT * FROM seq_1_to_25000; # bytes: 9437184 DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; --# bytes: 98304 -+# bytes: 24576 +-# bytes: 65536 ++# bytes: 16384 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; # bytes: 4194304 DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff index 23d9fbe608f..bcdcea31160 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff @@ -1,18 +1,18 @@ ---- check_ibd_filesize.result -+++ check_ibd_filesize.result,64k +--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:30:28.957174270 +0530 @@ -3,18 +3,12 @@ # SPACE IN 5.7 THAN IN 5.6 # CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; --# bytes: 98304 -+# bytes: 393216 +-# bytes: 65536 ++# bytes: 262144 INSERT INTO t1 SELECT * FROM seq_1_to_25000; -# bytes: 9437184 +# bytes: 983040 DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; --# bytes: 98304 -+# bytes: 393216 +-# bytes: 65536 ++# bytes: 262144 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; -# bytes: 4194304 -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff index 17936a3def9..7b699ef4cea 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff @@ -1,17 +1,17 @@ ---- check_ibd_filesize.result -+++ check_ibd_filesize.result,8k +--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:03.516962339 +0530 @@ -3,18 +3,18 @@ # SPACE IN 5.7 THAN IN 5.6 # CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; --# bytes: 98304 -+# bytes: 49152 +-# bytes: 65536 ++# bytes: 32768 INSERT INTO t1 SELECT * FROM seq_1_to_25000; # bytes: 9437184 DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; --# bytes: 98304 -+# bytes: 49152 +-# bytes: 65536 ++# bytes: 32768 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; # bytes: 4194304 DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize.result b/mysql-test/suite/innodb/r/check_ibd_filesize.result index a6f5fbd9387..0d224d6ac5f 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize.result +++ b/mysql-test/suite/innodb/r/check_ibd_filesize.result @@ -3,12 +3,12 @@ # SPACE IN 5.7 THAN IN 5.6 # CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; -# bytes: 98304 +# bytes: 65536 INSERT INTO t1 SELECT * FROM seq_1_to_25000; # bytes: 9437184 DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; -# bytes: 98304 +# bytes: 65536 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; # bytes: 4194304 DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/temporary_table.test b/mysql-test/suite/innodb/t/temporary_table.test index 5f64eb7d22b..cc290b03c34 100644 --- a/mysql-test/suite/innodb/t/temporary_table.test +++ b/mysql-test/suite/innodb/t/temporary_table.test @@ -5,6 +5,7 @@ # --source include/have_innodb.inc +--source include/innodb_page_size.inc # Embedded server does not restart of server --source include/not_embedded.inc --source include/no_valgrind_without_big.inc diff --git a/mysql-test/suite/mariabackup/log_page_corruption.result b/mysql-test/suite/mariabackup/log_page_corruption.result index 01ad4422c6a..b1dc6c8fd5f 100644 --- a/mysql-test/suite/mariabackup/log_page_corruption.result +++ b/mysql-test/suite/mariabackup/log_page_corruption.result @@ -30,13 +30,13 @@ FOUND 1 /Database page corruption detected.*/ in backup.log FOUND 1 /completed OK!/ in backup.log --- "innodb_corrupted_pages" file content: --- test/t1_corrupted -6 8 9 +4 6 7 test/t2_corrupted -7 8 10 +5 6 8 test/t4_corrupted_new 1 test/t5_corrupted_to_rename_renamed -6 +4 test/t7_corrupted_to_alter 3 ------ @@ -46,19 +46,19 @@ INSERT INTO t3_inc VALUES (3), (4), (5), (6), (7), (8), (9); # Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option --- "innodb_corrupted_pages" file content: --- test/t1_corrupted -6 8 9 +4 6 7 test/t1_inc_corrupted -6 8 9 +4 6 7 test/t2_corrupted -7 8 10 +5 6 8 test/t2_inc_corrupted -7 8 10 +5 6 8 test/t4_inc_corrupted_new 1 test/t5_corrupted_to_rename_renamed -6 +4 test/t5_inc_corrupted_to_rename_renamed -6 +4 test/t7_inc_corrupted_to_alter 3 ------ @@ -82,15 +82,15 @@ DROP TABLE t7_inc_corrupted_to_alter; # Full backup with --log-innodb-page-corruption --- "innodb_corrupted_pages" file content: --- test/t3 -6 8 +4 6 ------ # Extend some tablespace and corrupt extended pages for incremental backup # Incremental backup --log-innodb-page-corruption --- "innodb_corrupted_pages" file content: --- test/t3 -6 8 +4 6 test/t3_inc -6 8 +4 6 ------ # Full backup prepare # "innodb_corrupted_pages" file must not exist after successful prepare diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index ab143a16417..ba50483cee4 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1886,6 +1886,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, fseg_header_t* header = 0; /* remove warning */ ulint n_reserved; ulint i; + bool reserved_extent = false; DBUG_ENTER("fseg_create"); @@ -1909,17 +1910,34 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, fil_block_check_type(*block, type, mtr); } - if (!has_done_reservation - && !fsp_reserve_free_extents(&n_reserved, space, 2, - FSP_NORMAL, mtr)) { - DBUG_RETURN(NULL); - } - space_header = fsp_get_space_header(space, page_size, mtr); +inode_alloc: inode = fsp_alloc_seg_inode(space, space_header, mtr); if (inode == NULL) { +reserve_extent: + if (!has_done_reservation && !reserved_extent) { + + if (!fsp_reserve_free_extents( + &n_reserved, space, 2, + FSP_NORMAL, mtr)) { + DBUG_RETURN(NULL); + } + + /* Extents reserved successfully. So + try allocating the page or inode */ + reserved_extent = true; + if (inode) { + goto page_alloc; + } + + goto inode_alloc; + } + + if (inode) { + fsp_free_seg_inode(space, page_size, inode, mtr); + } goto funct_exit; } @@ -1944,6 +1962,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, } if (!block) { +page_alloc: block = fseg_alloc_free_page_low(space, page_size, inode, 0, FSP_UP, mtr, mtr @@ -1957,10 +1976,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, ut_ad(!has_done_reservation || block != NULL); if (block == NULL) { - - fsp_free_seg_inode(space, page_size, inode, mtr); - - goto funct_exit; + goto reserve_extent; } ut_ad(rw_lock_get_x_lock_count(&block->lock) == 1); @@ -1980,7 +1996,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, mlog_write_ulint(header + FSEG_HDR_SPACE, space->id, MLOG_4BYTES, mtr); funct_exit: - if (!has_done_reservation) { + if (!has_done_reservation && reserved_extent) { space->release_free_extents(n_reserved); } -- cgit v1.2.1 From a1055ab35d29437b717e83b1a388eaa02901c42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 19 Aug 2022 09:18:24 +0300 Subject: MDEV-29043 mariabackup --compress hangs Even though commit b817afaa1c148437e1016d1981f138d0c46ccbc8 passed the test mariabackup.compress_qpress, that test turned out to be too small to reveal one more problem that had previously been prevented by the existence of ctrl_mutex. I did not realize that there can be multiple concurrent callers to compress_write(). One of them is the log copying thread; further callers are data file copying threads (default: --parallel=1). By default, there is only one compression worker thread (--compress-threads=1). compress_write(): Fix a race condition between threads that would use the same worker thread object. Make thd->data_avail contain the thread identifier of the submitter, and add thd->avail_cond to notify other compress_write() threads that are waiting for a slot. --- extra/mariabackup/ds_compress.cc | 51 +++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/extra/mariabackup/ds_compress.cc b/extra/mariabackup/ds_compress.cc index dc1140edfee..a89e676190d 100644 --- a/extra/mariabackup/ds_compress.cc +++ b/extra/mariabackup/ds_compress.cc @@ -34,9 +34,10 @@ typedef struct { pthread_t id; uint num; pthread_mutex_t data_mutex; + pthread_cond_t avail_cond; pthread_cond_t data_cond; pthread_cond_t done_cond; - my_bool data_avail; + pthread_t data_avail; my_bool cancelled; const char *from; size_t from_len; @@ -197,9 +198,13 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len) threads = comp_ctxt->threads; nthreads = comp_ctxt->nthreads; + const pthread_t self = pthread_self(); + ptr = (const char *) buf; while (len > 0) { - uint max_thread; + bool wait = nthreads == 1; +retry: + bool submitted = false; /* Send data to worker threads for compression */ for (i = 0; i < nthreads; i++) { @@ -208,16 +213,33 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len) thd = threads + i; pthread_mutex_lock(&thd->data_mutex); + if (thd->data_avail == pthread_t(~0UL)) { + } else if (!wait) { +skip: + pthread_mutex_unlock(&thd->data_mutex); + continue; + } else { + for (;;) { + pthread_cond_wait(&thd->avail_cond, + &thd->data_mutex); + if (thd->data_avail + == pthread_t(~0UL)) { + break; + } + goto skip; + } + } chunk_len = (len > COMPRESS_CHUNK_SIZE) ? COMPRESS_CHUNK_SIZE : len; thd->from = ptr; thd->from_len = chunk_len; - thd->data_avail = TRUE; + thd->data_avail = self; pthread_cond_signal(&thd->data_cond); pthread_mutex_unlock(&thd->data_mutex); + submitted = true; len -= chunk_len; if (len == 0) { break; @@ -225,13 +247,20 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len) ptr += chunk_len; } - max_thread = (i < nthreads) ? i : nthreads - 1; + if (!submitted) { + wait = true; + goto retry; + } - /* Reap and stream the compressed data */ - for (i = 0; i <= max_thread; i++) { + for (i = 0; i < nthreads; i++) { thd = threads + i; pthread_mutex_lock(&thd->data_mutex); + if (thd->data_avail != self) { + pthread_mutex_unlock(&thd->data_mutex); + continue; + } + while (!thd->to_len) { pthread_cond_wait(&thd->done_cond, &thd->data_mutex); @@ -249,6 +278,8 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len) } thd->to_len = 0; + thd->data_avail = pthread_t(~0UL); + pthread_cond_signal(&thd->avail_cond); pthread_mutex_unlock(&thd->data_mutex); if (fail) { @@ -336,6 +367,7 @@ destroy_worker_thread(comp_thread_ctxt_t *thd) pthread_join(thd->id, NULL); + pthread_cond_destroy(&thd->avail_cond); pthread_cond_destroy(&thd->data_cond); pthread_cond_destroy(&thd->done_cond); pthread_mutex_destroy(&thd->data_mutex); @@ -363,11 +395,14 @@ create_worker_threads(uint n) /* Initialize and data mutex and condition var */ if (pthread_mutex_init(&thd->data_mutex, NULL) || + pthread_cond_init(&thd->avail_cond, NULL) || pthread_cond_init(&thd->data_cond, NULL) || pthread_cond_init(&thd->done_cond, NULL)) { goto err; } + thd->data_avail = pthread_t(~0UL); + if (pthread_create(&thd->id, NULL, compress_worker_thread_func, thd)) { msg("compress: pthread_create() failed: " @@ -409,13 +444,13 @@ compress_worker_thread_func(void *arg) pthread_mutex_lock(&thd->data_mutex); while (1) { - while (!thd->data_avail && !thd->cancelled) { + while (!thd->cancelled + && (thd->to_len || thd->data_avail == pthread_t(~0UL))) { pthread_cond_wait(&thd->data_cond, &thd->data_mutex); } if (thd->cancelled) break; - thd->data_avail = FALSE; thd->to_len = qlz_compress(thd->from, thd->to, thd->from_len, &thd->state); -- cgit v1.2.1 From fd0cd4801a00c61adb5ab6cbefcf360467a02f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 22 Aug 2022 12:32:47 +0300 Subject: MDEV-13013 fixup: Adjust a test --- .../suite/innodb_zip/r/wl6347_comp_indx_stat.result | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/innodb_zip/r/wl6347_comp_indx_stat.result b/mysql-test/suite/innodb_zip/r/wl6347_comp_indx_stat.result index bc766135e56..c48bc32d596 100644 --- a/mysql-test/suite/innodb_zip/r/wl6347_comp_indx_stat.result +++ b/mysql-test/suite/innodb_zip/r/wl6347_comp_indx_stat.result @@ -1022,7 +1022,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 122880 +The size of the tab5.ibd file: 106496 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data @@ -1329,7 +1329,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 245760 +The size of the tab5.ibd file: 212992 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data @@ -2633,7 +2633,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 122880 +The size of the tab5.ibd file: 106496 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data @@ -2942,7 +2942,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 245760 +The size of the tab5.ibd file: 212992 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data @@ -4147,7 +4147,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 122880 +The size of the tab5.ibd file: 106496 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data @@ -4435,7 +4435,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 245760 +The size of the tab5.ibd file: 212992 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data @@ -5692,7 +5692,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 122880 +The size of the tab5.ibd file: 106496 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data @@ -5999,7 +5999,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 245760 +The size of the tab5.ibd file: 212992 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data @@ -7282,7 +7282,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 122880 +The size of the tab5.ibd file: 106496 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data @@ -7589,7 +7589,7 @@ AND compress_ops BETWEEN @inl_val AND 1000 AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 245760 +The size of the tab5.ibd file: 212992 # for determintic resons simple data should be inserted. # insert some 100 records # Load the data -- cgit v1.2.1 From 6005f3c548d312f48b575961889194a0a4767ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 22 Aug 2022 12:33:46 +0300 Subject: MDEV-25257 follow-up: Fix a test Ever since commit 09177eadc39ae1e777ad473970456cb9dd9c3993 the test innodb.row_format_redundant cannot work when the data file was created with innodb_checksum_algorithm=full_crc32. Backport of 10.5 commit a9d0bb12e68a11c119a3534f354c7a7ef13dd5b5 --- mysql-test/suite/innodb/t/row_format_redundant.opt | 1 + 1 file changed, 1 insertion(+) create mode 100644 mysql-test/suite/innodb/t/row_format_redundant.opt diff --git a/mysql-test/suite/innodb/t/row_format_redundant.opt b/mysql-test/suite/innodb/t/row_format_redundant.opt new file mode 100644 index 00000000000..c44c611ed60 --- /dev/null +++ b/mysql-test/suite/innodb/t/row_format_redundant.opt @@ -0,0 +1 @@ +--innodb-checksum-algorithm=crc32 -- cgit v1.2.1