Skip to content

Commit b86e18c

Browse files
committed
MDEV-17780 innodb.truncate_recover crashes in recovery due to out-of-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.
1 parent ae96b47 commit b86e18c

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

storage/innobase/log/log0recv.cc

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,8 @@ static void recv_addr_trim(ulint space_id, unsigned pages, lsn_t lsn)
232232
hash_cell_t* const cell = hash_get_nth_cell(
233233
recv_sys->addr_hash, i);
234234
for (recv_addr_t* addr = static_cast<recv_addr_t*>(cell->node),
235-
*prev = NULL, *next;
236-
addr;
237-
prev = addr, addr = next) {
235+
*next;
236+
addr; addr = next) {
238237
next = static_cast<recv_addr_t*>(addr->addr_hash);
239238

240239
if (addr->space != space_id || addr->page_no < pages) {
@@ -256,22 +255,6 @@ static void recv_addr_trim(ulint space_id, unsigned pages, lsn_t lsn)
256255
}
257256
recv = n;
258257
}
259-
260-
if (UT_LIST_GET_LEN(addr->rec_list)) {
261-
DBUG_PRINT("ib_log",
262-
("preserving " ULINTPF
263-
" records for page %u:%u",
264-
UT_LIST_GET_LEN(addr->rec_list),
265-
addr->space, addr->page_no));
266-
} else {
267-
ut_ad(recv_sys->n_addrs);
268-
--recv_sys->n_addrs;
269-
if (addr == cell->node) {
270-
cell->node = next;
271-
} else {
272-
prev->addr_hash = next;
273-
}
274-
}
275258
}
276259
}
277260
if (fil_space_t* space = fil_space_get(space_id)) {
@@ -2169,8 +2152,7 @@ static ulint recv_read_in_area(const page_id_t page_id)
21692152
/** Apply the hash table of stored log records to persistent data pages.
21702153
@param[in] last_batch whether the change buffer merge will be
21712154
performed as part of the operation */
2172-
void
2173-
recv_apply_hashed_log_recs(bool last_batch)
2155+
void recv_apply_hashed_log_recs(bool last_batch)
21742156
{
21752157
ut_ad(srv_operation == SRV_OPERATION_NORMAL
21762158
|| srv_operation == SRV_OPERATION_RESTORE
@@ -2233,7 +2215,8 @@ recv_apply_hashed_log_recs(bool last_batch)
22332215
continue;
22342216
}
22352217

2236-
if (recv_addr->state == RECV_DISCARDED) {
2218+
if (recv_addr->state == RECV_DISCARDED
2219+
|| !UT_LIST_GET_LEN(recv_addr->rec_list)) {
22372220
ut_a(recv_sys->n_addrs);
22382221
recv_sys->n_addrs--;
22392222
continue;

0 commit comments

Comments
 (0)