Skip to content
Permalink
Browse files
Merge 10.5 into 10.6
  • Loading branch information
dr-m committed Jan 10, 2023
2 parents 12a85c6 + 17858e0 commit 56c9b0b
Show file tree
Hide file tree
Showing 20 changed files with 183 additions and 22 deletions.
@@ -266,7 +266,7 @@ SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug
FUNCTION(INSTALL_MYSQL_TEST from to)
IF(INSTALL_MYSQLTESTDIR)
IF(NOT WITH_WSREP)
SET(EXCL_GALERA "(suite/(galera|wsrep|sys_vars/[rt]/(sysvars_)?wsrep).*|include/((w.*)?wsrep.*|.*galera.*)\\.inc|std_data/(galera|wsrep).*)")
SET(EXCL_GALERA "(suite/(galera|wsrep|sys_vars/[rt]/(sysvars_)?wsrep).*|std_data/(galera|wsrep).*)")
ELSE()
SET(EXCL_GALERA "^DOES_NOT_EXIST$")
ENDIF()
@@ -129,6 +129,7 @@ xb_fil_cur_open(
in case of error */
cursor->buf = NULL;
cursor->node = NULL;
cursor->n_process_batch = 0;

cursor->space_id = node->space->id;

@@ -374,6 +375,8 @@ xb_fil_cur_result_t xb_fil_cur_read(xb_fil_cur_t* cursor,
return(XB_FIL_CUR_EOF);
}

reinit_buf:
cursor->n_process_batch++;
if (to_read > (ib_int64_t) cursor->buf_size) {
to_read = (ib_int64_t) cursor->buf_size;
}
@@ -416,8 +419,26 @@ xb_fil_cur_result_t xb_fil_cur_read(xb_fil_cur_t* cursor,

if (os_file_read(IORequestRead, cursor->file, cursor->buf, offset,
(ulint) to_read, nullptr) != DB_SUCCESS) {
ret = XB_FIL_CUR_ERROR;
goto func_exit;
if (!srv_is_undo_tablespace(cursor->space_id)) {
ret = XB_FIL_CUR_ERROR;
goto func_exit;
}

if (cursor->buf_page_no
>= SRV_UNDO_TABLESPACE_SIZE_IN_PAGES) {
ret = XB_FIL_CUR_SKIP;
goto func_exit;
}

to_read = SRV_UNDO_TABLESPACE_SIZE_IN_PAGES * page_size;

if (cursor->n_process_batch > 1) {
ret = XB_FIL_CUR_ERROR;
goto func_exit;
}

space->release();
goto reinit_buf;
}

defer = UT_LIST_GET_FIRST(space->chain)->deferred;
@@ -58,6 +58,7 @@ struct xb_fil_cur_t {
uint thread_n; /*!< thread number for diagnostics */
ulint space_id; /*!< ID of tablespace */
ulint space_size; /*!< space size in pages */
uint32_t n_process_batch;/*!< Number of batch processed */

/** @return whether this is not a file-per-table tablespace */
bool is_system() const
@@ -245,6 +245,10 @@ long innobase_file_io_threads = 4;
ulong innobase_read_io_threads = 4;
ulong innobase_write_io_threads = 4;

/** Store the failed read of undo tablespace ids. Protected by
backup mutex */
static std::set<uint32_t> fail_undo_ids;

longlong innobase_page_size = (1LL << 14); /* 16KB */
char* innobase_buffer_pool_filename = NULL;

@@ -406,6 +410,10 @@ struct ddl_tracker_t {

static ddl_tracker_t ddl_tracker;

/** Store the space ids of truncated undo log tablespaces. Protected
by recv_sys.mutex */
static std::set<uint32_t> undo_trunc_ids;

/** Stores the space ids of page0 INIT_PAGE redo records. It is
used to indicate whether the given deferred tablespace can
be reconstructed. */
@@ -920,6 +928,11 @@ static void backup_file_op_fail(ulint space_id, int type,
}
}

static void backup_undo_trunc(uint32_t space_id)
{
undo_trunc_ids.insert(space_id);
}

/* Function to store the space id of page0 INIT_PAGE
@param space_id space id which has page0 init page */
static void backup_first_page_op(ulint space_id)
@@ -2851,15 +2864,27 @@ static my_bool xtrabackup_copy_datafile(fil_node_t *node, uint thread_n,
}

/* The main copy loop */
while ((res = xb_fil_cur_read(&cursor, corrupted_pages)) ==
XB_FIL_CUR_SUCCESS) {
while (1) {
res = xb_fil_cur_read(&cursor, corrupted_pages);
if (res == XB_FIL_CUR_ERROR) {
goto error;
}

if (res == XB_FIL_CUR_EOF) {
break;
}

if (!write_filter.process(&write_filt_ctxt, dstfile)) {
goto error;
}
}

if (res == XB_FIL_CUR_ERROR) {
goto error;
if (res == XB_FIL_CUR_SKIP) {
pthread_mutex_lock(&backup_mutex);
fail_undo_ids.insert(
static_cast<uint32_t>(cursor.space_id));
pthread_mutex_unlock(&backup_mutex);
break;
}
}

if (write_filter.finalize
@@ -4450,6 +4475,23 @@ static bool xtrabackup_backup_low()

dst_log_file = NULL;

std::vector<uint32_t> failed_ids;
std::set_difference(
fail_undo_ids.begin(), fail_undo_ids.end(),
undo_trunc_ids.begin(), undo_trunc_ids.end(),
std::inserter(failed_ids, failed_ids.begin()));

for (uint32_t id : failed_ids) {
msg("mariabackup: Failed to read undo log "
"tablespace space id %d and there is no undo "
"tablespace truncation redo record.",
id);
}

if (failed_ids.size() > 0) {
return false;
}

if(!xtrabackup_incremental) {
strcpy(metadata_type, "full-backuped");
metadata_from_lsn = 0;
@@ -4524,6 +4566,7 @@ static bool xtrabackup_backup_func()

srv_operation = SRV_OPERATION_BACKUP;
log_file_op = backup_file_op;
undo_space_trunc = backup_undo_trunc;
first_page_init = backup_first_page_op;
metadata_to_lsn = 0;

@@ -4538,6 +4581,7 @@ static bool xtrabackup_backup_func()
}

log_file_op = NULL;
undo_space_trunc = NULL;
first_page_init = NULL;
if (dst_log_file) {
ds_close(dst_log_file);
@@ -4827,6 +4871,7 @@ static bool xtrabackup_backup_func()

innodb_shutdown();
log_file_op = NULL;
undo_space_trunc = NULL;
first_page_init = NULL;
pthread_mutex_destroy(&backup_mutex);
pthread_cond_destroy(&scanned_lsn_cond);
@@ -77,7 +77,6 @@ FOREACH(f ${HEADERS_GEN_CONFIGURE})
ENDFOREACH(f)
IF(NOT WITH_WSREP)
SET(EXCL_SERVICE_WSREP "service_wsrep.h")
SET(EXCL_WSREP "wsrep.h")
ENDIF()
INSTALL(DIRECTORY mysql/
DESTINATION ${INSTALL_INCLUDEDIR}/server/mysql COMPONENT Development
@@ -94,7 +93,6 @@ MACRO(INSTALL_PRIVATE DIR)
FILES_MATCHING PATTERN "*.h"
PATTERN CMakeFiles EXCLUDE
PATTERN mysql EXCLUDE
PATTERN "${EXCL_WSREP}" EXCLUDE
REGEX "\\./(${EXCL_RE}$)" EXCLUDE)
ENDMACRO()

@@ -4066,6 +4066,26 @@ owner_id
1
DROP TABLE t1;
#
# MDEV-30240 Wrong result upon aggregate function with SQL_BUFFER_RESULT
#
drop table if exists t1,t2;
Warnings:
Note 1051 Unknown table 'test.t1,test.t2'
CREATE TABLE t1 (pk INT PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (a INT);
INSERT INTO t2 VALUES (1),(2);
SELECT SQL_BUFFER_RESULT MIN(pk) FROM t1, t2;
MIN(pk)
1
SELECT MIN(pk) FROM t1, t2;
MIN(pk)
1
DROP TABLE t1, t2;
#
# End of 10.5 tests
#
#
# MDEV-24353: Adding GROUP BY slows down a query
#
CREATE TABLE t1 (p int NOT NULL, a int NOT NULL, PRIMARY KEY (p,a));
@@ -1725,6 +1725,23 @@ SELECT DISTINCT owner_id FROM t1 WHERE foo = true GROUP BY owner_id HAVING (COUN
SELECT DISTINCT owner_id FROM t1 WHERE foo = true GROUP BY owner_id HAVING (COUNT(*) = 1);
DROP TABLE t1;

--echo #
--echo # MDEV-30240 Wrong result upon aggregate function with SQL_BUFFER_RESULT
--echo #

drop table if exists t1,t2;
CREATE TABLE t1 (pk INT PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (a INT);
INSERT INTO t2 VALUES (1),(2);
SELECT SQL_BUFFER_RESULT MIN(pk) FROM t1, t2;
SELECT MIN(pk) FROM t1, t2;
DROP TABLE t1, t2;

--echo #
--echo # End of 10.5 tests
--echo #

--echo #
--echo # MDEV-24353: Adding GROUP BY slows down a query
--echo #
@@ -0,0 +1,13 @@
set default_storage_engine=Aria;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
#
# MDEV-30325 Wrong result upon range query using index condition
#
SELECT COUNT(*) FROM lineitem force index (i_l_orderkey_quantity,i_l_shipdate) WHERE l_shipdate < '1994-01-01' AND l_orderkey < 800 OR l_quantity > 3 AND l_orderkey NOT IN ( 157, 1444 );
COUNT(*)
5056
#
# End of 10.5 tests
#
DROP DATABASE dbt3_s001;
@@ -0,0 +1,24 @@
#
# This is generic tests using dbt3_s001 tables
# This file uses the Aria storage engine
#

set default_storage_engine=Aria;

CREATE DATABASE dbt3_s001;
use dbt3_s001;
--disable_query_log
--source include/dbt3_s001.inc
--enable_query_log

--echo #
--echo # MDEV-30325 Wrong result upon range query using index condition
--echo #

SELECT COUNT(*) FROM lineitem force index (i_l_orderkey_quantity,i_l_shipdate) WHERE l_shipdate < '1994-01-01' AND l_orderkey < 800 OR l_quantity > 3 AND l_orderkey NOT IN ( 157, 1444 );

--echo #
--echo # End of 10.5 tests
--echo #

DROP DATABASE dbt3_s001;
@@ -23,6 +23,7 @@
SYNOPSIS
init_dynamic_array2()
ps_key Key to register instrumented memory
array Pointer to an array
element_size Size of element
init_buffer Initial buffer pointer
@@ -60,8 +60,9 @@ my_hash_value_type my_hash_sort(CHARSET_INFO *cs, const uchar *key,
dynamic array that is part of the hash will allocate memory
as required during insertion.
@param[in] psi_key The key to register instrumented memory
@param[in,out] hash The hash that is initialized
@param[in[ growth_size size incrememnt for the underlying dynarray
@param[in] growth_size size incrememnt for the underlying dynarray
@param[in] charset The character set information
@param[in] size The hash size
@param[in] key_offest The key offset for the hash
@@ -34,8 +34,8 @@
SYNOPSIS
init_alloc_root()
key - key to register instrumented memory
mem_root - memory root to initialize
name - name of memroot (for debugging)
block_size - size of chunks (blocks) used for memory allocation
(It is external size of chunk i.e. it should include
memory required for internal structures, thus it
@@ -59,6 +59,7 @@ void set_malloc_size_cb(MALLOC_SIZE_CB func)
/**
Allocate a sized block of memory.
@param key Key to register instrumented memory
@param size The size of the memory block in bytes.
@param flags Failure action modifiers (bitmasks).
@@ -120,7 +121,8 @@ void *my_malloc(PSI_memory_key key, size_t size, myf my_flags)
/**
@brief wrapper around realloc()
@param old_point pointer to currently allocated area
@param key key to register instrumented memory
@param old_point pointer to currently allocated area
@param size new size requested, must be >0
@param my_flags flags
@@ -503,7 +503,7 @@ IF(WIN32)
ENDIF(WIN32)

IF(NOT WITH_WSREP)
SET(EXCL_WSREP "wsrep*.h")
SET(EXCL_WSREP "wsrep_[a-np-z]*.h")
ENDIF()
INSTALL(DIRECTORY . DESTINATION ${INSTALL_INCLUDEDIR}/server/private COMPONENT Development
FILES_MATCHING PATTERN "*.h"
@@ -2373,8 +2373,15 @@ Item *Item_sum_variance::result_item(THD *thd, Field *field)
void Item_sum_min_max::clear()
{
DBUG_ENTER("Item_sum_min_max::clear");
value->clear();
null_value= 1;
/*
We should not clear const items (from SELECT MIN(key) from t1) as then we would loose the
value cached in opt_sum_query() where we replace MIN/MAX/COUNT with constants.
*/
if (!const_item())
{
value->clear();
null_value= 1;
}
DBUG_VOID_RETURN;
}

@@ -2487,9 +2494,12 @@ void Item_sum_min_max::no_rows_in_result()
/* We may be called here twice in case of ref field in function */
if (was_values)
{
bool org_const_item_cache= const_item_cache;
was_values= FALSE;
was_null_value= value->null_value;
const_item_cache= 0; // Ensure that clear works on const items
clear();
const_item_cache= org_const_item_cache;
}
DBUG_VOID_RETURN;
}

0 comments on commit 56c9b0b

Please sign in to comment.