Commit 37d9d243 authored by Aditya A's avatar Aditya A

Bug#17033706 SINCE 5.5.32 & 5.6.12, INNODB CANT START WITH OWN

             MULTI-FILE TABLESPACE

ANALYSIS
--------

When a tablespace has multiple data files, InnoDB fails to 
open the tablespace.  This is because for each ibd file, 
the first page is checked.But the first page of all ibd file
need not be the first page of the tablespace.  Only the first
page of the tablespace contains the tablespace header. When 
we check the first page of an ibd file that is not the first
page of the tablespace, then the "tablespace flags" is not
really available.This was wrongly used to check if a page is
corrupt or not.

FIX
---
Use the tablespace flags only if the page number is 0 
in a tablespace.  

[Approved by Inaam rb#2836 ]
parent 18d34a47
...@@ -1860,7 +1860,7 @@ fil_write_flushed_lsn_to_data_files( ...@@ -1860,7 +1860,7 @@ fil_write_flushed_lsn_to_data_files(
} }
/*******************************************************************//** /*******************************************************************//**
Checks the consistency of the first data page of a data file Checks the consistency of the first data page of a tablespace
at database startup. at database startup.
@retval NULL on success, or if innodb_force_recovery is set @retval NULL on success, or if innodb_force_recovery is set
@return pointer to an error message string */ @return pointer to an error message string */
...@@ -1868,9 +1868,7 @@ static __attribute__((warn_unused_result)) ...@@ -1868,9 +1868,7 @@ static __attribute__((warn_unused_result))
const char* const char*
fil_check_first_page( fil_check_first_page(
/*=================*/ /*=================*/
const page_t* page, /*!< in: data page */ const page_t* page) /*!< in: data page */
ibool first_page) /*!< in: TRUE if this is the
first page of the tablespace */
{ {
ulint space_id; ulint space_id;
ulint flags; ulint flags;
...@@ -1882,7 +1880,7 @@ fil_check_first_page( ...@@ -1882,7 +1880,7 @@ fil_check_first_page(
space_id = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page); space_id = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page);
flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page); flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page);
if (first_page && !space_id && !flags) { if (!space_id && !flags) {
ulint nonzero_bytes = UNIV_PAGE_SIZE; ulint nonzero_bytes = UNIV_PAGE_SIZE;
const byte* b = page; const byte* b = page;
...@@ -1900,9 +1898,8 @@ fil_check_first_page( ...@@ -1900,9 +1898,8 @@ fil_check_first_page(
return("checksum mismatch"); return("checksum mismatch");
} }
if (!first_page if (page_get_space_id(page) == space_id
|| (page_get_space_id(page) == space_id && page_get_page_no(page) == 0) {
&& page_get_page_no(page) == 0)) {
return(NULL); return(NULL);
} }
...@@ -1937,7 +1934,7 @@ fil_read_first_page( ...@@ -1937,7 +1934,7 @@ fil_read_first_page(
byte* buf; byte* buf;
page_t* page; page_t* page;
ib_uint64_t flushed_lsn; ib_uint64_t flushed_lsn;
const char* check_msg; const char* check_msg = NULL;
buf = ut_malloc(2 * UNIV_PAGE_SIZE); buf = ut_malloc(2 * UNIV_PAGE_SIZE);
/* Align the memory for a possible read from a raw device */ /* Align the memory for a possible read from a raw device */
...@@ -1949,7 +1946,9 @@ fil_read_first_page( ...@@ -1949,7 +1946,9 @@ fil_read_first_page(
flushed_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN); flushed_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN);
check_msg = fil_check_first_page(page, !one_read_already); if (!one_read_already) {
check_msg = fil_check_first_page(page);
}
ut_free(buf); ut_free(buf);
...@@ -3272,7 +3271,7 @@ fil_open_single_table_tablespace( ...@@ -3272,7 +3271,7 @@ fil_open_single_table_tablespace(
success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE); success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
check_msg = fil_check_first_page(page, TRUE); check_msg = fil_check_first_page(page);
/* We have to read the tablespace id and flags from the file. */ /* We have to read the tablespace id and flags from the file. */
...@@ -3528,7 +3527,7 @@ fil_load_single_table_tablespace( ...@@ -3528,7 +3527,7 @@ fil_load_single_table_tablespace(
/* We have to read the tablespace id from the file */ /* We have to read the tablespace id from the file */
check_msg = fil_check_first_page(page, TRUE); check_msg = fil_check_first_page(page);
if (check_msg) { if (check_msg) {
fprintf(stderr, fprintf(stderr,
......
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