summaryrefslogtreecommitdiff
path: root/log/log0recv.c
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-07-14 21:22:41 +0200
committerSergei Golubchik <sergii@pisem.net>2011-07-14 21:22:41 +0200
commit54ab9ea20f00a2cf230aa173db83eb66497ba91f (patch)
tree7d210c55d9c3b332c600ed1054464a4ef99e9bec /log/log0recv.c
parentfecd255a16fc3be6206e03ad5e70d8e90118acc6 (diff)
downloadmariadb-git-54ab9ea20f00a2cf230aa173db83eb66497ba91f.tar.gz
xtradb 5.5.13
Diffstat (limited to 'log/log0recv.c')
-rw-r--r--log/log0recv.c106
1 files changed, 66 insertions, 40 deletions
diff --git a/log/log0recv.c b/log/log0recv.c
index 8ef24995b09..256b29cb777 100644
--- a/log/log0recv.c
+++ b/log/log0recv.c
@@ -148,6 +148,14 @@ is bigger than the lsn we are able to scan up to, that is an indication that
the recovery failed and the database may be corrupt. */
UNIV_INTERN ib_uint64_t recv_max_page_lsn;
+#ifdef UNIV_PFS_THREAD
+UNIV_INTERN mysql_pfs_key_t trx_rollback_clean_thread_key;
+#endif /* UNIV_PFS_THREAD */
+
+#ifdef UNIV_PFS_MUTEX
+UNIV_INTERN mysql_pfs_key_t recv_sys_mutex_key;
+#endif /* UNIV_PFS_MUTEX */
+
/* prototypes */
#ifndef UNIV_HOTBACKUP
@@ -175,7 +183,7 @@ recv_sys_create(void)
recv_sys = mem_alloc(sizeof(*recv_sys));
memset(recv_sys, 0x0, sizeof(*recv_sys));
- mutex_create(&recv_sys->mutex, SYNC_RECV);
+ mutex_create(recv_sys_mutex_key, &recv_sys->mutex, SYNC_RECV);
recv_sys->heap = NULL;
recv_sys->addr_hash = NULL;
@@ -299,12 +307,14 @@ recv_sys_init(
return;
}
+#ifndef UNIV_HOTBACKUP
/* Initialize red-black tree for fast insertions into the
flush_list during recovery process.
As this initialization is done while holding the buffer pool
mutex we perform it before acquiring recv_sys->mutex. */
#ifndef UNIV_HOTBACKUP
buf_flush_init_flush_rbt();
+#endif /* !UNIV_HOTBACKUP */
mutex_enter(&(recv_sys->mutex));
@@ -700,14 +710,14 @@ recv_find_max_checkpoint(
group->state = LOG_GROUP_OK;
- group->lsn = mach_read_ull(
+ group->lsn = mach_read_from_8(
buf + LOG_CHECKPOINT_LSN);
#ifdef UNIV_LOG_ARCHIVE
#error "UNIV_LOG_ARCHIVE could not be enabled"
#endif
{
- ib_uint64_t tmp_lsn_offset = mach_read_ull(
+ ib_uint64_t tmp_lsn_offset = mach_read_from_8(
buf + LOG_CHECKPOINT_ARCHIVED_LSN);
if (sizeof(ulint) != 4
&& tmp_lsn_offset != IB_ULONGLONG_MAX) {
@@ -718,7 +728,7 @@ recv_find_max_checkpoint(
}
}
- checkpoint_no = mach_read_ull(
+ checkpoint_no = mach_read_from_8(
buf + LOG_CHECKPOINT_NO);
#ifdef UNIV_DEBUG
@@ -788,14 +798,14 @@ recv_read_cp_info_for_backup(
cp_buf = hdr + LOG_CHECKPOINT_1;
if (recv_check_cp_is_consistent(cp_buf)) {
- max_cp_no = mach_read_ull(cp_buf + LOG_CHECKPOINT_NO);
+ max_cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO);
max_cp = LOG_CHECKPOINT_1;
}
cp_buf = hdr + LOG_CHECKPOINT_2;
if (recv_check_cp_is_consistent(cp_buf)) {
- if (mach_read_ull(cp_buf + LOG_CHECKPOINT_NO) > max_cp_no) {
+ if (mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO) > max_cp_no) {
max_cp = LOG_CHECKPOINT_2;
}
}
@@ -806,7 +816,7 @@ recv_read_cp_info_for_backup(
cp_buf = hdr + max_cp;
- *lsn = mach_read_ull(cp_buf + LOG_CHECKPOINT_LSN);
+ *lsn = mach_read_from_8(cp_buf + LOG_CHECKPOINT_LSN);
*offset = mach_read_from_4(cp_buf + LOG_CHECKPOINT_OFFSET);
/* If the user is running a pre-3.23.50 version of InnoDB, its
@@ -826,9 +836,9 @@ recv_read_cp_info_for_backup(
/* fprintf(stderr, "fsp limit %lu MB\n", *fsp_limit); */
- *cp_no = mach_read_ull(cp_buf + LOG_CHECKPOINT_NO);
+ *cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO);
- *first_header_lsn = mach_read_ull(hdr + LOG_FILE_START_LSN);
+ *first_header_lsn = mach_read_from_8(hdr + LOG_FILE_START_LSN);
return(TRUE);
}
@@ -1567,7 +1577,7 @@ recv_recover_page_func(
#endif /* !UNIV_HOTBACKUP */
/* Read the newest modification lsn from the page */
- page_lsn = mach_read_ull(page + FIL_PAGE_LSN);
+ page_lsn = mach_read_from_8(page + FIL_PAGE_LSN);
page_lsn_orig = page_lsn;
#ifndef UNIV_HOTBACKUP
@@ -1665,14 +1675,14 @@ recv_recover_page_func(
}
end_lsn = recv->start_lsn + recv->len;
- mach_write_ull(FIL_PAGE_LSN + page, end_lsn);
- mach_write_ull(UNIV_PAGE_SIZE
- - FIL_PAGE_END_LSN_OLD_CHKSUM
- + page, end_lsn);
+ mach_write_to_8(FIL_PAGE_LSN + page, end_lsn);
+ mach_write_to_8(UNIV_PAGE_SIZE
+ - FIL_PAGE_END_LSN_OLD_CHKSUM
+ + page, end_lsn);
if (page_zip) {
- mach_write_ull(FIL_PAGE_LSN
- + page_zip->data, end_lsn);
+ mach_write_to_8(FIL_PAGE_LSN
+ + page_zip->data, end_lsn);
}
}
@@ -1710,7 +1720,9 @@ recv_recover_page_func(
if (modification_to_page) {
ut_a(block);
+ log_flush_order_mutex_enter();
buf_flush_recv_note_modification(block, start_lsn, end_lsn);
+ log_flush_order_mutex_exit();
}
#endif /* !UNIV_HOTBACKUP */
@@ -1902,11 +1914,10 @@ loop:
mutex_exit(&(recv_sys->mutex));
mutex_exit(&(log_sys->mutex));
- n_pages = buf_flush_batch(BUF_FLUSH_LIST, ULINT_MAX,
- IB_ULONGLONG_MAX);
- ut_a(n_pages != ULINT_UNDEFINED);
-
- buf_flush_wait_batch_end(BUF_FLUSH_LIST);
+ n_pages = buf_flush_list(ULINT_MAX, IB_ULONGLONG_MAX);
+ ut_a(n_pages != ULINT_UNDEFINED);
+
+ buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST);
buf_pool_invalidate();
@@ -2050,7 +2061,7 @@ recv_apply_log_recs_for_backup(void)
buf_flush_init_for_writing(
block->frame, buf_block_get_page_zip(block),
- mach_read_ull(block->frame + FIL_PAGE_LSN));
+ mach_read_from_8(block->frame + FIL_PAGE_LSN));
if (zip_size) {
error = fil_io(OS_FILE_WRITE, TRUE,
@@ -2820,8 +2831,8 @@ recv_scan_log_recs(
recv_parse_log_recs(store_to_hash);
#ifndef UNIV_HOTBACKUP
- if (store_to_hash && mem_heap_get_size(recv_sys->heap)
- > available_memory) {
+ if (store_to_hash
+ && mem_heap_get_size(recv_sys->heap) > available_memory) {
/* Hash table of log records has grown too big:
empty it; FALSE means no ibuf operations
@@ -2873,8 +2884,10 @@ recv_group_scan_log_recs(
group, start_lsn, end_lsn);
finished = recv_scan_log_recs(
- (buf_pool->curr_size - recv_n_pool_free_frames)
- * UNIV_PAGE_SIZE, TRUE, log_sys->buf, RECV_SCAN_SIZE,
+ (buf_pool_get_n_pages()
+ - (recv_n_pool_free_frames * srv_buf_pool_instances))
+ * UNIV_PAGE_SIZE,
+ TRUE, log_sys->buf, RECV_SCAN_SIZE,
start_lsn, contiguous_lsn, group_scanned_lsn);
start_lsn = end_lsn;
}
@@ -2899,7 +2912,6 @@ recv_init_crash_recovery(void)
/*==========================*/
{
ut_a(!recv_needed_recovery);
- ut_a(!srv_buffer_pool_shm_is_reused);
recv_needed_recovery = TRUE;
@@ -3021,10 +3033,10 @@ recv_recovery_from_checkpoint_start_func(
buf = log_sys->checkpoint_buf;
- checkpoint_lsn = mach_read_ull(buf + LOG_CHECKPOINT_LSN);
- checkpoint_no = mach_read_ull(buf + LOG_CHECKPOINT_NO);
+ checkpoint_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN);
+ checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO);
#ifdef UNIV_LOG_ARCHIVE
- archived_lsn = mach_read_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN);
+ archived_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN);
#endif /* UNIV_LOG_ARCHIVE */
/* Read the first log file header to print a note if this is
@@ -3068,7 +3080,8 @@ recv_recovery_from_checkpoint_start_func(
if (log_hdr_log_block_size != srv_log_block_size) {
fprintf(stderr,
"InnoDB: Error: The block size of ib_logfile (%lu) "
- "is not equal to innodb_log_block_size.\n",
+ "is not equal to innodb_log_block_size.\n"
+ "InnoDB: Error: Suggestion - Recreate log files.\n",
log_hdr_log_block_size);
return(DB_ERROR);
}
@@ -3346,10 +3359,11 @@ recv_recovery_from_checkpoint_finish(void)
#endif /* UNIV_DEBUG */
if (recv_needed_recovery && srv_recovery_stats) {
+ ulint flush_list_len = 0;
ulint i;
fprintf(stderr,
- "InnoDB: Applying log records was done. Its statistics are followings.\n");
+ "InnoDB: Log records have been applied. The statistics that were gathered follow.\n");
fprintf(stderr,
"============================================================\n"
@@ -3361,6 +3375,12 @@ recv_recovery_from_checkpoint_finish(void)
difftime(time(NULL), recv_sys->stats_recv_start_time),
recv_sys->stats_recv_turns);
+ for (i = 0; i < srv_buf_pool_instances; i++) {
+ buf_pool_t* buf_pool;
+
+ buf_pool = buf_pool_from_array(i);
+ flush_list_len += UT_LIST_GET_LEN(buf_pool->flush_list);
+ }
fprintf(stderr,
"\n"
"Data page IO statistics\n"
@@ -3371,7 +3391,7 @@ recv_recovery_from_checkpoint_finish(void)
recv_sys->stats_read_requested_pages,
recv_sys->stats_read_io_pages,
recv_sys->stats_write_io_pages,
- UT_LIST_GET_LEN(buf_pool->flush_list));
+ flush_list_len);
fprintf(stderr,
" Grouping IO [times]:\n"
@@ -3594,8 +3614,10 @@ recv_reset_log_files_for_backup(
sprintf(name, "%s%s%lu", log_dir,
ib_logfile_basename, (ulong)i);
- log_file = os_file_create_simple(name, OS_FILE_CREATE,
- OS_FILE_READ_WRITE, &success);
+ log_file = os_file_create_simple(innodb_file_log_key,
+ name, OS_FILE_CREATE,
+ OS_FILE_READ_WRITE,
+ &success);
if (!success) {
fprintf(stderr,
"InnoDB: Cannot create %s. Check that"
@@ -3634,7 +3656,8 @@ recv_reset_log_files_for_backup(
LOG_BLOCK_HDR_SIZE);
sprintf(name, "%s%s%lu", log_dir, ib_logfile_basename, (ulong)0);
- log_file = os_file_create_simple(name, OS_FILE_OPEN,
+ log_file = os_file_create_simple(innodb_file_log_key,
+ name, OS_FILE_OPEN,
OS_FILE_READ_WRITE, &success);
if (!success) {
fprintf(stderr, "InnoDB: Cannot open %s.\n", name);
@@ -3652,6 +3675,7 @@ recv_reset_log_files_for_backup(
#endif /* UNIV_HOTBACKUP */
#ifdef UNIV_LOG_ARCHIVE
+/* Dead code */
/******************************************************//**
Reads from the archive of a log group and performs recovery.
@return TRUE if no more complete consistent archive files */
@@ -3684,7 +3708,8 @@ try_open_again:
log_archived_file_name_gen(name, group->id, group->archived_file_no);
- file_handle = os_file_create(name, OS_FILE_OPEN,
+ file_handle = os_file_create(innodb_file_log_key,
+ name, OS_FILE_OPEN,
OS_FILE_LOG, OS_FILE_AIO, &ret);
if (ret == FALSE) {
@@ -3761,8 +3786,8 @@ ask_again:
return(TRUE);
}
- start_lsn = mach_read_ull(buf + LOG_FILE_START_LSN);
- file_end_lsn = mach_read_ull(buf + LOG_FILE_END_LSN);
+ start_lsn = mach_read_from_8(buf + LOG_FILE_START_LSN);
+ file_end_lsn = mach_read_from_8(buf + LOG_FILE_END_LSN);
if (!recv_sys->scanned_lsn) {
@@ -3816,7 +3841,8 @@ ask_again:
read_offset % UNIV_PAGE_SIZE, len, buf, NULL);
ret = recv_scan_log_recs(
- (buf_pool->n_frames - recv_n_pool_free_frames)
+ (buf_pool_get_n_pages()
+ - (recv_n_pool_free_frames * srv_buf_pool_instances))
* UNIV_PAGE_SIZE, TRUE, buf, len, start_lsn,
&dummy_lsn, &scanned_lsn);