summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-01-12 12:33:19 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-01-12 12:33:19 +0200
commit0261eac57f137c5daae90f5bb1eaa4bf48ee431b (patch)
tree8a21fa13152bd3715b332dc3c15d93e0cb3b3c05
parent428b057ee06dca05a3d20f5b4cc32ceedbc37836 (diff)
parent017d1b867b12ff36b3b871c3d57719907a905659 (diff)
downloadmariadb-git-0261eac57f137c5daae90f5bb1eaa4bf48ee431b.tar.gz
Merge 10.5 into 10.6
-rw-r--r--cmake/pcre.cmake1
-rw-r--r--mysql-test/main/alter_table.result18
-rw-r--r--mysql-test/main/alter_table.test22
-rw-r--r--sql/lock.cc2
-rw-r--r--sql/sql_base.cc4
-rw-r--r--storage/innobase/log/log0recv.cc38
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc3
7 files changed, 81 insertions, 7 deletions
diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake
index 42f22d9fe19..678556c9a59 100644
--- a/cmake/pcre.cmake
+++ b/cmake/pcre.cmake
@@ -48,6 +48,7 @@ MACRO(BUNDLE_PCRE2)
URL_MD5 8c1699a725d4b28410adf4b964ebbcb7
INSTALL_COMMAND ""
CMAKE_ARGS
+ "-DCMAKE_WARN_DEPRECATED=FALSE"
"-DPCRE2_BUILD_TESTS=OFF"
"-DPCRE2_BUILD_PCRE2GREP=OFF"
"-DBUILD_SHARED_LIBS=OFF"
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result
index 1cad2f14a41..d44094b791b 100644
--- a/mysql-test/main/alter_table.result
+++ b/mysql-test/main/alter_table.result
@@ -3415,5 +3415,23 @@ ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITH
delete from t1 where a = 11;
drop table t1;
#
+# MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in
+# Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK)
+#
+SET @max_session_mem_used_save= @@max_session_mem_used;
+CREATE TABLE t1 (a INT);
+SELECT * FROM t1;
+a
+ALTER TABLE x MODIFY xx INT;
+ERROR 42S02: Table 'test.x' doesn't exist
+SET SESSION max_session_mem_used= 8192;
+LOCK TABLE t1 WRITE;
+ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT;
+Warnings:
+Note 1054 Unknown column 'b' in 't1'
+SET SESSION max_session_mem_used = @max_session_mem_used_save;
+UNLOCK TABLES;
+DROP TABLE t1;
+#
# End of 10.5 tests
#
diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test
index 1bff20a7bd7..cc17c3efec9 100644
--- a/mysql-test/main/alter_table.test
+++ b/mysql-test/main/alter_table.test
@@ -2662,5 +2662,27 @@ delete from t1 where a = 11;
drop table t1;
--echo #
+--echo # MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in
+--echo # Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK)
+--echo #
+
+SET @max_session_mem_used_save= @@max_session_mem_used;
+
+CREATE TABLE t1 (a INT);
+SELECT * FROM t1;
+
+--error ER_NO_SUCH_TABLE
+ALTER TABLE x MODIFY xx INT;
+
+SET SESSION max_session_mem_used= 8192;
+LOCK TABLE t1 WRITE;
+
+ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT;
+
+SET SESSION max_session_mem_used = @max_session_mem_used_save;
+UNLOCK TABLES;
+DROP TABLE t1;
+
+--echo #
--echo # End of 10.5 tests
--echo #
diff --git a/sql/lock.cc b/sql/lock.cc
index f6cdd40fa0b..9f53ffb3a69 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -356,7 +356,7 @@ bool mysql_lock_tables(THD *thd, MYSQL_LOCK *sql_lock, uint flags)
end:
THD_STAGE_INFO(thd, org_stage);
- if (thd->killed)
+ if (thd->killed && !thd->get_stmt_da()->is_ok())
{
thd->send_kill_message();
if (!rc)
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 8ee1d19961f..8d213ce103b 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2616,7 +2616,9 @@ void Locked_tables_list::mark_table_for_reopen(THD *thd, TABLE *table)
bool
Locked_tables_list::reopen_tables(THD *thd, bool need_reopen)
{
- Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN);
+ bool is_ok= thd->get_stmt_da()->is_ok();
+ Open_table_context ot_ctx(thd, !is_ok ? MYSQL_OPEN_REOPEN:
+ MYSQL_OPEN_IGNORE_KILLED | MYSQL_OPEN_REOPEN);
uint reopen_count= 0;
MYSQL_LOCK *lock;
MYSQL_LOCK *merged_lock;
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index ad2078aba88..b910f9075e3 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -3059,6 +3059,32 @@ inline fil_space_t *fil_system_t::find(const char *path) const
return nullptr;
}
+/** Thread-safe function which sorts flush_list by oldest_modification */
+static void log_sort_flush_list()
+{
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+
+ const size_t size= UT_LIST_GET_LEN(buf_pool.flush_list);
+ std::unique_ptr<buf_page_t *[]> list(new buf_page_t *[size]);
+
+ size_t idx= 0;
+ for (buf_page_t *p= UT_LIST_GET_FIRST(buf_pool.flush_list); p;
+ p= UT_LIST_GET_NEXT(list, p))
+ list.get()[idx++]= p;
+
+ std::sort(list.get(), list.get() + size,
+ [](const buf_page_t *lhs, const buf_page_t *rhs) {
+ return rhs->oldest_modification() < lhs->oldest_modification();
+ });
+
+ UT_LIST_INIT(buf_pool.flush_list, &buf_page_t::list);
+
+ for (size_t i= 0; i < size; i++)
+ UT_LIST_ADD_LAST(buf_pool.flush_list, list[i]);
+
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+}
+
/** Apply buffered log to persistent data pages.
@param last_batch whether it is possible to write more redo log */
void recv_sys_t::apply(bool last_batch)
@@ -3254,9 +3280,15 @@ next_page:
mysql_mutex_assert_not_owner(&log_sys.mutex);
mysql_mutex_unlock(&mutex);
- /* Instead of flushing, last_batch could sort the buf_pool.flush_list
- in ascending order of buf_page_t::oldest_modification. */
- buf_flush_sync_batch(recovered_lsn);
+ if (last_batch && srv_operation != SRV_OPERATION_RESTORE &&
+ srv_operation != SRV_OPERATION_RESTORE_EXPORT)
+ log_sort_flush_list();
+ else
+ {
+ /* Instead of flushing, last_batch could sort the buf_pool.flush_list
+ in ascending order of buf_page_t::oldest_modification. */
+ buf_flush_sync_batch(recovered_lsn);
+ }
if (!last_batch)
{
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index 0fcffce0cd8..fa72d95def3 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2021, 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
@@ -1373,7 +1373,6 @@ void mtr_t::modify(const buf_block_t &block)
{
/* This must be PageConverter::update_page() in IMPORT TABLESPACE. */
ut_ad(!block.page.in_LRU_list);
- ut_ad(!buf_pool.is_uncompressed(&block));
return;
}