Commit c08ea286 authored by marko's avatar marko

branches/zip: Merge revisions 4994:5148 from branches/5.1:

  ------------------------------------------------------------------------
  r5126 | vasil | 2009-05-26 16:57:12 +0300 (Tue, 26 May 2009) | 9 lines

  branches/5.1:

  Preparation for the fix of
  Bug#45097 Hang during recovery, redo logs for doublewrite buffer pages

  Non-functional change: move FSP_* macros from fsp0fsp.h to a new file
  fsp0types.h. This is needed in order to be able to use FSP_EXTENT_SIZE
  in mtr0log.ic.
  ------------------------------------------------------------------------
  r5127 | vasil | 2009-05-26 17:05:43 +0300 (Tue, 26 May 2009) | 9 lines

  branches/5.1:

  Preparation for the fix of
  Bug#45097 Hang during recovery, redo logs for doublewrite buffer pages

  Do not include unnecessary headers mtr0log.h and fut0lst.h in trx0sys.h
  and include fsp0fsp.h just before it is needed. This is needed in order
  to be able to use TRX_SYS_SPACE in mtr0log.ic.
  ------------------------------------------------------------------------
  r5128 | vasil | 2009-05-26 17:26:37 +0300 (Tue, 26 May 2009) | 7 lines

  branches/5.1:

  Fix Bug#45097 Hang during recovery, redo logs for doublewrite buffer pages

  Do not write redo log for the pages in the doublewrite buffer. Also, do not
  make a dummy change to the page because this is not needed.
  ------------------------------------------------------------------------
parent 57e9f00e
......@@ -49,6 +49,7 @@ Created 10/16/1994 Heikki Tuuri
#include "row0upd.h"
#ifndef UNIV_HOTBACKUP
#include "mtr0log.h"
#include "page0page.h"
#include "page0zip.h"
#include "rem0rec.h"
......
......@@ -32,37 +32,7 @@ Created 12/18/1995 Heikki Tuuri
#include "fut0lst.h"
#include "ut0byte.h"
#include "page0types.h"
/** If records are inserted in order, there are the following
flags to tell this (their type is made byte for the compiler
to warn if direction and hint parameters are switched in
fseg_alloc_free_page): */
/* @{ */
#define FSP_UP ((byte)111) /*!< alphabetically upwards */
#define FSP_DOWN ((byte)112) /*!< alphabetically downwards */
#define FSP_NO_DIR ((byte)113) /*!< no order */
/* @} */
/** File space extent size (one megabyte) in pages */
#define FSP_EXTENT_SIZE (1 << (20 - UNIV_PAGE_SIZE_SHIFT))
/** On a page of any file segment, data may be put starting from this
offset */
#define FSEG_PAGE_DATA FIL_PAGE_DATA
/** File segment header which points to the inode describing the file
segment */
/* @{ */
/** Data type for file segment header */
typedef byte fseg_header_t;
#define FSEG_HDR_SPACE 0 /*!< space id of the inode */
#define FSEG_HDR_PAGE_NO 4 /*!< page number of the inode */
#define FSEG_HDR_OFFSET 8 /*!< byte offset of the inode */
#define FSEG_HEADER_SIZE 10 /*!< Length of the file system
header, in bytes */
/* @} */
#include "fsp0types.h"
/**********************************************************************//**
Initializes the file space system. */
......@@ -394,41 +364,6 @@ fseg_print(
mtr_t* mtr); /*!< in: mtr */
#endif /* UNIV_BTR_PRINT */
/* Flags for fsp_reserve_free_extents */
#define FSP_NORMAL 1000000
#define FSP_UNDO 2000000
#define FSP_CLEANING 3000000
/* Number of pages described in a single descriptor page: currently each page
description takes less than 1 byte; a descriptor page is repeated every
this many file pages */
/* #define XDES_DESCRIBED_PER_PAGE UNIV_PAGE_SIZE */
/* This has been replaced with either UNIV_PAGE_SIZE or page_zip->size. */
/* The space low address page map */
/*--------------------------------------*/
/* The following two pages are repeated
every XDES_DESCRIBED_PER_PAGE pages in
every tablespace. */
#define FSP_XDES_OFFSET 0 /* extent descriptor */
#define FSP_IBUF_BITMAP_OFFSET 1 /* insert buffer bitmap */
/* The ibuf bitmap pages are the ones whose
page number is the number above plus a
multiple of XDES_DESCRIBED_PER_PAGE */
#define FSP_FIRST_INODE_PAGE_NO 2 /* in every tablespace */
/* The following pages exist
in the system tablespace (space 0). */
#define FSP_IBUF_HEADER_PAGE_NO 3 /* in tablespace 0 */
#define FSP_IBUF_TREE_ROOT_PAGE_NO 4 /* in tablespace 0 */
/* The ibuf tree root page number in
tablespace 0; its fseg inode is on the page
number FSP_FIRST_INODE_PAGE_NO */
#define FSP_TRX_SYS_PAGE_NO 5 /* in tablespace 0 */
#define FSP_FIRST_RSEG_PAGE_NO 6 /* in tablespace 0 */
#define FSP_DICT_HDR_PAGE_NO 7 /* in tablespace 0 */
/*--------------------------------------*/
#ifndef UNIV_NONINL
#include "fsp0fsp.ic"
#endif
......
/*****************************************************************************
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
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 include/fsp0types.h
File space management types
Created May 26, 2009 Vasil Dimov
*******************************************************/
#ifndef fsp0types_h
#define fsp0types_h
#include "univ.i"
#include "fil0fil.h" /* for FIL_PAGE_DATA */
/** @name Flags for inserting records in order
If records are inserted in order, there are the following
flags to tell this (their type is made byte for the compiler
to warn if direction and hint parameters are switched in
fseg_alloc_free_page) */
/* @{ */
#define FSP_UP ((byte)111) /*!< alphabetically upwards */
#define FSP_DOWN ((byte)112) /*!< alphabetically downwards */
#define FSP_NO_DIR ((byte)113) /*!< no order */
/* @} */
/** File space extent size (one megabyte) in pages */
#define FSP_EXTENT_SIZE (1 << (20 - UNIV_PAGE_SIZE_SHIFT))
/** On a page of any file segment, data may be put starting from this
offset */
#define FSEG_PAGE_DATA FIL_PAGE_DATA
/** @name File segment header
The file segment header points to the inode describing the file segment. */
/* @{ */
/** Data type for file segment header */
typedef byte fseg_header_t;
#define FSEG_HDR_SPACE 0 /*!< space id of the inode */
#define FSEG_HDR_PAGE_NO 4 /*!< page number of the inode */
#define FSEG_HDR_OFFSET 8 /*!< byte offset of the inode */
#define FSEG_HEADER_SIZE 10 /*!< Length of the file system
header, in bytes */
/* @} */
/** Flags for fsp_reserve_free_extents @{ */
#define FSP_NORMAL 1000000
#define FSP_UNDO 2000000
#define FSP_CLEANING 3000000
/* @} */
/* Number of pages described in a single descriptor page: currently each page
description takes less than 1 byte; a descriptor page is repeated every
this many file pages */
/* #define XDES_DESCRIBED_PER_PAGE UNIV_PAGE_SIZE */
/* This has been replaced with either UNIV_PAGE_SIZE or page_zip->size. */
/** @name The space low address page map
The pages at FSP_XDES_OFFSET and FSP_IBUF_BITMAP_OFFSET are repeated
every XDES_DESCRIBED_PER_PAGE pages in every tablespace. */
/* @{ */
/*--------------------------------------*/
#define FSP_XDES_OFFSET 0 /* !< extent descriptor */
#define FSP_IBUF_BITMAP_OFFSET 1 /* !< insert buffer bitmap */
/* The ibuf bitmap pages are the ones whose
page number is the number above plus a
multiple of XDES_DESCRIBED_PER_PAGE */
#define FSP_FIRST_INODE_PAGE_NO 2 /*!< in every tablespace */
/* The following pages exist
in the system tablespace (space 0). */
#define FSP_IBUF_HEADER_PAGE_NO 3 /*!< insert buffer
header page, in
tablespace 0 */
#define FSP_IBUF_TREE_ROOT_PAGE_NO 4 /*!< insert buffer
B-tree root page in
tablespace 0 */
/* The ibuf tree root page number in
tablespace 0; its fseg inode is on the page
number FSP_FIRST_INODE_PAGE_NO */
#define FSP_TRX_SYS_PAGE_NO 5 /*!< transaction
system header, in
tablespace 0 */
#define FSP_FIRST_RSEG_PAGE_NO 6 /*!< first rollback segment
page, in tablespace 0 */
#define FSP_DICT_HDR_PAGE_NO 7 /*!< data dictionary header
page, in tablespace 0 */
/*--------------------------------------*/
/* @} */
#endif /* fsp0types_h */
......@@ -27,6 +27,8 @@ Created 12/7/1995 Heikki Tuuri
#include "mach0data.h"
#include "ut0lst.h"
#include "buf0buf.h"
#include "fsp0types.h"
#include "trx0sys.h"
/********************************************************//**
Opens a buffer to mlog. It must be closed with mlog_close.
......@@ -195,6 +197,29 @@ mlog_write_initial_log_record_fast(
space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
offset = mach_read_from_4(page + FIL_PAGE_OFFSET);
/* check whether the page is in the doublewrite buffer;
the doublewrite buffer is located in pages
FSP_EXTENT_SIZE, ..., 3 * FSP_EXTENT_SIZE - 1 in the
system tablespace */
if (space == TRX_SYS_SPACE
&& offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) {
if (trx_doublewrite_buf_is_being_created) {
/* Do nothing: we only come to this branch in an
InnoDB database creation. We do not redo log
anything for the doublewrite buffer pages. */
return(log_ptr);
} else {
fprintf(stderr,
"Error: trying to redo log a record of type "
"%d on page %lu of space %lu in the "
"doublewrite buffer, continuing anyway.\n"
"Please post a bug report to "
"bugs.mysql.com.\n",
type, offset, space);
}
}
mach_write_to_1(log_ptr, type);
log_ptr++;
log_ptr += mach_write_compressed(log_ptr, space);
......
......@@ -24,6 +24,7 @@ Created 3/26/1996 Heikki Tuuri
*******************************************************/
#include "srv0srv.h"
#include "mtr0log.h"
/******************************************************************//**
Gets a rollback segment header.
......
......@@ -29,13 +29,11 @@ Created 3/26/1996 Heikki Tuuri
#include "univ.i"
#include "trx0types.h"
#include "fsp0fsp.h"
#include "fsp0types.h"
#include "fil0fil.h"
#include "fut0lst.h"
#include "buf0buf.h"
#ifndef UNIV_HOTBACKUP
#include "mtr0mtr.h"
#include "mtr0log.h"
#include "ut0byte.h"
#include "mem0mem.h"
#include "sync0sync.h"
......@@ -72,6 +70,8 @@ extern trx_doublewrite_t* trx_doublewrite;
/** The following is set to TRUE when we are upgrading from pre-4.1
format data files to the multiple tablespaces format data files */
extern ibool trx_doublewrite_must_reset_space_ids;
/** Set to TRUE when the doublewrite buffer is being created */
extern ibool trx_doublewrite_buf_is_being_created;
/** The following is TRUE when we are using the database in the
post-4.1 format, i.e., we have successfully upgraded, or have created
a new database installation */
......@@ -394,6 +394,7 @@ trx_sys_print_mysql_binlog_offset_from_page(
/* Space id and page no where the trx system file copy resides */
#define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */
#include "fsp0fsp.h"
#define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
/* The offset of the transaction system header on the page */
......
......@@ -27,6 +27,7 @@ Created 3/26/1996 Heikki Tuuri
#include "data0type.h"
#ifndef UNIV_HOTBACKUP
# include "srv0srv.h"
# include "mtr0log.h"
/* The typedef for rseg slot in the file copy */
typedef byte trx_sysf_rseg_t;
......
......@@ -28,14 +28,14 @@ Created 3/26/1996 Heikki Tuuri
#include "ut0byte.h"
/* prepare trx_t::id for being printed via printf(3) */
/** prepare trx_t::id for being printed via printf(3) */
#define TRX_ID_PREP_PRINTF(id) (ullint) ut_conv_dulint_to_longlong(id)
/* printf(3) format used for printing TRX_ID_PRINTF_PREP() */
/** printf(3) format used for printing TRX_ID_PRINTF_PREP() */
#define TRX_ID_FMT "%llX"
/* maximum length that a formatted trx_t::id could take, not including
the terminating '\0'. */
/** maximum length that a formatted trx_t::id could take, not including
the terminating NUL character. */
#define TRX_ID_MAX_LEN 17
/** Memory objects */
......
......@@ -31,6 +31,7 @@ Created 3/26/1996 Heikki Tuuri
#include "fsp0fsp.h"
#include "mach0data.h"
#include "mtr0log.h"
#include "trx0rseg.h"
#include "trx0trx.h"
#include "trx0roll.h"
......
......@@ -32,6 +32,7 @@ Created 3/26/1996 Heikki Tuuri
#ifndef UNIV_HOTBACKUP
#include "fsp0fsp.h"
#include "mtr0mtr.h"
#include "mtr0log.h"
#include "trx0trx.h"
#include "trx0rseg.h"
#include "trx0undo.h"
......@@ -60,6 +61,8 @@ UNIV_INTERN trx_doublewrite_t* trx_doublewrite = NULL;
/** The following is set to TRUE when we are upgrading from pre-4.1
format data files to the multiple tablespaces format data files */
UNIV_INTERN ibool trx_doublewrite_must_reset_space_ids = FALSE;
/** Set to TRUE when the doublewrite buffer is being created */
UNIV_INTERN ibool trx_doublewrite_buf_is_being_created = FALSE;
/** The following is TRUE when we are using the database in the
post-4.1 format, i.e., we have successfully upgraded, or have created
......@@ -251,6 +254,7 @@ trx_sys_create_doublewrite_buf(void)
start_again:
mtr_start(&mtr);
trx_doublewrite_buf_is_being_created = TRUE;
block = buf_page_get(TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO,
RW_X_LATCH, &mtr);
......@@ -266,6 +270,7 @@ start_again:
trx_doublewrite_init(doublewrite);
mtr_commit(&mtr);
trx_doublewrite_buf_is_being_created = FALSE;
} else {
fprintf(stderr,
"InnoDB: Doublewrite buffer not found:"
......@@ -341,15 +346,8 @@ start_again:
buf_block_dbg_add_level(new_block,
SYNC_NO_ORDER_CHECK);
/* Make a dummy change to the page to ensure it will
be written to disk in a flush */
mlog_write_ulint(buf_block_get_frame(new_block)
+ FIL_PAGE_TYPE,
FIL_PAGE_TYPE_ALLOCATED,
MLOG_2BYTES, &mtr);
if (i == FSP_EXTENT_SIZE / 2) {
ut_a(page_no == FSP_EXTENT_SIZE);
mlog_write_ulint(doublewrite
+ TRX_SYS_DOUBLEWRITE_BLOCK1,
page_no, MLOG_4BYTES, &mtr);
......@@ -359,6 +357,7 @@ start_again:
page_no, MLOG_4BYTES, &mtr);
} else if (i == FSP_EXTENT_SIZE / 2
+ TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
ut_a(page_no == 2 * FSP_EXTENT_SIZE);
mlog_write_ulint(doublewrite
+ TRX_SYS_DOUBLEWRITE_BLOCK2,
page_no, MLOG_4BYTES, &mtr);
......
......@@ -32,6 +32,7 @@ Created 3/26/1996 Heikki Tuuri
#include "fsp0fsp.h"
#ifndef UNIV_HOTBACKUP
#include "mach0data.h"
#include "mtr0log.h"
#include "trx0rseg.h"
#include "trx0trx.h"
#include "srv0srv.h"
......
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