summaryrefslogtreecommitdiff
path: root/storage/xtradb/log/log0log.c
diff options
context:
space:
mode:
Diffstat (limited to 'storage/xtradb/log/log0log.c')
-rw-r--r--storage/xtradb/log/log0log.c444
1 files changed, 237 insertions, 207 deletions
diff --git a/storage/xtradb/log/log0log.c b/storage/xtradb/log/log0log.c
index a41b02c32fa..3a89f540b77 100644
--- a/storage/xtradb/log/log0log.c
+++ b/storage/xtradb/log/log0log.c
@@ -15,8 +15,33 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2009, Google Inc.
-/******************************************************
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+*****************************************************************************/
+
+/**************************************************//**
+@file log/log0log.c
Database log
Created 12/9/1995 Heikki Tuuri
@@ -28,6 +53,7 @@ Created 12/9/1995 Heikki Tuuri
#include "log0log.ic"
#endif
+#ifndef UNIV_HOTBACKUP
#include "mem0mem.h"
#include "buf0buf.h"
#include "buf0flu.h"
@@ -75,8 +101,6 @@ UNIV_INTERN log_t* log_sys = NULL;
#ifdef UNIV_DEBUG
UNIV_INTERN ibool log_do_write = TRUE;
-
-UNIV_INTERN ibool log_debug_writes = FALSE;
#endif /* UNIV_DEBUG */
/* These control how often we print warnings if the last checkpoint is too
@@ -129,14 +153,14 @@ the previous */
#define LOG_ARCHIVE_READ 1
#define LOG_ARCHIVE_WRITE 2
-/**********************************************************
+/******************************************************//**
Completes a checkpoint write i/o to a log file. */
static
void
log_io_complete_checkpoint(void);
/*============================*/
#ifdef UNIV_LOG_ARCHIVE
-/**********************************************************
+/******************************************************//**
Completes an archiving i/o. */
static
void
@@ -144,7 +168,7 @@ log_io_complete_archive(void);
/*=========================*/
#endif /* UNIV_LOG_ARCHIVE */
-/********************************************************************
+/****************************************************************//**
Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint,
so that we know that the limit has been written to a log checkpoint field
on disk. */
@@ -152,7 +176,7 @@ UNIV_INTERN
void
log_fsp_current_free_limit_set_and_checkpoint(
/*==========================================*/
- ulint limit) /* in: limit to set */
+ ulint limit) /*!< in: limit to set */
{
ibool success;
@@ -171,9 +195,10 @@ log_fsp_current_free_limit_set_and_checkpoint(
}
}
-/********************************************************************
+/****************************************************************//**
Returns the oldest modified block lsn in the pool, or log_sys->lsn if none
-exists. */
+exists.
+@return LSN of oldest modification */
static
ib_uint64_t
log_buf_pool_get_oldest_modification(void)
@@ -193,15 +218,15 @@ log_buf_pool_get_oldest_modification(void)
return(lsn);
}
-/****************************************************************
+/************************************************************//**
Opens the log for log_write_low. The log must be closed with log_close and
-released with log_release. */
+released with log_release.
+@return start lsn of the log record */
UNIV_INTERN
ib_uint64_t
log_reserve_and_open(
/*=================*/
- /* out: start lsn of the log record */
- ulint len) /* in: length of data to be catenated */
+ ulint len) /*!< in: length of data to be catenated */
{
log_t* log = log_sys;
ulint len_upper_limit;
@@ -267,15 +292,15 @@ loop:
return(log->lsn);
}
-/****************************************************************
+/************************************************************//**
Writes to the log the string given. It is assumed that the caller holds the
log mutex. */
UNIV_INTERN
void
log_write_low(
/*==========*/
- byte* str, /* in: string */
- ulint str_len) /* in: string length */
+ byte* str, /*!< in: string */
+ ulint str_len) /*!< in: string length */
{
log_t* log = log_sys;
ulint len;
@@ -336,13 +361,13 @@ part_loop:
srv_log_write_requests++;
}
-/****************************************************************
-Closes the log. */
+/************************************************************//**
+Closes the log.
+@return lsn */
UNIV_INTERN
ib_uint64_t
log_close(void)
/*===========*/
- /* out: lsn */
{
byte* log_block;
ulint first_rec_group;
@@ -428,7 +453,7 @@ function_exit:
}
#ifdef UNIV_LOG_ARCHIVE
-/**********************************************************
+/******************************************************//**
Pads the current log block full with dummy log records. Used in producing
consistent archived log files. */
static
@@ -461,47 +486,49 @@ log_pad_current_log_block(void)
}
#endif /* UNIV_LOG_ARCHIVE */
-/**********************************************************
+/******************************************************//**
Calculates the data capacity of a log group, when the log file headers are not
-included. */
+included.
+@return capacity in bytes */
UNIV_INTERN
ulint
log_group_get_capacity(
/*===================*/
- /* out: capacity in bytes */
- log_group_t* group) /* in: log group */
+ const log_group_t* group) /*!< in: log group */
{
ut_ad(mutex_own(&(log_sys->mutex)));
return((group->file_size - LOG_FILE_HDR_SIZE) * group->n_files);
}
-/**********************************************************
+/******************************************************//**
Calculates the offset within a log group, when the log file headers are not
-included. */
+included.
+@return size offset (<= offset) */
UNIV_INLINE
ulint
log_group_calc_size_offset(
/*=======================*/
- /* out: size offset (<= offset) */
- ulint offset, /* in: real offset within the log group */
- log_group_t* group) /* in: log group */
+ ulint offset, /*!< in: real offset within the
+ log group */
+ const log_group_t* group) /*!< in: log group */
{
ut_ad(mutex_own(&(log_sys->mutex)));
return(offset - LOG_FILE_HDR_SIZE * (1 + offset / group->file_size));
}
-/**********************************************************
+/******************************************************//**
Calculates the offset within a log group, when the log file headers are
-included. */
+included.
+@return real offset (>= offset) */
UNIV_INLINE
ulint
log_group_calc_real_offset(
/*=======================*/
- /* out: real offset (>= offset) */
- ulint offset, /* in: size offset within the log group */
- log_group_t* group) /* in: log group */
+ ulint offset, /*!< in: size offset within the
+ log group */
+ const log_group_t* group) /*!< in: log group */
{
ut_ad(mutex_own(&(log_sys->mutex)));
@@ -509,16 +536,16 @@ log_group_calc_real_offset(
* (1 + offset / (group->file_size - LOG_FILE_HDR_SIZE)));
}
-/**********************************************************
-Calculates the offset of an lsn within a log group. */
+/******************************************************//**
+Calculates the offset of an lsn within a log group.
+@return offset within the log group */
static
ulint
log_group_calc_lsn_offset(
/*======================*/
- /* out: offset within the log group */
- ib_uint64_t lsn, /* in: lsn, must be within 4 GB of
- group->lsn */
- log_group_t* group) /* in: log group */
+ ib_uint64_t lsn, /*!< in: lsn, must be within 4 GB of
+ group->lsn */
+ const log_group_t* group) /*!< in: log group */
{
ib_uint64_t gr_lsn;
ib_int64_t gr_lsn_size_offset;
@@ -560,23 +587,28 @@ log_group_calc_lsn_offset(
return(log_group_calc_real_offset((ulint)offset, group));
}
+#endif /* !UNIV_HOTBACKUP */
+
+#ifdef UNIV_DEBUG
+UNIV_INTERN ibool log_debug_writes = FALSE;
+#endif /* UNIV_DEBUG */
-/***********************************************************************
-Calculates where in log files we find a specified lsn. */
+/*******************************************************************//**
+Calculates where in log files we find a specified lsn.
+@return log file number */
UNIV_INTERN
ulint
log_calc_where_lsn_is(
/*==================*/
- /* out: log file number */
- ib_int64_t* log_file_offset, /* out: offset in that file
+ ib_int64_t* log_file_offset, /*!< out: offset in that file
(including the header) */
- ib_uint64_t first_header_lsn, /* in: first log file start
+ ib_uint64_t first_header_lsn, /*!< in: first log file start
lsn */
- ib_uint64_t lsn, /* in: lsn whose position to
+ ib_uint64_t lsn, /*!< in: lsn whose position to
determine */
- ulint n_log_files, /* in: total number of log
+ ulint n_log_files, /*!< in: total number of log
files */
- ib_int64_t log_file_size) /* in: log file size
+ ib_int64_t log_file_size) /*!< in: log file size
(including the header) */
{
ib_int64_t capacity = log_file_size - LOG_FILE_HDR_SIZE;
@@ -601,7 +633,8 @@ log_calc_where_lsn_is(
return(file_no);
}
-/************************************************************
+#ifndef UNIV_HOTBACKUP
+/********************************************************//**
Sets the field values in group to correspond to a given lsn. For this function
to work, the values must already be correctly initialized to correspond to
some lsn, for instance, a checkpoint lsn. */
@@ -609,24 +642,23 @@ UNIV_INTERN
void
log_group_set_fields(
/*=================*/
- log_group_t* group, /* in: group */
- ib_uint64_t lsn) /* in: lsn for which the values should be
+ log_group_t* group, /*!< in/out: group */
+ ib_uint64_t lsn) /*!< in: lsn for which the values should be
set */
{
group->lsn_offset = log_group_calc_lsn_offset(lsn, group);
group->lsn = lsn;
}
-/*********************************************************************
+/*****************************************************************//**
Calculates the recommended highest values for lsn - last_checkpoint_lsn,
-lsn - buf_get_oldest_modification(), and lsn - max_archive_lsn_age. */
+lsn - buf_get_oldest_modification(), and lsn - max_archive_lsn_age.
+@return error value FALSE if the smallest log group is too small to
+accommodate the number of OS threads in the database server */
static
ibool
log_calc_max_ages(void)
/*===================*/
- /* out: error value FALSE if the smallest log group is
- too small to accommodate the number of OS threads in
- the database server */
{
log_group_t* group;
ulint margin;
@@ -720,8 +752,7 @@ failure:
" After an ERROR-FREE shutdown\n"
"InnoDB: of mysqld you can adjust the size of"
" ib_logfiles, as explained in\n"
- "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
- "adding-and-removing.html\n"
+ "InnoDB: " REFMAN "adding-and-removing.html\n"
"InnoDB: Cannot continue operation."
" Calling exit(1).\n",
(ulong)srv_thread_concurrency);
@@ -732,7 +763,7 @@ failure:
return(success);
}
-/**********************************************************
+/******************************************************//**
Initializes the log. */
UNIV_INTERN
void
@@ -842,7 +873,7 @@ log_init(void)
#ifdef UNIV_LOG_DEBUG
recv_sys_create();
- recv_sys_init(FALSE, buf_pool_get_curr_size());
+ recv_sys_init(buf_pool_get_curr_size());
recv_sys->parse_start_lsn = log_sys->lsn;
recv_sys->scanned_lsn = log_sys->lsn;
@@ -852,20 +883,20 @@ log_init(void)
#endif
}
-/**********************************************************************
+/******************************************************************//**
Inits a log group to the log system. */
UNIV_INTERN
void
log_group_init(
/*===========*/
- ulint id, /* in: group id */
- ulint n_files, /* in: number of log files */
- ulint file_size, /* in: log file size in bytes */
- ulint space_id, /* in: space id of the file space
+ ulint id, /*!< in: group id */
+ ulint n_files, /*!< in: number of log files */
+ ulint file_size, /*!< in: log file size in bytes */
+ ulint space_id, /*!< in: space id of the file space
which contains the log files of this
group */
ulint archive_space_id __attribute__((unused)))
- /* in: space id of the file space
+ /*!< in: space id of the file space
which contains some archived log
files for this group; currently, only
for the first log group this is
@@ -925,13 +956,13 @@ log_group_init(
ut_a(log_calc_max_ages());
}
-/**********************************************************************
+/******************************************************************//**
Does the unlockings needed in flush i/o completion. */
UNIV_INLINE
void
log_flush_do_unlocks(
/*=================*/
- ulint code) /* in: any ORed combination of LOG_UNLOCK_FLUSH_LOCK
+ ulint code) /*!< in: any ORed combination of LOG_UNLOCK_FLUSH_LOCK
and LOG_UNLOCK_NONE_FLUSHED_LOCK */
{
ut_ad(mutex_own(&(log_sys->mutex)));
@@ -956,15 +987,15 @@ log_flush_do_unlocks(
}
}
-/**********************************************************************
+/******************************************************************//**
Checks if a flush is completed for a log group and does the completion
-routine if yes. */
+routine if yes.
+@return LOG_UNLOCK_NONE_FLUSHED_LOCK or 0 */
UNIV_INLINE
ulint
log_group_check_flush_completion(
/*=============================*/
- /* out: LOG_UNLOCK_NONE_FLUSHED_LOCK or 0 */
- log_group_t* group) /* in: log group */
+ log_group_t* group) /*!< in: log group */
{
ut_ad(mutex_own(&(log_sys->mutex)));
@@ -992,13 +1023,13 @@ log_group_check_flush_completion(
return(0);
}
-/**********************************************************
-Checks if a flush is completed and does the completion routine if yes. */
+/******************************************************//**
+Checks if a flush is completed and does the completion routine if yes.
+@return LOG_UNLOCK_FLUSH_LOCK or 0 */
static
ulint
log_sys_check_flush_completion(void)
/*================================*/
- /* out: LOG_UNLOCK_FLUSH_LOCK or 0 */
{
ulint move_start;
ulint move_end;
@@ -1033,13 +1064,13 @@ log_sys_check_flush_completion(void)
return(0);
}
-/**********************************************************
+/******************************************************//**
Completes an i/o to a log file. */
UNIV_INTERN
void
log_io_complete(
/*============*/
- log_group_t* group) /* in: log group or a dummy pointer */
+ log_group_t* group) /*!< in: log group or a dummy pointer */
{
ulint unlock;
@@ -1075,7 +1106,7 @@ log_io_complete(
return;
}
- ut_error; /* We currently use synchronous writing of the
+ ut_error; /*!< We currently use synchronous writing of the
logs and cannot end up here! */
if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
@@ -1101,16 +1132,16 @@ log_io_complete(
mutex_exit(&(log_sys->mutex));
}
-/**********************************************************
+/******************************************************//**
Writes a log file header to a log file space. */
static
void
log_group_file_header_flush(
/*========================*/
- log_group_t* group, /* in: log group */
- ulint nth_file, /* in: header to the nth file in the
+ log_group_t* group, /*!< in: log group */
+ ulint nth_file, /*!< in: header to the nth file in the
log file space */
- ib_uint64_t start_lsn) /* in: log file data starts at this
+ ib_uint64_t start_lsn) /*!< in: log file data starts at this
lsn */
{
byte* buf;
@@ -1151,7 +1182,7 @@ log_group_file_header_flush(
}
}
-/**********************************************************
+/******************************************************//**
Stores a 4-byte checksum to the trailer checksum field of a log block
before writing it to a log file. This checksum is used in recovery to
check the consistency of a log block. */
@@ -1159,25 +1190,25 @@ static
void
log_block_store_checksum(
/*=====================*/
- byte* block) /* in/out: pointer to a log block */
+ byte* block) /*!< in/out: pointer to a log block */
{
log_block_set_checksum(block, log_block_calc_checksum(block));
}
-/**********************************************************
+/******************************************************//**
Writes a buffer to a log file group. */
UNIV_INTERN
void
log_group_write_buf(
/*================*/
- log_group_t* group, /* in: log group */
- byte* buf, /* in: buffer */
- ulint len, /* in: buffer len; must be divisible
+ log_group_t* group, /*!< in: log group */
+ byte* buf, /*!< in: buffer */
+ ulint len, /*!< in: buffer len; must be divisible
by OS_FILE_LOG_BLOCK_SIZE */
- ib_uint64_t start_lsn, /* in: start lsn of the buffer; must
+ ib_uint64_t start_lsn, /*!< in: start lsn of the buffer; must
be divisible by
OS_FILE_LOG_BLOCK_SIZE */
- ulint new_data_offset)/* in: start offset of new data in
+ ulint new_data_offset)/*!< in: start offset of new data in
buf: this parameter is used to decide
if we have to write a new log file
header */
@@ -1281,7 +1312,7 @@ loop:
}
}
-/**********************************************************
+/******************************************************//**
This function is called, e.g., when a transaction wants to commit. It checks
that the log has been written to the log file up to the last log entry written
by the transaction. If there is a flush running, it waits and checks if the
@@ -1290,13 +1321,13 @@ UNIV_INTERN
void
log_write_up_to(
/*============*/
- ib_uint64_t lsn, /* in: log sequence number up to which
+ ib_uint64_t lsn, /*!< in: log sequence number up to which
the log should be written,
IB_ULONGLONG_MAX if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
+ ulint wait, /*!< in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
or LOG_WAIT_ALL_GROUPS */
ibool flush_to_disk)
- /* in: TRUE if we want the written log
+ /*!< in: TRUE if we want the written log
also to be flushed to disk */
{
log_group_t* group;
@@ -1398,7 +1429,7 @@ loop:
log_sys->n_pending_writes++;
group = UT_LIST_GET_FIRST(log_sys->log_groups);
- group->n_pending_writes++; /* We assume here that we have only
+ group->n_pending_writes++; /*!< We assume here that we have only
one log group! */
os_event_reset(log_sys->no_flush_event);
@@ -1507,7 +1538,7 @@ do_waits:
}
}
-/********************************************************************
+/****************************************************************//**
Does a syncronous flush of the log buffer to disk. */
UNIV_INTERN
void
@@ -1525,13 +1556,16 @@ log_buffer_flush_to_disk(void)
log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE);
}
-/********************************************************************
-Flush the log buffer. Force it to disk depending on the value of
-innodb_flush_log_at_trx_commit. */
+/****************************************************************//**
+This functions writes the log buffer to the log file and if 'flush'
+is set it forces a flush of the log file as well. This is meant to be
+called from background master thread only as it does not wait for
+the write (+ possible flush) to finish. */
UNIV_INTERN
void
-log_buffer_flush_maybe_sync(void)
-/*=============================*/
+log_buffer_sync_in_background(
+/*==========================*/
+ ibool flush) /*!< in: flush the logs to disk */
{
ib_uint64_t lsn;
@@ -1541,11 +1575,11 @@ log_buffer_flush_maybe_sync(void)
mutex_exit(&(log_sys->mutex));
- /* Force log buffer to disk when innodb_flush_log_at_trx_commit = 1. */
- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS,
- srv_flush_log_at_trx_commit == 1 ? TRUE : FALSE);
+ log_write_up_to(lsn, LOG_NO_WAIT, flush);
}
+
/********************************************************************
+
Tries to establish a big enough margin of free space in the log buffer, such
that a new log entry can be catenated without an immediate need for a flush. */
static
@@ -1575,23 +1609,20 @@ log_flush_margin(void)
}
}
-/********************************************************************
+/****************************************************************//**
Advances the smallest lsn for which there are unflushed dirty blocks in the
buffer pool. NOTE: this function may only be called if the calling thread owns
-no synchronization objects! */
+no synchronization objects!
+@return FALSE if there was a flush batch of the same type running,
+which means that we could not start this flush batch */
UNIV_INTERN
ibool
log_preflush_pool_modified_pages(
/*=============================*/
- /* out: FALSE if there was a
- flush batch of the same type
- running, which means that we
- could not start this flush
- batch */
- ib_uint64_t new_oldest, /* in: try to advance
+ ib_uint64_t new_oldest, /*!< in: try to advance
oldest_modified_lsn at least
to this lsn */
- ibool sync) /* in: TRUE if synchronous
+ ibool sync) /*!< in: TRUE if synchronous
operation is desired */
{
ulint n_pages;
@@ -1623,7 +1654,7 @@ log_preflush_pool_modified_pages(
return(TRUE);
}
-/**********************************************************
+/******************************************************//**
Completes a checkpoint. */
static
void
@@ -1640,7 +1671,7 @@ log_complete_checkpoint(void)
rw_lock_x_unlock_gen(&(log_sys->checkpoint_lock), LOG_CHECKPOINT);
}
-/**********************************************************
+/******************************************************//**
Completes an asynchronous checkpoint info write i/o to a log file. */
static
void
@@ -1660,16 +1691,16 @@ log_io_complete_checkpoint(void)
mutex_exit(&(log_sys->mutex));
}
-/***********************************************************************
+/*******************************************************************//**
Writes info to a checkpoint about a log group. */
static
void
log_checkpoint_set_nth_group_info(
/*==============================*/
- byte* buf, /* in: buffer for checkpoint info */
- ulint n, /* in: nth slot */
- ulint file_no,/* in: archived file number */
- ulint offset) /* in: archived file offset */
+ byte* buf, /*!< in: buffer for checkpoint info */
+ ulint n, /*!< in: nth slot */
+ ulint file_no,/*!< in: archived file number */
+ ulint offset) /*!< in: archived file offset */
{
ut_ad(n < LOG_MAX_N_GROUPS);
@@ -1679,16 +1710,16 @@ log_checkpoint_set_nth_group_info(
+ 8 * n + LOG_CHECKPOINT_ARCHIVED_OFFSET, offset);
}
-/***********************************************************************
+/*******************************************************************//**
Gets info from a checkpoint about a log group. */
UNIV_INTERN
void
log_checkpoint_get_nth_group_info(
/*==============================*/
- byte* buf, /* in: buffer containing checkpoint info */
- ulint n, /* in: nth slot */
- ulint* file_no,/* out: archived file number */
- ulint* offset) /* out: archived file offset */
+ const byte* buf, /*!< in: buffer containing checkpoint info */
+ ulint n, /*!< in: nth slot */
+ ulint* file_no,/*!< out: archived file number */
+ ulint* offset) /*!< out: archived file offset */
{
ut_ad(n < LOG_MAX_N_GROUPS);
@@ -1698,13 +1729,13 @@ log_checkpoint_get_nth_group_info(
+ 8 * n + LOG_CHECKPOINT_ARCHIVED_OFFSET);
}
-/**********************************************************
+/******************************************************//**
Writes the checkpoint info to a log group header. */
static
void
log_group_checkpoint(
/*=================*/
- log_group_t* group) /* in: log group */
+ log_group_t* group) /*!< in: log group */
{
log_group_t* group2;
#ifdef UNIV_LOG_ARCHIVE
@@ -1817,18 +1848,19 @@ log_group_checkpoint(
ut_ad(((ulint)group & 0x1UL) == 0);
}
}
+#endif /* !UNIV_HOTBACKUP */
#ifdef UNIV_HOTBACKUP
-/**********************************************************
+/******************************************************//**
Writes info to a buffer of a log group when log files are created in
backup restoration. */
UNIV_INTERN
void
log_reset_first_header_and_checkpoint(
/*==================================*/
- byte* hdr_buf,/* in: buffer which will be written to the
+ byte* hdr_buf,/*!< in: buffer which will be written to the
start of the first log file */
- ib_uint64_t start) /* in: lsn of the start of the first log file;
+ ib_uint64_t start) /*!< in: lsn of the start of the first log file;
we pretend that there is a checkpoint at
start + LOG_BLOCK_HDR_SIZE */
{
@@ -1872,14 +1904,15 @@ log_reset_first_header_and_checkpoint(
}
#endif /* UNIV_HOTBACKUP */
-/**********************************************************
+#ifndef UNIV_HOTBACKUP
+/******************************************************//**
Reads a checkpoint info from a log group header to log_sys->checkpoint_buf. */
UNIV_INTERN
void
log_group_read_checkpoint_info(
/*===========================*/
- log_group_t* group, /* in: log group */
- ulint field) /* in: LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2 */
+ log_group_t* group, /*!< in: log group */
+ ulint field) /*!< in: LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2 */
{
ut_ad(mutex_own(&(log_sys->mutex)));
@@ -1890,7 +1923,7 @@ log_group_read_checkpoint_info(
OS_FILE_LOG_BLOCK_SIZE, log_sys->checkpoint_buf, NULL);
}
-/**********************************************************
+/******************************************************//**
Writes checkpoint info to groups. */
UNIV_INTERN
void
@@ -1910,20 +1943,19 @@ log_groups_write_checkpoint_info(void)
}
}
-/**********************************************************
+/******************************************************//**
Makes a checkpoint. Note that this function does not flush dirty
blocks from the buffer pool: it only checks what is lsn of the oldest
modification in the pool, and writes information about the lsn in
-log files. Use log_make_checkpoint_at to flush also the pool. */
+log files. Use log_make_checkpoint_at to flush also the pool.
+@return TRUE if success, FALSE if a checkpoint write was already running */
UNIV_INTERN
ibool
log_checkpoint(
/*===========*/
- /* out: TRUE if success, FALSE if a checkpoint
- write was already running */
- ibool sync, /* in: TRUE if synchronous operation is
+ ibool sync, /*!< in: TRUE if synchronous operation is
desired */
- ibool write_always) /* in: the function normally checks if the
+ ibool write_always) /*!< in: the function normally checks if the
the new checkpoint would have a greater
lsn than the previous one: if not, then no
physical write is done; by setting this
@@ -2005,16 +2037,16 @@ log_checkpoint(
return(TRUE);
}
-/********************************************************************
+/****************************************************************//**
Makes a checkpoint at a given lsn or later. */
UNIV_INTERN
void
log_make_checkpoint_at(
/*===================*/
- ib_uint64_t lsn, /* in: make a checkpoint at this or a
+ ib_uint64_t lsn, /*!< in: make a checkpoint at this or a
later lsn, if IB_ULONGLONG_MAX, makes
a checkpoint at the latest lsn */
- ibool write_always) /* in: the function normally checks if
+ ibool write_always) /*!< in: the function normally checks if
the the new checkpoint would have a
greater lsn than the previous one: if
not, then no physical write is done;
@@ -2029,7 +2061,7 @@ log_make_checkpoint_at(
while (!log_checkpoint(TRUE, write_always));
}
-/********************************************************************
+/****************************************************************//**
Tries to establish a big enough margin of free space in the log groups, such
that a new log entry can be catenated without an immediate need for a
checkpoint. NOTE: this function may only be called if the calling thread
@@ -2131,17 +2163,17 @@ loop:
}
}
-/**********************************************************
+/******************************************************//**
Reads a specified log segment to a buffer. */
UNIV_INTERN
void
log_group_read_log_seg(
/*===================*/
- ulint type, /* in: LOG_ARCHIVE or LOG_RECOVER */
- byte* buf, /* in: buffer where to read */
- log_group_t* group, /* in: log group */
- ib_uint64_t start_lsn, /* in: read area start */
- ib_uint64_t end_lsn) /* in: read area end */
+ ulint type, /*!< in: LOG_ARCHIVE or LOG_RECOVER */
+ byte* buf, /*!< in: buffer where to read */
+ log_group_t* group, /*!< in: log group */
+ ib_uint64_t start_lsn, /*!< in: read area start */
+ ib_uint64_t end_lsn) /*!< in: read area end */
{
ulint len;
ulint source_offset;
@@ -2185,32 +2217,32 @@ loop:
}
#ifdef UNIV_LOG_ARCHIVE
-/**********************************************************
+/******************************************************//**
Generates an archived log file name. */
UNIV_INTERN
void
log_archived_file_name_gen(
/*=======================*/
- char* buf, /* in: buffer where to write */
+ char* buf, /*!< in: buffer where to write */
ulint id __attribute__((unused)),
- /* in: group id;
+ /*!< in: group id;
currently we only archive the first group */
- ulint file_no)/* in: file number */
+ ulint file_no)/*!< in: file number */
{
sprintf(buf, "%sib_arch_log_%010lu", srv_arch_dir, (ulong) file_no);
}
-/**********************************************************
+/******************************************************//**
Writes a log file header to a log file space. */
static
void
log_group_archive_file_header_write(
/*================================*/
- log_group_t* group, /* in: log group */
- ulint nth_file, /* in: header to the nth file in the
+ log_group_t* group, /*!< in: log group */
+ ulint nth_file, /*!< in: header to the nth file in the
archive log file space */
- ulint file_no, /* in: archived file number */
- ib_uint64_t start_lsn) /* in: log file data starts at this
+ ulint file_no, /*!< in: archived file number */
+ ib_uint64_t start_lsn) /*!< in: log file data starts at this
lsn */
{
byte* buf;
@@ -2239,16 +2271,16 @@ log_group_archive_file_header_write(
buf, &log_archive_io);
}
-/**********************************************************
+/******************************************************//**
Writes a log file header to a completed archived log file. */
static
void
log_group_archive_completed_header_write(
/*=====================================*/
- log_group_t* group, /* in: log group */
- ulint nth_file, /* in: header to the nth file in the
+ log_group_t* group, /*!< in: log group */
+ ulint nth_file, /*!< in: header to the nth file in the
archive log file space */
- ib_uint64_t end_lsn) /* in: end lsn of the file */
+ ib_uint64_t end_lsn) /*!< in: end lsn of the file */
{
byte* buf;
ulint dest_offset;
@@ -2273,13 +2305,13 @@ log_group_archive_completed_header_write(
&log_archive_io);
}
-/**********************************************************
+/******************************************************//**
Does the archive writes for a single log group. */
static
void
log_group_archive(
/*==============*/
- log_group_t* group) /* in: log group */
+ log_group_t* group) /*!< in: log group */
{
os_file_t file_handle;
ib_uint64_t start_lsn;
@@ -2414,7 +2446,7 @@ loop:
ut_a(group->next_archived_offset % OS_FILE_LOG_BLOCK_SIZE == 0);
}
-/*********************************************************
+/*****************************************************//**
(Writes to the archive of each log group.) Currently, only the first
group is archived. */
static
@@ -2431,7 +2463,7 @@ log_archive_groups(void)
log_group_archive(group);
}
-/*********************************************************
+/*****************************************************//**
Completes the archiving write phase for (each log group), currently,
the first log group. */
static
@@ -2505,7 +2537,7 @@ log_archive_write_complete_groups(void)
#endif /* UNIV_DEBUG */
}
-/**********************************************************
+/******************************************************//**
Completes an archiving i/o. */
static
void
@@ -2541,7 +2573,7 @@ log_archive_check_completion_low(void)
}
}
-/**********************************************************
+/******************************************************//**
Completes an archiving i/o. */
static
void
@@ -2569,16 +2601,15 @@ log_io_complete_archive(void)
mutex_exit(&(log_sys->mutex));
}
-/************************************************************************
-Starts an archiving operation. */
+/********************************************************************//**
+Starts an archiving operation.
+@return TRUE if succeed, FALSE if an archiving operation was already running */
UNIV_INTERN
ibool
log_archive_do(
/*===========*/
- /* out: TRUE if succeed, FALSE if an archiving
- operation was already running */
- ibool sync, /* in: TRUE if synchronous operation is desired */
- ulint* n_bytes)/* out: archive log buffer size, 0 if nothing to
+ ibool sync, /*!< in: TRUE if synchronous operation is desired */
+ ulint* n_bytes)/*!< out: archive log buffer size, 0 if nothing to
archive */
{
ibool calc_new_limit;
@@ -2684,7 +2715,7 @@ arch_none:
return(TRUE);
}
-/********************************************************************
+/****************************************************************//**
Writes the log contents to the archive at least up to the lsn when this
function was called. */
static
@@ -2725,14 +2756,14 @@ log_archive_all(void)
}
}
-/*********************************************************
+/*****************************************************//**
Closes the possible open archive log file (for each group) the first group,
and if it was open, increments the group file count by 2, if desired. */
static
void
log_archive_close_groups(
/*=====================*/
- ibool increment_file_count) /* in: TRUE if we want to increment
+ ibool increment_file_count) /*!< in: TRUE if we want to increment
the file count */
{
log_group_t* group;
@@ -2777,16 +2808,16 @@ log_archive_close_groups(
}
}
-/********************************************************************
+/****************************************************************//**
Writes the log contents to the archive up to the lsn when this function was
called, and stops the archiving. When archiving is started again, the archived
log file numbers start from 2 higher, so that the archiving will not write
-again to the archived log files which exist when this function returns. */
+again to the archived log files which exist when this function returns.
+@return DB_SUCCESS or DB_ERROR */
UNIV_INTERN
ulint
log_archive_stop(void)
/*==================*/
- /* out: DB_SUCCESS or DB_ERROR */
{
ibool success;
@@ -2844,13 +2875,13 @@ log_archive_stop(void)
return(DB_SUCCESS);
}
-/********************************************************************
-Starts again archiving which has been stopped. */
+/****************************************************************//**
+Starts again archiving which has been stopped.
+@return DB_SUCCESS or DB_ERROR */
UNIV_INTERN
ulint
log_archive_start(void)
/*===================*/
- /* out: DB_SUCCESS or DB_ERROR */
{
mutex_enter(&(log_sys->mutex));
@@ -2870,13 +2901,13 @@ log_archive_start(void)
return(DB_SUCCESS);
}
-/********************************************************************
-Stop archiving the log so that a gap may occur in the archived log files. */
+/****************************************************************//**
+Stop archiving the log so that a gap may occur in the archived log files.
+@return DB_SUCCESS or DB_ERROR */
UNIV_INTERN
ulint
log_archive_noarchivelog(void)
/*==========================*/
- /* out: DB_SUCCESS or DB_ERROR */
{
loop:
mutex_enter(&(log_sys->mutex));
@@ -2902,13 +2933,13 @@ loop:
goto loop;
}
-/********************************************************************
-Start archiving the log so that a gap may occur in the archived log files. */
+/****************************************************************//**
+Start archiving the log so that a gap may occur in the archived log files.
+@return DB_SUCCESS or DB_ERROR */
UNIV_INTERN
ulint
log_archive_archivelog(void)
/*========================*/
- /* out: DB_SUCCESS or DB_ERROR */
{
mutex_enter(&(log_sys->mutex));
@@ -2929,7 +2960,7 @@ log_archive_archivelog(void)
return(DB_ERROR);
}
-/********************************************************************
+/****************************************************************//**
Tries to establish a big enough margin of free space in the log groups, such
that a new log entry can be catenated without an immediate need for
archiving. */
@@ -2984,7 +3015,7 @@ loop:
}
#endif /* UNIV_LOG_ARCHIVE */
-/************************************************************************
+/********************************************************************//**
Checks that there is enough free space in the log to start a new query step.
Flushes the log buffer or makes a new checkpoint if necessary. NOTE: this
function may only be called if the calling thread owns no synchronization
@@ -3015,7 +3046,7 @@ loop:
mutex_exit(&(log_sys->mutex));
}
-/********************************************************************
+/****************************************************************//**
Makes a checkpoint at the latest lsn and writes it to first page of each
data file in the database, so that we know that the file spaces contain
all modifications up to that lsn. This can only be called at database
@@ -3203,18 +3234,18 @@ loop:
ut_a(lsn == log_sys->lsn);
}
-/**********************************************************
+/******************************************************//**
Checks by parsing that the catenated log segment for a single mtr is
consistent. */
UNIV_INTERN
ibool
log_check_log_recs(
/*===============*/
- byte* buf, /* in: pointer to the start of
+ byte* buf, /*!< in: pointer to the start of
the log segment in the
log_sys->buf log buffer */
- ulint len, /* in: segment length in bytes */
- ib_uint64_t buf_start_lsn) /* in: buffer start lsn */
+ ulint len, /*!< in: segment length in bytes */
+ ib_uint64_t buf_start_lsn) /*!< in: buffer start lsn */
{
ib_uint64_t contiguous_lsn;
ib_uint64_t scanned_lsn;
@@ -3238,8 +3269,7 @@ log_check_log_recs(
ut_memcpy(scan_buf, start, end - start);
- recv_scan_log_recs(TRUE,
- (buf_pool->curr_size
+ recv_scan_log_recs((buf_pool->curr_size
- recv_n_pool_free_frames) * UNIV_PAGE_SIZE,
FALSE, scan_buf, end - start,
ut_uint64_align_down(buf_start_lsn,
@@ -3254,15 +3284,14 @@ log_check_log_recs(
return(TRUE);
}
-/**********************************************************
-Peeks the current lsn. */
+/******************************************************//**
+Peeks the current lsn.
+@return TRUE if success, FALSE if could not get the log system mutex */
UNIV_INTERN
ibool
log_peek_lsn(
/*=========*/
- /* out: TRUE if success, FALSE if
- could not get the log system mutex */
- ib_uint64_t* lsn) /* out: if returns TRUE, current lsn is here */
+ ib_uint64_t* lsn) /*!< out: if returns TRUE, current lsn is here */
{
if (0 == mutex_enter_nowait(&(log_sys->mutex))) {
*lsn = log_sys->lsn;
@@ -3275,13 +3304,13 @@ log_peek_lsn(
return(FALSE);
}
-/**********************************************************
+/******************************************************//**
Prints info of the log. */
UNIV_INTERN
void
log_print(
/*======*/
- FILE* file) /* in: file where to print */
+ FILE* file) /*!< in: file where to print */
{
double time_elapsed;
time_t current_time;
@@ -3324,7 +3353,7 @@ log_print(
mutex_exit(&(log_sys->mutex));
}
-/**************************************************************************
+/**********************************************************************//**
Refreshes the statistics used to print per-second averages. */
UNIV_INTERN
void
@@ -3334,3 +3363,4 @@ log_refresh_stats(void)
log_sys->n_log_ios_old = log_sys->n_log_ios;
log_sys->last_printout_time = time(NULL);
}
+#endif /* !UNIV_HOTBACKUP */