From 1a6c130c4f157434e2272bacb680efa89eb4955e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 12 Sep 2021 15:23:34 +0200 Subject: [PATCH 01/10] perfschema: use correct type for left shifts set_item() uses 1UL << bit, so is_set_item() must do the same. This fixes sporadic perfschema.show_aggregate failures (sporadic, because `bit` is the thread id, so depending on how many tests were run before perfschema.show_aggregate it can be above or below 32). --- storage/perfschema/pfs_engine_table.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/perfschema/pfs_engine_table.cc b/storage/perfschema/pfs_engine_table.cc index 22ed3132c6b..c0b91cbb3b0 100644 --- a/storage/perfschema/pfs_engine_table.cc +++ b/storage/perfschema/pfs_engine_table.cc @@ -226,7 +226,7 @@ bool PFS_table_context::is_item_set(ulong n) { ulong word= n / m_word_size; ulong bit= n % m_word_size; - return (m_map[word] & (1 << bit)); + return (m_map[word] & (1UL << bit)); } From 07abcb5045f9914d023ca630f7a35f4fcbf18a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sun, 5 Sep 2021 20:22:45 -0700 Subject: [PATCH 02/10] Deb: Fix Gitlab-CI/Salsa-CI builds failures The debian/salsa-ci.yml used to work also on upstream MariaDB.org branches, but has recently regressed and several jobs stopped working. These fixes are necessary to get it working again. * Partially revert 8642f592 that never worked, as MariaDB 10.2 does not have a mysql.global table nor a mariadb.sys user. Those features weren't introduced until MariaDB 10.4. * Partially revert 0268b871 as we don't want ColumnStore as part of the native Debian build. It should build only when the build is triggered via autobake-deb.sh (MariaDB.org builds). * Adjust salsa-ci.yml to cope with various Stretch to Sid upgrade issues and remove the legacy mariadb-connector-c job completely as that package hasn't been around for years anymore. * Extend Lintian overrides to be otherwise Lintian clean --- debian/autobake-deb.sh | 10 ++++++---- debian/rules | 17 +++++++++++++++-- debian/salsa-ci.yml | 28 +++++----------------------- debian/source/lintian-overrides | 6 ++++++ 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index c09ebb1d0cd..80bcabe7412 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -22,12 +22,14 @@ if [[ $TRAVIS ]] || [[ $GITLAB_CI ]] then # On both Travis and Gitlab the output log must stay under 4MB so make the # build less verbose - # MCOL-4149: ColumnStore builds are so slow and big that they must be skipped on - # both Travis-CI and Gitlab-CI - sed -e 's|$(CMAKEFLAGS)|$(CMAKEFLAGS) -DPLUGIN_COLUMNSTORE=NO|' \ - -i debian/rules + sed '/Add support for verbose builds/,/^$/d' -i debian/rules elif [ -d storage/columnstore/columnstore/debian ] then + # ColumnStore is explicitly disabled in the native Debian build, so allow it + # now when build is triggered by autobake-deb.sh (MariaDB.org) and when the + # build is not running on Travis or Gitlab-CI + sed '/-DPLUGIN_COLUMNSTORE=NO/d' -i debian/rules + # Take the files and part of control from MCS directory cp -v storage/columnstore/columnstore/debian/mariadb-plugin-columnstore.* debian/ echo >> debian/control cat storage/columnstore/columnstore/debian/control >> debian/control diff --git a/debian/rules b/debian/rules index 650f807e0ec..df0ee3ee7b6 100755 --- a/debian/rules +++ b/debian/rules @@ -38,6 +38,16 @@ else NUMJOBS = 1 endif +# RocksDB cannot build on 32-bit platforms +ifeq (32,$(DEB_HOST_ARCH_BITS)) + CMAKEFLAGS += -DPLUGIN_ROCKSDB=NO +endif + +# ColumnStore can build only on amd64 and arm64 +ifneq (,$(filter $(DEB_HOST_ARCH_CPU),amd64 arm64)) + CMAKEFLAGS += -DPLUGIN_COLUMNSTORE=NO +endif + ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) ifneq (,$(filter $(DEB_HOST_ARCH_CPU),alpha amd64 arm arm64 i386 ia64 m68k mips64el mipsel powerpc ppc64 ppc64el riscv64 s390x sh4 sparc64)) CMAKEFLAGS += -DSTACK_DIRECTION=-1 @@ -72,13 +82,15 @@ endif echo "server:Version=$(DEB_VERSION)" >> debian/substvars - # RocksDB and Column Store cannot build on 32-bit platforms + # Don't build ColumnStore as part of the native build as it does not meet the + # quality standards in Debian. Also building it requires an extra 4 GB of disk + # space which makes native Debian builds fail as the total disk space needed + # for MariaDB becomes over 10 GB. Only build CS via autobake-deb.sh. PATH=$${MYSQL_BUILD_PATH:-"/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin"} \ NO_UPDATE_BUILD_VERSION=1 \ dh_auto_configure --builddirectory=$(BUILDDIR) -- \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ $(CMAKEFLAGS) \ - $(if $(findstring $(DEB_HOST_ARCH_BITS),32),-DPLUGIN_ROCKSDB=NO -DPLUGIN_COLUMNSTORE=NO) \ $(if $(filter $(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)),,-DIMPORT_EXECUTABLES=$(CURDIR)/builddir-native/import_executables.cmake) \ -DCOMPILATION_COMMENT="mariadb.org binary distribution" \ -DMYSQL_SERVER_SUFFIX="-$(DEB_VERSION_REVISION)" \ @@ -88,6 +100,7 @@ endif -DPLUGIN_TOKUDB=NO \ -DPLUGIN_CASSANDRA=NO \ -DPLUGIN_AWS_KEY_MANAGEMENT=NO \ + -DPLUGIN_COLUMNSTORE=NO \ -DDEB=$(DEB_VENDOR) # This is needed, otherwise 'make test' will run before binaries have been built diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml index 45847909192..98bcab60b8f 100644 --- a/debian/salsa-ci.yml +++ b/debian/salsa-ci.yml @@ -278,6 +278,8 @@ mariadb-10.1 Stretch to mariadb-10.5 upgrade: - apt-get install -y 'default-mysql*' 'mariadb-*' 'libmariadbd*' 'libmariadbclient*' # Verify installation of MariaDB from Stretch - *test-verify-initial + # Remove manpages 4.10 that conflicts with manpages-dev 5.10 on console_ioctl.4.gz + - apt-get remove -y manpages - *test-enable-sid-repos - *test-install - service mysql status @@ -486,28 +488,8 @@ default-libmysqlclient-dev Stretch upgrade: - *test-prepare-container - apt-get install -y pkg-config default-libmysqlclient-dev - pkg-config --list-all - - *test-enable-sid-repos - - *test-install-all-libs - - *test-verify-libs - except: - variables: - - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ - -mariadb-connector-c Stretch upgrade: - stage: upgrade from Buster/Stretch - needs: - - job: build - artifacts: true - image: debian:stretch - artifacts: - when: always - name: "$CI_BUILD_NAME" - paths: - - ${WORKING_DIR}/debug - script: - - *test-prepare-container - - apt-get install -y pkg-config libmariadb2 libmariadb-dev libmariadb-dev-compat - - pkg-config --list-all + # Remove manpages 4.10 that conflicts with manpages-dev 5.10 on console_ioctl.4.gz + - apt-get remove -y manpages - *test-enable-sid-repos - *test-install-all-libs - *test-verify-libs @@ -751,7 +733,7 @@ mariadb.org-10.2 to mariadb-10.5 upgrade: # prepending with --defaults-file=/etc/mysql/debian.cnf is needed in upstream 5.5–10.3 - mysql --defaults-file=/etc/mysql/debian.cnf --skip-column-names -e "SELECT @@version, @@version_comment" - echo 'SHOW DATABASES;' | mysql --defaults-file=/etc/mysql/debian.cnf - - mysql --defaults-file=/etc/mysql/debian.cnf -e "SELECT * FROM mysql.global_priv; SHOW CREATE USER root@localhost; SHOW CREATE USER 'mariadb.sys'@localhost" + - mysql --defaults-file=/etc/mysql/debian.cnf -e "SELECT * FROM mysql.user; SHOW CREATE USER root@localhost" - mysql --defaults-file=/etc/mysql/debian.cnf -e "SELECT * FROM mysql.plugin; SHOW PLUGINS" - *test-install - service mysql status diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides index e2741658428..593e88609bf 100644 --- a/debian/source/lintian-overrides +++ b/debian/source/lintian-overrides @@ -22,3 +22,9 @@ version-substvar-for-external-package mariadb-client-10.5 -> mysql-client-core-8 version-substvar-for-external-package libmariadbd-dev -> libmariadbclient-dev # ColumnStore not used in Debian, safe to ignore. Reported upstream in https://jira.mariadb.org/browse/MDEV-24124 source-is-missing storage/columnstore/columnstore/utils/jemalloc/libjemalloc.so.2 +# Must be fixed upstream +source-is-missing storage/mroonga/vendor/groonga/examples/dictionary/html/js/jquery-ui-1.8.18.custom.js line 58 is 273 characters long (>256) +# Intentional control relationships +version-substvar-for-external-package Replaces (line 216) ${source:Version} libmariadbd-dev -> libmariadbclient-dev +version-substvar-for-external-package Replaces (line 66) ${source:Version} libmariadb-dev -> libmysqlclient-dev +version-substvar-for-external-package Replaces (line 66) ${source:Version} libmariadb-dev -> libmysqld-dev From 5527fc58617d5e1f39e035ff7a10e6b7d739e742 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Tue, 7 Sep 2021 15:04:39 +0200 Subject: [PATCH 03/10] MDEV-21613 Failed to open table mysql.wsrep_streaming_log for writing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix sporadic failure for MTR test galera_sr.GCF-1018B. The test sometimes fails due to an error that is logged to the error log unnecessarily. A deterministic test case (included in this patch) shows that the error is loggen when a transaction is BF aborted right before it opens the streaming log table to perform fragment removal. When that happens, the attempt to open the table fails and consequently an error is logged. There is no need to log this error, as an ER_LOCK_DEADLOCK error is returned to the client. Reviewed-by: Jan Lindström --- .../suite/galera_sr/r/MDEV-21613.result | 20 +++++++++++ mysql-test/suite/galera_sr/t/MDEV-21613.cnf | 7 ++++ mysql-test/suite/galera_sr/t/MDEV-21613.test | 36 +++++++++++++++++++ sql/wsrep_client_service.cc | 1 + sql/wsrep_schema.cc | 17 ++++----- 5 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 mysql-test/suite/galera_sr/r/MDEV-21613.result create mode 100644 mysql-test/suite/galera_sr/t/MDEV-21613.cnf create mode 100644 mysql-test/suite/galera_sr/t/MDEV-21613.test diff --git a/mysql-test/suite/galera_sr/r/MDEV-21613.result b/mysql-test/suite/galera_sr/r/MDEV-21613.result new file mode 100644 index 00000000000..67af2d49331 --- /dev/null +++ b/mysql-test/suite/galera_sr/r/MDEV-21613.result @@ -0,0 +1,20 @@ +connection node_2; +connection node_1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +connection node_1; +SET SESSION wsrep_trx_fragment_size = 1; +SET DEBUG_SYNC = "wsrep_before_fragment_removal SIGNAL fragment_removal_reached WAIT_FOR fragment_removal_continue"; +START TRANSACTION; +INSERT INTO t1 VALUES(1), (2); +COMMIT; +connect node_ctrl, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_ctrl; +SET DEBUG_SYNC = "now WAIT_FOR fragment_removal_reached"; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; +TRUNCATE TABLE t1; +connection node_1; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +connection node_ctrl; +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; diff --git a/mysql-test/suite/galera_sr/t/MDEV-21613.cnf b/mysql-test/suite/galera_sr/t/MDEV-21613.cnf new file mode 100644 index 00000000000..d8e3488f044 --- /dev/null +++ b/mysql-test/suite/galera_sr/t/MDEV-21613.cnf @@ -0,0 +1,7 @@ +# Set thread-handling as a workaround to avoid MDEV-26528. +# The file can be removed once fixed. + +!include ../galera_2nodes.cnf + +[mysqld.1] +thread-handling=pool-of-threads diff --git a/mysql-test/suite/galera_sr/t/MDEV-21613.test b/mysql-test/suite/galera_sr/t/MDEV-21613.test new file mode 100644 index 00000000000..8a1fea1b7f5 --- /dev/null +++ b/mysql-test/suite/galera_sr/t/MDEV-21613.test @@ -0,0 +1,36 @@ +# +# MDEV-21613 - galera_sr.GCF-1018B MTR failed: +# Failed to open table mysql.wsrep_streaming_log for writing +# +# A BF abort right before fragment removal caused this error to +# be logged to the error log. +# +--source include/galera_cluster.inc +--source include/have_debug_sync.inc + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); + +--connection node_1 +SET SESSION wsrep_trx_fragment_size = 1; +SET DEBUG_SYNC = "wsrep_before_fragment_removal SIGNAL fragment_removal_reached WAIT_FOR fragment_removal_continue"; +START TRANSACTION; +INSERT INTO t1 VALUES(1), (2); +--send COMMIT + +--connect node_ctrl, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_ctrl +SET DEBUG_SYNC = "now WAIT_FOR fragment_removal_reached"; + + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +TRUNCATE TABLE t1; + + +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +--connection node_ctrl +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; diff --git a/sql/wsrep_client_service.cc b/sql/wsrep_client_service.cc index f045e5d271a..dd993097135 100644 --- a/sql/wsrep_client_service.cc +++ b/sql/wsrep_client_service.cc @@ -193,6 +193,7 @@ cleanup: int Wsrep_client_service::remove_fragments() { DBUG_ENTER("Wsrep_client_service::remove_fragments"); + DEBUG_SYNC(m_thd, "wsrep_before_fragment_removal"); if (wsrep_schema->remove_fragments(m_thd, Wsrep_server_state::instance().id(), m_thd->wsrep_trx().id(), diff --git a/sql/wsrep_schema.cc b/sql/wsrep_schema.cc index 5ee6468e9c1..06f0f7840ab 100644 --- a/sql/wsrep_schema.cc +++ b/sql/wsrep_schema.cc @@ -251,13 +251,7 @@ static int open_table(THD* thd, thd->lex->query_tables_own_last= 0; if (!open_n_lock_single_table(thd, &tables, tables.lock_type, flags)) { - if (thd->is_error()) { - WSREP_WARN("Can't lock table %s.%s : %d (%s)", - schema_name->str, table_name->str, - thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message()); - } close_thread_tables(thd); - my_error(ER_NO_SUCH_TABLE, MYF(0), schema_name->str, table_name->str); DBUG_RETURN(1); } @@ -273,8 +267,15 @@ static int open_for_write(THD* thd, const char* table_name, TABLE** table) { LEX_CSTRING table_str= { table_name, strlen(table_name) }; if (Wsrep_schema_impl::open_table(thd, &schema_str, &table_str, TL_WRITE, table)) { - WSREP_ERROR("Failed to open table %s.%s for writing", - schema_str.str, table_name); + // No need to log an error if the query was bf aborted, + // thd client will get ER_LOCK_DEADLOCK in the end. + const bool interrupted= thd->killed || + (thd->is_error() && + (thd->get_stmt_da()->sql_errno() == ER_QUERY_INTERRUPTED)); + if (!interrupted) { + WSREP_ERROR("Failed to open table %s.%s for writing", + schema_str.str, table_name); + } return 1; } empty_record(*table); From adaf0dde7fb205818f2ff51139a3f3114bacc527 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 14 Sep 2021 19:07:49 +1000 Subject: [PATCH 04/10] MDEV-26601: mysys - O_TMPFILE ^ O_CREAT Thanks to Fabian Vogt for noticing the mutual exclusions of these open flags on tmpfs caused by mariadb opening it incorrectly. As such we clear the O_CREAT flag while opening it as O_TMPFILE. --- mysys/mf_tempfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c index 51a3efa05ad..0f1c6d6b1bc 100644 --- a/mysys/mf_tempfile.c +++ b/mysys/mf_tempfile.c @@ -121,7 +121,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix, /* explictly don't use O_EXCL here has it has a different meaning with O_TMPFILE */ - if ((file= open(dir, mode | O_TMPFILE | O_CLOEXEC, + if ((file= open(dir, (mode & ~O_CREAT) | O_TMPFILE | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) >= 0) { my_snprintf(to, FN_REFLEN, "%s/#sql/fd=%d", dir, file); From 689b8d060ac890dcf1071b34a68234b30005e9a1 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 13 Sep 2021 18:51:40 +0300 Subject: [PATCH 05/10] MDEV-23519 Protocol packet - "Original Name" info is showing alias name, instead of original name of the column When doing refactoring of temporary table field creation a mistake was done when copying the column name when creating internal temporary tables. For internal temporary tables we should use the original field name, not the item name (= alias). --- client/mysql.cc | 5 +++-- mysql-test/main/alias.result | 19 +++++++++++++++++++ mysql-test/main/alias.test | 15 +++++++++++++++ sql/sql_select.cc | 20 +++++++++++++++----- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index b7a2d6c5e72..7b3f34b755f 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3503,6 +3503,7 @@ print_field_types(MYSQL_RES *result) while ((field = mysql_fetch_field(result))) { tee_fprintf(PAGER, "Field %3u: `%s`\n" + "Org_field: `%s`\n" "Catalog: `%s`\n" "Database: `%s`\n" "Table: `%s`\n" @@ -3514,8 +3515,8 @@ print_field_types(MYSQL_RES *result) "Decimals: %u\n" "Flags: %s\n\n", ++i, - field->name, field->catalog, field->db, field->table, - field->org_table, fieldtype2str(field->type), + field->name, field->org_name, field->catalog, field->db, + field->table, field->org_table, fieldtype2str(field->type), get_charset_name(field->charsetnr), field->charsetnr, field->length, field->max_length, field->decimals, fieldflags2str(field->flags)); diff --git a/mysql-test/main/alias.result b/mysql-test/main/alias.result index defd44f2548..d8bb211539f 100644 --- a/mysql-test/main/alias.result +++ b/mysql-test/main/alias.result @@ -218,3 +218,22 @@ DELETE ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 't1 WHERE 1=1' at line 1 connection default; disconnect c1; +# +# MDEV-23519 +# +create or replace table t1 (a int); +create or replace table t2 (b int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +select t1.a as a1 from t1 as t1,t2 order by t2.b,t1.a; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 a a1 3 11 1 Y 32768 0 63 +a1 +1 +2 +1 +2 +drop table t1,t2; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/alias.test b/mysql-test/main/alias.test index c02ebe2f5ff..f0c4e13abfd 100644 --- a/mysql-test/main/alias.test +++ b/mysql-test/main/alias.test @@ -226,3 +226,18 @@ connection c1; DELETE ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ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ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZROM t1 WHERE 1=1; connection default; disconnect c1; +--echo # +--echo # MDEV-23519 +--echo # +create or replace table t1 (a int); +create or replace table t2 (b int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +--enable_metadata +select t1.a as a1 from t1 as t1,t2 order by t2.b,t1.a; +--disable_metadata +drop table t1,t2; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 77832a657ff..1eb0a492ecd 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17972,7 +17972,14 @@ Field *Item::create_field_for_schema(THD *thd, TABLE *table) /** Create a temporary field for Item_field (or its descendant), either direct or referenced by an Item_ref. + + param->modify_item is set when we create a field for an internal temporary + table. In this case we have to ensure the new field name is identical to + the original field name as the field will info will be sent to the client. + In other cases, the field name is set from orig_item or name if org_item is + not set. */ + Field * Item_field::create_tmp_field_from_item_field(TABLE *new_table, Item_ref *orig_item, @@ -17980,6 +17987,10 @@ Item_field::create_tmp_field_from_item_field(TABLE *new_table, { DBUG_ASSERT(!is_result_field()); Field *result; + LEX_CSTRING *new_name= (orig_item ? &orig_item->name : + !param->modify_item() ? &name : + &field->field_name); + /* If item have to be able to store NULLs but underlaid field can't do it, create_tmp_field_from_field() can't be used for tmp field creation. @@ -17998,26 +18009,25 @@ Item_field::create_tmp_field_from_item_field(TABLE *new_table, Record_addr rec(orig_item ? orig_item->maybe_null : maybe_null); const Type_handler *handler= type_handler()-> type_handler_for_tmp_table(this); - result= handler->make_and_init_table_field(orig_item ? &orig_item->name : &name, + result= handler->make_and_init_table_field(new_name, rec, *this, new_table); } else if (param->table_cant_handle_bit_fields() && field->type() == MYSQL_TYPE_BIT) { const Type_handler *handler= type_handler_long_or_longlong(); - result= handler->make_and_init_table_field(&name, + result= handler->make_and_init_table_field(new_name, Record_addr(maybe_null), *this, new_table); } else { - LEX_CSTRING *tmp= orig_item ? &orig_item->name : &name; bool tmp_maybe_null= param->modify_item() ? maybe_null : field->maybe_null(); result= field->create_tmp_field(new_table->in_use->mem_root, new_table, tmp_maybe_null); - if (result) - result->field_name= *tmp; + if (result && ! param->modify_item()) + result->field_name= *new_name; } if (result && param->modify_item()) result_field= result; From 6be0ddae5edb080219226525c4423300f063081d Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 15 Sep 2021 19:16:37 +0300 Subject: [PATCH 06/10] Fixed compiler warnings in CONNECT --- storage/connect/json.cpp | 5 ++++- storage/connect/tabrest.h | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index b9f9492320b..17c6ba9791a 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -1051,7 +1051,7 @@ int JOBJECT::GetSize(bool b) { for (PJPR jpp = First; jpp; jpp = jpp->Next) // If b return only non null pairs - if (!b || jpp->Val && !jpp->Val->IsNull()) + if (!b || (jpp->Val && !jpp->Val->IsNull())) n++; return n; @@ -1581,10 +1581,12 @@ PVAL JVALUE::GetValue(PGLOBAL g) PVAL valp = NULL; if (DataType != TYPE_JSON) + { if (DataType == TYPE_STRG) valp = AllocateValue(g, Strp, DataType, Nd); else valp = AllocateValue(g, &LLn, DataType, Nd); + } return valp; } // end of GetValue @@ -1755,6 +1757,7 @@ void JVALUE::SetValue(PGLOBAL g, PVAL valp) case TYPE_TINY: B = valp->GetTinyValue() != 0; DataType = TYPE_BOOL; + break; case TYPE_INT: N = valp->GetIntValue(); DataType = TYPE_INTG; diff --git a/storage/connect/tabrest.h b/storage/connect/tabrest.h index 9066a89b306..901d9102e95 100644 --- a/storage/connect/tabrest.h +++ b/storage/connect/tabrest.h @@ -6,9 +6,7 @@ #pragma once #if defined(_WIN32) -static PCSZ slash = "\\"; #else // !_WIN32 -static PCSZ slash = "/"; #define stricmp strcasecmp #endif // !_WIN32 From f03fee06b0f4bdb1d754d987db3375cade02445e Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 15 Sep 2021 19:18:11 +0300 Subject: [PATCH 07/10] Improve error messages from Aria - Error on commit now returns HA_ERR_COMMIT_ERROR instead of HA_ERR_INTERNAL_ERROR - If checkpoint fails, it will now print out where it failed. --- include/handler_ername.h | 1 + include/my_base.h | 3 ++- include/my_handler_errors.h | 3 ++- sql/handler.cc | 3 +++ storage/maria/ha_maria.cc | 9 +++++---- storage/maria/ma_checkpoint.c | 20 +++++++++++++++++++- 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/include/handler_ername.h b/include/handler_ername.h index fe55062e6fb..c9d09717a14 100644 --- a/include/handler_ername.h +++ b/include/handler_ername.h @@ -79,3 +79,4 @@ { "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" }, { "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" }, { "HA_ERR_INCOMPATIBLE_DEFINITION", HA_ERR_INCOMPATIBLE_DEFINITION, "" }, +{ "HA_ERR_COMMIT_ERROR", HA_ERR_COMMIT_ERROR, "" }, diff --git a/include/my_base.h b/include/my_base.h index 6a9a14fa91e..b4e7c1c7707 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -525,7 +525,8 @@ enum ha_base_keytype { #define HA_ERR_TABLESPACE_MISSING 194 /* Missing Tablespace */ #define HA_ERR_SEQUENCE_INVALID_DATA 195 #define HA_ERR_SEQUENCE_RUN_OUT 196 -#define HA_ERR_LAST 196 /* Copy of last error nr * */ +#define HA_ERR_COMMIT_ERROR 197 +#define HA_ERR_LAST 197 /* Copy of last error nr * */ /* Number of different errors */ #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) diff --git a/include/my_handler_errors.h b/include/my_handler_errors.h index faf7b9f459e..69b1566557d 100644 --- a/include/my_handler_errors.h +++ b/include/my_handler_errors.h @@ -107,7 +107,8 @@ static const char *handler_error_messages[]= "Foreign key cascade delete/update exceeds max depth", "Tablespace is missing for a table", "Sequence has been run out", - "Sequence values are conflicting" + "Sequence values are conflicting", + "Error during commit" }; #endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */ diff --git a/sql/handler.cc b/sql/handler.cc index 9cf270f9cf3..d49a695f197 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4217,6 +4217,9 @@ void handler::print_error(int error, myf errflag) case HA_ERR_TABLE_IN_FK_CHECK: textno= ER_TABLE_IN_FK_CHECK; break; + case HA_ERR_COMMIT_ERROR: + textno= ER_ERROR_DURING_COMMIT; + break; default: { /* The error was "unknown" to this function. diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index b93039190b0..79bebc90837 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2904,7 +2904,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) if (file->autocommit) { if (ma_commit(trn)) - result= HA_ERR_INTERNAL_ERROR; + result= HA_ERR_COMMIT_ERROR; thd_set_ha_data(thd, maria_hton, 0); } } @@ -3043,7 +3043,7 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) error= 0; if (unlikely(ma_commit(trn))) - error= 1; + error= HA_ERR_COMMIT_ERROR; if (!new_trn) { reset_thd_trn(thd, used_tables); @@ -3480,7 +3480,7 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)), THD *thd, bool all) { TRN *trn= THD_TRN; - int res; + int res= 0; MARIA_HA *used_instances; DBUG_ENTER("maria_commit"); @@ -3499,7 +3499,8 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)), trnman_reset_locked_tables(trn, 0); trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED); trn->used_instances= 0; - res= ma_commit(trn); + if (ma_commit(trn)) + res= HA_ERR_COMMIT_ERROR; reset_thd_trn(thd, used_instances); thd_set_ha_data(thd, maria_hton, 0); DBUG_RETURN(res); diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c index 3af808478e4..2741f54d7d7 100644 --- a/storage/maria/ma_checkpoint.c +++ b/storage/maria/ma_checkpoint.c @@ -153,8 +153,10 @@ end: static int really_execute_checkpoint(void) { uint i, error= 0; + int error_errno= 0; /** @brief checkpoint_start_log_horizon will be stored there */ char *ptr; + const char *error_place= 0; LEX_STRING record_pieces[4]; /**< only malloc-ed pieces */ LSN min_page_rec_lsn, min_trn_rec_lsn, min_first_undo_lsn; TRANSLOG_ADDRESS checkpoint_start_log_horizon; @@ -191,13 +193,19 @@ static int really_execute_checkpoint(void) &record_pieces[1], &min_trn_rec_lsn, &min_first_undo_lsn))) + { + error_place= "trnman_collect_transaction"; goto err; + } /* STEP 3: fetch information about table files */ if (unlikely(collect_tables(&record_pieces[2], checkpoint_start_log_horizon))) + { + error_place= "collect_tables"; goto err; + } /* STEP 4: fetch information about dirty pages */ @@ -211,7 +219,10 @@ static int really_execute_checkpoint(void) if (unlikely(pagecache_collect_changed_blocks_with_lsn(maria_pagecache, &record_pieces[3], &min_page_rec_lsn))) + { + error_place= "collect_pages"; goto err; + } /* LAST STEP: now write the checkpoint log record */ @@ -240,7 +251,10 @@ static int really_execute_checkpoint(void) sizeof(log_array)/sizeof(log_array[0]), log_array, NULL, NULL) || translog_flush(lsn))) + { + error_place= "translog_write_record"; goto err; + } translog_lock(); /* This cannot be done as a inwrite_rec_hook of LOGREC_CHECKPOINT, because @@ -251,6 +265,8 @@ static int really_execute_checkpoint(void) max_trid_in_control_file, recovery_failures))) { + error_place= "ma_control_file_write"; + error_errno= my_errno; translog_unlock(); goto err; } @@ -287,7 +303,9 @@ static int really_execute_checkpoint(void) err: error= 1; - ma_message_no_user(0, "checkpoint failed"); + my_printf_error(HA_ERR_GENERIC, "Aria engine: checkpoint failed at %s with " + "error %d", MYF(ME_ERROR_LOG), + error_place, (error_errno ? error_errno : my_errno)); /* we were possibly not able to determine what pages to flush */ pages_to_flush_before_next_checkpoint= 0; From 0d47945b58c0f12ca35f4803af9bfa8cc498f5cc Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 15 Sep 2021 21:21:03 +0300 Subject: [PATCH 08/10] Fixed bug in aria_chk that overwrote sort_buffer_length This bug happens when one runs aria_chk on multiple tables. It does not affect REPAIR TABLE. aria_chk tries to optimize the sort buffer size to minimize memory usage when used with small tables. The bug was that the adjusted value was used as a base for the next table, which could cause problems. --- include/myisamchk.h | 2 +- storage/maria/aria_chk.c | 4 ++-- storage/maria/ha_maria.cc | 8 ++++---- storage/maria/ma_check.c | 4 +++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/myisamchk.h b/include/myisamchk.h index f9a55ba467f..c494c672ec7 100644 --- a/include/myisamchk.h +++ b/include/myisamchk.h @@ -87,7 +87,7 @@ typedef struct st_handler_check_param /* Following is used to check if rows are visible */ ulonglong max_trid, max_found_trid; ulonglong not_visible_rows_found; - ulonglong sort_buffer_length; + ulonglong sort_buffer_length, orig_sort_buffer_length; ulonglong use_buffers; /* Used as param to getopt() */ size_t read_buffer_length, write_buffer_length, sort_key_blocks; time_t backup_time; /* To sign backup files */ diff --git a/storage/maria/aria_chk.c b/storage/maria/aria_chk.c index 7463adf34c1..30bb2cf0d96 100644 --- a/storage/maria/aria_chk.c +++ b/storage/maria/aria_chk.c @@ -434,8 +434,8 @@ static struct my_option my_long_options[] = ~0UL, (long) MALLOC_OVERHEAD, (long) 1L, 0}, { "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "Size of sort buffer. Used by --recover", - &check_param.sort_buffer_length, - &check_param.sort_buffer_length, 0, GET_ULL, REQUIRED_ARG, + &check_param.orig_sort_buffer_length, + &check_param.orig_sort_buffer_length, 0, GET_ULL, REQUIRED_ARG, SORT_BUFFER_INIT, MIN_SORT_BUFFER, SIZE_T_MAX, MALLOC_OVERHEAD, 1L, 0}, { "sort_key_blocks", OPT_SORT_KEY_BLOCKS, "Internal buffer for sorting keys; Don't touch :)", diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 79bebc90837..80d3d669703 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1481,7 +1481,7 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) param->testflag= ((check_opt->flags & ~(T_EXTEND)) | T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM | (check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT)); - param->sort_buffer_length= THDVAR(thd, sort_buffer_size); + param->orig_sort_buffer_length= THDVAR(thd, sort_buffer_size); param->backup_time= check_opt->start_time; start_records= file->state->records; old_proc_info= thd_proc_info(thd, "Checking table"); @@ -1552,7 +1552,7 @@ int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt) param->thd= thd; param->op_name= "zerofill"; param->testflag= check_opt->flags | T_SILENT | T_ZEROFILL; - param->sort_buffer_length= THDVAR(thd, sort_buffer_size); + param->orig_sort_buffer_length= THDVAR(thd, sort_buffer_size); param->db_name= table->s->db.str; param->table_name= table->alias.c_ptr(); @@ -1588,7 +1588,7 @@ int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt) param->op_name= "optimize"; param->testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE | T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX); - param->sort_buffer_length= THDVAR(thd, sort_buffer_size); + param->orig_sort_buffer_length= THDVAR(thd, sort_buffer_size); thd_progress_init(thd, 1); if ((error= repair(thd, param, 1)) && param->retry_repair) { @@ -2056,7 +2056,7 @@ int ha_maria::enable_indexes(uint mode) } param->myf_rw &= ~MY_WAIT_IF_FULL; - param->sort_buffer_length= THDVAR(thd,sort_buffer_size); + param->orig_sort_buffer_length= THDVAR(thd,sort_buffer_size); param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method); param->tmpdir= &mysql_tmpdir_list; if ((error= (repair(thd, param, 0) != HA_ADMIN_OK)) && param->retry_repair) diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 358d563b63a..a244a9326ab 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -114,7 +114,7 @@ void maria_chk_init(HA_CHECK *param) param->use_buffers= PAGE_BUFFER_INIT; param->read_buffer_length=READ_BUFFER_INIT; param->write_buffer_length=READ_BUFFER_INIT; - param->sort_buffer_length=SORT_BUFFER_INIT; + param->orig_sort_buffer_length=SORT_BUFFER_INIT; param->sort_key_blocks=BUFFERS_WHEN_SORTING; param->tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL; param->myf_rw=MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL); @@ -2483,6 +2483,8 @@ static int initialize_variables_for_repair(HA_CHECK *param, tmp= (size_t) MY_MIN(sort_info->filelength, (my_off_t) (SIZE_T_MAX/10/threads)); tmp= MY_MAX(tmp * 8 * threads, (size_t) 65536); /* Some margin */ + param->sort_buffer_length= MY_MIN(param->orig_sort_buffer_length, + tmp); set_if_smaller(param->sort_buffer_length, tmp); /* Protect against too big sort buffer length */ #if SIZEOF_SIZE_T >= 8 From 65cce297beea09afc8132efc91372aaee1c70f7c Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 16 Sep 2021 14:06:29 +0300 Subject: [PATCH 09/10] Updated rocksdb test result This was required as I added a new error code to my_base.h and rocksdb is adding it's own errors after the last official one Updated result file also for index_merge_rocksdb2. This is a big test and we have probably not before noticed that some optimizer changes caused a difference. --- .../r/corrupted_data_reads_debug.result | 10 +++---- .../rocksdb/r/index_merge_rocksdb2.result | 8 +++--- .../rocksdb/r/tbl_opt_data_index_dir.result | 26 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result b/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result index 47f7bb923ba..01fa9dac7fd 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result @@ -20,7 +20,7 @@ set @tmp1=@@rocksdb_verify_row_debug_checksums; set rocksdb_verify_row_debug_checksums=1; set session debug_dbug= "+d,myrocks_simulate_bad_row_read1"; select * from t1 where pk=1; -ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 203 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_row_read1"; set rocksdb_verify_row_debug_checksums=@tmp1; select * from t1 where pk=1; @@ -28,11 +28,11 @@ pk col1 1 1 set session debug_dbug= "+d,myrocks_simulate_bad_row_read2"; select * from t1 where pk=1; -ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 203 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_row_read2"; set session debug_dbug= "+d,myrocks_simulate_bad_row_read3"; select * from t1 where pk=1; -ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 203 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_row_read3"; insert into t1 values(4,'0123456789'); select * from t1; @@ -56,7 +56,7 @@ pk col1 ABCD 1 set session debug_dbug= "+d,myrocks_simulate_bad_pk_read1"; select * from t2; -ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 203 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_pk_read1"; drop table t2; create table t2 ( @@ -69,6 +69,6 @@ pk col1 ABCD 1 set session debug_dbug= "+d,myrocks_simulate_bad_pk_read1"; select * from t2; -ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 203 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_pk_read1"; drop table t2; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result index d96c40127a8..9de77014593 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result @@ -63,7 +63,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 ALL i1 NULL NULL NULL # Using where explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where +1 SIMPLE t0 ref i1,i2,i3 i3 4 const # Using where explain select * from t0 use index (i1,i2) where (key1 < 2 or key2 <3) and key3 = 50; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where @@ -121,11 +121,11 @@ id select_type table type possible_keys key key_len ref rows Extra explain select * from t0 where (key1 < 3 or key2 < 3) and (key3 < 70); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where +1 SIMPLE t0 range i1,i2,i3 i3 4 NULL # Using index condition; Using where explain select * from t0 where (key1 < 3 or key2 < 3) and (key3 < 1000); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where +1 SIMPLE t0 range i1,i2,i3 i3 4 NULL # Using index condition; Using where explain select * from t0 where ((key1 < 3 or key2 < 3) and (key2 <4 or key3 < 3)) or @@ -287,7 +287,7 @@ id select_type table type possible_keys key key_len ref rows Extra NULL UNION RESULT ALL NULL NULL NULL NULL NULL explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge i1,i2,i8 i1,i2 4,4 NULL 4 Using union(i1,i2); Using where +1 SIMPLE t1 range i1,i2,i8 i8 4 NULL 2 Using index condition; Using where create table t3 like t0; insert into t3 select * from t0; alter table t3 add key9 int not null, add index i9(key9); diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_data_index_dir.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_data_index_dir.result index 95dae68b4e6..90f163b7d4b 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_data_index_dir.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_data_index_dir.result @@ -1,16 +1,16 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb DATA DIRECTORY = '/foo/bar/data'; -ERROR HY000: Can't create table `test`.`t1` (errno: 198 "Unknown error 198") -show warnings; -Level Code Message -Error 1005 Can't create table `test`.`t1` (errno: 198 "Unknown error 198") -Warning 1296 Got error 198 'Specifying DATA DIRECTORY for an individual table is not supported.' from ROCKSDB -CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb INDEX DIRECTORY = '/foo/bar/index'; ERROR HY000: Can't create table `test`.`t1` (errno: 199 "Unknown error 199") show warnings; Level Code Message Error 1005 Can't create table `test`.`t1` (errno: 199 "Unknown error 199") -Warning 1296 Got error 199 'Specifying INDEX DIRECTORY for an individual table is not supported.' from ROCKSDB +Warning 1296 Got error 199 'Specifying DATA DIRECTORY for an individual table is not supported.' from ROCKSDB +CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb INDEX DIRECTORY = '/foo/bar/index'; +ERROR HY000: Can't create table `test`.`t1` (errno: 200 "Unknown error 200") +show warnings; +Level Code Message +Error 1005 Can't create table `test`.`t1` (errno: 200 "Unknown error 200") +Warning 1296 Got error 200 'Specifying INDEX DIRECTORY for an individual table is not supported.' from ROCKSDB CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY) ENGINE=rocksdb PARTITION BY RANGE (id) ( PARTITION P0 VALUES LESS THAN (1000) @@ -19,11 +19,11 @@ PARTITION P1 VALUES LESS THAN (2000) DATA DIRECTORY = '/foo/bar/data/', PARTITION P2 VALUES LESS THAN (MAXVALUE) ); -ERROR HY000: Can't create table `test`.`t1` (errno: 198 "Unknown error 198") +ERROR HY000: Can't create table `test`.`t1` (errno: 199 "Unknown error 199") show warnings; Level Code Message -Error 1005 Can't create table `test`.`t1` (errno: 198 "Unknown error 198") -Warning 1296 Got error 198 'Specifying DATA DIRECTORY for an individual table is not supported.' from ROCKSDB +Error 1005 Can't create table `test`.`t1` (errno: 199 "Unknown error 199") +Warning 1296 Got error 199 'Specifying DATA DIRECTORY for an individual table is not supported.' from ROCKSDB Error 6 Error on delete of './test/t1.par' (Errcode: 2 "No such file or directory") CREATE TABLE t1 (id int not null primary key) ENGINE=rocksdb PARTITION BY RANGE (id) ( @@ -33,9 +33,9 @@ PARTITION P1 VALUES LESS THAN (2000) INDEX DIRECTORY = '/foo/bar/data/', PARTITION P2 VALUES LESS THAN (MAXVALUE) ); -ERROR HY000: Can't create table `test`.`t1` (errno: 199 "Unknown error 199") +ERROR HY000: Can't create table `test`.`t1` (errno: 200 "Unknown error 200") show warnings; Level Code Message -Error 1005 Can't create table `test`.`t1` (errno: 199 "Unknown error 199") -Warning 1296 Got error 199 'Specifying INDEX DIRECTORY for an individual table is not supported.' from ROCKSDB +Error 1005 Can't create table `test`.`t1` (errno: 200 "Unknown error 200") +Warning 1296 Got error 200 'Specifying INDEX DIRECTORY for an individual table is not supported.' from ROCKSDB Error 6 Error on delete of './test/t1.par' (Errcode: 2 "No such file or directory") From c430aa72abbdccb1ece7f0d65b49a6b48e7c5ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 16 Sep 2021 20:10:42 +0300 Subject: [PATCH 10/10] MDEV-26626 InnoDB fails to advance the log checkpoint buf_flush_page_cleaner(): Always try to advance the log checkpoint, even when no pages were flushed during the latest batch. Maybe, since the previous batch, there was an LRU flush that removed the last dirty pages. Failure to advance the log checkpoint will cause unnecessary work in Mariabackup and on crash recovery. --- storage/innobase/buf/buf0flu.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 10a84d99a2e..fb687b4f51b 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -2266,6 +2266,15 @@ furious_flush: unemployed: buf_flush_async_lsn= 0; buf_pool.page_cleaner_set_idle(true); + + DBUG_EXECUTE_IF("ib_log_checkpoint_avoid", continue;); + + mysql_mutex_unlock(&buf_pool.flush_list_mutex); + + if (!recv_recovery_is_on() && srv_operation == SRV_OPERATION_NORMAL) + log_checkpoint(); + + mysql_mutex_lock(&buf_pool.flush_list_mutex); continue; }