Commit 15b607b5 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.5 into 10.6

parents ec7db2bd 4c343394
......@@ -24,6 +24,7 @@ Insert buffer
Created 7/19/1997 Heikki Tuuri
*******************************************************/
#include <tuple>
#include "ibuf0ibuf.h"
#include "btr0sea.h"
......@@ -2323,7 +2324,8 @@ static void ibuf_delete_recs(const page_id_t page_id)
/** Merge the change buffer to some pages. */
static void ibuf_read_merge_pages(const uint32_t* space_ids,
const uint32_t* page_nos, ulint n_stored)
const uint32_t* page_nos, ulint n_stored,
bool slow_shutdown_cleanup)
{
for (ulint i = 0; i < n_stored; i++) {
const ulint space_id = space_ids[i];
......@@ -2348,30 +2350,28 @@ static void ibuf_read_merge_pages(const uint32_t* space_ids,
if (UNIV_LIKELY(page_nos[i] < size)) {
mtr.start();
dberr_t err;
buf_block_t *block =
/* Load the page and apply change buffers. */
std::ignore =
buf_page_get_gen(page_id_t(space_id, page_nos[i]),
zip_size, RW_X_LATCH, nullptr,
BUF_GET_POSSIBLY_FREED,
&mtr, &err, true);
bool remove = !block
|| fil_page_get_type(block->page.frame)
!= FIL_PAGE_INDEX
|| !page_is_leaf(block->page.frame);
mtr.commit();
if (err == DB_TABLESPACE_DELETED) {
s->x_unlock();
goto tablespace_deleted;
}
if (!remove) {
s->x_unlock();
continue;
}
}
s->x_unlock();
if (srv_shutdown_state == SRV_SHUTDOWN_NONE
|| srv_fast_shutdown) {
/* During slow shutdown cleanup, we apply all pending IBUF
changes and need to cleanup any left-over IBUF records. There
are a few cases when the changes are already discarded and IBUF
bitmap is cleaned but we miss to delete the record. Even after
the issues are fixed, we need to keep this safety measure for
upgraded DBs with such left over records. */
if (!slow_shutdown_cleanup) {
continue;
}
......@@ -2442,7 +2442,7 @@ ATTRIBUTE_COLD ulint ibuf_contract()
space_ids, 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, true);
return(sum_sizes + 1);
}
......@@ -2523,7 +2523,7 @@ ibuf_merge_space(
}
#endif /* UNIV_DEBUG */
ibuf_read_merge_pages(spaces, pages, n_pages);
ibuf_read_merge_pages(spaces, pages, n_pages, false);
}
return(n_pages);
......
......@@ -431,7 +431,8 @@ btr_pcur_open(
}
/** Open a cursor on the first user record satisfying the search condition;
in case of no match, after the last index record. */
in case of no match, after the last index record.
@return DB_SUCCESS or error code */
MY_ATTRIBUTE((nonnull, warn_unused_result))
inline
dberr_t
......
......@@ -347,12 +347,11 @@ inline void mtr_t::memmove(const buf_block_t &b, ulint d, ulint s, ulint len)
ut_ad(d >= 8);
ut_ad(s >= 8);
ut_ad(len);
ut_d(const ulint ps= srv_page_size);
ut_ad(s <= ps);
ut_ad(s + len <= ps);
ut_ad(s <= ulint(srv_page_size));
ut_ad(s + len <= ulint(srv_page_size));
ut_ad(s != d);
ut_ad(d <= ps);
ut_ad(d + len <= ps);
ut_ad(d <= ulint(srv_page_size));
ut_ad(d + len <= ulint(srv_page_size));
set_modified(b);
if (!is_logged())
......@@ -360,17 +359,17 @@ inline void mtr_t::memmove(const buf_block_t &b, ulint d, ulint s, ulint len)
static_assert(MIN_4BYTE > UNIV_PAGE_SIZE_MAX, "consistency");
size_t lenlen= (len < MIN_2BYTE ? 1 : len < MIN_3BYTE ? 2 : 3);
/* The source offset is encoded relative to the destination offset,
with the sign in the least significant bit.
Because the source offset 0 is not possible, our encoding
subtracts 1 from the offset. */
const uint16_t S= s > d
? uint16_t((s - d - 1) << 1)
: uint16_t((d - s - 1) << 1 | 1);
with the sign in the least significant bit. */
if (s > d)
s= (s - d) << 1;
else
s= (d - s) << 1 | 1;
/* The source offset 0 is not possible. */
size_t slen= (S < MIN_2BYTE ? 1 : S < MIN_3BYTE ? 2 : 3);
s-= 1 << 1;
size_t slen= (s < MIN_2BYTE ? 1 : s < MIN_3BYTE ? 2 : 3);
byte *l= log_write<MEMMOVE>(b.page.id(), &b.page, lenlen + slen, true, d);
l= mlog_encode_varint(l, len);
l= mlog_encode_varint(l, S);
l= mlog_encode_varint(l, s);
m_log.close(l);
m_last_offset= static_cast<uint16_t>(d + len);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment