Commit 1d30b7b1 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-12699 preparation: Clean up recv_sys

The recv_sys data structures are accessed not only from the thread
that executes InnoDB plugin initialization, but also from the
InnoDB I/O threads, which can invoke recv_recover_page().

Assert that sufficient concurrency control is in place.
Some code was accessing recv_sys data structures without
holding recv_sys->mutex.

recv_recover_page(bpage): Refactor the call from buf_page_io_complete()
into a separate function that performs necessary steps. The
main thread was unnecessarily releasing and reacquiring recv_sys->mutex.

recv_recover_page(block,mtr,recv_addr): Pass more parameters from
the caller. Avoid redundant lookups and computations. Eliminate some
redundant variables.

recv_get_fil_addr_struct(): Assert that recv_sys->mutex is being held.
That was not always the case!

recv_scan_log_recs(): Acquire recv_sys->mutex for the whole duration
of the function. (While we are scanning and buffering redo log records,
no pages can be read in.)

recv_read_in_area(): Properly protect access with recv_sys->mutex.

recv_apply_hashed_log_recs(): Check recv_addr->state only once,
and continuously hold recv_sys->mutex. The mutex will be released
and reacquired inside recv_recover_page() and recv_read_in_area(),
allowing concurrent processing by buf_page_io_complete() in I/O threads.
parent aa3f7a10
......@@ -2752,8 +2752,13 @@ static bool xtrabackup_copy_logfile(bool last = false)
my_sleep(1000);
}
start_lsn = (lsn == start_lsn)
? 0 : xtrabackup_copy_log(start_lsn, lsn, last);
if (lsn == start_lsn) {
start_lsn = 0;
} else {
mutex_enter(&recv_sys->mutex);
start_lsn = xtrabackup_copy_log(start_lsn, lsn, last);
mutex_exit(&recv_sys->mutex);
}
log_mutex_exit();
......
......@@ -6057,9 +6057,7 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict)
page_not_corrupt: bpage = bpage; );
if (recv_recovery_is_on()) {
/* Pages must be uncompressed for crash recovery. */
ut_a(uncompressed);
recv_recover_page(TRUE, (buf_block_t*) bpage);
recv_recover_page(bpage);
}
/* If space is being truncated then avoid ibuf operation.
......@@ -6079,7 +6077,7 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict)
<< " encrypted. However key "
"management plugin or used "
<< "key_version " << key_version
<< "is not found or"
<< " is not found or"
" used encryption algorithm or method does not match."
" Can't continue opening the table.";
} else {
......
......@@ -49,12 +49,9 @@ dberr_t
recv_find_max_checkpoint(ulint* max_field)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/** Apply the hashed log records to the page, if the page lsn is less than the
lsn of a log record.
@param just_read_in whether the page recently arrived to the I/O handler
@param block the page in the buffer pool */
void
recv_recover_page(bool just_read_in, buf_block_t* block);
/** Apply any buffered redo log to a page that was just read from a data file.
@param[in,out] bpage buffer pool page */
ATTRIBUTE_COLD void recv_recover_page(buf_page_t* bpage);
/** Start recovering from a redo log checkpoint.
@see recv_recovery_from_checkpoint_finish
......
This diff is collapsed.
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