Skip to content

Commit

Permalink
MDEV-17780 innodb.truncate_recover crashes in recovery due to out-of-…
Browse files Browse the repository at this point in the history
…bounds page read

recv_addr_trim(): Do not try to detach the hash bucket, because
the code for doing that does not always work.

recv_apply_hashed_log_recs(): Do not attempt to read pages for which
there exist no redo log records.
  • Loading branch information
dr-m committed Nov 20, 2018
1 parent ae96b47 commit b86e18c
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions storage/innobase/log/log0recv.cc
Expand Up @@ -232,9 +232,8 @@ static void recv_addr_trim(ulint space_id, unsigned pages, lsn_t lsn)
hash_cell_t* const cell = hash_get_nth_cell(
recv_sys->addr_hash, i);
for (recv_addr_t* addr = static_cast<recv_addr_t*>(cell->node),
*prev = NULL, *next;
addr;
prev = addr, addr = next) {
*next;
addr; addr = next) {
next = static_cast<recv_addr_t*>(addr->addr_hash);

if (addr->space != space_id || addr->page_no < pages) {
Expand All @@ -256,22 +255,6 @@ static void recv_addr_trim(ulint space_id, unsigned pages, lsn_t lsn)
}
recv = n;
}

if (UT_LIST_GET_LEN(addr->rec_list)) {
DBUG_PRINT("ib_log",
("preserving " ULINTPF
" records for page %u:%u",
UT_LIST_GET_LEN(addr->rec_list),
addr->space, addr->page_no));
} else {
ut_ad(recv_sys->n_addrs);
--recv_sys->n_addrs;
if (addr == cell->node) {
cell->node = next;
} else {
prev->addr_hash = next;
}
}
}
}
if (fil_space_t* space = fil_space_get(space_id)) {
Expand Down Expand Up @@ -2169,8 +2152,7 @@ static ulint recv_read_in_area(const page_id_t page_id)
/** Apply the hash table of stored log records to persistent data pages.
@param[in] last_batch whether the change buffer merge will be
performed as part of the operation */
void
recv_apply_hashed_log_recs(bool last_batch)
void recv_apply_hashed_log_recs(bool last_batch)
{
ut_ad(srv_operation == SRV_OPERATION_NORMAL
|| srv_operation == SRV_OPERATION_RESTORE
Expand Down Expand Up @@ -2233,7 +2215,8 @@ recv_apply_hashed_log_recs(bool last_batch)
continue;
}

if (recv_addr->state == RECV_DISCARDED) {
if (recv_addr->state == RECV_DISCARDED
|| !UT_LIST_GET_LEN(recv_addr->rec_list)) {
ut_a(recv_sys->n_addrs);
recv_sys->n_addrs--;
continue;
Expand Down

0 comments on commit b86e18c

Please sign in to comment.