You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
4.6 KiB

MDEV-11623 MariaDB 10.1 fails to start datadir created with MariaDB 10.0/MySQL 5.6 using innodb-page-size!=16K The storage format of FSP_SPACE_FLAGS was accidentally broken already in MariaDB 10.1.0. This fix is bringing the format in line with other MySQL and MariaDB release series. Please refer to the comments that were added to fsp0fsp.h for details. This is an INCOMPATIBLE CHANGE that affects users of page_compression and non-default innodb_page_size. Upgrading to this release will correct the flags in the data files. If you want to downgrade to earlier MariaDB 10.1.x, please refer to the test innodb.101_compatibility how to reset the FSP_SPACE_FLAGS in the files. NOTE: MariaDB 10.1.0 to 10.1.20 can misinterpret uncompressed data files with innodb_page_size=4k or 64k as compressed innodb_page_size=16k files, and then probably fail when trying to access the pages. See the comments in the function fsp_flags_convert_from_101() for detailed analysis. Move PAGE_COMPRESSION to FSP_SPACE_FLAGS bit position 16. In this way, compressed innodb_page_size=16k tablespaces will not be mistaken for uncompressed ones by MariaDB 10.1.0 to 10.1.20. Derive PAGE_COMPRESSION_LEVEL, ATOMIC_WRITES and DATA_DIR from the dict_table_t::flags when the table is available, in fil_space_for_table_exists_in_mem() or fil_open_single_table_tablespace(). During crash recovery, fil_load_single_table_tablespace() will use innodb_compression_level for the PAGE_COMPRESSION_LEVEL. FSP_FLAGS_MEM_MASK: A bitmap of the memory-only fil_space_t::flags that are not to be written to FSP_SPACE_FLAGS. Currently, these will include PAGE_COMPRESSION_LEVEL, ATOMIC_WRITES and DATA_DIR. Introduce the macro FSP_FLAGS_PAGE_SSIZE(). We only support one innodb_page_size for the whole instance. When creating a dummy tablespace for the redo log, use fil_space_t::flags=0. The flags are never written to the redo log files. Remove many FSP_FLAGS_SET_ macros. dict_tf_verify_flags(): Remove. This is basically only duplicating the logic of dict_tf_to_fsp_flags(), used in a debug assertion. fil_space_t::mark: Remove. This flag was not used for anything. fil_space_for_table_exists_in_mem(): Remove the unnecessary parameter mark_space, and add a parameter for table flags. Check that fil_space_t::flags match the table flags, and adjust the (memory-only) flags based on the table flags. fil_node_open_file(): Remove some redundant or unreachable conditions, do not use stderr for output, and avoid unnecessary server aborts. fil_user_tablespace_restore_page(): Convert the flags, so that the correct page_size will be used when restoring a page from the doublewrite buffer. fil_space_get_page_compressed(), fsp_flags_is_page_compressed(): Remove. It suffices to have fil_space_is_page_compressed(). FSP_FLAGS_WIDTH_DATA_DIR, FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL, FSP_FLAGS_WIDTH_ATOMIC_WRITES: Remove, because these flags do not exist in the FSP_SPACE_FLAGS but only in memory. fsp_flags_try_adjust(): New function, to adjust the FSP_SPACE_FLAGS in page 0. Called by fil_open_single_table_tablespace(), fil_space_for_table_exists_in_mem(), innobase_start_or_create_for_mysql() except if --innodb-read-only is active. fsp_flags_is_valid(ulint): Reimplement from the scratch, with accurate comments. Do not display any details of detected inconsistencies, because the output could be confusing when dealing with MariaDB 10.1.x data files. fsp_flags_convert_from_101(ulint): Convert flags from buggy MariaDB 10.1.x format, or return ULINT_UNDEFINED if the flags cannot be in MariaDB 10.1.x format. fsp_flags_match(): Check the flags when probing files. Implemented based on fsp_flags_is_valid() and fsp_flags_convert_from_101(). dict_check_tablespaces_and_store_max_id(): Do not access the page after committing the mini-transaction. IMPORT TABLESPACE fixes: AbstractCallback::init(): Convert the flags. FetchIndexRootPages::operator(): Check that the tablespace flags match the table flags. Do not attempt to convert tablespace flags to table flags, because the conversion would necessarily be lossy. PageConverter::update_header(): Write back the correct flags. This takes care of the flags in IMPORT TABLESPACE.
9 years ago
  1. /*****************************************************************************
  2. Copyright (C) 2013, 2017 MariaDB Corporation. All Rights Reserved.
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free Software
  5. Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along with
  10. this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  12. *****************************************************************************/
  13. #ifndef fil0pagecompress_h
  14. #define fil0pagecompress_h
  15. #include "fsp0fsp.h"
  16. #include "fsp0pagecompress.h"
  17. /******************************************************************//**
  18. @file include/fil0pagecompress.h
  19. Helper functions for extracting/storing page compression and
  20. atomic writes information to table space.
  21. Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
  22. ***********************************************************************/
  23. /*******************************************************************//**
  24. Find out wheather the page is index page or not
  25. @return true if page type index page, false if not */
  26. UNIV_INLINE
  27. ibool
  28. fil_page_is_index_page(
  29. /*===================*/
  30. byte *buf); /*!< in: page */
  31. /****************************************************************//**
  32. Get the name of the compression algorithm used for page
  33. compression.
  34. @return compression algorithm name or "UNKNOWN" if not known*/
  35. UNIV_INLINE
  36. const char*
  37. fil_get_compression_alg_name(
  38. /*=========================*/
  39. ulint comp_alg); /*!<in: compression algorithm number */
  40. /****************************************************************//**
  41. For page compressed pages compress the page before actual write
  42. operation.
  43. @return compressed page to be written*/
  44. UNIV_INTERN
  45. byte*
  46. fil_compress_page(
  47. /*==============*/
  48. fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */
  49. byte* buf, /*!< in: buffer from which to write; in aio
  50. this must be appropriately aligned */
  51. byte* out_buf, /*!< out: compressed buffer */
  52. ulint len, /*!< in: length of input buffer.*/
  53. ulint level, /* in: compression level */
  54. ulint block_size, /*!< in: block size */
  55. bool encrypted, /*!< in: is page also encrypted */
  56. ulint* out_len, /*!< out: actual length of compressed
  57. page */
  58. byte* lzo_mem); /*!< in: temporal memory used by LZO */
  59. /****************************************************************//**
  60. For page compressed pages decompress the page after actual read
  61. operation. */
  62. UNIV_INTERN
  63. void
  64. fil_decompress_page(
  65. /*================*/
  66. byte* page_buf, /*!< in: preallocated buffer or NULL */
  67. byte* buf, /*!< out: buffer from which to read; in aio
  68. this must be appropriately aligned */
  69. ulong len, /*!< in: length of output buffer.*/
  70. ulint* write_size, /*!< in/out: Actual payload size of
  71. the compressed data. */
  72. bool return_error=false);
  73. /*!< in: true if only an error should
  74. be produced when decompression fails.
  75. By default this parameter is false. */
  76. /****************************************************************//**
  77. Get space id from fil node
  78. @return space id*/
  79. UNIV_INTERN
  80. ulint
  81. fil_node_get_space_id(
  82. /*==================*/
  83. fil_node_t* node); /*!< in: Node where to get space id*/
  84. /****************************************************************//**
  85. Get block size from fil node
  86. @return block size*/
  87. UNIV_INLINE
  88. ulint
  89. fil_node_get_block_size(
  90. fil_node_t* node); /*!< in: Node where to get block
  91. size */
  92. /*******************************************************************//**
  93. Find out wheather the page is page compressed
  94. @return true if page is page compressed*/
  95. UNIV_INLINE
  96. ibool
  97. fil_page_is_compressed(
  98. /*===================*/
  99. byte* buf); /*!< in: page */
  100. /*******************************************************************//**
  101. Find out wheather the page is page compressed
  102. @return true if page is page compressed*/
  103. UNIV_INLINE
  104. ibool
  105. fil_page_is_compressed_encrypted(
  106. /*=============================*/
  107. byte* buf); /*!< in: page */
  108. /*******************************************************************//**
  109. Find out wheather the page is page compressed with lzo method
  110. @return true if page is page compressed with lzo method*/
  111. UNIV_INLINE
  112. ibool
  113. fil_page_is_lzo_compressed(
  114. /*=======================*/
  115. byte* buf); /*!< in: page */
  116. #endif