Commit bb9da13b authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-31373 innodb_undo_log_truncate=ON recovery results in a corrupted undo log

recv_sys_t::apply(): When applying an undo log truncation operation,
invoke os_file_truncate() on space->recv_size, which must not be
less than the original truncated file size.

Alternatively, as pointed out by Thirunarayanan Balathandayuthapani,
we could assign space->size = t.pages, so that
fil_system_t::extend_to_recv_size() would extend the file back
to space->recv_size.
parent 3aea77ed
...@@ -2690,10 +2690,12 @@ void recv_sys_t::apply(bool last_batch) ...@@ -2690,10 +2690,12 @@ void recv_sys_t::apply(bool last_batch)
if (fil_space_t *space = fil_space_get(id + srv_undo_space_id_start)) if (fil_space_t *space = fil_space_get(id + srv_undo_space_id_start))
{ {
ut_ad(UT_LIST_GET_LEN(space->chain) == 1); ut_ad(UT_LIST_GET_LEN(space->chain) == 1);
ut_ad(space->recv_size >= t.pages);
fil_node_t *file= UT_LIST_GET_FIRST(space->chain); fil_node_t *file= UT_LIST_GET_FIRST(space->chain);
ut_ad(file->is_open()); ut_ad(file->is_open());
os_file_truncate(file->name, file->handle, os_file_truncate(file->name, file->handle,
os_offset_t{t.pages} << srv_page_size_shift, true); os_offset_t{space->recv_size} <<
srv_page_size_shift, true);
} }
} }
} }
......
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