Skip to content

Commit

Permalink
Merge 10.5 into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Nov 14, 2022
2 parents c82f3f1 + dc2741b commit ae6ebaf
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 228 deletions.
10 changes: 10 additions & 0 deletions mysql-test/suite/encryption/r/innochecksum,debug.rdiff
@@ -0,0 +1,10 @@
@@ -30,6 +30,9 @@
# Space ID mismatch
# Restore the original tables
# Corrupt FIL_DATA+10 (data)
+# FOUND 1 is expected for both.
+FOUND 1 /InnoDB: Crash recovery is broken due to insufficient innodb_log_file_size; last checkpoint LSN=\d+, current LSN=\d+\. Shutdown is in progress\..*InnoDB: Crash recovery was broken.*/ in mysqld.1.err
+FOUND 1 /InnoDB: Crash recovery was broken/ in mysqld.1.err
# Run innochecksum on t2
# Run innochecksum on t3
# Run innochecksum on t6
14 changes: 14 additions & 0 deletions mysql-test/suite/encryption/t/innochecksum.test
Expand Up @@ -9,6 +9,7 @@
-- source include/have_file_key_management_plugin.inc
-- source include/innodb_page_size_small.inc
-- source include/innodb_checksum_algorithm.inc
-- source include/maybe_debug.inc

if (!$INNOCHECKSUM) {
--echo Need innochecksum binary
Expand All @@ -18,6 +19,10 @@ if (!$INNOCHECKSUM) {
--disable_query_log
# This may be triggered on a slow system or one that lacks native AIO.
call mtr.add_suppression("InnoDB: Trying to delete tablespace.*pending operations");
if ($have_debug) {
SET GLOBAL DEBUG_DBUG='+d,ib_log_checkpoint_avoid_hard';
call mtr.add_suppression("InnoDB: Crash recovery is broken due to insufficient innodb_log_file_size");
}
--enable_query_log

let $checksum_algorithm = `SELECT @@innodb_checksum_algorithm`;
Expand Down Expand Up @@ -259,6 +264,15 @@ print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
EOF

if ($have_debug) {
--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err
--let SEARCH_PATTERN= InnoDB: Crash recovery is broken due to insufficient innodb_log_file_size; last checkpoint LSN=\\d+, current LSN=\\d+\\. Shutdown is in progress\\..*InnoDB: Crash recovery was broken.*
--echo # FOUND 1 is expected for both.
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN= InnoDB: Crash recovery was broken
--source include/search_pattern_in_file.inc
}

-- disable_result_log
--error 1
--exec $INNOCHECKSUM $t1_IBD
Expand Down
2 changes: 1 addition & 1 deletion mysys/my_gethwaddr.c
Expand Up @@ -116,7 +116,7 @@ my_bool my_gethwaddr(uchar *to)
uint i;
for (i= 0; res && i < ifc.ifc_len / sizeof(ifr[0]); i++)
{
#if !defined(_AIX) || !defined(__linux__)
#if defined(_AIX) || defined(__linux__)
#if defined(__linux__)
#define HWADDR_DATA ifr[i].ifr_hwaddr.sa_data
#else
Expand Down
3 changes: 1 addition & 2 deletions storage/innobase/CMakeLists.txt
Expand Up @@ -280,8 +280,7 @@ SET(INNOBASE_SOURCES
include/handler0alter.h
include/hash0hash.h
include/ibuf0ibuf.h
include/ibuf0ibuf.inl/
include/ibuf0types.h
include/ibuf0ibuf.inl
include/lock0iter.h
include/lock0lock.h
include/lock0lock.inl
Expand Down
5 changes: 5 additions & 0 deletions storage/innobase/buf/buf0flu.cc
Expand Up @@ -1886,6 +1886,7 @@ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn)
write out before we can advance the checkpoint. */
if (sync_lsn > log_sys.get_flushed_lsn())
log_write_up_to(sync_lsn, true);
DBUG_EXECUTE_IF("ib_log_checkpoint_avoid_hard", return;);
log_checkpoint();
}
}
Expand All @@ -1901,6 +1902,8 @@ ATTRIBUTE_COLD void buf_flush_ahead(lsn_t lsn, bool furious)
if (recv_recovery_is_on())
recv_sys.apply(true);

DBUG_EXECUTE_IF("ib_log_checkpoint_avoid_hard", return;);

Atomic_relaxed<lsn_t> &limit= furious
? buf_flush_sync_lsn : buf_flush_async_lsn;

Expand Down Expand Up @@ -2253,6 +2256,7 @@ static void buf_flush_page_cleaner()
buf_pool.page_cleaner_set_idle(true);

DBUG_EXECUTE_IF("ib_log_checkpoint_avoid", continue;);
DBUG_EXECUTE_IF("ib_log_checkpoint_avoid_hard", continue;);

mysql_mutex_unlock(&buf_pool.flush_list_mutex);

Expand Down Expand Up @@ -2336,6 +2340,7 @@ static void buf_flush_page_cleaner()
here should not affect correctness, because log_free_check()
should still be invoking checkpoints when needed. */
DBUG_EXECUTE_IF("ib_log_checkpoint_avoid", goto next;);
DBUG_EXECUTE_IF("ib_log_checkpoint_avoid_hard", goto next;);

if (!recv_recovery_is_on() && srv_operation == SRV_OPERATION_NORMAL)
log_checkpoint();
Expand Down
110 changes: 16 additions & 94 deletions storage/innobase/ibuf/ibuf0ibuf.cc
Expand Up @@ -2385,25 +2385,18 @@ static void ibuf_read_merge_pages(const uint32_t* space_ids,
#endif
}

/*********************************************************************//**
Contracts insert buffer trees by reading pages to the buffer pool.
/** Contract the change buffer by reading pages to the buffer pool.
@return a lower limit for the combined size in bytes of entries which
will be merged from ibuf trees to the pages read, 0 if ibuf is
empty */
static
ulint
ibuf_merge_pages(
/*=============*/
ulint* n_pages) /*!< out: number of pages to which merged */
will be merged from ibuf trees to the pages read
@retval 0 if ibuf.empty */
ulint ibuf_contract()
{
mtr_t mtr;
btr_pcur_t pcur;
ulint sum_sizes;
uint32_t page_nos[IBUF_MAX_N_PAGES_MERGED];
uint32_t space_ids[IBUF_MAX_N_PAGES_MERGED];

*n_pages = 0;

ibuf_mtr_start(&mtr);

/* Open a cursor to a randomly chosen leaf of the tree, at a random
Expand Down Expand Up @@ -2436,13 +2429,14 @@ ibuf_merge_pages(
return(0);
}

ulint n_pages = 0;
sum_sizes = ibuf_get_merge_page_nos(TRUE,
btr_pcur_get_rec(&pcur), &mtr,
space_ids,
page_nos, n_pages);
page_nos, &n_pages);
ibuf_mtr_commit(&mtr);

ibuf_read_merge_pages(space_ids, page_nos, *n_pages);
ibuf_read_merge_pages(space_ids, page_nos, n_pages);

return(sum_sizes + 1);
}
Expand Down Expand Up @@ -2514,73 +2508,6 @@ ibuf_merge_space(
return(n_pages);
}

/** Contract the change buffer by reading pages to the buffer pool.
@param[out] n_pages number of pages merged
@param[in] sync whether the caller waits for
the issued reads to complete
@return a lower limit for the combined size in bytes of entries which
will be merged from ibuf trees to the pages read, 0 if ibuf is
empty */
MY_ATTRIBUTE((warn_unused_result))
static ulint ibuf_merge(ulint* n_pages)
{
*n_pages = 0;

/* We perform a dirty read of ibuf.empty, without latching
the insert buffer root page. We trust this dirty read except
when a slow shutdown is being executed. During a slow
shutdown, the insert buffer merge must be completed. */

if (ibuf.empty && srv_shutdown_state <= SRV_SHUTDOWN_INITIATED) {
return(0);
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
} else if (ibuf_debug) {
return(0);
#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
} else {
return ibuf_merge_pages(n_pages);
}
}

/** Contract the change buffer by reading pages to the buffer pool.
@return a lower limit for the combined size in bytes of entries which
will be merged from ibuf trees to the pages read, 0 if ibuf is empty */
static ulint ibuf_contract()
{
ulint n_pages;
return ibuf_merge_pages(&n_pages);
}

/** Contract the change buffer by reading pages to the buffer pool.
@return a lower limit for the combined size in bytes of entries which
will be merged from ibuf trees to the pages read, 0 if ibuf is
empty */
ulint ibuf_merge_all()
{
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
if (ibuf_debug) {
return(0);
}
#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */

ulint sum_bytes = 0;
ulint n_pages = srv_io_capacity;

for (ulint sum_pages = 0; sum_pages < n_pages; ) {
log_free_check();
ulint n_pag2;
ulint n_bytes = ibuf_merge(&n_pag2);

if (n_bytes == 0) {
break;
}

sum_bytes += n_bytes;
}

return sum_bytes;
}

/*********************************************************************//**
Contract insert buffer trees after insert if they are too big. */
UNIV_INLINE
Expand All @@ -2590,13 +2517,7 @@ ibuf_contract_after_insert(
ulint entry_size) /*!< in: size of a record which was inserted
into an ibuf tree */
{
/* Perform dirty reads of ibuf.size and ibuf.max_size, to
reduce ibuf_mutex contention. ibuf.max_size remains constant
after ibuf_init_at_db_start(), but ibuf.size should be
protected by ibuf_mutex. Given that ibuf.size fits in a
machine word, this should be OK; at worst we are doing some
excessive ibuf_contract() or occasionally skipping a
ibuf_contract(). */
/* dirty comparison, to avoid contention on ibuf_mutex */
if (ibuf.size < ibuf.max_size) {
return;
}
Expand Down Expand Up @@ -3224,16 +3145,17 @@ ibuf_insert_low(

do_merge = FALSE;

/* Perform dirty reads of ibuf.size and ibuf.max_size, to
reduce ibuf_mutex contention. Given that ibuf.max_size and
ibuf.size fit in a machine word, this should be OK; at worst
we are doing some excessive ibuf_contract() or occasionally
/* Perform dirty comparison of ibuf.max_size and ibuf.size to
reduce ibuf_mutex contention. This should be OK; at worst we
are doing some excessive ibuf_contract() or occasionally
skipping an ibuf_contract(). */
if (ibuf.max_size == 0) {
const ulint max_size = ibuf.max_size;

if (max_size == 0) {
return(DB_STRONG_FAIL);
}

if (ibuf.size >= ibuf.max_size + IBUF_CONTRACT_DO_NOT_INSERT) {
if (ibuf.size >= max_size + IBUF_CONTRACT_DO_NOT_INSERT) {
/* Insert buffer is now too big, contract it but do not try
to insert */

Expand Down Expand Up @@ -4576,7 +4498,7 @@ ibuf_print(
fprintf(file,
"Ibuf: size " ULINTPF ", free list len " ULINTPF ","
" seg size " ULINTPF ", " ULINTPF " merges\n",
ibuf.size,
ulint{ibuf.size},
ibuf.free_list_len,
ibuf.seg_size,
ulint{ibuf.n_merges});
Expand Down
38 changes: 34 additions & 4 deletions storage/innobase/include/ibuf0ibuf.h
Expand Up @@ -30,7 +30,6 @@ Created 7/19/1997 Heikki Tuuri
#include "mtr0mtr.h"
#include "dict0mem.h"
#include "fsp0fsp.h"
#include "ibuf0types.h"

/** Default value for maximum on-disk size of change buffer in terms
of percentage of the buffer pool. */
Expand Down Expand Up @@ -61,6 +60,37 @@ enum ibuf_use_t {
/** Operations that can currently be buffered. */
extern ulong innodb_change_buffering;

/** Insert buffer struct */
struct ibuf_t{
Atomic_relaxed<ulint> size; /*!< current size of the ibuf index
tree, in pages */
Atomic_relaxed<ulint> max_size; /*!< recommended maximum size of the
ibuf index tree, in pages */
ulint seg_size; /*!< allocated pages of the file
segment containing ibuf header and
tree */
bool empty; /*!< Protected by the page
latch of the root page of the
insert buffer tree
(FSP_IBUF_TREE_ROOT_PAGE_NO). true
if and only if the insert
buffer tree is empty. */
ulint free_list_len; /*!< length of the free list */
ulint height; /*!< tree height */
dict_index_t* index; /*!< insert buffer index */

/** number of pages merged */
Atomic_counter<ulint> n_merges;
Atomic_counter<ulint> n_merged_ops[IBUF_OP_COUNT];
/*!< number of operations of each type
merged to index pages */
Atomic_counter<ulint> n_discarded_ops[IBUF_OP_COUNT];
/*!< number of operations of each type
discarded without merging due to the
tablespace being deleted or the
index being dropped */
};

/** The insert buffer control structure */
extern ibuf_t ibuf;

Expand Down Expand Up @@ -339,9 +369,9 @@ void ibuf_delete_for_discarded_space(ulint space);

/** Contract the change buffer by reading pages to the buffer pool.
@return a lower limit for the combined size in bytes of entries which
will be merged from ibuf trees to the pages read, 0 if ibuf is
empty */
ulint ibuf_merge_all();
will be merged from ibuf trees to the pages read
@retval 0 if ibuf.empty */
ulint ibuf_contract();

/** Contracts insert buffer trees by reading pages referring to space_id
to the buffer pool.
Expand Down
31 changes: 0 additions & 31 deletions storage/innobase/include/ibuf0ibuf.inl
Expand Up @@ -64,37 +64,6 @@ ibuf_mtr_commit(
mtr_commit(mtr);
}

/** Insert buffer struct */
struct ibuf_t{
ulint size; /*!< current size of the ibuf index
tree, in pages */
ulint max_size; /*!< recommended maximum size of the
ibuf index tree, in pages */
ulint seg_size; /*!< allocated pages of the file
segment containing ibuf header and
tree */
bool empty; /*!< Protected by the page
latch of the root page of the
insert buffer tree
(FSP_IBUF_TREE_ROOT_PAGE_NO). true
if and only if the insert
buffer tree is empty. */
ulint free_list_len; /*!< length of the free list */
ulint height; /*!< tree height */
dict_index_t* index; /*!< insert buffer index */

/** number of pages merged */
Atomic_counter<ulint> n_merges;
Atomic_counter<ulint> n_merged_ops[IBUF_OP_COUNT];
/*!< number of operations of each type
merged to index pages */
Atomic_counter<ulint> n_discarded_ops[IBUF_OP_COUNT];
/*!< number of operations of each type
discarded without merging due to the
tablespace being deleted or the
index being dropped */
};

/************************************************************************//**
Sets the free bit of the page in the ibuf bitmap. This is done in a separate
mini-transaction, hence this operation does not restrict further work to only
Expand Down
31 changes: 0 additions & 31 deletions storage/innobase/include/ibuf0types.h

This file was deleted.

0 comments on commit ae6ebaf

Please sign in to comment.