From 391b1af0fbb9723ce768d0b06830865fa983a8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 10 Aug 2017 13:09:27 +0300 Subject: [PATCH 001/101] MDEV-13471: Test failure on innodb.log_file_size,4k Problem was that 4k page size is not really supported in Galera. For reference see: codership/galera#398 Page size 4k is problematic because WSREP XID info location that was set to constant UNIV_PAGE_SIZE - 3500 and that is conflicting with rseg undo slots location if there is lot of undo tablespaces. Undo tablespace identifiers and page numbers require at least 126*8=1024 bytes starting from offset 56. Therefore, WSREP XID startig from offset 596 would overwrite several space_id,page_no pairs starting from 72th undo log tablespace space_id,page_no pair at offset 594. This will cause InnoDB startup failure seen as [ERROR] InnoDB: Unable to open undo tablespace './undo30579'. Originally, the undo tablespace ID would always be between 0 and 127. Starting with MySQL 5.6.36 which introduced Bug #25551311 BACKPORT BUG #23517560 REMOVE SPACE_ID RESTRICTION FOR UNDO TABLESPACES (merged to MariaDB 10.0.31) it is possible for an undo tablespace ID to be 0x7773. But in this case, the page number should be 3, not 0x72650003. This is just the first collision. The WSREP XID data would overwrite subsequent slots. trx0sys.h trx0sys.cc Code formatting and add comments. --- storage/innobase/include/trx0sys.h | 86 +++++++++++++-- storage/innobase/trx/trx0sys.cc | 161 +++++++++++++++-------------- storage/xtradb/include/trx0sys.h | 86 +++++++++++++-- storage/xtradb/trx/trx0sys.cc | 161 +++++++++++++++-------------- 4 files changed, 322 insertions(+), 172 deletions(-) diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index 8c6b13f9dd4..83814d088f3 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -307,19 +308,26 @@ UNIV_INTERN void trx_sys_print_mysql_binlog_offset(void); /*===================================*/ + #ifdef WITH_WSREP -/** Update WSREP checkpoint XID in sys header. */ + +/** Update WSREP XID info in sys_header of TRX_SYS_PAGE_NO = 5. +@param[in] xid Transaction XID +@param[in,out] sys_header sys_header +@param[in] mtr minitransaction */ void trx_sys_update_wsrep_checkpoint( - const XID* xid, /*!< in: WSREP XID */ - trx_sysf_t* sys_header, /*!< in: sys_header */ - mtr_t* mtr); /*!< in: mtr */ + const XID* xid, + trx_sysf_t* sys_header, + mtr_t* mtr); +/** Read WSREP XID from sys_header of TRX_SYS_PAGE_NO = 5. +@param[out] xid Transaction XID */ void -/** Read WSREP checkpoint XID from sys header. */ -trx_sys_read_wsrep_checkpoint( - XID* xid); /*!< out: WSREP XID */ +trx_sys_read_wsrep_checkpoint(XID* xid); + #endif /* WITH_WSREP */ + /*****************************************************************//** Prints to stderr the MySQL master log offset info in the trx system header if the magic number shows it valid. */ @@ -548,13 +556,71 @@ this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */ within that file */ #define TRX_SYS_MYSQL_LOG_NAME 12 /*!< MySQL log file name */ +/** Memory map TRX_SYS_PAGE_NO = 5 when UNIV_PAGE_SIZE = 4096 + +0...37 FIL_HEADER +38...45 TRX_SYS_TRX_ID_STORE +46...55 TRX_SYS_FSEG_HEADER (FSEG_HEADER_SIZE == 10) +56 TRX_SYS_RSEGS + 56...59 TRX_SYS_RSEG_SPACE for slot 0 + 60...63 TRX_SYS_RSEG_PAGE_NO for slot 0 + 64...67 TRX_SYS_RSEG_SPACE for slot 1 + 68...71 TRX_SYS_RSEG_PAGE_NO for slot 1 +.... + 594..597 TRX_SYS_RSEG_SPACE for slot 72 + 598..601 TRX_SYS_RSEG_PAGE_NO for slot 72 +... + ...1063 TRX_SYS_RSEG_PAGE_NO for slot 126 + +(UNIV_PAGE_SIZE-3500 WSREP ::: FAIL would overwrite undo tablespace +space_id, page_no pairs :::) +596 TRX_SYS_WSREP_XID_INFO TRX_SYS_WSREP_XID_MAGIC_N_FLD +600 TRX_SYS_WSREP_XID_FORMAT +604 TRX_SYS_WSREP_XID_GTRID_LEN +608 TRX_SYS_WSREP_XID_BQUAL_LEN +612 TRX_SYS_WSREP_XID_DATA (len = 128) +739 TRX_SYS_WSREP_XID_DATA_END + +FIXED WSREP XID info offsets for 4k page size 10.0.32-galera +(UNIV_PAGE_SIZE-2500) +1596 TRX_SYS_WSREP_XID_INFO TRX_SYS_WSREP_XID_MAGIC_N_FLD +1600 TRX_SYS_WSREP_XID_FORMAT +1604 TRX_SYS_WSREP_XID_GTRID_LEN +1608 TRX_SYS_WSREP_XID_BQUAL_LEN +1612 TRX_SYS_WSREP_XID_DATA (len = 128) +1739 TRX_SYS_WSREP_XID_DATA_END + +(UNIV_PAGE_SIZE - 2000 MYSQL MASTER LOG) +2096 TRX_SYS_MYSQL_MASTER_LOG_INFO TRX_SYS_MYSQL_LOG_MAGIC_N_FLD +2100 TRX_SYS_MYSQL_LOG_OFFSET_HIGH +2104 TRX_SYS_MYSQL_LOG_OFFSET_LOW +2108 TRX_SYS_MYSQL_LOG_NAME + +(UNIV_PAGE_SIZE - 1000 MYSQL LOG) +3096 TRX_SYS_MYSQL_LOG_INFO TRX_SYS_MYSQL_LOG_MAGIC_N_FLD +3100 TRX_SYS_MYSQL_LOG_OFFSET_HIGH +3104 TRX_SYS_MYSQL_LOG_OFFSET_LOW +3108 TRX_SYS_MYSQL_LOG_NAME + +(UNIV_PAGE_SIZE - 200 DOUBLEWRITE) +3896 TRX_SYS_DOUBLEWRITE TRX_SYS_DOUBLEWRITE_FSEG +3906 TRX_SYS_DOUBLEWRITE_MAGIC +3910 TRX_SYS_DOUBLEWRITE_BLOCK1 +3914 TRX_SYS_DOUBLEWRITE_BLOCK2 +3918 TRX_SYS_DOUBLEWRITE_REPEAT +3930 TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N + +(UNIV_PAGE_SIZE - 8, TAILER) +4088..4096 FIL_TAILER + +*/ #ifdef WITH_WSREP -/* The offset to WSREP XID headers */ -#define TRX_SYS_WSREP_XID_INFO (UNIV_PAGE_SIZE - 3500) +/** The offset to WSREP XID headers */ +#define TRX_SYS_WSREP_XID_INFO (ut_max(UNIV_PAGE_SIZE - 3500, 1596)) #define TRX_SYS_WSREP_XID_MAGIC_N_FLD 0 #define TRX_SYS_WSREP_XID_MAGIC_N 0x77737265 -/* XID field: formatID, gtrid_len, bqual_len, xid_data */ +/** XID field: formatID, gtrid_len, bqual_len, xid_data */ #define TRX_SYS_WSREP_XID_LEN (4 + 4 + 4 + XIDDATASIZE) #define TRX_SYS_WSREP_XID_FORMAT 4 #define TRX_SYS_WSREP_XID_GTRID_LEN 8 diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 7f8bbafe99c..152813d9f3b 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -325,112 +326,120 @@ trx_sys_print_mysql_binlog_offset(void) static long long trx_sys_cur_xid_seqno = -1; static unsigned char trx_sys_cur_xid_uuid[16]; -long long read_wsrep_xid_seqno(const XID* xid) +/** Read WSREP XID seqno */ +static inline long long read_wsrep_xid_seqno(const XID* xid) { - long long seqno; - memcpy(&seqno, xid->data + 24, sizeof(long long)); - return seqno; + long long seqno; + memcpy(&seqno, xid->data + 24, sizeof(long long)); + return seqno; } -void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) +/** Read WSREP XID UUID */ +static inline void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) { - memcpy(buf, xid->data + 8, 16); + memcpy(buf, xid->data + 8, 16); } #endif /* UNIV_DEBUG */ +/** Update WSREP XID info in sys_header of TRX_SYS_PAGE_NO = 5. +@param[in] xid Transaction XID +@param[in,out] sys_header sys_header +@param[in] mtr minitransaction */ void trx_sys_update_wsrep_checkpoint( - const XID* xid, /*!< in: transaction XID */ - trx_sysf_t* sys_header, /*!< in: sys_header */ - mtr_t* mtr) /*!< in: mtr */ + const XID* xid, + trx_sysf_t* sys_header, + mtr_t* mtr) { #ifdef UNIV_DEBUG - { - /* Check that seqno is monotonically increasing */ - unsigned char xid_uuid[16]; - long long xid_seqno = read_wsrep_xid_seqno(xid); - read_wsrep_xid_uuid(xid, xid_uuid); - if (!memcmp(xid_uuid, trx_sys_cur_xid_uuid, 8)) - { - ut_ad(xid_seqno > trx_sys_cur_xid_seqno); - trx_sys_cur_xid_seqno = xid_seqno; - } - else - { - memcpy(trx_sys_cur_xid_uuid, xid_uuid, 16); - } - trx_sys_cur_xid_seqno = xid_seqno; - } + if (xid->formatID != -1 + && mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD) + == TRX_SYS_WSREP_XID_MAGIC_N) { + /* Check that seqno is monotonically increasing */ + unsigned char xid_uuid[16]; + long long xid_seqno = read_wsrep_xid_seqno(xid); + read_wsrep_xid_uuid(xid, xid_uuid); + + if (!memcmp(xid_uuid, trx_sys_cur_xid_uuid, 8)) { + ut_ad(xid_seqno > trx_sys_cur_xid_seqno); + trx_sys_cur_xid_seqno = xid_seqno; + } else { + memcpy(trx_sys_cur_xid_uuid, xid_uuid, 16); + } + + trx_sys_cur_xid_seqno = xid_seqno; + } #endif /* UNIV_DEBUG */ - ut_ad(xid && mtr); - ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid(xid)); + ut_ad(xid && mtr); + ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid((const void *)xid)); - if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD) - != TRX_SYS_WSREP_XID_MAGIC_N) { - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD, - TRX_SYS_WSREP_XID_MAGIC_N, - MLOG_4BYTES, mtr); - } - - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_FORMAT, - (int)xid->formatID, - MLOG_4BYTES, mtr); - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_GTRID_LEN, - (int)xid->gtrid_length, - MLOG_4BYTES, mtr); - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_BQUAL_LEN, - (int)xid->bqual_length, - MLOG_4BYTES, mtr); - mlog_write_string(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_DATA, - (const unsigned char*) xid->data, - XIDDATASIZE, mtr); + if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD) + != TRX_SYS_WSREP_XID_MAGIC_N) { + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD, + TRX_SYS_WSREP_XID_MAGIC_N, + MLOG_4BYTES, mtr); + } + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_FORMAT, + (int)xid->formatID, + MLOG_4BYTES, mtr); + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_GTRID_LEN, + (int)xid->gtrid_length, + MLOG_4BYTES, mtr); + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_BQUAL_LEN, + (int)xid->bqual_length, + MLOG_4BYTES, mtr); + mlog_write_string(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_DATA, + (const unsigned char*) xid->data, + XIDDATASIZE, mtr); } +/** Read WSREP XID from sys_header of TRX_SYS_PAGE_NO = 5. +@param[out] xid Transaction XID */ void trx_sys_read_wsrep_checkpoint(XID* xid) -/*===================================*/ { - trx_sysf_t* sys_header; + trx_sysf_t* sys_header; mtr_t mtr; - ulint magic; + ulint magic; - ut_ad(xid); + ut_ad(xid); mtr_start(&mtr); sys_header = trx_sysf_get(&mtr); - if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD)) - != TRX_SYS_WSREP_XID_MAGIC_N) { - memset(xid, 0, sizeof(*xid)); - xid->formatID = -1; - trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); - mtr_commit(&mtr); - return; + if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD)) + != TRX_SYS_WSREP_XID_MAGIC_N) { + memset(xid, 0, sizeof(*xid)); + xid->formatID = -1; + trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); + mtr_commit(&mtr); + return; } - xid->formatID = (int)mach_read_from_4( - sys_header - + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_FORMAT); - xid->gtrid_length = (int)mach_read_from_4( - sys_header - + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_GTRID_LEN); - xid->bqual_length = (int)mach_read_from_4( - sys_header - + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_BQUAL_LEN); - ut_memcpy(xid->data, - sys_header + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_DATA, - XIDDATASIZE); + xid->formatID = (int)mach_read_from_4( + sys_header + + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_FORMAT); + xid->gtrid_length = (int)mach_read_from_4( + sys_header + + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_GTRID_LEN); + xid->bqual_length = (int)mach_read_from_4( + sys_header + + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_BQUAL_LEN); + ut_memcpy(xid->data, + sys_header + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_DATA, + XIDDATASIZE); mtr_commit(&mtr); } diff --git a/storage/xtradb/include/trx0sys.h b/storage/xtradb/include/trx0sys.h index e4956c6a822..7f06d3247a1 100644 --- a/storage/xtradb/include/trx0sys.h +++ b/storage/xtradb/include/trx0sys.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -328,19 +329,26 @@ UNIV_INTERN void trx_sys_print_mysql_binlog_offset(void); /*===================================*/ + #ifdef WITH_WSREP -/** Update WSREP checkpoint XID in sys header. */ + +/** Update WSREP XID info in sys_header of TRX_SYS_PAGE_NO = 5. +@param[in] xid Transaction XID +@param[in,out] sys_header sys_header +@param[in] mtr minitransaction */ void trx_sys_update_wsrep_checkpoint( - const XID* xid, /*!< in: WSREP XID */ - trx_sysf_t* sys_header, /*!< in: sys_header */ - mtr_t* mtr); /*!< in: mtr */ + const XID* xid, + trx_sysf_t* sys_header, + mtr_t* mtr); +/** Read WSREP XID from sys_header of TRX_SYS_PAGE_NO = 5. +@param[out] xid Transaction XID */ void -/** Read WSREP checkpoint XID from sys header. */ -trx_sys_read_wsrep_checkpoint( - XID* xid); /*!< out: WSREP XID */ +trx_sys_read_wsrep_checkpoint(XID* xid); + #endif /* WITH_WSREP */ + /*****************************************************************//** Prints to stderr the MySQL master log offset info in the trx system header if the magic number shows it valid. */ @@ -569,13 +577,71 @@ this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */ within that file */ #define TRX_SYS_MYSQL_LOG_NAME 12 /*!< MySQL log file name */ +/** Memory map TRX_SYS_PAGE_NO = 5 when UNIV_PAGE_SIZE = 4096 + +0...37 FIL_HEADER +38...45 TRX_SYS_TRX_ID_STORE +46...55 TRX_SYS_FSEG_HEADER (FSEG_HEADER_SIZE == 10) +56 TRX_SYS_RSEGS + 56...59 TRX_SYS_RSEG_SPACE for slot 0 + 60...63 TRX_SYS_RSEG_PAGE_NO for slot 0 + 64...67 TRX_SYS_RSEG_SPACE for slot 1 + 68...71 TRX_SYS_RSEG_PAGE_NO for slot 1 +.... + 594..597 TRX_SYS_RSEG_SPACE for slot 72 + 598..601 TRX_SYS_RSEG_PAGE_NO for slot 72 +... + ...1063 TRX_SYS_RSEG_PAGE_NO for slot 126 + +(UNIV_PAGE_SIZE-3500 WSREP ::: FAIL would overwrite undo tablespace +space_id, page_no pairs :::) +596 TRX_SYS_WSREP_XID_INFO TRX_SYS_WSREP_XID_MAGIC_N_FLD +600 TRX_SYS_WSREP_XID_FORMAT +604 TRX_SYS_WSREP_XID_GTRID_LEN +608 TRX_SYS_WSREP_XID_BQUAL_LEN +612 TRX_SYS_WSREP_XID_DATA (len = 128) +739 TRX_SYS_WSREP_XID_DATA_END + +FIXED WSREP XID info offsets for 4k page size 10.0.32-galera +(UNIV_PAGE_SIZE-2500) +1596 TRX_SYS_WSREP_XID_INFO TRX_SYS_WSREP_XID_MAGIC_N_FLD +1600 TRX_SYS_WSREP_XID_FORMAT +1604 TRX_SYS_WSREP_XID_GTRID_LEN +1608 TRX_SYS_WSREP_XID_BQUAL_LEN +1612 TRX_SYS_WSREP_XID_DATA (len = 128) +1739 TRX_SYS_WSREP_XID_DATA_END + +(UNIV_PAGE_SIZE - 2000 MYSQL MASTER LOG) +2096 TRX_SYS_MYSQL_MASTER_LOG_INFO TRX_SYS_MYSQL_LOG_MAGIC_N_FLD +2100 TRX_SYS_MYSQL_LOG_OFFSET_HIGH +2104 TRX_SYS_MYSQL_LOG_OFFSET_LOW +2108 TRX_SYS_MYSQL_LOG_NAME + +(UNIV_PAGE_SIZE - 1000 MYSQL LOG) +3096 TRX_SYS_MYSQL_LOG_INFO TRX_SYS_MYSQL_LOG_MAGIC_N_FLD +3100 TRX_SYS_MYSQL_LOG_OFFSET_HIGH +3104 TRX_SYS_MYSQL_LOG_OFFSET_LOW +3108 TRX_SYS_MYSQL_LOG_NAME + +(UNIV_PAGE_SIZE - 200 DOUBLEWRITE) +3896 TRX_SYS_DOUBLEWRITE TRX_SYS_DOUBLEWRITE_FSEG +3906 TRX_SYS_DOUBLEWRITE_MAGIC +3910 TRX_SYS_DOUBLEWRITE_BLOCK1 +3914 TRX_SYS_DOUBLEWRITE_BLOCK2 +3918 TRX_SYS_DOUBLEWRITE_REPEAT +3930 TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N + +(UNIV_PAGE_SIZE - 8, TAILER) +4088..4096 FIL_TAILER + +*/ #ifdef WITH_WSREP -/* The offset to WSREP XID headers */ -#define TRX_SYS_WSREP_XID_INFO (UNIV_PAGE_SIZE - 3500) +/** The offset to WSREP XID headers */ +#define TRX_SYS_WSREP_XID_INFO (ut_max(UNIV_PAGE_SIZE - 3500, 1596)) #define TRX_SYS_WSREP_XID_MAGIC_N_FLD 0 #define TRX_SYS_WSREP_XID_MAGIC_N 0x77737265 -/* XID field: formatID, gtrid_len, bqual_len, xid_data */ +/** XID field: formatID, gtrid_len, bqual_len, xid_data */ #define TRX_SYS_WSREP_XID_LEN (4 + 4 + 4 + XIDDATASIZE) #define TRX_SYS_WSREP_XID_FORMAT 4 #define TRX_SYS_WSREP_XID_GTRID_LEN 8 diff --git a/storage/xtradb/trx/trx0sys.cc b/storage/xtradb/trx/trx0sys.cc index 9a0b7180435..8c11d22489a 100644 --- a/storage/xtradb/trx/trx0sys.cc +++ b/storage/xtradb/trx/trx0sys.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -325,112 +326,120 @@ trx_sys_print_mysql_binlog_offset(void) static long long trx_sys_cur_xid_seqno = -1; static unsigned char trx_sys_cur_xid_uuid[16]; -long long read_wsrep_xid_seqno(const XID* xid) +/** Read WSREP XID seqno */ +static inline long long read_wsrep_xid_seqno(const XID* xid) { - long long seqno; - memcpy(&seqno, xid->data + 24, sizeof(long long)); - return seqno; + long long seqno; + memcpy(&seqno, xid->data + 24, sizeof(long long)); + return seqno; } -void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) +/** Read WSREP XID UUID */ +static inline void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) { - memcpy(buf, xid->data + 8, 16); + memcpy(buf, xid->data + 8, 16); } #endif /* UNIV_DEBUG */ +/** Update WSREP XID info in sys_header of TRX_SYS_PAGE_NO = 5. +@param[in] xid Transaction XID +@param[in,out] sys_header sys_header +@param[in] mtr minitransaction */ void trx_sys_update_wsrep_checkpoint( - const XID* xid, /*!< in: transaction XID */ - trx_sysf_t* sys_header, /*!< in: sys_header */ - mtr_t* mtr) /*!< in: mtr */ + const XID* xid, + trx_sysf_t* sys_header, + mtr_t* mtr) { #ifdef UNIV_DEBUG - { - /* Check that seqno is monotonically increasing */ - unsigned char xid_uuid[16]; - long long xid_seqno = read_wsrep_xid_seqno(xid); - read_wsrep_xid_uuid(xid, xid_uuid); - if (!memcmp(xid_uuid, trx_sys_cur_xid_uuid, 8)) - { - ut_ad(xid_seqno > trx_sys_cur_xid_seqno); - trx_sys_cur_xid_seqno = xid_seqno; - } - else - { - memcpy(trx_sys_cur_xid_uuid, xid_uuid, 16); - } - trx_sys_cur_xid_seqno = xid_seqno; - } + if (xid->formatID != -1 + && mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD) + == TRX_SYS_WSREP_XID_MAGIC_N) { + /* Check that seqno is monotonically increasing */ + unsigned char xid_uuid[16]; + long long xid_seqno = read_wsrep_xid_seqno(xid); + read_wsrep_xid_uuid(xid, xid_uuid); + + if (!memcmp(xid_uuid, trx_sys_cur_xid_uuid, 8)) { + ut_ad(xid_seqno > trx_sys_cur_xid_seqno); + trx_sys_cur_xid_seqno = xid_seqno; + } else { + memcpy(trx_sys_cur_xid_uuid, xid_uuid, 16); + } + + trx_sys_cur_xid_seqno = xid_seqno; + } #endif /* UNIV_DEBUG */ - ut_ad(xid && mtr); - ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid((const void *)xid)); + ut_ad(xid && mtr); + ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid((const void *)xid)); - if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD) - != TRX_SYS_WSREP_XID_MAGIC_N) { - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD, - TRX_SYS_WSREP_XID_MAGIC_N, - MLOG_4BYTES, mtr); - } - - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_FORMAT, - (int)xid->formatID, - MLOG_4BYTES, mtr); - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_GTRID_LEN, - (int)xid->gtrid_length, - MLOG_4BYTES, mtr); - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_BQUAL_LEN, - (int)xid->bqual_length, - MLOG_4BYTES, mtr); - mlog_write_string(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_DATA, - (const unsigned char*) xid->data, - XIDDATASIZE, mtr); + if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD) + != TRX_SYS_WSREP_XID_MAGIC_N) { + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD, + TRX_SYS_WSREP_XID_MAGIC_N, + MLOG_4BYTES, mtr); + } + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_FORMAT, + (int)xid->formatID, + MLOG_4BYTES, mtr); + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_GTRID_LEN, + (int)xid->gtrid_length, + MLOG_4BYTES, mtr); + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_BQUAL_LEN, + (int)xid->bqual_length, + MLOG_4BYTES, mtr); + mlog_write_string(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_DATA, + (const unsigned char*) xid->data, + XIDDATASIZE, mtr); } +/** Read WSREP XID from sys_header of TRX_SYS_PAGE_NO = 5. +@param[out] xid Transaction XID */ void trx_sys_read_wsrep_checkpoint(XID* xid) -/*===================================*/ { - trx_sysf_t* sys_header; + trx_sysf_t* sys_header; mtr_t mtr; - ulint magic; + ulint magic; - ut_ad(xid); + ut_ad(xid); mtr_start(&mtr); sys_header = trx_sysf_get(&mtr); - if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD)) - != TRX_SYS_WSREP_XID_MAGIC_N) { - memset(xid, 0, sizeof(*xid)); - xid->formatID = -1; - trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); - mtr_commit(&mtr); - return; + if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD)) + != TRX_SYS_WSREP_XID_MAGIC_N) { + memset(xid, 0, sizeof(*xid)); + xid->formatID = -1; + trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); + mtr_commit(&mtr); + return; } - xid->formatID = (int)mach_read_from_4( - sys_header - + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_FORMAT); - xid->gtrid_length = (int)mach_read_from_4( - sys_header - + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_GTRID_LEN); - xid->bqual_length = (int)mach_read_from_4( - sys_header - + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_BQUAL_LEN); - ut_memcpy(xid->data, - sys_header + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_DATA, - XIDDATASIZE); + xid->formatID = (int)mach_read_from_4( + sys_header + + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_FORMAT); + xid->gtrid_length = (int)mach_read_from_4( + sys_header + + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_GTRID_LEN); + xid->bqual_length = (int)mach_read_from_4( + sys_header + + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_BQUAL_LEN); + ut_memcpy(xid->data, + sys_header + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_DATA, + XIDDATASIZE); mtr_commit(&mtr); } From 77f5b188d35ba5a5bf5f06c4e0ef25d25dacd963 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 6 Feb 2017 18:07:21 +0100 Subject: [PATCH 002/101] MW-357 Reset thd->wsrep_apply_toi regardless of applier exiting Applier does not reset thd->wsrep_apply_toi if applier thread decides to exit by setting 'exit= true'. The problem is that galera side may decide not to kill the applier thread: for instance if we try to SET wsrep_slave_threads = 0; then galera refuses to kill the last applier thread. If this happens we are left with a thd which has not been reset to the initial state. This patch ensures that the thd is reset regardless of the applier thread exiting or not. --- mysql-test/suite/galera/r/MW-357.result | 6 ++++++ mysql-test/suite/galera/t/MW-357.test | 13 +++++++++++++ sql/wsrep_applier.cc | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera/r/MW-357.result create mode 100644 mysql-test/suite/galera/t/MW-357.test diff --git a/mysql-test/suite/galera/r/MW-357.result b/mysql-test/suite/galera/r/MW-357.result new file mode 100644 index 00000000000..d249d5997f7 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-357.result @@ -0,0 +1,6 @@ +SET GLOBAL wsrep_slave_threads = 0; +Warnings: +Warning 1292 Truncated incorrect wsrep_slave_threads value: '0' +CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; +INSERT INTO t1 VALUES (1); +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-357.test b/mysql-test/suite/galera/t/MW-357.test new file mode 100644 index 00000000000..d13cf058aeb --- /dev/null +++ b/mysql-test/suite/galera/t/MW-357.test @@ -0,0 +1,13 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_2 +SET GLOBAL wsrep_slave_threads = 0; + +--connection node_1 +CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; + +--connection node_1 +INSERT INTO t1 VALUES (1); + +DROP TABLE t1; diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 73a43185162..49087d09224 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -217,6 +217,8 @@ wsrep_cb_status_t wsrep_apply_cb(void* const ctx, { THD* const thd((THD*)ctx); + assert(thd->wsrep_apply_toi == false); + // Allow tests to block the applier thread using the DBUG facilities. DBUG_EXECUTE_IF("sync.wsrep_apply_cb", { @@ -380,7 +382,7 @@ wsrep_cb_status_t wsrep_commit_cb(void* const ctx, mysql_mutex_unlock(&LOCK_wsrep_slave_threads); } - if (*exit == false && thd->wsrep_applier) + if (thd->wsrep_applier) { /* From trans_begin() */ thd->variables.option_bits|= OPTION_BEGIN; From 7af44d7aa07e1678bb48d4f4b9ce2c809b611079 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 8 Feb 2017 06:56:00 -0800 Subject: [PATCH 003/101] Galera MTR Tests: MW-359 Include include/have_innodb.inc part of include/galera_cluster.inc --- mysql-test/include/galera_cluster.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/include/galera_cluster.inc b/mysql-test/include/galera_cluster.inc index bc652225722..c1834c3c26f 100644 --- a/mysql-test/include/galera_cluster.inc +++ b/mysql-test/include/galera_cluster.inc @@ -8,3 +8,5 @@ --let $galera_cluster_size = 2 --source include/galera_init.inc + +--source include/have_innodb.inc From 364b15c090e7337eb752eec4bea239052f73b2ed Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 8 Feb 2017 23:36:34 +0100 Subject: [PATCH 004/101] MW-336 Avoid slave threads leaking This patch fixes two problems that may arise when changing the value of wsrep_slave_threads: 1) Threads may be leaked if wsrep_slave_threads is changed repeatedly. Specifically, when changing the number of slave threads, we keep track of wsrep_slave_count_change, the number of slaves to start / stop. The problem arises when wsrep_slave_count_change is updated before slaves had a chance to exit (threads may take some time to exit, as they exit only after commiting one more replication event). The fix is to update wsrep_slave_count_change such that it reflects the number of threads that already exited or are scheduled to exit. 2) Attempting to set out of range value for wsrep_slave_threads (below 1 / above 512) results in wsrep_slave_count_change to be computed based on the out of range value, even though a warning is generated and wsrep_slave_threads is set to a truncated value. wsrep_slave_count_change is computed in wsrep_slave_threads_check(), which is called before mysql checks for valid range. Fix is to update wsrep_count_change whenever wsrep_slave_threads is updated with a valid value. --- mysql-test/suite/galera/r/MW-336.result | 42 ++++++++++++++++ mysql-test/suite/galera/t/MW-336.test | 64 +++++++++++++++++++++++++ sql/sys_vars.cc | 2 +- sql/wsrep_var.cc | 13 +++-- 4 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 mysql-test/suite/galera/r/MW-336.result create mode 100644 mysql-test/suite/galera/t/MW-336.test diff --git a/mysql-test/suite/galera/r/MW-336.result b/mysql-test/suite/galera/r/MW-336.result new file mode 100644 index 00000000000..9bdb61c1a9c --- /dev/null +++ b/mysql-test/suite/galera/r/MW-336.result @@ -0,0 +1,42 @@ +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +SET GLOBAL wsrep_slave_threads = 10; +SET GLOBAL wsrep_slave_threads = 1; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_slave_threads = 10; +SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +COUNT(*) = 11 +1 +SET GLOBAL wsrep_slave_threads = 20; +SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +COUNT(*) = 21 +1 +SET GLOBAL wsrep_slave_threads = 1; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); +SET GLOBAL wsrep_slave_threads = 10; +SET GLOBAL wsrep_slave_threads = 0; +Warnings: +Warning 1292 Truncated incorrect wsrep_slave_threads value: '0' +INSERT INTO t1 VALUES (10); +INSERT INTO t1 VALUES (11); +INSERT INTO t1 VALUES (12); +INSERT INTO t1 VALUES (13); +INSERT INTO t1 VALUES (14); +INSERT INTO t1 VALUES (15); +INSERT INTO t1 VALUES (16); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (18); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (20); +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +COUNT(*) = 2 +1 +SET GLOBAL wsrep_slave_threads = 1; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-336.test b/mysql-test/suite/galera/t/MW-336.test new file mode 100644 index 00000000000..79d8951a822 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-336.test @@ -0,0 +1,64 @@ +# +# MW-336 Slave threads may leak if variable wsrep_slave_threads is set repeatedly +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; + +--connection node_1 +SET GLOBAL wsrep_slave_threads = 10; +SET GLOBAL wsrep_slave_threads = 1; + +--connection node_2 +INSERT INTO t1 VALUES (1); + +--connection node_1 +--sleep 0.5 +SET GLOBAL wsrep_slave_threads = 10; +--sleep 0.5 +SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; + +SET GLOBAL wsrep_slave_threads = 20; +--sleep 0.5 +SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; + + +SET GLOBAL wsrep_slave_threads = 1; + +--connection node_2 +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); + + +--connection node_1 +SET GLOBAL wsrep_slave_threads = 10; +SET GLOBAL wsrep_slave_threads = 0; + +--connection node_2 +INSERT INTO t1 VALUES (10); +INSERT INTO t1 VALUES (11); +INSERT INTO t1 VALUES (12); +INSERT INTO t1 VALUES (13); +INSERT INTO t1 VALUES (14); +INSERT INTO t1 VALUES (15); +INSERT INTO t1 VALUES (16); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (18); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (20); + +--connection node_1 +--sleep 0.5 +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; + +SET GLOBAL wsrep_slave_threads = 1; +DROP TABLE t1; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 000a424faeb..e234d441b78 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4568,7 +4568,7 @@ static Sys_var_ulong Sys_wsrep_slave_threads( GLOBAL_VAR(wsrep_slave_threads), CMD_LINE(REQUIRED_ARG), VALID_RANGE(1, 512), DEFAULT(1), BLOCK_SIZE(1), &PLock_wsrep_slave_threads, NOT_IN_BINLOG, - ON_CHECK(wsrep_slave_threads_check), + ON_CHECK(NULL), ON_UPDATE(wsrep_slave_threads_update)); static Sys_var_charptr Sys_wsrep_dbug_option( diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 8a507711daf..9a5c7b86068 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -36,6 +36,8 @@ const char* wsrep_node_address = 0; const char* wsrep_node_incoming_address = 0; const char* wsrep_start_position = 0; +static long wsrep_prev_slave_threads = wsrep_slave_threads; + int wsrep_init_vars() { wsrep_provider = my_strdup(WSREP_NONE, MYF(MY_WME)); @@ -497,18 +499,15 @@ void wsrep_node_address_init (const char* value) wsrep_node_address = (value) ? my_strdup(value, MYF(0)) : NULL; } -bool wsrep_slave_threads_check (sys_var *self, THD* thd, set_var* var) +static void wsrep_slave_count_change_update () { - mysql_mutex_lock(&LOCK_wsrep_slave_threads); - wsrep_slave_count_change += (var->save_result.ulonglong_value - - wsrep_slave_threads); - mysql_mutex_unlock(&LOCK_wsrep_slave_threads); - - return 0; + wsrep_slave_count_change += (wsrep_slave_threads - wsrep_prev_slave_threads); + wsrep_prev_slave_threads = wsrep_slave_threads; } bool wsrep_slave_threads_update (sys_var *self, THD* thd, enum_var_type type) { + wsrep_slave_count_change_update(); if (wsrep_slave_count_change > 0) { wsrep_create_appliers(wsrep_slave_count_change); From 7ef2d5aa5b5d0179d40bd42afea874235b8b60f8 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Thu, 16 Feb 2017 23:19:10 +0200 Subject: [PATCH 005/101] Refs: MW-360 * splitting DROP TABLE query in separate DROP commands for temporary and real tables * not replicating temporary table DROP command * using wsrep_sidno GTID group only for innodb table drop command part all this follows more or less the logic of how mysql wants to split drop table list --- sql/sql_class.cc | 5 +- sql/sql_class.h | 2 + sql/sql_parse.cc | 28 +++++++---- sql/sql_parse.h | 26 ++-------- sql/sql_partition_admin.cc | 4 +- sql/sql_table.cc | 100 +++++++++++++++++++++++++++++++++++++ sql/sql_truncate.cc | 2 +- sql/wsrep_hton.cc | 1 + sql/wsrep_mysqld.cc | 11 ++-- sql/wsrep_mysqld.h | 26 +++++++++- 10 files changed, 163 insertions(+), 42 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f0543becc0c..5964f4475a4 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1213,6 +1213,8 @@ THD::THD() wsrep_TOI_pre_query_len = 0; wsrep_sync_wait_gtid = WSREP_GTID_UNDEFINED; wsrep_affected_rows = 0; + wsrep_replicate_GTID = false; + wsrep_skip_wsrep_GTID = false; #endif /* Call to init() below requires fully initialized Open_tables_state. */ reset_open_tables_state(this); @@ -1631,7 +1633,8 @@ void THD::init(void) wsrep_TOI_pre_query_len = 0; wsrep_sync_wait_gtid = WSREP_GTID_UNDEFINED; wsrep_affected_rows = 0; - + wsrep_replicate_GTID = false; + wsrep_skip_wsrep_GTID = false; /* @@wsrep_causal_reads is now being handled via wsrep_sync_wait, update it appropriately. diff --git a/sql/sql_class.h b/sql/sql_class.h index beef22a8140..8c9b8f92040 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3867,6 +3867,8 @@ public: bool wsrep_skip_append_keys; wsrep_gtid_t wsrep_sync_wait_gtid; ulong wsrep_affected_rows; + bool wsrep_replicate_GTID; + bool wsrep_skip_wsrep_GTID; #endif /* WITH_WSREP */ }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9f0b6e25a5c..a4442653839 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4031,16 +4031,24 @@ end_with_restore_list: thd->variables.option_bits|= OPTION_KEEP_LOG; } #ifdef WITH_WSREP - for (TABLE_LIST *table= all_tables; table; table= table->next_global) - { - if (!lex->drop_temporary && - (!thd->is_current_stmt_binlog_format_row() || - !find_temporary_table(thd, table))) - { - WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); - break; - } - } + bool has_tmp_tables= false; + for (TABLE_LIST *table= all_tables; table; table= table->next_global) + { + if (lex->drop_temporary || find_temporary_table(thd, table)) + { + has_tmp_tables= true; + break; + } + } + if (has_tmp_tables) + { + wsrep_replicate_drop_query(thd, first_table, lex->check_exists, + lex->drop_temporary, false); + } + else + { + WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); + } #endif /* WITH_WSREP */ /* If we are a slave, we should add IF EXISTS if the query executed diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 368bba91c20..c2dbb950f2a 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -208,31 +208,13 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) { return MY_TEST(cs->mbminlen == 1); } -#ifdef WITH_WSREP - -#define WSREP_MYSQL_DB (char *)"mysql" -#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ - if (WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; - -#define WSREP_TO_ISOLATION_END \ - if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ - wsrep_to_isolation_end(thd); - -/* - Checks if lex->no_write_to_binlog is set for statements that use LOCAL or - NO_WRITE_TO_BINLOG. -*/ -#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ - if (WSREP(thd) && !thd->lex->no_write_to_binlog \ - && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; - -#else +#ifndef WITH_WSREP #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) +#define WSREP_TO_ISOLATION_BEGIN_QUERY(db_, query_, table_, table_list_) #define WSREP_TO_ISOLATION_END -#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) - -#endif /* WITH_WSREP */ +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, query_, table_, table_list_) +#endif /* !WITH_WSREP */ #endif /* SQL_PARSE_INCLUDED */ diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 2a76c8d6671..d50fe0379f3 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -537,7 +537,7 @@ bool Sql_cmd_alter_table_exchange_partition:: if ((!thd->is_current_stmt_binlog_format_row() || /* TODO: Do we really need to check for temp tables in this case? */ !find_temporary_table(thd, table_list)) && - wsrep_to_isolation_begin(thd, table_list->db, table_list->table_name, + wsrep_to_isolation_begin(thd, NULL, table_list->db, table_list->table_name, NULL)) { WSREP_WARN("ALTER TABLE EXCHANGE PARTITION isolation failure"); @@ -785,7 +785,7 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd) if (WSREP(thd) && (!thd->is_current_stmt_binlog_format_row() || !find_temporary_table(thd, first_table)) && wsrep_to_isolation_begin( - thd, first_table->db, first_table->table_name, NULL) + thd, NULL, first_table->db, first_table->table_name, NULL) ) { WSREP_WARN("ALTER TABLE TRUNCATE PARTITION isolation failure"); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e591b8a1eb7..6a9107cb240 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2156,7 +2156,95 @@ static uint32 comment_length(THD *thd, uint32 comment_pos, return 0; } +#ifdef WITH_WSREP +static void +wsrep_append_name(THD *thd, String *packet, const char *name, uint length, + const CHARSET_INFO *from_cs, const CHARSET_INFO *to_cs) +{ + const char *to_name= name; + size_t to_length= length; + String to_string(name,length, from_cs); + if (from_cs != NULL && to_cs != NULL && from_cs != to_cs) + thd->convert_string(&to_string, from_cs, to_cs); + if (to_cs != NULL) + { + to_name= to_string.c_ptr(); + to_length= to_string.length(); + } + packet->append(to_name, to_length, packet->charset()); +} + +int wsrep_replicate_drop_query(THD *thd, TABLE_LIST *tables, bool if_exists, + bool drop_temporary, bool dont_log_query) +{ + TABLE_LIST *table; + int error= 0; + String built_query; + bool non_tmp_table_deleted= FALSE; + + DBUG_ENTER("wsrep_build_drop_query"); + + if (!dont_log_query) + { + if (!drop_temporary) + { + built_query.set_charset(system_charset_info); + if (if_exists) + built_query.append("DROP TABLE IF EXISTS "); + else + built_query.append("DROP TABLE "); + } + } + + for (table= tables; table; table= table->next_local) + { + char *db=table->db; + int db_len= table->db_length; + + DBUG_PRINT("table", ("table_l: '%s'.'%s' table: 0x%lx s: 0x%lx", + table->db, table->table_name, (long) table->table, + table->table ? (long) table->table->s : (long) -1)); + + if (!find_temporary_table(thd, table)) + { + non_tmp_table_deleted= TRUE; + + if (thd->db == NULL || strcmp(db,thd->db) != 0) + { + wsrep_append_name(thd, &built_query, db, db_len, + system_charset_info, thd->charset()); + built_query.append("."); + } + + thd->variables.option_bits &= ~OPTION_QUOTE_SHOW_CREATE; + wsrep_append_name(thd, &built_query, table->table_name, + strlen(table->table_name), system_charset_info, + thd->charset()); + built_query.append(","); + } + } + +err: + if (non_tmp_table_deleted) + { + /* Chop of the last comma */ + built_query.chop(); + built_query.append(" /* generated by server */"); + WSREP_DEBUG("TOI for %s", built_query.ptr()); + if (WSREP_TO_ISOLATION_BEGIN_QUERY(built_query.ptr(), NULL, NULL, tables)) + { + WSREP_DEBUG("TOI failed for DROP TABLE: %s", WSREP_QUERY(thd)); + error= 1; + goto end; + } + } + +end: + DBUG_RETURN(error); +} + +#endif /* WITH_WSREP */ /** Execute the drop of a normal or temporary table. @@ -2591,6 +2679,9 @@ err: /* Chop of the last comma */ built_non_trans_tmp_query.chop(); built_non_trans_tmp_query.append(" /* generated by server */"); +#ifdef WITH_WSREP + thd->wsrep_skip_wsrep_GTID = true; +#endif /* WITH_WSREP */ error |= thd->binlog_query(THD::STMT_QUERY_TYPE, built_non_trans_tmp_query.ptr(), built_non_trans_tmp_query.length(), @@ -2603,6 +2694,9 @@ err: /* Chop of the last comma */ built_trans_tmp_query.chop(); built_trans_tmp_query.append(" /* generated by server */"); +#ifdef WITH_WSREP + thd->wsrep_skip_wsrep_GTID = true; +#endif /* WITH_WSREP */ error |= thd->binlog_query(THD::STMT_QUERY_TYPE, built_trans_tmp_query.ptr(), built_trans_tmp_query.length(), @@ -2617,6 +2711,9 @@ err: built_query.append(" /* generated by server */"); int error_code = non_tmp_error ? thd->get_stmt_da()->sql_errno() : 0; +#ifdef WITH_WSREP + thd->wsrep_skip_wsrep_GTID = false; +#endif /* WITH_WSREP */ error |= thd->binlog_query(THD::STMT_QUERY_TYPE, built_query.ptr(), built_query.length(), @@ -2665,6 +2762,9 @@ err: } end: +#ifdef WITH_WSREP + thd->wsrep_skip_wsrep_GTID = false; +#endif /* WITH_WSREP */ DBUG_RETURN(error); } diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 16c2a5027e3..d047186b2cf 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -487,7 +487,7 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) bool hton_can_recreate; #ifdef WITH_WSREP - if (WSREP(thd) && wsrep_to_isolation_begin(thd, + if (WSREP(thd) && wsrep_to_isolation_begin(thd, NULL, table_ref->db, table_ref->table_name, NULL)) DBUG_RETURN(TRUE); diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 78d189fbd61..47697c34eb4 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -45,6 +45,7 @@ void wsrep_cleanup_transaction(THD *thd) thd->wsrep_trx_meta.depends_on= WSREP_SEQNO_UNDEFINED; thd->wsrep_exec_mode= LOCAL_STATE; thd->wsrep_affected_rows= 0; + thd->wsrep_skip_wsrep_GTID= false; return; } diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 353911dcfde..6d0c5e75592 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1211,7 +1211,7 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len) 1: TOI replication was skipped -1: TOI replication failed */ -static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, +static int wsrep_TOI_begin(THD *thd, const char *query, char *db_, char *table_, const TABLE_LIST* table_list) { wsrep_status_t ret(WSREP_WARNING); @@ -1247,8 +1247,9 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, } /* fallthrough */ default: - buf_err= wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), &buf, - &buf_len); + buf_err= wsrep_to_buf_helper(thd, (query) ? query : thd->query(), + (query) ? strlen(query) : thd->query_length(), + &buf, &buf_len); break; } @@ -1397,7 +1398,7 @@ static void wsrep_RSU_end(THD *thd) thd->variables.wsrep_on = 1; } -int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, +int wsrep_to_isolation_begin(THD *thd, const char *query, char *db_, char *table_, const TABLE_LIST* table_list) { @@ -1452,7 +1453,7 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, if (thd->variables.wsrep_on && thd->wsrep_exec_mode==LOCAL_STATE) { switch (thd->variables.wsrep_OSU_method) { - case WSREP_OSU_TOI: ret = wsrep_TOI_begin(thd, db_, table_, + case WSREP_OSU_TOI: ret = wsrep_TOI_begin(thd, query, db_, table_, table_list); break; case WSREP_OSU_RSU: ret = wsrep_RSU_begin(thd, db_, table_); break; default: diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 5ec183f7186..fa069723021 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -254,6 +254,8 @@ extern wsrep_seqno_t wsrep_locked_seqno; #define WSREP_PROVIDER_EXISTS \ (wsrep_provider && strncasecmp(wsrep_provider, WSREP_NONE, FN_REFLEN)) +#define WSREP_QUERY(thd) (thd->query()) + extern void wsrep_ready_wait(); enum wsrep_trx_status { @@ -318,7 +320,7 @@ extern PSI_mutex_key key_LOCK_wsrep_slave_threads; extern PSI_mutex_key key_LOCK_wsrep_desync; #endif /* HAVE_PSI_INTERFACE */ struct TABLE_LIST; -int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, +int wsrep_to_isolation_begin(THD *thd, const char * query, char *db_, char *table_, const TABLE_LIST* table_list); void wsrep_to_isolation_end(THD *thd); void wsrep_cleanup_transaction(THD *thd); @@ -335,4 +337,26 @@ void wsrep_init_sidno(const wsrep_uuid_t&); bool wsrep_node_is_donor(); bool wsrep_node_is_synced(); +int wsrep_replicate_drop_query(THD *thd, TABLE_LIST *tables, bool if_exists, + bool drop_temporary, bool dont_log_query); + + +#define WSREP_MYSQL_DB (char *)"mysql" +#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ + if (WSREP(thd) && wsrep_to_isolation_begin(thd, NULL, db_, table_, table_list_)) goto error; + +#define WSREP_TO_ISOLATION_BEGIN_QUERY(query, db_, table_, table_list_) \ + (WSREP(thd) && wsrep_to_isolation_begin(thd, query, db_, table_, table_list_)) + +#define WSREP_TO_ISOLATION_END \ + if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ + wsrep_to_isolation_end(thd); + +/* Checks if lex->no_write_to_binlog is set for statements that use + LOCAL or NO_WRITE_TO_BINLOG +*/ +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ + if (WSREP(thd) && !thd->lex->no_write_to_binlog \ + && wsrep_to_isolation_begin(thd, NULL, db_, table_, table_list_)) goto error; + #endif /* WSREP_MYSQLD_H */ From a754387a09023c3715170527b8fe396acd6c67c2 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 17 Feb 2017 10:25:05 +0200 Subject: [PATCH 006/101] Refs: MW-360, fix for compiler warning --- sql/sql_table.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6a9107cb240..95a12abf986 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2225,7 +2225,6 @@ int wsrep_replicate_drop_query(THD *thd, TABLE_LIST *tables, bool if_exists, } } -err: if (non_tmp_table_deleted) { /* Chop of the last comma */ From 04c6b03c9b2155500d82ce880f3b8bea88f0c5a5 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 20 Feb 2017 23:29:25 +0200 Subject: [PATCH 007/101] Refs: MW-360 * merged relevant parts of DROP TABLE query splitting from mysql-wsrep-features --- sql/sql_parse.cc | 21 +--- sql/sql_table.cc | 88 -------------- sql/wsrep_mysqld.cc | 288 ++++++++++++++++++++++++++++++++------------ sql/wsrep_mysqld.h | 3 - 4 files changed, 209 insertions(+), 191 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a4442653839..d63a61e0ab1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4030,26 +4030,6 @@ end_with_restore_list: /* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */ thd->variables.option_bits|= OPTION_KEEP_LOG; } -#ifdef WITH_WSREP - bool has_tmp_tables= false; - for (TABLE_LIST *table= all_tables; table; table= table->next_global) - { - if (lex->drop_temporary || find_temporary_table(thd, table)) - { - has_tmp_tables= true; - break; - } - } - if (has_tmp_tables) - { - wsrep_replicate_drop_query(thd, first_table, lex->check_exists, - lex->drop_temporary, false); - } - else - { - WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); - } -#endif /* WITH_WSREP */ /* If we are a slave, we should add IF EXISTS if the query executed on the master without an error. This will help a slave to @@ -4060,6 +4040,7 @@ end_with_restore_list: slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) lex->check_exists= 1; + WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); /* DDL and binlog write order are protected by metadata locks. */ res= mysql_rm_table(thd, first_table, lex->check_exists, lex->drop_temporary); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 95a12abf986..e2b16d402bf 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2156,94 +2156,6 @@ static uint32 comment_length(THD *thd, uint32 comment_pos, return 0; } -#ifdef WITH_WSREP -static void -wsrep_append_name(THD *thd, String *packet, const char *name, uint length, - const CHARSET_INFO *from_cs, const CHARSET_INFO *to_cs) -{ - const char *to_name= name; - size_t to_length= length; - String to_string(name,length, from_cs); - if (from_cs != NULL && to_cs != NULL && from_cs != to_cs) - thd->convert_string(&to_string, from_cs, to_cs); - - if (to_cs != NULL) - { - to_name= to_string.c_ptr(); - to_length= to_string.length(); - } - packet->append(to_name, to_length, packet->charset()); -} - -int wsrep_replicate_drop_query(THD *thd, TABLE_LIST *tables, bool if_exists, - bool drop_temporary, bool dont_log_query) -{ - TABLE_LIST *table; - int error= 0; - String built_query; - bool non_tmp_table_deleted= FALSE; - - DBUG_ENTER("wsrep_build_drop_query"); - - if (!dont_log_query) - { - if (!drop_temporary) - { - built_query.set_charset(system_charset_info); - if (if_exists) - built_query.append("DROP TABLE IF EXISTS "); - else - built_query.append("DROP TABLE "); - } - } - - for (table= tables; table; table= table->next_local) - { - char *db=table->db; - int db_len= table->db_length; - - DBUG_PRINT("table", ("table_l: '%s'.'%s' table: 0x%lx s: 0x%lx", - table->db, table->table_name, (long) table->table, - table->table ? (long) table->table->s : (long) -1)); - - if (!find_temporary_table(thd, table)) - { - non_tmp_table_deleted= TRUE; - - if (thd->db == NULL || strcmp(db,thd->db) != 0) - { - wsrep_append_name(thd, &built_query, db, db_len, - system_charset_info, thd->charset()); - built_query.append("."); - } - - thd->variables.option_bits &= ~OPTION_QUOTE_SHOW_CREATE; - wsrep_append_name(thd, &built_query, table->table_name, - strlen(table->table_name), system_charset_info, - thd->charset()); - built_query.append(","); - } - } - - if (non_tmp_table_deleted) - { - /* Chop of the last comma */ - built_query.chop(); - built_query.append(" /* generated by server */"); - WSREP_DEBUG("TOI for %s", built_query.ptr()); - if (WSREP_TO_ISOLATION_BEGIN_QUERY(built_query.ptr(), NULL, NULL, tables)) - { - WSREP_DEBUG("TOI failed for DROP TABLE: %s", WSREP_QUERY(thd)); - error= 1; - goto end; - } - } - -end: - DBUG_RETURN(error); -} - -#endif /* WITH_WSREP */ /** Execute the drop of a normal or temporary table. diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 6d0c5e75592..fa8991709db 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -2,7 +2,7 @@ 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. + the Free Software Foundation; version 2 of the License.x1 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,6 +16,7 @@ #include #include #include +#include /* find_temporary_table() */ #include "wsrep_priv.h" #include "wsrep_thd.h" #include "wsrep_sst.h" @@ -948,86 +949,66 @@ static bool wsrep_prepare_keys_for_isolation(THD* thd, const TABLE_LIST* table_list, wsrep_key_arr_t* ka) { - ka->keys= 0; - ka->keys_len= 0; + ka->keys= 0; + ka->keys_len= 0; - extern TABLE* find_temporary_table(THD*, const TABLE_LIST*); - - if (db || table) + if (db || table) + { + if (!(ka->keys= (wsrep_key_t*)my_malloc(sizeof(wsrep_key_t), MYF(0)))) { - TABLE_LIST tmp_table; - MDL_request mdl_request; - - memset(&tmp_table, 0, sizeof(tmp_table)); - tmp_table.table_name= (char*)table; - tmp_table.db= (char*)db; - tmp_table.mdl_request.init(MDL_key::GLOBAL, (db) ? db : "", - (table) ? table : "", - MDL_INTENTION_EXCLUSIVE, MDL_STATEMENT); - - if (!table || !find_temporary_table(thd, &tmp_table)) - { - if (!(ka->keys= (wsrep_key_t*)my_malloc(sizeof(wsrep_key_t), MYF(0)))) - { - WSREP_ERROR("Can't allocate memory for key_array"); - goto err; - } - ka->keys_len= 1; - if (!(ka->keys[0].key_parts= (wsrep_buf_t*) - my_malloc(sizeof(wsrep_buf_t)*2, MYF(0)))) - { - WSREP_ERROR("Can't allocate memory for key_parts"); - goto err; - } - ka->keys[0].key_parts_num= 2; - if (!wsrep_prepare_key_for_isolation( - db, table, - (wsrep_buf_t*)ka->keys[0].key_parts, - &ka->keys[0].key_parts_num)) - { - WSREP_ERROR("Preparing keys for isolation failed"); - goto err; - } - } + WSREP_ERROR("Can't allocate memory for key_array"); + goto err; } - - for (const TABLE_LIST* table= table_list; table; table= table->next_global) + ka->keys_len= 1; + if (!(ka->keys[0].key_parts= (wsrep_buf_t*) + my_malloc(sizeof(wsrep_buf_t)*2, MYF(0)))) { - if (!find_temporary_table(thd, table)) - { - wsrep_key_t* tmp; - tmp= (wsrep_key_t*)my_realloc( - ka->keys, (ka->keys_len + 1) * sizeof(wsrep_key_t), - MYF(MY_ALLOW_ZERO_PTR)); - - if (!tmp) - { - WSREP_ERROR("Can't allocate memory for key_array"); - goto err; - } - ka->keys= tmp; - if (!(ka->keys[ka->keys_len].key_parts= (wsrep_buf_t*) - my_malloc(sizeof(wsrep_buf_t)*2, MYF(0)))) - { - WSREP_ERROR("Can't allocate memory for key_parts"); - goto err; - } - ka->keys[ka->keys_len].key_parts_num= 2; - ++ka->keys_len; - if (!wsrep_prepare_key_for_isolation( - table->db, table->table_name, - (wsrep_buf_t*)ka->keys[ka->keys_len - 1].key_parts, - &ka->keys[ka->keys_len - 1].key_parts_num)) - { - WSREP_ERROR("Preparing keys for isolation failed"); - goto err; - } - } + WSREP_ERROR("Can't allocate memory for key_parts"); + goto err; + } + ka->keys[0].key_parts_num= 2; + if (!wsrep_prepare_key_for_isolation( + db, table, + (wsrep_buf_t*)ka->keys[0].key_parts, + &ka->keys[0].key_parts_num)) + { + WSREP_ERROR("Preparing keys for isolation failed (1)"); + goto err; } - return true; + } + + for (const TABLE_LIST* table= table_list; table; table= table->next_global) + { + wsrep_key_t* tmp; + tmp= (wsrep_key_t*)my_realloc(ka->keys, + (ka->keys_len + 1) * sizeof(wsrep_key_t), + MYF(0)); + if (!tmp) + { + WSREP_ERROR("Can't allocate memory for key_array"); + goto err; + } + ka->keys= tmp; + if (!(ka->keys[ka->keys_len].key_parts= (wsrep_buf_t*) + my_malloc(sizeof(wsrep_buf_t)*2, MYF(0)))) + { + WSREP_ERROR("Can't allocate memory for key_parts"); + goto err; + } + ka->keys[ka->keys_len].key_parts_num= 2; + ++ka->keys_len; + if (!wsrep_prepare_key_for_isolation(table->db, table->table_name, + (wsrep_buf_t*)ka->keys[ka->keys_len - 1].key_parts, + &ka->keys[ka->keys_len - 1].key_parts_num)) + { + WSREP_ERROR("Preparing keys for isolation failed (2)"); + goto err; + } + } + return 0; err: wsrep_keys_free(ka); - return false; + return 1; } @@ -1205,6 +1186,144 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len) return wsrep_to_buf_helper(thd, buff.ptr(), buff.length(), buf, buf_len); } +/* + Rewrite DROP TABLE for TOI. Temporary tables are eliminated from + the query as they are visible only to client connection. + + TODO: See comments for sql_base.cc:drop_temporary_table() and refine + the function to deal with transactional locked tables. + */ +static int wsrep_drop_table_query(THD* thd, uchar** buf, size_t* buf_len) +{ + + LEX* lex= thd->lex; + SELECT_LEX* select_lex= &lex->select_lex; + TABLE_LIST* first_table= select_lex->table_list.first; + String buff; + + DBUG_ASSERT(!lex->drop_temporary); + + bool found_temp_table= false; + for (TABLE_LIST* table= first_table; table; table= table->next_global) + { + if (find_temporary_table(thd, table->db, table->table_name)) + { + found_temp_table= true; + break; + } + } + + if (found_temp_table) + { + buff.append("DROP TABLE "); + if (lex->check_exists) + buff.append("IF EXISTS "); + + for (TABLE_LIST* table= first_table; table; table= table->next_global) + { + if (!find_temporary_table(thd, table->db, table->table_name)) + { + append_identifier(thd, &buff, table->db, strlen(table->db)); + buff.append("."); + append_identifier(thd, &buff, table->table_name, + strlen(table->table_name)); + buff.append(","); + } + } + + /* Chop the last comma */ + buff.chop(); + buff.append(" /* generated by wsrep */"); + + WSREP_DEBUG("Rewrote '%s' as '%s'", thd->query(), buff.ptr()); + + return wsrep_to_buf_helper(thd, buff.ptr(), buff.length(), buf, buf_len); + } + else + { + return wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), + buf, buf_len); + } +} + +/* + Decide if statement should run in TOI. + + Look if table or table_list contain temporary tables. If the + statement affects only temporary tables, statement should not run + in TOI. If the table list contains mix of regular and temporary tables + (DROP TABLE, OPTIMIZE, ANALYZE), statement should be run in TOI but + should be rewritten at later time for replication to contain only + non-temporary tables. + */ +static bool wsrep_can_run_in_toi(THD *thd, const char *db, const char *table, + const TABLE_LIST *table_list) +{ + DBUG_ASSERT(!table || db); + DBUG_ASSERT(table_list || db); + + LEX* lex= thd->lex; + SELECT_LEX* select_lex= &lex->select_lex; + TABLE_LIST* first_table= select_lex->table_list.first; + + switch (lex->sql_command) + { + case SQLCOM_CREATE_TABLE: + DBUG_ASSERT(!table_list); + if (thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) + { + return false; + } + return true; + + case SQLCOM_CREATE_VIEW: + + DBUG_ASSERT(!table_list); + DBUG_ASSERT(first_table); /* First table is view name */ + /* + If any of the remaining tables refer to temporary table error + is returned to client, so TOI can be skipped + */ + for (TABLE_LIST* it= first_table->next_global; it; it= it->next_global) + { + if (find_temporary_table(thd, it)) + { + return false; + } + } + return true; + + case SQLCOM_CREATE_TRIGGER: + + DBUG_ASSERT(!table_list); + DBUG_ASSERT(first_table); + + if (find_temporary_table(thd, first_table)) + { + return false; + } + return true; + + default: + if (table && !find_temporary_table(thd, db, table)) + { + return true; + } + + if (table_list) + { + for (TABLE_LIST* table= first_table; table; table= table->next_global) + { + if (!find_temporary_table(thd, table->db, table->table_name)) + { + return true; + } + } + } + return !(table || table_list); + } +} + /* returns: 0: statement was replicated as TOI @@ -1220,6 +1339,12 @@ static int wsrep_TOI_begin(THD *thd, const char *query, char *db_, char *table_, int buf_err; int rc= 0; + if (wsrep_can_run_in_toi(thd, db_, table_, table_list) == false) + { + WSREP_DEBUG("No TOI for %s", WSREP_QUERY(thd)); + return 1; + } + WSREP_DEBUG("TO BEGIN: %lld, %d : %s", (long long)wsrep_thd_trx_seqno(thd), thd->wsrep_exec_mode, thd->query() ); switch (thd->lex->sql_command) @@ -1255,9 +1380,9 @@ static int wsrep_TOI_begin(THD *thd, const char *query, char *db_, char *table_, wsrep_key_arr_t key_arr= {0, 0}; struct wsrep_buf buff = { buf, buf_len }; - if (!buf_err && - wsrep_prepare_keys_for_isolation(thd, db_, table_, table_list, &key_arr)&& - key_arr.keys_len > 0 && + if (!buf_err && + !wsrep_prepare_keys_for_isolation(thd, db_, table_, table_list, &key_arr) && + key_arr.keys_len > 0 && WSREP_OK == (ret = wsrep->to_execute_start(wsrep, thd->thread_id, key_arr.keys, key_arr.keys_len, &buff, 1, @@ -1453,9 +1578,12 @@ int wsrep_to_isolation_begin(THD *thd, const char *query, char *db_, char *table if (thd->variables.wsrep_on && thd->wsrep_exec_mode==LOCAL_STATE) { switch (thd->variables.wsrep_OSU_method) { - case WSREP_OSU_TOI: ret = wsrep_TOI_begin(thd, query, db_, table_, - table_list); break; - case WSREP_OSU_RSU: ret = wsrep_RSU_begin(thd, db_, table_); break; + case WSREP_OSU_TOI: + ret = wsrep_TOI_begin(thd, query, db_, table_, table_list); + break; + case WSREP_OSU_RSU: + ret = wsrep_RSU_begin(thd, db_, table_); + break; default: WSREP_ERROR("Unsupported OSU method: %lu", thd->variables.wsrep_OSU_method); diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index fa069723021..ea7e7df9e10 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -337,9 +337,6 @@ void wsrep_init_sidno(const wsrep_uuid_t&); bool wsrep_node_is_donor(); bool wsrep_node_is_synced(); -int wsrep_replicate_drop_query(THD *thd, TABLE_LIST *tables, bool if_exists, - bool drop_temporary, bool dont_log_query); - #define WSREP_MYSQL_DB (char *)"mysql" #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ From 790a8274cd0ea471a81652aef932191660deb64b Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 22 Feb 2017 23:10:36 +0200 Subject: [PATCH 008/101] Refs: MW-360 * reverted WSREP_TO_ISOLATION macros back to original form --- sql/sql_parse.cc | 14 +++++++++++++- sql/sql_parse.h | 29 +++++++++++++++++++++++------ sql/sql_partition_admin.cc | 4 ++-- sql/sql_truncate.cc | 6 +++--- sql/wsrep_mysqld.cc | 4 ++-- sql/wsrep_mysqld.h | 20 +------------------- 6 files changed, 44 insertions(+), 33 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d63a61e0ab1..e381f14f627 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4040,7 +4040,19 @@ end_with_restore_list: slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) lex->check_exists= 1; - WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); +#ifdef WITH_WSREP + for (TABLE_LIST *table= all_tables; table; table= table->next_global) + { + if (!lex->drop_temporary && + (!thd->is_current_stmt_binlog_format_row() || + !find_temporary_table(thd, table))) + { + WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); + break; + } + } +#endif /* WITH_WSREP */ + /* DDL and binlog write order are protected by metadata locks. */ res= mysql_rm_table(thd, first_table, lex->check_exists, lex->drop_temporary); diff --git a/sql/sql_parse.h b/sql/sql_parse.h index c2dbb950f2a..306ceed1863 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -209,12 +209,29 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) return MY_TEST(cs->mbminlen == 1); } -#ifndef WITH_WSREP -#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) -#define WSREP_TO_ISOLATION_BEGIN_QUERY(db_, query_, table_, table_list_) -#define WSREP_TO_ISOLATION_END -#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, query_, table_, table_list_) -#endif /* !WITH_WSREP */ +#ifdef WITH_WSREP +#define WSREP_MYSQL_DB (char *)"mysql" +#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ + if (WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; + +#define WSREP_TO_ISOLATION_END \ + if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ + wsrep_to_isolation_end(thd); + +/* Checks if lex->no_write_to_binlog is set for statements that use + LOCAL or NO_WRITE_TO_BINLOG +*/ +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ + if (WSREP(thd) && !thd->lex->no_write_to_binlog \ + && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; + +#else + +#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) +#define WSREP_TO_ISOLATION_END +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) + +#endif /* WITH_WSREP */ #endif /* SQL_PARSE_INCLUDED */ diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index d50fe0379f3..56c9c5bf3bf 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -537,7 +537,7 @@ bool Sql_cmd_alter_table_exchange_partition:: if ((!thd->is_current_stmt_binlog_format_row() || /* TODO: Do we really need to check for temp tables in this case? */ !find_temporary_table(thd, table_list)) && - wsrep_to_isolation_begin(thd, NULL, table_list->db, table_list->table_name, + wsrep_to_isolation_begin(thd, table_list->db, table_list->table_name, NULL)) { WSREP_WARN("ALTER TABLE EXCHANGE PARTITION isolation failure"); @@ -785,7 +785,7 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd) if (WSREP(thd) && (!thd->is_current_stmt_binlog_format_row() || !find_temporary_table(thd, first_table)) && wsrep_to_isolation_begin( - thd, NULL, first_table->db, first_table->table_name, NULL) + thd, first_table->db, first_table->table_name, NULL) ) { WSREP_WARN("ALTER TABLE TRUNCATE PARTITION isolation failure"); diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index d047186b2cf..5182b35d80f 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -487,9 +487,9 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) bool hton_can_recreate; #ifdef WITH_WSREP - if (WSREP(thd) && wsrep_to_isolation_begin(thd, NULL, - table_ref->db, - table_ref->table_name, NULL)) + if (WSREP(thd) && wsrep_to_isolation_begin(thd, + table_ref->db, + table_ref->table_name, NULL)) DBUG_RETURN(TRUE); #endif /* WITH_WSREP */ if (lock_table(thd, table_ref, &hton_can_recreate)) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index fa8991709db..cf8ac25aa6a 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1523,7 +1523,7 @@ static void wsrep_RSU_end(THD *thd) thd->variables.wsrep_on = 1; } -int wsrep_to_isolation_begin(THD *thd, const char *query, char *db_, char *table_, +int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, const TABLE_LIST* table_list) { @@ -1579,7 +1579,7 @@ int wsrep_to_isolation_begin(THD *thd, const char *query, char *db_, char *table { switch (thd->variables.wsrep_OSU_method) { case WSREP_OSU_TOI: - ret = wsrep_TOI_begin(thd, query, db_, table_, table_list); + ret = wsrep_TOI_begin(thd, thd->query(), db_, table_, table_list); break; case WSREP_OSU_RSU: ret = wsrep_RSU_begin(thd, db_, table_); diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index ea7e7df9e10..1cda5d23986 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -320,7 +320,7 @@ extern PSI_mutex_key key_LOCK_wsrep_slave_threads; extern PSI_mutex_key key_LOCK_wsrep_desync; #endif /* HAVE_PSI_INTERFACE */ struct TABLE_LIST; -int wsrep_to_isolation_begin(THD *thd, const char * query, char *db_, char *table_, +int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, const TABLE_LIST* table_list); void wsrep_to_isolation_end(THD *thd); void wsrep_cleanup_transaction(THD *thd); @@ -338,22 +338,4 @@ void wsrep_init_sidno(const wsrep_uuid_t&); bool wsrep_node_is_donor(); bool wsrep_node_is_synced(); -#define WSREP_MYSQL_DB (char *)"mysql" -#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ - if (WSREP(thd) && wsrep_to_isolation_begin(thd, NULL, db_, table_, table_list_)) goto error; - -#define WSREP_TO_ISOLATION_BEGIN_QUERY(query, db_, table_, table_list_) \ - (WSREP(thd) && wsrep_to_isolation_begin(thd, query, db_, table_, table_list_)) - -#define WSREP_TO_ISOLATION_END \ - if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ - wsrep_to_isolation_end(thd); - -/* Checks if lex->no_write_to_binlog is set for statements that use - LOCAL or NO_WRITE_TO_BINLOG -*/ -#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ - if (WSREP(thd) && !thd->lex->no_write_to_binlog \ - && wsrep_to_isolation_begin(thd, NULL, db_, table_, table_list_)) goto error; - #endif /* WSREP_MYSQLD_H */ From 0ddf32c840b8b30957104d2a5b59d4edd9dcc297 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 16 Jan 2017 16:10:37 +0200 Subject: [PATCH 009/101] refs: MW-322 * generating fake trx id for CTAS, requires trx_sys mutex protection to be safe for concurrent CTAS processors --- storage/innobase/handler/ha_innodb.cc | 2 +- storage/xtradb/handler/ha_innodb.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a60c615828b..17fd02112d9 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -17945,7 +17945,7 @@ wsrep_fake_trx_id( mutex_enter(&trx_sys->mutex); trx_id_t trx_id = trx_sys_get_new_trx_id(); mutex_exit(&trx_sys->mutex); - + WSREP_DEBUG("innodb fake trx id: %lu thd: %s", trx_id, wsrep_thd_query(thd)); (void *)wsrep_ws_handle_for_trx(wsrep_thd_ws_handle(thd), trx_id); } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 8d48f63b962..ac2bf1010d6 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -19247,7 +19247,7 @@ wsrep_fake_trx_id( mutex_enter(&trx_sys->mutex); trx_id_t trx_id = trx_sys_get_new_trx_id(); mutex_exit(&trx_sys->mutex); - + WSREP_DEBUG("innodb fake trx id: %lu thd: %s", trx_id, wsrep_thd_query(thd)); (void *)wsrep_ws_handle_for_trx(wsrep_thd_ws_handle(thd), trx_id); } From ba3d26d3ab1bd7a58bb7455dc57c458e12eb72eb Mon Sep 17 00:00:00 2001 From: sjaakola Date: Sun, 26 Feb 2017 23:48:32 +0200 Subject: [PATCH 010/101] Refs: MW-360 * fixes required in pull request review --- sql/sql_table.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e2b16d402bf..f789df26475 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2110,6 +2110,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, DBUG_RETURN(TRUE); my_ok(thd); DBUG_RETURN(FALSE); + } @@ -2674,7 +2675,7 @@ err: end: #ifdef WITH_WSREP - thd->wsrep_skip_wsrep_GTID = false; + thd->wsrep_skip_wsrep_GTID = false; #endif /* WITH_WSREP */ DBUG_RETURN(error); } From 5fb1260365a6dd8249414a58173ab238fe6d5996 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 1 Mar 2017 11:27:33 +0200 Subject: [PATCH 011/101] Refs: MW-360, white space fix --- sql/sql_parse.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 306ceed1863..cf58ecb19e1 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -208,7 +208,6 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) { return MY_TEST(cs->mbminlen == 1); } - #ifdef WITH_WSREP #define WSREP_MYSQL_DB (char *)"mysql" From 906426370318b4ab0af53485e7835c4ef43c7097 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 3 Mar 2017 03:51:07 -0800 Subject: [PATCH 012/101] Galera MTR Tests: Test for GAL-491: Progress output for IST --- .../suite/galera/r/galera_ist_progress.result | 19 +++++ .../suite/galera/t/galera_ist_progress.cnf | 5 ++ .../suite/galera/t/galera_ist_progress.test | 74 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera_ist_progress.result create mode 100644 mysql-test/suite/galera/t/galera_ist_progress.cnf create mode 100644 mysql-test/suite/galera/t/galera_ist_progress.test diff --git a/mysql-test/suite/galera/r/galera_ist_progress.result b/mysql-test/suite/galera/r/galera_ist_progress.result new file mode 100644 index 00000000000..9fc7febbea5 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ist_progress.result @@ -0,0 +1,19 @@ +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; +SET SESSION wsrep_on = OFF; +SET SESSION wsrep_on = ON; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); +INSERT INTO t1 VALUES (10); +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; +include/assert_grep.inc [Receiving IST: 11 writesets, seqnos] +include/assert_grep.inc [Receiving IST\.\.\. 0\.0% \( 0/11 events\) complete] +include/assert_grep.inc [Receiving IST\.\.\.100\.0% \(11/11 events\) complete] +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_ist_progress.cnf b/mysql-test/suite/galera/t/galera_ist_progress.cnf new file mode 100644 index 00000000000..0a26f6d6c83 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_progress.cnf @@ -0,0 +1,5 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_ist_progress.test b/mysql-test/suite/galera/t/galera_ist_progress.test new file mode 100644 index 00000000000..a4d331b37d7 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_progress.test @@ -0,0 +1,74 @@ +# +# Test progress output during IST +# + +--source include/galera_cluster.inc + +# Isolate node #2 +--connection node_2 +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +SET SESSION wsrep_on = OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +SET SESSION wsrep_on = ON; + +# Node #2 is now isolated. Run some transactions to accumulate writesets for IST + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); +INSERT INTO t1 VALUES (10); + +# Restore node #2, IST is performed + +--connection node_2 +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +# +# Grep for expected IST output in joiner log +# + +--connection node_1 + +--let $assert_count = 1 +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err +--let $assert_only_after = Need state transfer + +--let $assert_text = Receiving IST: 11 writesets, seqnos +--let $assert_select = Receiving IST: 11 writesets, seqnos +--source include/assert_grep.inc + +--let $assert_text = Receiving IST\.\.\. 0\.0% \( 0/11 events\) complete +--let $assert_select = Receiving IST\.\.\. 0\.0% \( 0/11 events\) complete +--source include/assert_grep.inc + +--let $assert_text = Receiving IST\.\.\.100\.0% \(11/11 events\) complete +--let $assert_select = Receiving IST\.\.\.100\.0% \(11/11 events\) complete +--source include/assert_grep.inc + +# Cleanup + +--connection node_1 +DROP TABLE t1; From 3ef3c467ad4ced24e7ed858fc080eb5ba985f1ee Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 2 Mar 2017 17:53:16 +0100 Subject: [PATCH 013/101] MW-365 Do not load/dump innodb buffer pool with wsrep_recover --- storage/innobase/buf/buf0dump.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index 83f870692a9..0682b8ef46e 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -41,6 +41,9 @@ Created April 08, 2011 Vasil Dimov #include "sync0rw.h" /* rw_lock_s_lock() */ #include "ut0byte.h" /* ut_ull_create() */ #include "ut0sort.h" /* UT_SORT_FUNCTION_BODY */ +#ifdef WITH_WSREP +extern my_bool wsrep_recovery; +#endif /* WITH_WSREP */ enum status_severity { STATUS_INFO, @@ -689,7 +692,13 @@ DECLARE_THREAD(buf_dump_thread)( buf_load_status(STATUS_INFO, "not started"); if (srv_buffer_pool_load_at_startup) { +#ifdef WITH_WSREP + if (!wsrep_recovery) { +#endif /* WITH_WSREP */ buf_load(); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ } while (!SHUTTING_DOWN()) { @@ -713,8 +722,14 @@ DECLARE_THREAD(buf_dump_thread)( } if (srv_buffer_pool_dump_at_shutdown && srv_fast_shutdown != 2) { +#ifdef WITH_WSREP + if (!wsrep_recovery) { +#endif /* WITH_WSREP */ buf_dump(FALSE /* ignore shutdown down flag, keep going even if we are in a shutdown state */); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ } srv_buf_dump_thread_active = FALSE; From 6da41e17d8cf833a5eb648fe8204e7031bb0e410 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 2 Mar 2017 17:53:16 +0100 Subject: [PATCH 014/101] MW-365 Do not load/dump innodb buffer pool with wsrep_recover --- storage/xtradb/buf/buf0dump.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/storage/xtradb/buf/buf0dump.cc b/storage/xtradb/buf/buf0dump.cc index 51c41cc1b78..d0892a4f6a5 100644 --- a/storage/xtradb/buf/buf0dump.cc +++ b/storage/xtradb/buf/buf0dump.cc @@ -41,6 +41,9 @@ Created April 08, 2011 Vasil Dimov #include "sync0rw.h" /* rw_lock_s_lock() */ #include "ut0byte.h" /* ut_ull_create() */ #include "ut0sort.h" /* UT_SORT_FUNCTION_BODY */ +#ifdef WITH_WSREP +extern my_bool wsrep_recovery; +#endif /* WITH_WSREP */ enum status_severity { STATUS_INFO, @@ -690,7 +693,13 @@ DECLARE_THREAD(buf_dump_thread)( buf_load_status(STATUS_INFO, "not started"); if (srv_buffer_pool_load_at_startup) { +#ifdef WITH_WSREP + if (!wsrep_recovery) { +#endif /* WITH_WSREP */ buf_load(); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ } while (!SHUTTING_DOWN()) { @@ -714,8 +723,14 @@ DECLARE_THREAD(buf_dump_thread)( } if (srv_buffer_pool_dump_at_shutdown && srv_fast_shutdown != 2) { +#ifdef WITH_WSREP + if (!wsrep_recovery) { +#endif /* WITH_WSREP */ buf_dump(FALSE /* ignore shutdown down flag, keep going even if we are in a shutdown state */); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ } srv_buf_dump_thread_active = FALSE; From 5108deded580998db3dbc7f9ef44134caeb42616 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 8 Mar 2017 01:35:05 -0800 Subject: [PATCH 015/101] Galera MTR Tests: Stability fixes --- mysql-test/suite/galera/t/GAL-401.test | 2 ++ mysql-test/suite/galera/t/lp1376747-4.test | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/t/GAL-401.test b/mysql-test/suite/galera/t/GAL-401.test index 05295d1b977..b419770f804 100644 --- a/mysql-test/suite/galera/t/GAL-401.test +++ b/mysql-test/suite/galera/t/GAL-401.test @@ -32,6 +32,8 @@ SET wsrep_dirty_reads=0; --source include/wait_condition.inc --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc # Must return 0: SHOW STATUS LIKE 'wsrep_desync_count'; diff --git a/mysql-test/suite/galera/t/lp1376747-4.test b/mysql-test/suite/galera/t/lp1376747-4.test index be56ee5edc1..0c707d6d681 100644 --- a/mysql-test/suite/galera/t/lp1376747-4.test +++ b/mysql-test/suite/galera/t/lp1376747-4.test @@ -45,7 +45,7 @@ SHOW CREATE TABLE t1; --connection node_2a --reap UNLOCK TABLES; ---sleep 1 +--sleep 2 SHOW CREATE TABLE t1; SELECT * from t1; From 83664e21e4fb6755c8c0c90d3dee8819d36928c9 Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Fri, 3 Mar 2017 20:28:27 +0000 Subject: [PATCH 016/101] MW-366 Improved support for IPv6 networks - made mysqld and SST scripts to recognize []-escaped IPv6 addresses - pulled in latest Percona and MariaDB updates to SST scripts - instruct netcat and socat in wsrep_sst_xtrabackup-v2 to listen on IPv6 socket via sockopt parameter in the [sst] section of my.cnf In summary, wsrep_node_address and wsrep_sst_receive_address can now be set to IPv6 addresses escaped by []. Rsync SST works out ouf the box thanks to rsync daemon listening on both IPv4 and IPv6 sockets by default. For xtrabackup SST onver IPv6 one needs to set sockopt in the [sst] section of joiner's configuration file to ",pf=ip6" if using socat as a streamer or to "-6" if using netcat. --- scripts/wsrep_sst_common.sh | 57 +++++ scripts/wsrep_sst_mysqldump.sh | 6 +- scripts/wsrep_sst_rsync.sh | 44 ++-- scripts/wsrep_sst_xtrabackup-v2.sh | 386 ++++++++++++++++++++++------- sql/wsrep_mysqld.cc | 22 +- sql/wsrep_sst.cc | 37 +-- sql/wsrep_utils.cc | 15 ++ sql/wsrep_utils.h | 3 + 8 files changed, 415 insertions(+), 155 deletions(-) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 25ec0baae80..6906bcbc315 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -30,6 +30,22 @@ while [ $# -gt 0 ]; do case "$1" in '--address') readonly WSREP_SST_OPT_ADDR="$2" + # + # Break address string into host:port/path parts + # + if echo $WSREP_SST_OPT_ADDR | grep -qe '^\[.*\]' + then + # IPv6 notation + readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR/\]*/\]} + readonly WSREP_SST_OPT_HOST_UNESCAPED=$(echo $WSREP_SST_OPT_HOST | \ + cut -d '[' -f 2 | cut -d ']' -f 1) + else + # "traditional" notation + readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR%%[:/]*} + fi + readonly WSREP_SST_OPT_PORT=$(echo $WSREP_SST_OPT_ADDR | \ + cut -d ']' -f 2 | cut -s -d ':' -f 2 | cut -d '/' -f 1) + readonly WSREP_SST_OPT_PATH=${WSREP_SST_OPT_ADDR#*/} shift ;; '--bypass') @@ -169,6 +185,11 @@ wsrep_log_error() wsrep_log "[ERROR] $*" } +wsrep_log_warning() +{ + wsrep_log "[WARNING] $*" +} + wsrep_log_info() { wsrep_log "[INFO] $*" @@ -202,3 +223,39 @@ wsrep_check_programs() return $ret } + +# +# user can specify xtrabackup specific settings that will be used during sst +# process like encryption, etc..... +# parse such configuration option. (group for xb settings is [sst] in my.cnf +# +# 1st param: group : name of the config file section, e.g. mysqld +# 2nd param: var : name of the variable in the section, e.g. server-id +# 3rd param: - : default value for the param +parse_cnf() +{ + local group=$1 + local var=$2 + local reval="" + + # print the default settings for given group using my_print_default. + # normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin) + # then grep for needed variable + # finally get the variable value (if variables has been specified multiple time use the last value only) + + # look in group+suffix + if [[ -n $WSREP_SST_OPT_CONF_SUFFIX ]]; then + reval=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF "${group}${WSREP_SST_OPT_CONF_SUFFIX}" | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) + fi + + # look in group + if [[ -z $reval ]]; then + reval=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) + fi + + # use default if we haven't found a value + if [[ -z $reval ]]; then + [[ -n $3 ]] && reval=$3 + fi + echo $reval +} diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh index 9a061f89e43..f6f2187006d 100644 --- a/scripts/wsrep_sst_mysqldump.sh +++ b/scripts/wsrep_sst_mysqldump.sh @@ -30,6 +30,7 @@ local_ip() { [ "$1" = "127.0.0.1" ] && return 0 [ "$1" = "localhost" ] && return 0 + [ "$1" = "[::1]" ] && return 0 [ "$1" = "$(hostname -s)" ] && return 0 [ "$1" = "$(hostname -f)" ] && return 0 [ "$1" = "$(hostname -d)" ] && return 0 @@ -105,8 +106,9 @@ GTID_BINLOG_STATE=$(echo "SHOW GLOBAL VARIABLES LIKE 'gtid_binlog_state'" |\ $MYSQL_CLIENT $AUTH -S$WSREP_SST_OPT_SOCKET --disable-reconnect --connect_timeout=10 |\ tail -1 | awk -F ' ' '{ print $2 }') -MYSQL="$MYSQL_CLIENT $AUTH -h$WSREP_SST_OPT_HOST -P$WSREP_SST_OPT_PORT "\ -"--disable-reconnect --connect_timeout=10" +MYSQL="$MYSQL_CLIENT --defaults-extra-file=$WSREP_SST_OPT_CONF "\ +"$AUTH -h${WSREP_SST_OPT_HOST_UNESCAPED:-$WSREP_SST_OPT_HOST} "\ +"-P$WSREP_SST_OPT_PORT --disable-reconnect --connect_timeout=10" # Check if binary logging is enabled on the joiner node. # Note: SELECT cannot be used at this point. diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 62f9e234d0e..1c1b09ce68f 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -67,6 +67,11 @@ check_pid_and_port() exit 2 # ENOENT fi + if ! which lsof > /dev/null; then + wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed." + exit 2 # ENOENT + fi + local port_info=$(lsof -i :$rsync_port -Pn 2>/dev/null | \ grep "(LISTEN)") local is_rsync=$(echo $port_info | \ @@ -97,10 +102,19 @@ fi WSREP_LOG_DIR=${WSREP_LOG_DIR:-""} # if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf if [ -z "$WSREP_LOG_DIR" ]; then - WSREP_LOG_DIR=$($MY_PRINT_DEFAULTS --defaults-file \ - "$WSREP_SST_OPT_CONF" mysqld server mysqld-10.0 mariadb mariadb-10.0 \ - | grep -- '--innodb[-_]log[-_]group[-_]home[-_]dir=' \ - | cut -b 29- ) + WSREP_LOG_DIR=$(parse_cnf mariadb-10.0 innodb_log_group_home_dir "") +fi +if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$(parse_cnf mysqld innodb_log_group_home_dir "") +fi +if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$(parse_cnf server innodb_log_group_home_dir "") +fi +if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$(parse_cnf mariadb innodb_log_group_home_dir "") +fi +if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$(parse_cnf mysqld-10.0 innodb_log_group_home_dir "") fi if [ -n "$WSREP_LOG_DIR" ]; then @@ -208,8 +222,8 @@ then [ "$OS" == "Linux" ] && count=$(grep -c processor /proc/cpuinfo) [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ] && count=$(sysctl -n hw.ncpu) - find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" -print0 | \ - xargs -I{} -0 -P $count \ + find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" \ + -print0 | xargs -I{} -0 -P $count \ rsync --owner --group --perms --links --specials \ --ignore-times --inplace --recursive --delete --quiet \ $WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \ @@ -252,25 +266,24 @@ then fi rm -rf "$RSYNC_PID" - ADDR=$WSREP_SST_OPT_ADDR - RSYNC_PORT=$(echo $ADDR | awk -F ':' '{ print $2 }') - if [ -z "$RSYNC_PORT" ] - then - RSYNC_PORT=4444 - ADDR="$(echo $ADDR | awk -F ':' '{ print $1 }'):$RSYNC_PORT" - fi - trap "exit 32" HUP PIPE trap "exit 3" INT TERM ABRT trap cleanup_joiner EXIT RSYNC_CONF="$WSREP_SST_OPT_DATA/$MODULE.conf" + if [ -n "${MYSQL_TMP_DIR:-}" ] ; then + SILENT="log file = $MYSQL_TMP_DIR/rsyncd.log" + else + SILENT="" + fi + cat << EOF > "$RSYNC_CONF" pid file = $RSYNC_PID use chroot = no read only = no timeout = 300 +$SILENT [$MODULE] path = $WSREP_SST_OPT_DATA [$MODULE-log_dir] @@ -280,6 +293,7 @@ EOF # rm -rf "$DATA"/ib_logfile* # we don't want old logs around # listen at all interfaces (for firewalled setups) + readonly RSYNC_PORT=${WSREP_SST_OPT_PORT:-4444} rsync --daemon --no-detach --port $RSYNC_PORT --config "$RSYNC_CONF" & RSYNC_REAL_PID=$! @@ -288,7 +302,7 @@ EOF sleep 0.2 done - echo "ready $ADDR/$MODULE" + echo "ready $WSREP_SST_OPT_HOST:$RSYNC_PORT/$MODULE" # wait for SST to complete by monitoring magic file while [ ! -r "$MAGIC_FILE" ] && check_pid "$RSYNC_PID" && \ diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index 6ce3120be43..a702dc641e0 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -34,8 +34,8 @@ ssystag="" XTRABACKUP_PID="" SST_PORT="" REMOTEIP="" +tca="" tcert="" -tpem="" tkey="" sockopt="" progress="" @@ -47,7 +47,6 @@ rlimit="" # Initially stagemsg="${WSREP_SST_OPT_ROLE}" cpat="" -speciald=1 ib_home_dir="" ib_log_dir="" ib_undo_dir="" @@ -71,6 +70,11 @@ xtmpdir="" scomp="" sdecomp="" +ssl_dhparams="" + +ssl_cert="" +ssl_ca="" +ssl_key="" # Required for backup locks # For backup locks it is 1 sent by joiner @@ -150,6 +154,10 @@ get_keys() if [[ -z $ekey ]];then ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile" else + wsrep_log_warning "Using the 'encrypt-key' option causes the encryption key" + wsrep_log_warning "to be set via the command-line and is considered insecure." + wsrep_log_warning "It is recommended to use the 'encrypt-key-file' option instead." + ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key=$ekey" fi @@ -160,6 +168,86 @@ get_keys() stagemsg+="-XB-Encrypted" } +# +# If the ssl_dhparams variable is already set, uses that as a source +# of dh parameters for OpenSSL. Otherwise, looks for dhparams.pem in the +# datadir, and creates it there if it can't find the file. +# No input parameters +# +check_for_dhparams() +{ + if [[ -z "$ssl_dhparams" ]]; then + if ! [[ -r "$DATA/dhparams.pem" ]]; then + wsrep_check_programs openssl + wsrep_log_info "Could not find dhparams file, creating $DATA/dhparams.pem" + + if ! openssl dhparam -out "$DATA/dhparams.pem" 2048 >/dev/null 2>&1 + then + wsrep_log_error "******** FATAL ERROR ********************************* " + wsrep_log_error "* Could not create the dhparams.pem file with OpenSSL. " + wsrep_log_error "****************************************************** " + exit 22 + fi + fi + ssl_dhparams="$DATA/dhparams.pem" + fi +} + +# +# verifies that the certificate matches the private key +# doing this will save us having to wait for a timeout that would +# otherwise occur. +# +# 1st param: path to the cert +# 2nd param: path to the private key +# +verify_cert_matches_key() +{ + local cert_path=$1 + local key_path=$2 + + wsrep_check_programs openssl diff + + # generate the public key from the cert and the key + # they should match (otherwise we can't create an SSL connection) + if ! diff <(openssl x509 -in "$cert_path" -pubkey -noout) <(openssl rsa -in "$key_path" -pubout 2>/dev/null) >/dev/null 2>&1 + then + wsrep_log_error "******** FATAL ERROR ************************* " + wsrep_log_error "* The certifcate and private key do not match. " + wsrep_log_error "* Please check your certificate and key files. " + wsrep_log_error "********************************************** " + exit 22 + fi +} + +# Checks to see if the file exists +# If the file does not exist (or cannot be read), issues an error +# and exits +# +# 1st param: file name to be checked (for read access) +# 2nd param: 1st error message (header) +# 3rd param: 2nd error message (footer, optional) +# +verify_file_exists() +{ + local file_path=$1 + local error_message1=$2 + local error_message2=$3 + + if ! [[ -r "$file_path" ]]; then + wsrep_log_error "******** FATAL ERROR ************************* " + wsrep_log_error "* $error_message1 " + wsrep_log_error "* Could not find/access : $file_path " + + if ! [[ -z "$error_message2" ]]; then + wsrep_log_error "* $error_message2 " + fi + + wsrep_log_error "********************************************** " + exit 22 + fi +} + get_transfer() { if [[ -z $SST_PORT ]];then @@ -173,15 +261,25 @@ get_transfer() wsrep_log_error "nc(netcat) not found in path: $PATH" exit 2 fi + + if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then + wsrep_log_error "******** FATAL ERROR *********************** " + wsrep_log_error "* Using SSL encryption (encrypt= 2, 3, or 4) " + wsrep_log_error "* is not supported when using nc(netcat). " + wsrep_log_error "******************************************** " + exit 22 + fi + wsrep_log_info "Using netcat as streamer" if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then - if nc -h 2>&1 | grep -q ncat;then - tcmd="nc -l ${TSST_PORT}" + if nc -h 2>&1 | grep -q ncat; then + tcmd="nc $sockopt -l ${TSST_PORT}" else - tcmd="nc -dl ${TSST_PORT}" + tcmd="nc $sockopt -dl ${TSST_PORT}" fi else - tcmd="nc ${REMOTEIP} ${TSST_PORT}" + # netcat doesn't understand [] around IPv6 address + tcmd="nc ${REMOTEIP//[\[\]]/} ${TSST_PORT}" fi else tfmt='socat' @@ -191,64 +289,111 @@ get_transfer() exit 2 fi - if [[ $encrypt -eq 2 || $encrypt -eq 3 ]] && ! socat -V | grep -q WITH_OPENSSL;then - wsrep_log_info "NOTE: socat is not openssl enabled, falling back to plain transfer" - encrypt=-1 + donor_extra="" + joiner_extra="" + if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then + if ! socat -V | grep -q WITH_OPENSSL; then + wsrep_log_error "******** FATAL ERROR ****************** " + wsrep_log_error "* socat is not openssl enabled. " + wsrep_log_error "* Unable to encrypt SST communications. " + wsrep_log_error "*************************************** " + exit 2 + fi + + # Determine the socat version + SOCAT_VERSION=`socat -V 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1` + if [[ -z "$SOCAT_VERSION" ]]; then + wsrep_log_error "******** FATAL ERROR **************** " + wsrep_log_error "* Cannot determine the socat version. " + wsrep_log_error "************************************* " + exit 2 + fi + + # socat versions < 1.7.3 will have 512-bit dhparams (too small) + # so create 2048-bit dhparams and send that as a parameter + # socat version >= 1.7.3, checks to see if the peername matches the hostname + # set commonname="" to disable the peername checks + # + if ! check_for_version "$SOCAT_VERSION" "1.7.3"; then + if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then + # dhparams check (will create ssl_dhparams if needed) + check_for_dhparams + joiner_extra=",dhparam=$ssl_dhparams" + fi + fi + if check_for_version "$SOCAT_VERSION" "1.7.3"; then + donor_extra=',commonname=""' + fi fi - if [[ $encrypt -eq 2 ]];then - wsrep_log_info "Using openssl based encryption with socat: with crt and pem" - if [[ -z $tpem || -z $tcert ]];then - wsrep_log_error "Both PEM and CRT files required" - exit 22 - fi + if [[ $encrypt -eq 2 ]]; then + wsrep_log_warning "**** WARNING **** encrypt=2 is deprecated and will be removed in a future release" + wsrep_log_info "Using openssl based encryption with socat: with crt and ca" + + verify_file_exists "$tcert" "Both certificate and CA files are required." \ + "Please check the 'tcert' option. " + verify_file_exists "$tca" "Both certificate and CA files are required." \ + "Please check the 'tca' option. " + stagemsg+="-OpenSSL-Encrypted-2" if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then - wsrep_log_info "Decrypting with PEM $tpem, CA: $tcert" - tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=$tpem,cafile=${tcert}${sockopt} stdio" + wsrep_log_info "Decrypting with CERT: $tcert, CA: $tca" + tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},cafile=${tca}${joiner_extra}${sockopt} stdio" else - wsrep_log_info "Encrypting with PEM $tpem, CA: $tcert" - tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=$tpem,cafile=${tcert}${sockopt}" + wsrep_log_info "Encrypting with CERT: $tcert, CA: $tca" + tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tcert},cafile=${tca}${donor_extra}${sockopt}" fi elif [[ $encrypt -eq 3 ]];then + wsrep_log_warning "**** WARNING **** encrypt=3 is deprecated and will be removed in a future release" wsrep_log_info "Using openssl based encryption with socat: with key and crt" - if [[ -z $tpem || -z $tkey ]];then - wsrep_log_error "Both certificate and key files required" - exit 22 - fi + + verify_file_exists "$tcert" "Both certificate and key files are required." \ + "Please check the 'tcert' option. " + verify_file_exists "$tkey" "Both certificate and key files are required." \ + "Please check the 'tkey' option. " + stagemsg+="-OpenSSL-Encrypted-3" if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then - wsrep_log_info "Decrypting with certificate $tpem, key $tkey" - tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=$tpem,key=${tkey},verify=0${sockopt} stdio" + wsrep_log_info "Decrypting with CERT: $tcert, KEY: $tkey" + tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},key=${tkey},verify=0${joiner_extra}${sockopt} stdio" else - wsrep_log_info "Encrypting with certificate $tpem, key $tkey" - tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=$tpem,key=${tkey},verify=0${sockopt}" + wsrep_log_info "Encrypting with CERT: $tcert, KEY: $tkey" + tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tcert},key=${tkey},verify=0${sockopt}" + fi + elif [[ $encrypt -eq 4 ]]; then + wsrep_log_info "Using openssl based encryption with socat: with key, crt, and ca" + + verify_file_exists "$ssl_ca" "CA, certificate, and key files are required." \ + "Please check the 'ssl-ca' option. " + verify_file_exists "$ssl_cert" "CA, certificate, and key files are required." \ + "Please check the 'ssl-cert' option. " + verify_file_exists "$ssl_key" "CA, certificate, and key files are required." \ + "Please check the 'ssl-key' option. " + + # Check to see that the key matches the cert + verify_cert_matches_key $ssl_cert $ssl_key + + stagemsg+="-OpenSSL-Encrypted-4" + if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then + wsrep_log_info "Decrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca" + tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${joiner_extra}${sockopt} stdio" + else + wsrep_log_info "Encrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca" + tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${donor_extra}${sockopt}" fi - else - if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then + else + if [[ $encrypt -eq 1 ]]; then + wsrep_log_warning "**** WARNING **** encrypt=1 is deprecated and will be removed in a future release" + fi + + if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio" else tcmd="socat -u stdio TCP:${REMOTEIP}:${TSST_PORT}${sockopt}" fi fi fi - -} - -parse_cnf() -{ - local group=$1 - local var=$2 - # print the default settings for given group using my_print_default. - # normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin) - # then grep for needed variable - # finally get the variable value (if variables has been specified multiple time use the last value only) - reval=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) - if [[ -z $reval ]];then - [[ -n $3 ]] && reval=$3 - fi - echo $reval } get_footprint() @@ -298,15 +443,15 @@ read_cnf() { sfmt=$(parse_cnf sst streamfmt "xbstream") tfmt=$(parse_cnf sst transferfmt "socat") - tcert=$(parse_cnf sst tca "") - tpem=$(parse_cnf sst tcert "") + tca=$(parse_cnf sst tca "") + tcert=$(parse_cnf sst tcert "") tkey=$(parse_cnf sst tkey "") encrypt=$(parse_cnf sst encrypt 0) sockopt=$(parse_cnf sst sockopt "") progress=$(parse_cnf sst progress "") rebuild=$(parse_cnf sst rebuild 0) ttime=$(parse_cnf sst time 0) - cpat=$(parse_cnf sst cpat '.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$') + cpat=$(parse_cnf sst cpat '.*\.pem$\|.*init\.ok$\|.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$') ealgo=$(parse_cnf xtrabackup encrypt "") ekey=$(parse_cnf xtrabackup encrypt-key "") ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "") @@ -320,9 +465,23 @@ read_cnf() ekey=$(parse_cnf sst encrypt-key "") ekeyfile=$(parse_cnf sst encrypt-key-file "") fi + + # Pull the parameters needed for encrypt=4 + ssl_ca=$(parse_cnf sst ssl-ca "") + if [[ -z "$ssl_ca" ]]; then + ssl_ca=$(parse_cnf mysqld ssl-ca "") + fi + ssl_cert=$(parse_cnf sst ssl-cert "") + if [[ -z "$ssl_cert" ]]; then + ssl_cert=$(parse_cnf mysqld ssl-cert "") + fi + ssl_key=$(parse_cnf sst ssl-key "") + if [[ -z "$ssl_key" ]]; then + ssl_key=$(parse_cnf mysqld ssl-key "") + fi + rlimit=$(parse_cnf sst rlimit "") uextra=$(parse_cnf sst use-extra 0) - speciald=$(parse_cnf sst sst-special-dirs 1) iopts=$(parse_cnf sst inno-backup-opts "") iapts=$(parse_cnf sst inno-apply-opts "") impts=$(parse_cnf sst inno-move-opts "") @@ -331,13 +490,8 @@ read_cnf() ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}") ssystag+="-" - if [[ $speciald -eq 0 ]];then - wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1" - speciald=1 - fi - if [[ $ssyslog -ne -1 ]];then - if my_print_defaults -c $WSREP_SST_OPT_CONF mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then + if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then ssyslog=1 fi fi @@ -483,28 +637,30 @@ kill_xtrabackup() setup_ports() { if [[ "$WSREP_SST_OPT_ROLE" == "donor" ]];then - SST_PORT=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $2 }') - REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F ':' '{ print $1 }') - lsn=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $4 }') - sst_ver=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $5 }') + SST_PORT=$WSREP_SST_OPT_PORT + REMOTEIP=$WSREP_SST_OPT_HOST + lsn=$(echo $WSREP_SST_OPT_PATH | awk -F '[/]' '{ print $2 }') + sst_ver=$(echo $WSREP_SST_OPT_PATH | awk -F '[/]' '{ print $3 }') else - SST_PORT=$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $2 }') + SST_PORT=$WSREP_SST_OPT_PORT fi } -# waits ~10 seconds for nc to open the port and then reports ready +# waits ~1 minute for nc/socat to open the port and then reports ready # (regardless of timeout) wait_for_listen() { - local PORT=$1 - local ADDR=$2 + local HOST=$1 + local PORT=$2 local MODULE=$3 - for i in {1..50} + + for i in {1..300} do ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break sleep 0.2 done - echo "ready ${ADDR}/${MODULE}//$sst_ver" + + echo "ready ${HOST}:${PORT}/${MODULE}//$sst_ver" } check_extra() @@ -512,7 +668,7 @@ check_extra() local use_socket=1 if [[ $uextra -eq 1 ]];then if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then - local eport=$(my_print_defaults -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2) + local eport=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2) if [[ -n $eport ]];then # Xtrabackup works only locally. # Hence, setting host to 127.0.0.1 unconditionally. @@ -607,11 +763,64 @@ send_donor() } +# Returns the version string in a standardized format +# Input "1.2.3" => echoes "010203" +# Wrongly formatted values => echoes "000000" +normalize_version() +{ + local major=0 + local minor=0 + local patch=0 + + # Only parses purely numeric version numbers, 1.2.3 + # Everything after the first three values are ignored + if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.?([0-9]*)([\.0-9])*$ ]]; then + major=${BASH_REMATCH[1]} + minor=${BASH_REMATCH[2]} + patch=${BASH_REMATCH[3]} + fi + + printf %02d%02d%02d $major $minor $patch +} + +# Compares two version strings +# The first parameter is the version to be checked +# The second parameter is the minimum version required +# Returns 1 (failure) if $1 >= $2, 0 (success) otherwise +check_for_version() +{ + local local_version_str="$( normalize_version $1 )" + local required_version_str="$( normalize_version $2 )" + + if [[ "$local_version_str" < "$required_version_str" ]]; then + return 1 + else + return 0 + fi +} + + if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then wsrep_log_error "innobackupex not in path: $PATH" exit 2 fi +# check the version, we require XB-2.4 to ensure that we can pass the +# datadir via the command-line option +XB_REQUIRED_VERSION="2.3.5" + +XB_VERSION=`$INNOBACKUPEX_BIN --version 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1` +if [[ -z $XB_VERSION ]]; then + wsrep_log_error "FATAL: Cannot determine the $INNOBACKUPEX_BIN version. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST" + exit 2 +fi + +if ! check_for_version $XB_VERSION $XB_REQUIRED_VERSION; then + wsrep_log_error "FATAL: The $INNOBACKUPEX_BIN version is $XB_VERSION. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST" + exit 2 +fi + + rm -f "${MAGIC_FILE}" if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then @@ -655,13 +864,13 @@ if [[ $ssyslog -eq 1 ]];then } INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply " - INNOMOVE="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move " + INNOMOVE="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} $disver $impts --datadir=${DATA} --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move " INNOBACKUP="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)" fi else INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log" - INNOMOVE="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} --defaults-group=mysqld${WSREP_SST_OPT_CONF_SUFFIX} $disver $impts --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log" + INNOMOVE="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} --defaults-group=mysqld${WSREP_SST_OPT_CONF_SUFFIX} $disver $impts --datadir=${DATA} --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log" INNOBACKUP="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} --defaults-group=mysqld${WSREP_SST_OPT_CONF_SUFFIX} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2>\${DATA}/innobackup.backup.log" fi @@ -703,15 +912,6 @@ then fi get_keys - if [[ $encrypt -eq 1 ]];then - if [[ -n $ekey ]];then - INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey " - else - INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile " - fi - fi - - check_extra wsrep_log_info "Streaming GTID file before SST" @@ -722,17 +922,17 @@ then if [[ $encrypt -eq 1 ]];then if [[ -n $scomp ]];then - tcmd=" $ecmd | $scomp | $tcmd " + tcmd=" \$ecmd | $scomp | $tcmd " else - tcmd=" $ecmd | $tcmd " + tcmd=" \$ecmd | $tcmd " fi elif [[ -n $scomp ]];then tcmd=" $scomp | $tcmd " fi - send_donor $DATA "${stagemsg}-gtid" + # Restore the transport commmand to its original state tcmd="$ttcmd" if [[ -n $progress ]];then get_footprint @@ -747,10 +947,16 @@ then wsrep_log_info "Streaming the backup to joiner at ${REMOTEIP} ${SST_PORT:-4444}" - if [[ -n $scomp ]];then + # Add compression to the head of the stream (if specified) + if [[ -n $scomp ]]; then tcmd="$scomp | $tcmd" fi + # Add encryption to the head of the stream (if specified) + if [[ $encrypt -eq 1 ]]; then + tcmd=" \$ecmd | $tcmd " + fi + set +e timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )" set -e @@ -777,9 +983,9 @@ then get_keys if [[ $encrypt -eq 1 ]];then if [[ -n $scomp ]];then - tcmd=" $ecmd | $scomp | $tcmd " + tcmd=" \$ecmd | $scomp | $tcmd " else - tcmd=" $ecmd | $tcmd " + tcmd=" \$ecmd | $tcmd " fi elif [[ -n $scomp ]];then tcmd=" $scomp | $tcmd " @@ -804,7 +1010,6 @@ then stagemsg="Joiner-Recv" - sencrypted=1 nthreads=1 @@ -815,14 +1020,7 @@ then # May need xtrabackup_checkpoints later on rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile - ADDR=${WSREP_SST_OPT_ADDR} - if [ -z "${SST_PORT}" ] - then - SST_PORT=4444 - ADDR="$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $1 }'):${SST_PORT}" - fi - - wait_for_listen ${SST_PORT} ${ADDR} ${MODULE} & + wait_for_listen ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT:-4444} ${MODULE} & trap sig_joiner_cleanup HUP PIPE INT TERM trap cleanup_joiner EXIT @@ -835,9 +1033,9 @@ then get_keys if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then if [[ -n $sdecomp ]];then - strmcmd=" $sdecomp | $ecmd | $strmcmd" + strmcmd=" $sdecomp | \$ecmd | $strmcmd" else - strmcmd=" $ecmd | $strmcmd" + strmcmd=" \$ecmd | $strmcmd" fi elif [[ -n $sdecomp ]];then strmcmd=" $sdecomp | $strmcmd" diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index cf8ac25aa6a..ad6b8eedf3e 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -571,27 +571,17 @@ int wsrep_init() size_t const node_addr_len= strlen(node_addr); if (node_addr_len > 0) { - const char* const colon= strrchr(node_addr, ':'); - if (strchr(node_addr, ':') == colon) // 1 or 0 ':' + size_t const ip_len= wsrep_host_len(node_addr, node_addr_len); + if (ip_len + 7 /* :55555\0 */ < inc_addr_max) { - size_t const ip_len= colon ? colon - node_addr : node_addr_len; - if (ip_len + 7 /* :55555\0 */ < inc_addr_max) - { - memcpy (inc_addr, node_addr, ip_len); - snprintf(inc_addr + ip_len, inc_addr_max - ip_len, ":%u", - (int)mysqld_port); - } - else - { - WSREP_WARN("Guessing address for incoming client connections: " - "address too long."); - inc_addr[0]= '\0'; - } + memcpy (inc_addr, node_addr, ip_len); + snprintf(inc_addr + ip_len, inc_addr_max - ip_len, ":%u", + (int)mysqld_port); } else { WSREP_WARN("Guessing address for incoming client connections: " - "too many colons :) ."); + "address too long."); inc_addr[0]= '\0'; } } diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 11698089582..331185e2cf3 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -634,18 +634,19 @@ ssize_t wsrep_sst_prepare (void** msg) // Figure out SST address. Common for all SST methods if (wsrep_sst_receive_address && - strcmp (wsrep_sst_receive_address, WSREP_SST_ADDRESS_AUTO)) + strcmp (wsrep_sst_receive_address, WSREP_SST_ADDRESS_AUTO)) { addr_in= wsrep_sst_receive_address; } else if (wsrep_node_address && strlen(wsrep_node_address)) { - const char* const colon= strchr (wsrep_node_address, ':'); - if (colon) + size_t const addr_len= strlen(wsrep_node_address); + size_t const host_len= wsrep_host_len(wsrep_node_address, addr_len); + + if (host_len < addr_len) { - ptrdiff_t const len= colon - wsrep_node_address; - strncpy (ip_buf, wsrep_node_address, len); - ip_buf[len]= '\0'; + strncpy (ip_buf, wsrep_node_address, host_len); + ip_buf[host_len]= '\0'; addr_in= ip_buf; } else @@ -772,25 +773,6 @@ static int sst_donate_mysqldump (const char* addr, bool bypass, char** env) // carries auth info { - size_t host_len; - const char* port = strchr (addr, ':'); - - if (port) - { - port += 1; - host_len = port - addr; - } - else - { - port = ""; - host_len = strlen (addr) + 1; - } - - char *host= (char *) alloca(host_len); - - strncpy (host, addr, host_len - 1); - host[host_len - 1] = '\0'; - int const cmd_len= 4096; wsp::string cmd_str(cmd_len); @@ -805,14 +787,13 @@ static int sst_donate_mysqldump (const char* addr, int ret= snprintf (cmd_str(), cmd_len, "wsrep_sst_mysqldump " - WSREP_SST_OPT_HOST" '%s' " - WSREP_SST_OPT_PORT" '%s' " + WSREP_SST_OPT_ADDR" '%s' " WSREP_SST_OPT_LPORT" '%u' " WSREP_SST_OPT_SOCKET" '%s' " WSREP_SST_OPT_CONF" '%s' " WSREP_SST_OPT_GTID" '%s:%lld'" "%s", - host, port, mysqld_port, mysqld_unix_port, + addr, mysqld_port, mysqld_unix_port, wsrep_defaults_file, uuid_str, (long long)seqno, bypass ? " " WSREP_SST_OPT_BYPASS : ""); diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc index 719e8e6b473..9c5cef6a997 100644 --- a/sql/wsrep_utils.cc +++ b/sql/wsrep_utils.cc @@ -554,3 +554,18 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len) return 0; } + +/* returns the length of the host part of the address string */ +size_t wsrep_host_len(const char* const addr, size_t const addr_len) +{ + // check for IPv6 notation first + const char* const bracket= ('[' == addr[0] ? strchr(addr, ']') : NULL); + + if (bracket) { // IPv6 + return (bracket - addr + 1); + } + else { // host part ends at ':' or end of string + const char* const colon= strchr(addr, ':'); + return (colon ? colon - addr : addr_len); + } +} diff --git a/sql/wsrep_utils.h b/sql/wsrep_utils.h index 7d864603c7f..0ae5c68df21 100644 --- a/sql/wsrep_utils.h +++ b/sql/wsrep_utils.h @@ -21,6 +21,9 @@ unsigned int wsrep_check_ip (const char* addr); size_t wsrep_guess_ip (char* buf, size_t buf_len); +/* returns the length of the host part of the address string */ +size_t wsrep_host_len(const char* addr, size_t addr_len); + namespace wsp { class node_status { From afbaa5c697bfa090de5845f80ec8975402ca3f6f Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 7 Mar 2017 23:47:22 -0800 Subject: [PATCH 017/101] Galera MTR Tests: Tests for MW-366 - improved support for IPv6 --- .../r/galera_ipv6_mysqldump.result | 26 ++++++++ .../galera_3nodes/r/galera_ipv6_rsync.result | 14 +++++ .../r/galera_ipv6_xtrabackup-v2.result | 18 ++++++ .../galera_3nodes/t/galera_ipv6_mysqldump.cnf | 22 +++++++ .../t/galera_ipv6_mysqldump.test | 56 +++++++++++++++++ .../galera_3nodes/t/galera_ipv6_rsync.cnf | 22 +++++++ .../galera_3nodes/t/galera_ipv6_rsync.test | 32 ++++++++++ .../t/galera_ipv6_xtrabackup-v2.cnf | 26 ++++++++ .../t/galera_ipv6_xtrabackup-v2.test | 62 +++++++++++++++++++ 9 files changed, 278 insertions(+) create mode 100644 mysql-test/suite/galera_3nodes/r/galera_ipv6_mysqldump.result create mode 100644 mysql-test/suite/galera_3nodes/r/galera_ipv6_rsync.result create mode 100644 mysql-test/suite/galera_3nodes/r/galera_ipv6_xtrabackup-v2.result create mode 100644 mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.cnf create mode 100644 mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.test create mode 100644 mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.cnf create mode 100644 mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.test create mode 100644 mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.cnf create mode 100644 mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.test diff --git a/mysql-test/suite/galera_3nodes/r/galera_ipv6_mysqldump.result b/mysql-test/suite/galera_3nodes/r/galera_ipv6_mysqldump.result new file mode 100644 index 00000000000..f519654952b --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_ipv6_mysqldump.result @@ -0,0 +1,26 @@ +GRANT ALL PRIVILEGES ON *.* TO 'sst'; +SET GLOBAL wsrep_sst_auth = 'sst:'; +SET GLOBAL wsrep_sst_method = 'mysqldump'; +Unloading wsrep provider ... +SET GLOBAL wsrep_provider = 'none'; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +Loading wsrep provider ... +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +VARIABLE_VALUE LIKE '%[::1]%' +1 +CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); +DROP USER sst; +CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); +CALL mtr.add_suppression("InnoDB: Error: Table \"mysql\"\\.\"innodb_index_stats\" not found"); +CALL mtr.add_suppression("InnoDB: New log files created"); +CALL mtr.add_suppression("InnoDB: Creating foreign key constraint system tables"); +CALL mtr.add_suppression("Can't open and lock time zone table"); +CALL mtr.add_suppression("Can't open and lock privilege tables"); +CALL mtr.add_suppression("Info table is not ready to be used"); +CALL mtr.add_suppression("Native table .* has the wrong structure"); +CALL mtr.add_suppression("Unsupported protocol downgrade: incremental data collection disabled. Expect abort"); diff --git a/mysql-test/suite/galera_3nodes/r/galera_ipv6_rsync.result b/mysql-test/suite/galera_3nodes/r/galera_ipv6_rsync.result new file mode 100644 index 00000000000..a2bf5f4d98c --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_ipv6_rsync.result @@ -0,0 +1,14 @@ +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +VARIABLE_VALUE LIKE '%[::1]%' +1 +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 3 +1 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/r/galera_ipv6_xtrabackup-v2.result b/mysql-test/suite/galera_3nodes/r/galera_ipv6_xtrabackup-v2.result new file mode 100644 index 00000000000..53e35939a79 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_ipv6_xtrabackup-v2.result @@ -0,0 +1,18 @@ +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +VARIABLE_VALUE LIKE '%[::1]%' +1 +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 3 +1 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; +include/assert_grep.inc [Streaming the backup to joiner at \[::1\]] +include/assert_grep.inc [async IST sender starting to serve tcp://\[::1\]:] +include/assert_grep.inc [IST receiver addr using tcp://\[::1\]] +include/assert_grep.inc [Prepared IST receiver, listening at: tcp://\[::1\]] diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.cnf b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.cnf new file mode 100644 index 00000000000..3728e1ce005 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.cnf @@ -0,0 +1,22 @@ +!include ../galera_3nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep-cluster-address=gcomm:// +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.1.#galera_port;ist.recv_addr=[::1]:@mysqld.1.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.1.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.1.port' + +[mysqld.2] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.2.#galera_port;ist.recv_addr=[::1]:@mysqld.2.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.2.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.2.port' + +[mysqld.3] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.3.#galera_port;ist.recv_addr=[::1]:@mysqld.3.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.3.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.3.port' diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.test new file mode 100644 index 00000000000..5b06e617eef --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.test @@ -0,0 +1,56 @@ +--source include/galera_cluster.inc +--source include/have_ipv6.inc + +--connection node_1 +GRANT ALL PRIVILEGES ON *.* TO 'sst'; + +--let $wsrep_sst_auth_orig = `SELECT @@wsrep_sst_auth` +SET GLOBAL wsrep_sst_auth = 'sst:'; + +--connection node_2 +--source include/wait_until_connected_again.inc +--let $wsrep_sst_method_orig = `SELECT @@wsrep_sst_method` +--let $wsrep_sst_receive_address_orig = `SELECT @@wsrep_sst_receive_address` + +--disable_query_log +--eval SET GLOBAL wsrep_sst_receive_address = '[::1]:$NODE_MYPORT_2'; +--enable_query_log +SET GLOBAL wsrep_sst_method = 'mysqldump'; + + +# +# Force mysqldump SST +# + +--connection node_2 +--source suite/galera/include/galera_unload_provider.inc +--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + + +--connection node_2 +--source suite/galera/include/galera_load_provider.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; + +# Confirm that initial handshake happened over ipv6 + +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; + +--source suite/galera/include/galera_sst_restore.inc +--connection node_2 +CALL mtr.add_suppression("Unsupported protocol downgrade: incremental data collection disabled. Expect abort"); diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.cnf b/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.cnf new file mode 100644 index 00000000000..3728e1ce005 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.cnf @@ -0,0 +1,22 @@ +!include ../galera_3nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep-cluster-address=gcomm:// +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.1.#galera_port;ist.recv_addr=[::1]:@mysqld.1.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.1.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.1.port' + +[mysqld.2] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.2.#galera_port;ist.recv_addr=[::1]:@mysqld.2.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.2.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.2.port' + +[mysqld.3] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.3.#galera_port;ist.recv_addr=[::1]:@mysqld.3.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.3.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.3.port' diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.test new file mode 100644 index 00000000000..7ee209d8e72 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.test @@ -0,0 +1,32 @@ +--source include/galera_cluster.inc +--source include/have_ipv6.inc + +# Confirm that initial handshake happened over ipv6 + +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# Force IST + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; + +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.cnf b/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.cnf new file mode 100644 index 00000000000..8a80be0d2a9 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.cnf @@ -0,0 +1,26 @@ +!include ../galera_3nodes.cnf + +[mysqld] +wsrep_sst_method=xtrabackup-v2 +wsrep_sst_auth="root:" + +[mysqld.1] +wsrep-cluster-address=gcomm:// +wsrep_provider_options='base_host=[::1];base_port=@mysqld.1.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.1.#galera_port;ist.recv_addr=[::1]:@mysqld.1.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.1.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.1.port' + +[mysqld.2] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_host=[::1];base_port=@mysqld.2.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.2.#galera_port;ist.recv_addr=[::1]:@mysqld.2.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.2.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.2.port' + +[mysqld.3] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_host=[::1];base_port=@mysqld.3.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.3.#galera_port;ist.recv_addr=[::1]:@mysqld.3.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.3.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.3.port' + +[SST] +sockopt=",pf=ip6" diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.test new file mode 100644 index 00000000000..84eee017700 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.test @@ -0,0 +1,62 @@ +--source include/galera_cluster.inc +--source include/have_ipv6.inc + +# Confirm that initial handshake happened over ipv6 + +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# Force IST + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; + +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; + +# Confirm that key messages around SST and IST reference IPv6 + +--connection node_1 +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err +--let $assert_only_after = CURRENT_TEST + +--let $assert_count = 2 +--let $assert_text = Streaming the backup to joiner at \[::1\] +--let $assert_select = Streaming the backup to joiner at \[::1\] +--source include/assert_grep.inc + +--let $assert_count = 1 +--let $assert_text = async IST sender starting to serve tcp://\[::1\]: +--let $assert_select = async IST sender starting to serve tcp://\[::1\]: +--source include/assert_grep.inc + +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err + +--let $assert_text = IST receiver addr using tcp://\[::1\] +--let $assert_select = IST receiver addr using tcp://\[::1\] +--source include/assert_grep.inc + +--let $assert_text = Prepared IST receiver, listening at: tcp://\[::1\] +--let $assert_select = Prepared IST receiver, listening at: tcp://\[::1\] +--source include/assert_grep.inc + + + + From 7a219b6f23077e4d07338ae155ef388520108c1e Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 8 Mar 2017 13:08:21 +0100 Subject: [PATCH 018/101] MW-86 Add separate wsrep_sync_wait bitmask value for SHOW commands Previously, setting `wsrep_sync_wait = 1` would have an effect on both SELECT and SHOW statements. This patch changes wsrep_sync_wait so that bitmask value 1 is used for SELECT statements, while bitmask value 8 is reserved for SHOW statements. It is still possible to achieve sync wait on both SELECT and SHOW statements by setting `wsrep_sync_wait = 9`. --- sql/sql_parse.cc | 89 ++++++++++++---------------------------------- sql/sql_parse.h | 5 +++ sql/wsrep_mysqld.h | 5 +-- 3 files changed, 30 insertions(+), 69 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e381f14f627..38d53b6c5c6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2788,10 +2788,6 @@ mysql_execute_command(THD *thd) /* fall through */ case SQLCOM_SHOW_STATUS_PROC: case SQLCOM_SHOW_STATUS_FUNC: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ - case SQLCOM_SHOW_DATABASES: case SQLCOM_SHOW_TABLES: case SQLCOM_SHOW_TRIGGERS: @@ -2800,27 +2796,21 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_PLUGINS: case SQLCOM_SHOW_FIELDS: case SQLCOM_SHOW_KEYS: -#ifndef WITH_WSREP - case SQLCOM_SHOW_VARIABLES: - case SQLCOM_SHOW_CHARSETS: - case SQLCOM_SHOW_COLLATIONS: - case SQLCOM_SHOW_STORAGE_ENGINES: - case SQLCOM_SHOW_PROFILE: -#endif /* WITH_WSREP */ case SQLCOM_SHOW_CLIENT_STATS: case SQLCOM_SHOW_USER_STATS: case SQLCOM_SHOW_TABLE_STATS: case SQLCOM_SHOW_INDEX_STATS: - case SQLCOM_SELECT: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; case SQLCOM_SHOW_VARIABLES: case SQLCOM_SHOW_CHARSETS: case SQLCOM_SHOW_COLLATIONS: case SQLCOM_SHOW_STORAGE_ENGINES: case SQLCOM_SHOW_PROFILE: -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); + case SQLCOM_SELECT: { + if (lex->sql_command == SQLCOM_SELECT) + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ); + thd->status_var.last_query_cost= 0.0; /* @@ -3518,9 +3508,7 @@ end_with_restore_list: goto error; #else { -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); /* Access check: @@ -3584,9 +3572,7 @@ end_with_restore_list: case SQLCOM_CHECKSUM: { DBUG_ASSERT(first_table == all_tables && first_table != 0); -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ); if (check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE)) @@ -3596,11 +3582,8 @@ end_with_restore_list: break; } case SQLCOM_UPDATE: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error; -#endif /* WITH_WSREP */ { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); ha_rows found= 0, updated= 0; DBUG_ASSERT(first_table == all_tables && first_table != 0); if (update_precheck(thd, all_tables)) @@ -3639,10 +3622,7 @@ end_with_restore_list: /* if we switched from normal update, rights are checked */ if (up_result != 2) { -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); if ((res= multi_update_precheck(thd, all_tables))) break; } @@ -3712,10 +3692,7 @@ end_with_restore_list: break; } case SQLCOM_REPLACE: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); #ifndef DBUG_OFF if (mysql_bin_log.is_open()) { @@ -3752,11 +3729,8 @@ end_with_restore_list: #endif /* fall through */ case SQLCOM_INSERT: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) goto error; -#endif /* WITH_WSREP */ { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); DBUG_ASSERT(first_table == all_tables && first_table != 0); /* @@ -3809,11 +3783,8 @@ end_with_restore_list: } case SQLCOM_REPLACE_SELECT: case SQLCOM_INSERT_SELECT: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) goto error; -#endif /* WITH_WSREP */ { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); select_result *sel_result; bool explain= MY_TEST(lex->describe); DBUG_ASSERT(first_table == all_tables && first_table != 0); @@ -3927,11 +3898,8 @@ end_with_restore_list: break; } case SQLCOM_DELETE: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error; -#endif /* WITH_WSREP */ { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); select_result *sel_result=lex->result; DBUG_ASSERT(first_table == all_tables && first_table != 0); if ((res= delete_precheck(thd, all_tables))) @@ -3951,11 +3919,8 @@ end_with_restore_list: break; } case SQLCOM_DELETE_MULTI: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error; -#endif /* WITH_WSREP */ { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); DBUG_ASSERT(first_table == all_tables && first_table != 0); TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first; bool explain= MY_TEST(lex->describe); @@ -4361,9 +4326,7 @@ end_with_restore_list: db_name.length= lex->name.length; strmov(db_name.str, lex->name.str); -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (check_db_name(&db_name)) { @@ -4421,9 +4384,7 @@ end_with_restore_list: /* lex->unit.cleanup() is called outside, no need to call it here */ break; case SQLCOM_SHOW_CREATE_EVENT: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res= Events::show_create_event(thd, lex->spname->m_db, lex->spname->m_name); break; @@ -5382,18 +5343,14 @@ create_sp_error: } case SQLCOM_SHOW_CREATE_PROC: { -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (sp_show_create_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname)) goto error; break; } case SQLCOM_SHOW_CREATE_FUNC: { -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (sp_show_create_routine(thd, TYPE_ENUM_FUNCTION, lex->spname)) goto error; break; @@ -5406,9 +5363,7 @@ create_sp_error: stored_procedure_type type= (lex->sql_command == SQLCOM_SHOW_PROC_CODE ? TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (sp_cache_routine(thd, type, lex->spname, FALSE, &sp)) goto error; if (!sp || sp->show_routine_code(thd)) @@ -5430,9 +5385,7 @@ create_sp_error: if (check_ident_length(&lex->spname->m_name)) goto error; -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (show_create_trigger(thd, lex->spname)) goto error; /* Error has been already logged. */ @@ -5850,9 +5803,11 @@ static bool execute_show_status(THD *thd, TABLE_LIST *all_tables) bool res; system_status_var old_status_var= thd->status_var; thd->initial_status_var= &old_status_var; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (!(res= check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE))) res= execute_sqlcom_select(thd, all_tables); +error: /* Don't log SHOW STATUS commands to slow query log */ thd->server_status&= ~(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED); diff --git a/sql/sql_parse.h b/sql/sql_parse.h index cf58ecb19e1..e9c82b9df48 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -225,11 +225,16 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) if (WSREP(thd) && !thd->lex->no_write_to_binlog \ && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; +#define WSREP_SYNC_WAIT(thd_, before_) \ + if (WSREP_CLIENT(thd_) && \ + wsrep_sync_wait(thd_, before_)) goto error; + #else #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) #define WSREP_TO_ISOLATION_END #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) +#define WSREP_SYNC_WAIT(thd_, before_) #endif /* WITH_WSREP */ diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 1cda5d23986..6dabdb66022 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -118,11 +118,12 @@ enum enum_wsrep_OSU_method { enum enum_wsrep_sync_wait { WSREP_SYNC_WAIT_NONE = 0x0, - // show, select, begin + // select, begin WSREP_SYNC_WAIT_BEFORE_READ = 0x1, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE = 0x2, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE = 0x4, - WSREP_SYNC_WAIT_MAX = 0x7 + WSREP_SYNC_WAIT_BEFORE_SHOW = 0x8, + WSREP_SYNC_WAIT_MAX = 0xF }; // MySQL status variables From f20b21a29a5c7e132d59c2e66f89376647fd3ee9 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 8 Mar 2017 13:11:57 +0100 Subject: [PATCH 019/101] MW-86 Adjust MTR tests for changes to wsrep_sync_wait --- mysql-test/suite/galera/galera_2nodes.cnf | 2 +- .../suite/galera/galera_2nodes_as_master.cnf | 4 +- .../galera/galera_2nodes_as_master_slave.cnf | 4 +- ...lera_2nodes_as_master_with_repl_filter.cnf | 4 +- .../suite/galera/galera_2nodes_as_slave.cnf | 4 +- .../suite/galera/galera_3nodes_as_slave.cnf | 6 +- mysql-test/suite/galera/galera_4nodes.cnf | 2 +- mysql-test/suite/galera/r/GAL-401.result | 2 +- .../r/galera_applier_ftwrl_table.result | 2 +- .../r/galera_applier_ftwrl_table_alter.result | 2 +- .../r/galera_bf_abort_flush_for_export.result | 2 +- .../suite/galera/r/galera_defaults.result | 2 +- .../galera/r/galera_insert_ignore.result | 4 +- .../suite/galera/r/galera_many_rows.result | 2 +- .../r/galera_parallel_apply_lock_table.result | 2 +- .../galera/r/galera_parallel_simple.result | 2 +- .../r/galera_query_cache_sync_wait.result | 5 - .../galera/r/galera_sync_wait_show.result | 2 +- .../r/galera_unicode_identifiers.result | 4 +- .../galera/r/galera_var_sync_wait.result | 5 +- .../suite/galera/r/mysql-wsrep#201.result | 1 - mysql-test/suite/galera/t/GAL-401.test | 2 +- .../galera/t/galera_applier_ftwrl_table.test | 2 +- .../t/galera_applier_ftwrl_table_alter.test | 2 +- .../t/galera_bf_abort_flush_for_export.test | 2 +- .../suite/galera/t/galera_insert_ignore.test | 4 +- .../suite/galera/t/galera_many_rows.test | 2 +- mysql-test/suite/galera/t/galera_migrate.cnf | 2 +- .../galera/t/galera_parallel_simple.test | 2 +- .../t/galera_query_cache_sync_wait.test | 5 - .../suite/galera/t/galera_sync_wait_show.test | 3 +- .../galera/t/galera_unicode_identifiers.test | 4 +- .../suite/galera/t/galera_var_sync_wait.test | 5 +- .../suite/galera/t/mysql-wsrep#201.test | 1 - .../suite/galera_3nodes/galera_3nodes.cnf | 2 +- .../r/galera_var_dirty_reads2.result | 48 ++++++++ .../t/galera_var_dirty_reads2.test | 112 ++++++++++++++++++ sql/wsrep_mysqld.cc | 6 +- 38 files changed, 210 insertions(+), 57 deletions(-) create mode 100644 mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result create mode 100644 mysql-test/suite/galera_3nodes/t/galera_var_dirty_reads2.test diff --git a/mysql-test/suite/galera/galera_2nodes.cnf b/mysql-test/suite/galera/galera_2nodes.cnf index 0dc22ee4a81..3d510d74429 100644 --- a/mysql-test/suite/galera/galera_2nodes.cnf +++ b/mysql-test/suite/galera/galera_2nodes.cnf @@ -12,7 +12,7 @@ wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#gale # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.1] #galera_port=@OPT.port diff --git a/mysql-test/suite/galera/galera_2nodes_as_master.cnf b/mysql-test/suite/galera/galera_2nodes_as_master.cnf index 08d860e9ba4..78b0ac84273 100644 --- a/mysql-test/suite/galera/galera_2nodes_as_master.cnf +++ b/mysql-test/suite/galera/galera_2nodes_as_master.cnf @@ -28,7 +28,7 @@ wsrep_node_address=127.0.0.1 wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.2] #galera_port=@OPT.port @@ -47,7 +47,7 @@ wsrep_node_address=127.0.0.1 wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.3] server-id=3 diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf index 716a790fea6..f68fe524904 100644 --- a/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf +++ b/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf @@ -29,7 +29,7 @@ wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = P # enforce read-committed characteristics across the cluster wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 wsrep_node_address=127.0.0.1 wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port @@ -49,7 +49,7 @@ wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.install_timeout = P # enforce read-committed characteristics across the cluster wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 wsrep_node_address=127.0.0.1 wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf index 5f0af2e58e5..d5490280ab2 100644 --- a/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf +++ b/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf @@ -23,7 +23,7 @@ wsrep_provider_options='base_port=@mysqld.1.#galera_port' # enforce read-committed characteristics across the cluster wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 wsrep_node_address=127.0.0.1 wsrep_sst_receive_address=127.0.0.2:@mysqld.1.#sst_port @@ -49,7 +49,7 @@ wsrep_provider_options='base_port=@mysqld.2.#galera_port' # enforce read-committed characteristics across the cluster wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 wsrep_node_address=127.0.0.1 wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port diff --git a/mysql-test/suite/galera/galera_2nodes_as_slave.cnf b/mysql-test/suite/galera/galera_2nodes_as_slave.cnf index 2a4b18da5f8..cf1eccb1ba9 100644 --- a/mysql-test/suite/galera/galera_2nodes_as_slave.cnf +++ b/mysql-test/suite/galera/galera_2nodes_as_slave.cnf @@ -31,7 +31,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=2 [mysqld.3] @@ -53,7 +53,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=3 [ENV] diff --git a/mysql-test/suite/galera/galera_3nodes_as_slave.cnf b/mysql-test/suite/galera/galera_3nodes_as_slave.cnf index aed33ba365b..ac1ca34e242 100644 --- a/mysql-test/suite/galera/galera_3nodes_as_slave.cnf +++ b/mysql-test/suite/galera/galera_3nodes_as_slave.cnf @@ -30,7 +30,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=2 [mysqld.3] @@ -51,7 +51,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=3 [mysqld.4] @@ -72,7 +72,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.4.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=4 [ENV] diff --git a/mysql-test/suite/galera/galera_4nodes.cnf b/mysql-test/suite/galera/galera_4nodes.cnf index e54ff27759e..a0ef1dc092b 100644 --- a/mysql-test/suite/galera/galera_4nodes.cnf +++ b/mysql-test/suite/galera/galera_4nodes.cnf @@ -9,7 +9,7 @@ wsrep-provider=@ENV.WSREP_PROVIDER wsrep_node_address=127.0.0.1 # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.1] #galera_port=@OPT.port diff --git a/mysql-test/suite/galera/r/GAL-401.result b/mysql-test/suite/galera/r/GAL-401.result index 4de13cf142b..fbdb2d39a28 100644 --- a/mysql-test/suite/galera/r/GAL-401.result +++ b/mysql-test/suite/galera/r/GAL-401.result @@ -9,7 +9,7 @@ SHOW STATUS LIKE 'wsrep_desync_count'; Variable_name Value wsrep_desync_count 0 SET @@global.wsrep_desync = 0; -SET SESSION wsrep_sync_wait=7; +SET SESSION wsrep_sync_wait=15; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result b/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result index cecbfc1f3cf..1b2a3b937bb 100644 --- a/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result +++ b/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result @@ -8,7 +8,7 @@ SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 diff --git a/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result b/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result index ee967356c85..c30f78896e5 100644 --- a/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result +++ b/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result @@ -12,7 +12,7 @@ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system use COUNT(*) = 1 1 UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result index 96ed226c3ab..3c5c07ae396 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result @@ -6,7 +6,7 @@ SET SESSION wsrep_sync_wait = 0; UNLOCK TABLES; COMMIT; SET AUTOCOMMIT=ON; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index 878fe80ff98..b242a468f72 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -47,7 +47,7 @@ WSREP_SST_AUTH WSREP_SST_DONOR WSREP_SST_DONOR_REJECTS_QUERIES OFF WSREP_SST_METHOD rsync -WSREP_SYNC_WAIT 7 +WSREP_SYNC_WAIT 15 ; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.recover = no; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' diff --git a/mysql-test/suite/galera/r/galera_insert_ignore.result b/mysql-test/suite/galera/r/galera_insert_ignore.result index b53b5795416..b98a308efb5 100644 --- a/mysql-test/suite/galera/r/galera_insert_ignore.result +++ b/mysql-test/suite/galera/r/galera_insert_ignore.result @@ -1,5 +1,5 @@ -SET GLOBAL wsrep_sync_wait = 7; -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; +SET GLOBAL wsrep_sync_wait = 15; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); INSERT IGNORE INTO t1 VALUES (1), (2); diff --git a/mysql-test/suite/galera/r/galera_many_rows.result b/mysql-test/suite/galera/r/galera_many_rows.result index a34367d6e46..e650dd6f5de 100644 --- a/mysql-test/suite/galera/r/galera_many_rows.result +++ b/mysql-test/suite/galera/r/galera_many_rows.result @@ -5,7 +5,7 @@ INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB; INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; SET SESSION wsrep_sync_wait = 0; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SET GLOBAL wsrep_provider_options = 'repl.causal_read_timeout=PT1H'; SELECT COUNT(*) = 100000 FROM t1; COUNT(*) = 100000 diff --git a/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result b/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result index db4528ac22d..27768dc441a 100644 --- a/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result +++ b/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result @@ -18,7 +18,7 @@ SELECT COUNT(*) = 0 FROM t2; COUNT(*) = 0 1 UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7;; +SET SESSION wsrep_sync_wait = 15;; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_parallel_simple.result b/mysql-test/suite/galera/r/galera_parallel_simple.result index 6d023c38a57..3b10815c63d 100644 --- a/mysql-test/suite/galera/r/galera_parallel_simple.result +++ b/mysql-test/suite/galera/r/galera_parallel_simple.result @@ -16,7 +16,7 @@ INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); SET SESSION wsrep_sync_wait = 0; UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 10 FROM t1; COUNT(*) = 10 0 diff --git a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result index 856abbb43be..5fe382048fb 100644 --- a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result +++ b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result @@ -4,7 +4,6 @@ SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; MAX(id) 1 @@ -16,7 +15,6 @@ Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; FLUSH QUERY CACHE; -SET SESSION wsrep_sync_wait = 7; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead @@ -29,11 +27,9 @@ Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; INSERT INTO t1 VALUES (4); -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; MAX(id) 4 -SET SESSION wsrep_sync_wait = 7; FLUSH STATUS; SELECT MAX(id) FROM t1; MAX(id) @@ -45,7 +41,6 @@ SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead INSERT INTO t1 VALUES (5); -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1 ; SET GLOBAL DEBUG = ""; Warnings: diff --git a/mysql-test/suite/galera/r/galera_sync_wait_show.result b/mysql-test/suite/galera/r/galera_sync_wait_show.result index c719aaab5d8..2eac93ad665 100644 --- a/mysql-test/suite/galera/r/galera_sync_wait_show.result +++ b/mysql-test/suite/galera/r/galera_sync_wait_show.result @@ -1,4 +1,4 @@ -SET SESSION wsrep_sync_wait = 1; +SET SESSION wsrep_sync_wait = 8; CREATE DATABASE db1; SHOW CREATE DATABASE db1; Database Create Database diff --git a/mysql-test/suite/galera/r/galera_unicode_identifiers.result b/mysql-test/suite/galera/r/galera_unicode_identifiers.result index 8bea105c77e..9aee4616ec5 100644 --- a/mysql-test/suite/galera/r/galera_unicode_identifiers.result +++ b/mysql-test/suite/galera/r/galera_unicode_identifiers.result @@ -1,5 +1,5 @@ -SET GLOBAL wsrep_sync_wait = 7; -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; +SET GLOBAL wsrep_sync_wait = 15; CREATE DATABASE `database with space`; USE `database with space`; CREATE TABLE `table with space` ( diff --git a/mysql-test/suite/galera/r/galera_var_sync_wait.result b/mysql-test/suite/galera/r/galera_var_sync_wait.result index f6136a4ddc4..f573c251bdd 100644 --- a/mysql-test/suite/galera/r/galera_var_sync_wait.result +++ b/mysql-test/suite/galera/r/galera_var_sync_wait.result @@ -1,8 +1,5 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; SET GLOBAL wsrep_sync_wait = 1; -SHOW TABLES LIKE '%t1'; -Tables_in_test (%t1) -t1 SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 @@ -15,7 +12,7 @@ SET GLOBAL wsrep_sync_wait = 2; UPDATE t3 SET f1 = 2; affected rows: 1 info: Rows matched: 1 Changed: 1 Warnings: 0 -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; diff --git a/mysql-test/suite/galera/r/mysql-wsrep#201.result b/mysql-test/suite/galera/r/mysql-wsrep#201.result index 1c0998e35ac..34d184d8ec1 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#201.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#201.result @@ -1,4 +1,3 @@ CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; INSERT INTO t1 VALUES (DEFAULT); SET GLOBAL query_cache_size=1355776; -SET SESSION wsrep_sync_wait = 7; diff --git a/mysql-test/suite/galera/t/GAL-401.test b/mysql-test/suite/galera/t/GAL-401.test index b419770f804..25ab9502bec 100644 --- a/mysql-test/suite/galera/t/GAL-401.test +++ b/mysql-test/suite/galera/t/GAL-401.test @@ -44,7 +44,7 @@ SET @@global.wsrep_desync = 0; --let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; --source include/wait_condition.inc -SET SESSION wsrep_sync_wait=7; +SET SESSION wsrep_sync_wait=15; SHOW CREATE TABLE t1; DROP TABLE t1; CALL mtr.add_suppression("WSREP: Protocol violation. JOIN message sender (.*) is not in state transfer \\(SYNCED\\). Message ignored."); diff --git a/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test b/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test index 6747977812b..97819384a75 100644 --- a/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test +++ b/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test @@ -28,7 +28,7 @@ SELECT COUNT(*) = 0 FROM t1; --connection node_1 UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 2 FROM t1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test b/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test index 99c45c04ba0..67f2108d263 100644 --- a/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test +++ b/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test @@ -29,7 +29,7 @@ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system use UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SHOW CREATE TABLE t1; SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test index e32089ce21e..fde783e2cef 100644 --- a/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test +++ b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test @@ -27,7 +27,7 @@ UNLOCK TABLES; COMMIT; SET AUTOCOMMIT=ON; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 1 FROM t1; --let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` diff --git a/mysql-test/suite/galera/t/galera_insert_ignore.test b/mysql-test/suite/galera/t/galera_insert_ignore.test index 4b4b0a6e9fb..027f70e96d9 100644 --- a/mysql-test/suite/galera/t/galera_insert_ignore.test +++ b/mysql-test/suite/galera/t/galera_insert_ignore.test @@ -2,10 +2,10 @@ --source include/have_innodb.inc --let $wsrep_sync_wait_orig = (SELECT @@wsrep_sync_wait) -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; --connection node_2 -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; # diff --git a/mysql-test/suite/galera/t/galera_many_rows.test b/mysql-test/suite/galera/t/galera_many_rows.test index 653dc2dd75a..58ba85e1b9e 100644 --- a/mysql-test/suite/galera/t/galera_many_rows.test +++ b/mysql-test/suite/galera/t/galera_many_rows.test @@ -16,7 +16,7 @@ INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4 --connection node_2 SET SESSION wsrep_sync_wait = 0; --let $wsrep_provider_options_node2 = `SELECT @@wsrep_provider_options` -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SET GLOBAL wsrep_provider_options = 'repl.causal_read_timeout=PT1H'; diff --git a/mysql-test/suite/galera/t/galera_migrate.cnf b/mysql-test/suite/galera/t/galera_migrate.cnf index 47bdf53afef..ed48f208e52 100644 --- a/mysql-test/suite/galera/t/galera_migrate.cnf +++ b/mysql-test/suite/galera/t/galera_migrate.cnf @@ -13,7 +13,7 @@ log-bin=mysqld-bin wsrep_node_address=127.0.0.1 wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 [mysqld.1] #galera_port=@OPT.port diff --git a/mysql-test/suite/galera/t/galera_parallel_simple.test b/mysql-test/suite/galera/t/galera_parallel_simple.test index e078a342c16..41cd0c8e6fa 100644 --- a/mysql-test/suite/galera/t/galera_parallel_simple.test +++ b/mysql-test/suite/galera/t/galera_parallel_simple.test @@ -45,7 +45,7 @@ SET SESSION wsrep_sync_wait = 0; UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 10 FROM t1; SELECT COUNT(*) = 10 FROM t2; diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test index 6b14118d5fc..87afc2d7bb2 100644 --- a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test +++ b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test @@ -10,7 +10,6 @@ INSERT INTO t1 VALUES (1); --let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; # first lookup miss # @@ -27,7 +26,6 @@ SET GLOBAL DEBUG = ""; SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; FLUSH QUERY CACHE; -SET SESSION wsrep_sync_wait = 7; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; SET DEBUG_SYNC = "RESET"; @@ -52,9 +50,7 @@ SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; INSERT INTO t1 VALUES (4); --connection node_2 -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; -SET SESSION wsrep_sync_wait = 7; # # Query cache hit @@ -73,7 +69,6 @@ SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; INSERT INTO t1 VALUES (5); --connection node_2 -SET SESSION wsrep_sync_wait = 7; --send SELECT MAX(id) FROM t1 --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 diff --git a/mysql-test/suite/galera/t/galera_sync_wait_show.test b/mysql-test/suite/galera/t/galera_sync_wait_show.test index 250b1f76e98..58de5433030 100644 --- a/mysql-test/suite/galera/t/galera_sync_wait_show.test +++ b/mysql-test/suite/galera/t/galera_sync_wait_show.test @@ -7,7 +7,8 @@ --source include/have_debug.inc --connection node_2 -SET SESSION wsrep_sync_wait = 1; +# MW-86 SHOW commands have now bitmap value 8 +SET SESSION wsrep_sync_wait = 8; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_unicode_identifiers.test b/mysql-test/suite/galera/t/galera_unicode_identifiers.test index 9adac1aa555..f3df60a6415 100644 --- a/mysql-test/suite/galera/t/galera_unicode_identifiers.test +++ b/mysql-test/suite/galera/t/galera_unicode_identifiers.test @@ -6,10 +6,10 @@ --source include/have_innodb.inc --let $wsrep_sync_wait_orig = (SELECT @@wsrep_sync_wait) -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; --connection node_2 -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_var_sync_wait.test b/mysql-test/suite/galera/t/galera_var_sync_wait.test index 935c271a4d6..046724e1635 100644 --- a/mysql-test/suite/galera/t/galera_var_sync_wait.test +++ b/mysql-test/suite/galera/t/galera_var_sync_wait.test @@ -13,7 +13,10 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; --connection node_2 SET GLOBAL wsrep_sync_wait = 1; # Those statements should see the table -SHOW TABLES LIKE '%t1'; + +# MW-86 SHOW commands have now their own bitmask +# SHOW TABLES LIKE '%t1'; + SELECT COUNT(*) = 0 FROM t1; --connection node_1 diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201.test b/mysql-test/suite/galera/t/mysql-wsrep#201.test index e9327540195..21cf05db008 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#201.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#201.test @@ -8,7 +8,6 @@ INSERT INTO t1 VALUES (DEFAULT); --connection node_2 --let $qcache_size_orig = `SELECT @@GLOBAL.query_cache_size` SET GLOBAL query_cache_size=1355776; -SET SESSION wsrep_sync_wait = 7; --disable_query_log diff --git a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf index 3921e3aa362..48c7180cb51 100644 --- a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf +++ b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf @@ -9,7 +9,7 @@ wsrep-provider=@ENV.WSREP_PROVIDER wsrep_node_address=127.0.0.1 # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.1] wsrep-cluster-address='gcomm://' diff --git a/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result b/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result new file mode 100644 index 00000000000..88780a2c87f --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result @@ -0,0 +1,48 @@ +CREATE TABLE t1 (f1 INTEGER); +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_dirty_reads = 1; +SELECT f1 FROM t1; +f1 +1 +USE test; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +LOCK TABLE t1 WRITE; +UNLOCK TABLES; +FLUSH TABLES WITH READ LOCK; +UNLOCK TABLES; +PREPARE stmt_select FROM 'SELECT f1 FROM t1'; +EXECUTE stmt_select; +f1 +1 +PREPARE stmt_update FROM 'UPDATE t1 SET f1 = f1 + f1'; +SET GLOBAL wsrep_dirty_reads = 1; +SET GLOBAL wsrep_sync_wait = 0; +SET GLOBAL wsrep_dirty_reads = 0; +SET GLOBAL wsrep_sync_wait = 15; +SET SESSION wsrep_dirty_reads = 1; +INSERT INTO t1 SELECT * FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use +DELETE FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use +UPDATE t1 SET f1 = f1 + 1; +ERROR 08S01: WSREP has not yet prepared node for application use +DROP TABLE t1; +ERROR 08S01: WSREP has not yet prepared node for application use +EXECUTE stmt_update; +ERROR 08S01: WSREP has not yet prepared node for application use +SET SESSION wsrep_dirty_reads = 0; +SELECT * FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use +EXECUTE stmt_select; +ERROR 08S01: WSREP has not yet prepared node for application use +SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST; +COUNT(*) > 0 +1 +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/t/galera_var_dirty_reads2.test b/mysql-test/suite/galera_3nodes/t/galera_var_dirty_reads2.test new file mode 100644 index 00000000000..129ba2e1f38 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_var_dirty_reads2.test @@ -0,0 +1,112 @@ +# +# Additional tests for wsrep_dirty_reads +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER); +INSERT INTO t1 VALUES (1); + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +SET SESSION wsrep_sync_wait = 0; + +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +SET SESSION wsrep_dirty_reads = 1; + +# Those statements should succeed + +--error 0 +SELECT f1 FROM t1; + +--error 0 +USE test; + +--error 0 +SHOW CREATE TABLE t1; + +--error 0 +LOCK TABLE t1 WRITE; + +--error 0 +UNLOCK TABLES; + +--error 0 +FLUSH TABLES WITH READ LOCK; + +--error 0 +UNLOCK TABLES; + +--error 0 +PREPARE stmt_select FROM 'SELECT f1 FROM t1'; + +--error 0 +EXECUTE stmt_select; + +--error 0 +PREPARE stmt_update FROM 'UPDATE t1 SET f1 = f1 + f1'; + +# Mysqldump should succeed + +SET GLOBAL wsrep_dirty_reads = 1; +SET GLOBAL wsrep_sync_wait = 0; +--error 0 +--exec $MYSQL_DUMP -u root -S $NODE_MYSOCK_2 test >/dev/null +SET GLOBAL wsrep_dirty_reads = 0; +SET GLOBAL wsrep_sync_wait = 15; + +# Those statements should fail + +SET SESSION wsrep_dirty_reads = 1; + +--error ER_UNKNOWN_COM_ERROR +INSERT INTO t1 SELECT * FROM t1; + +--error ER_UNKNOWN_COM_ERROR +DELETE FROM t1; + +--error ER_UNKNOWN_COM_ERROR +UPDATE t1 SET f1 = f1 + 1; + +--error ER_UNKNOWN_COM_ERROR +DROP TABLE t1; + +--error ER_UNKNOWN_COM_ERROR +EXECUTE stmt_update; + +# With wsrep_dirty_reads = 0 , even SELECTS are not allowed + +SET SESSION wsrep_dirty_reads = 0; + +--error ER_UNKNOWN_COM_ERROR +SELECT * FROM t1; + +--error ER_UNKNOWN_COM_ERROR +EXECUTE stmt_select; + +# But reads from INFORMATION_SCHEMA are allowed + +--error 0 +SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST; + +# Restore cluster +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +DROP TABLE t1; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index ad6b8eedf3e..dfae06b262d 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -970,9 +970,13 @@ static bool wsrep_prepare_keys_for_isolation(THD* thd, for (const TABLE_LIST* table= table_list; table; table= table->next_global) { wsrep_key_t* tmp; - tmp= (wsrep_key_t*)my_realloc(ka->keys, + if (ka->keys) + tmp= (wsrep_key_t*)my_realloc(ka->keys, (ka->keys_len + 1) * sizeof(wsrep_key_t), MYF(0)); + else + tmp= (wsrep_key_t*)my_malloc((ka->keys_len + 1) * sizeof(wsrep_key_t), MYF(0)); + if (!tmp) { WSREP_ERROR("Can't allocate memory for key_array"); From 3d4708554cde8f76219d1c25fce81e142737745d Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 8 Mar 2017 15:29:31 +0100 Subject: [PATCH 020/101] MW-86 MTR test: check that SHOW commands no longer obey wsrep_sync_wait = 1 --- mysql-test/suite/galera/r/MW-86.result | 18 ++++++++++ mysql-test/suite/galera/t/MW-86.test | 46 ++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-86.result create mode 100644 mysql-test/suite/galera/t/MW-86.test diff --git a/mysql-test/suite/galera/r/MW-86.result b/mysql-test/suite/galera/r/MW-86.result new file mode 100644 index 00000000000..d0799a0a708 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-86.result @@ -0,0 +1,18 @@ +SET SESSION wsrep_sync_wait = 1; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +CREATE DATABASE db1; +SHOW CREATE DATABASE db1; +ERROR 42000: Unknown database 'db1' +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +SET SESSION wsrep_sync_wait = 8; +DROP DATABASE db1; +SET SESSION wsrep_sync_wait = 8; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; +CREATE DATABASE db1; +SHOW CREATE DATABASE db1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +DROP DATABASE db1; diff --git a/mysql-test/suite/galera/t/MW-86.test b/mysql-test/suite/galera/t/MW-86.test new file mode 100644 index 00000000000..cc92dbbd818 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-86.test @@ -0,0 +1,46 @@ +--source include/galera_cluster.inc + +# +# Test 1: SHOW commands no longer obey wsrep_sync_wait = 1 +# + +--connection node_2 +SET SESSION wsrep_sync_wait = 1; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; + +--connection node_1 +CREATE DATABASE db1; + +--connection node_2 +--error ER_BAD_DB_ERROR +SHOW CREATE DATABASE db1; +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +SET SESSION wsrep_sync_wait = 8; +DROP DATABASE db1; + + +# +# Test 2: SHOW commands now obey wsrep_sync_wait = 8 +# + +--connection node_2 +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET SESSION wsrep_sync_wait = 8; +SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; + +--connection node_1 +CREATE DATABASE db1; + +--connection node_2 +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE DATABASE db1; + +SET GLOBAL DEBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +DROP DATABASE db1; + +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = "$wsrep_provider_options_orig" From 795713405b0605caddf77f422a0414f1169487b9 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 10 Mar 2017 09:25:24 +0200 Subject: [PATCH 021/101] Refs: MW-360 * fix for regression with galera_toi_ddl_nonconflicting test --- sql/wsrep_mysqld.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index dfae06b262d..6e847a33dfb 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1324,7 +1324,7 @@ static bool wsrep_can_run_in_toi(THD *thd, const char *db, const char *table, 1: TOI replication was skipped -1: TOI replication failed */ -static int wsrep_TOI_begin(THD *thd, const char *query, char *db_, char *table_, +static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, const TABLE_LIST* table_list) { wsrep_status_t ret(WSREP_WARNING); @@ -1366,8 +1366,7 @@ static int wsrep_TOI_begin(THD *thd, const char *query, char *db_, char *table_, } /* fallthrough */ default: - buf_err= wsrep_to_buf_helper(thd, (query) ? query : thd->query(), - (query) ? strlen(query) : thd->query_length(), + buf_err= wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), &buf, &buf_len); break; } @@ -1573,7 +1572,7 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, { switch (thd->variables.wsrep_OSU_method) { case WSREP_OSU_TOI: - ret = wsrep_TOI_begin(thd, thd->query(), db_, table_, table_list); + ret = wsrep_TOI_begin(thd, db_, table_, table_list); break; case WSREP_OSU_RSU: ret = wsrep_RSU_begin(thd, db_, table_); From e2ccbe1aeac1f866344b33d564f1983aaea3ea80 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 13 Mar 2017 02:30:01 -0700 Subject: [PATCH 022/101] Galera MTR Tests: Tests for MW-360 DROP TABLE containing temporary tables results in binlog divergence --- mysql-test/suite/galera/r/MW-360.result | 161 ++++++++++++++++++ .../galera/r/galera_ddl_multiline.result | 80 +++++++++ mysql-test/suite/galera/t/MW-360-master.opt | 2 + mysql-test/suite/galera/t/MW-360.test | 103 +++++++++++ .../suite/galera/t/galera_ddl_multiline.test | 54 ++++++ 5 files changed, 400 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-360.result create mode 100644 mysql-test/suite/galera/r/galera_ddl_multiline.result create mode 100644 mysql-test/suite/galera/t/MW-360-master.opt create mode 100644 mysql-test/suite/galera/t/MW-360.test create mode 100644 mysql-test/suite/galera/t/galera_ddl_multiline.test diff --git a/mysql-test/suite/galera/r/MW-360.result b/mysql-test/suite/galera/r/MW-360.result new file mode 100644 index 00000000000..4195b8f07bc --- /dev/null +++ b/mysql-test/suite/galera/r/MW-360.result @@ -0,0 +1,161 @@ +SET GLOBAL wsrep_on=OFF; +RESET MASTER; +SET GLOBAL wsrep_on=ON; +SET GLOBAL wsrep_on=OFF; +RESET MASTER; +SET GLOBAL wsrep_on=ON; +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +DROP TABLE t1; +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t2 VALUES (2); +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t2 VALUES (2); +DROP TABLE t1, t2; +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t2 VALUES (2); +CREATE TEMPORARY TABLE t3 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t3 VALUES (3); +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t2 VALUES (2); +CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t3 VALUES (3); +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (2); +DROP TABLE t1; +DROP TABLE t1; +SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-bin.000001 120 Previous_gtids 1 151 +mysqld-bin.000001 151 Gtid 1 199 SET @@SESSION.GTID_NEXT= ':1' +mysqld-bin.000001 199 Query 1 339 use `test`; DROP TEMPORARY TABLE IF EXISTS `t1` /* generated by server */ +mysqld-bin.000001 339 Gtid 1 387 SET @@SESSION.GTID_NEXT= ':1' +mysqld-bin.000001 387 Query 1 503 use `test`; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 503 Gtid 1 551 SET @@SESSION.GTID_NEXT= ':2' +mysqld-bin.000001 551 Query 1 628 BEGIN +mysqld-bin.000001 628 Table_map 1 673 table_id: # (test.t2) +mysqld-bin.000001 673 Write_rows 1 713 table_id: # flags: STMT_END_F +mysqld-bin.000001 713 Xid 1 744 COMMIT /* xid=# */ +mysqld-bin.000001 744 Gtid 1 792 SET @@SESSION.GTID_NEXT= ':2' +mysqld-bin.000001 792 Query 1 927 use `test`; DROP TEMPORARY TABLE IF EXISTS `t1` /* generated by server */ +mysqld-bin.000001 927 Gtid 1 975 SET @@SESSION.GTID_NEXT= ':3' +mysqld-bin.000001 975 Query 1 1090 use `test`; DROP TABLE `t2` /* generated by server */ +mysqld-bin.000001 1090 Gtid 1 1138 SET @@SESSION.GTID_NEXT= ':4' +mysqld-bin.000001 1138 Query 1 1254 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 1254 Gtid 1 1302 SET @@SESSION.GTID_NEXT= ':5' +mysqld-bin.000001 1302 Query 1 1379 BEGIN +mysqld-bin.000001 1379 Table_map 1 1424 table_id: # (test.t1) +mysqld-bin.000001 1424 Write_rows 1 1464 table_id: # flags: STMT_END_F +mysqld-bin.000001 1464 Xid 1 1495 COMMIT /* xid=# */ +mysqld-bin.000001 1495 Gtid 1 1543 SET @@SESSION.GTID_NEXT= ':3' +mysqld-bin.000001 1543 Query 1 1678 use `test`; DROP TEMPORARY TABLE IF EXISTS `t2` /* generated by server */ +mysqld-bin.000001 1678 Gtid 1 1726 SET @@SESSION.GTID_NEXT= ':6' +mysqld-bin.000001 1726 Query 1 1841 use `test`; DROP TABLE `t1` /* generated by server */ +mysqld-bin.000001 1841 Gtid 1 1889 SET @@SESSION.GTID_NEXT= ':7' +mysqld-bin.000001 1889 Query 1 2005 use `test`; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 2005 Gtid 1 2053 SET @@SESSION.GTID_NEXT= ':8' +mysqld-bin.000001 2053 Query 1 2130 BEGIN +mysqld-bin.000001 2130 Table_map 1 2175 table_id: # (test.t2) +mysqld-bin.000001 2175 Write_rows 1 2215 table_id: # flags: STMT_END_F +mysqld-bin.000001 2215 Xid 1 2246 COMMIT /* xid=# */ +mysqld-bin.000001 2246 Gtid 1 2294 SET @@SESSION.GTID_NEXT= ':4' +mysqld-bin.000001 2294 Query 1 2434 use `test`; DROP TEMPORARY TABLE IF EXISTS `t1`,`t3` /* generated by server */ +mysqld-bin.000001 2434 Gtid 1 2482 SET @@SESSION.GTID_NEXT= ':9' +mysqld-bin.000001 2482 Query 1 2597 use `test`; DROP TABLE `t2` /* generated by server */ +mysqld-bin.000001 2597 Gtid 1 2645 SET @@SESSION.GTID_NEXT= ':10' +mysqld-bin.000001 2645 Query 1 2761 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 2761 Gtid 1 2809 SET @@SESSION.GTID_NEXT= ':11' +mysqld-bin.000001 2809 Query 1 2886 BEGIN +mysqld-bin.000001 2886 Table_map 1 2931 table_id: # (test.t1) +mysqld-bin.000001 2931 Write_rows 1 2971 table_id: # flags: STMT_END_F +mysqld-bin.000001 2971 Xid 1 3002 COMMIT /* xid=# */ +mysqld-bin.000001 3002 Gtid 1 3050 SET @@SESSION.GTID_NEXT= ':12' +mysqld-bin.000001 3050 Query 1 3166 use `test`; CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 3166 Gtid 1 3214 SET @@SESSION.GTID_NEXT= ':13' +mysqld-bin.000001 3214 Query 1 3291 BEGIN +mysqld-bin.000001 3291 Table_map 1 3336 table_id: # (test.t3) +mysqld-bin.000001 3336 Write_rows 1 3376 table_id: # flags: STMT_END_F +mysqld-bin.000001 3376 Xid 1 3407 COMMIT /* xid=# */ +mysqld-bin.000001 3407 Gtid 1 3455 SET @@SESSION.GTID_NEXT= ':5' +mysqld-bin.000001 3455 Query 1 3590 use `test`; DROP TEMPORARY TABLE IF EXISTS `t2` /* generated by server */ +mysqld-bin.000001 3590 Gtid 1 3638 SET @@SESSION.GTID_NEXT= ':14' +mysqld-bin.000001 3638 Query 1 3758 use `test`; DROP TABLE `t1`,`t3` /* generated by server */ +mysqld-bin.000001 3758 Gtid 1 3806 SET @@SESSION.GTID_NEXT= ':15' +mysqld-bin.000001 3806 Query 1 3922 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 3922 Gtid 1 3970 SET @@SESSION.GTID_NEXT= ':16' +mysqld-bin.000001 3970 Query 1 4047 BEGIN +mysqld-bin.000001 4047 Table_map 1 4092 table_id: # (test.t1) +mysqld-bin.000001 4092 Write_rows 1 4132 table_id: # flags: STMT_END_F +mysqld-bin.000001 4132 Xid 1 4163 COMMIT /* xid=# */ +mysqld-bin.000001 4163 Gtid 1 4211 SET @@SESSION.GTID_NEXT= ':6' +mysqld-bin.000001 4211 Query 1 4351 use `test`; DROP TEMPORARY TABLE IF EXISTS `t1` /* generated by server */ +mysqld-bin.000001 4351 Gtid 1 4399 SET @@SESSION.GTID_NEXT= ':17' +mysqld-bin.000001 4399 Query 1 4514 use `test`; DROP TABLE `t1` /* generated by server */ +SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-bin.000001 120 Previous_gtids 2 151 +mysqld-bin.000001 151 Gtid 1 199 SET @@SESSION.GTID_NEXT= ':1' +mysqld-bin.000001 199 Query 1 315 use `test`; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 315 Gtid 1 363 SET @@SESSION.GTID_NEXT= ':2' +mysqld-bin.000001 363 Query 1 431 BEGIN +mysqld-bin.000001 431 Table_map 1 476 table_id: # (test.t2) +mysqld-bin.000001 476 Write_rows 1 516 table_id: # flags: STMT_END_F +mysqld-bin.000001 516 Xid 1 547 COMMIT /* xid=# */ +mysqld-bin.000001 547 Gtid 1 595 SET @@SESSION.GTID_NEXT= ':3' +mysqld-bin.000001 595 Query 1 710 use `test`; DROP TABLE `t2` /* generated by server */ +mysqld-bin.000001 710 Gtid 1 758 SET @@SESSION.GTID_NEXT= ':4' +mysqld-bin.000001 758 Query 1 874 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 874 Gtid 1 922 SET @@SESSION.GTID_NEXT= ':5' +mysqld-bin.000001 922 Query 1 990 BEGIN +mysqld-bin.000001 990 Table_map 1 1035 table_id: # (test.t1) +mysqld-bin.000001 1035 Write_rows 1 1075 table_id: # flags: STMT_END_F +mysqld-bin.000001 1075 Xid 1 1106 COMMIT /* xid=# */ +mysqld-bin.000001 1106 Gtid 1 1154 SET @@SESSION.GTID_NEXT= ':6' +mysqld-bin.000001 1154 Query 1 1269 use `test`; DROP TABLE `t1` /* generated by server */ +mysqld-bin.000001 1269 Gtid 1 1317 SET @@SESSION.GTID_NEXT= ':7' +mysqld-bin.000001 1317 Query 1 1433 use `test`; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 1433 Gtid 1 1481 SET @@SESSION.GTID_NEXT= ':8' +mysqld-bin.000001 1481 Query 1 1549 BEGIN +mysqld-bin.000001 1549 Table_map 1 1594 table_id: # (test.t2) +mysqld-bin.000001 1594 Write_rows 1 1634 table_id: # flags: STMT_END_F +mysqld-bin.000001 1634 Xid 1 1665 COMMIT /* xid=# */ +mysqld-bin.000001 1665 Gtid 1 1713 SET @@SESSION.GTID_NEXT= ':9' +mysqld-bin.000001 1713 Query 1 1828 use `test`; DROP TABLE `t2` /* generated by server */ +mysqld-bin.000001 1828 Gtid 1 1876 SET @@SESSION.GTID_NEXT= ':10' +mysqld-bin.000001 1876 Query 1 1992 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 1992 Gtid 1 2040 SET @@SESSION.GTID_NEXT= ':11' +mysqld-bin.000001 2040 Query 1 2108 BEGIN +mysqld-bin.000001 2108 Table_map 1 2153 table_id: # (test.t1) +mysqld-bin.000001 2153 Write_rows 1 2193 table_id: # flags: STMT_END_F +mysqld-bin.000001 2193 Xid 1 2224 COMMIT /* xid=# */ +mysqld-bin.000001 2224 Gtid 1 2272 SET @@SESSION.GTID_NEXT= ':12' +mysqld-bin.000001 2272 Query 1 2388 use `test`; CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 2388 Gtid 1 2436 SET @@SESSION.GTID_NEXT= ':13' +mysqld-bin.000001 2436 Query 1 2504 BEGIN +mysqld-bin.000001 2504 Table_map 1 2549 table_id: # (test.t3) +mysqld-bin.000001 2549 Write_rows 1 2589 table_id: # flags: STMT_END_F +mysqld-bin.000001 2589 Xid 1 2620 COMMIT /* xid=# */ +mysqld-bin.000001 2620 Gtid 1 2668 SET @@SESSION.GTID_NEXT= ':14' +mysqld-bin.000001 2668 Query 1 2788 use `test`; DROP TABLE `t1`,`t3` /* generated by server */ +mysqld-bin.000001 2788 Gtid 1 2836 SET @@SESSION.GTID_NEXT= ':15' +mysqld-bin.000001 2836 Query 1 2952 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB +mysqld-bin.000001 2952 Gtid 1 3000 SET @@SESSION.GTID_NEXT= ':16' +mysqld-bin.000001 3000 Query 1 3068 BEGIN +mysqld-bin.000001 3068 Table_map 1 3113 table_id: # (test.t1) +mysqld-bin.000001 3113 Write_rows 1 3153 table_id: # flags: STMT_END_F +mysqld-bin.000001 3153 Xid 1 3184 COMMIT /* xid=# */ +mysqld-bin.000001 3184 Gtid 1 3232 SET @@SESSION.GTID_NEXT= ':17' +mysqld-bin.000001 3232 Query 1 3347 use `test`; DROP TABLE `t1` /* generated by server */ diff --git a/mysql-test/suite/galera/r/galera_ddl_multiline.result b/mysql-test/suite/galera/r/galera_ddl_multiline.result new file mode 100644 index 00000000000..602f18326e8 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ddl_multiline.result @@ -0,0 +1,80 @@ +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t4 (f1 INTEGER) ENGINE=InnoDB;; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (1); +CREATE TABLE t5 (f1 INTEGER) ENGINE=InnoDB; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +SHOW CREATE TABLE t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +SHOW CREATE TABLE t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CREATE TABLE t6 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t2 VALUES (1);; +SELECT COUNT(*) = 1 FROM t2; +COUNT(*) = 1 +1 +SHOW CREATE TABLE t6; +Table Create Table +t6 CREATE TABLE `t6` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT COUNT(*) = 1 FROM t2; +COUNT(*) = 1 +1 +SHOW CREATE TABLE t6; +Table Create Table +t6 CREATE TABLE `t6` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +include/diff_servers.inc [servers=1 2] +DROP TABLE t1, t2, t3, t4, t5, t6; diff --git a/mysql-test/suite/galera/t/MW-360-master.opt b/mysql-test/suite/galera/t/MW-360-master.opt new file mode 100644 index 00000000000..6cfaed135e4 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-360-master.opt @@ -0,0 +1,2 @@ +--gtid-mode=ON --log-bin --log-slave-updates --enforce-gtid-consistency + diff --git a/mysql-test/suite/galera/t/MW-360.test b/mysql-test/suite/galera/t/MW-360.test new file mode 100644 index 00000000000..7ea743cdb3d --- /dev/null +++ b/mysql-test/suite/galera/t/MW-360.test @@ -0,0 +1,103 @@ +# +# MW-360 DROP TABLE containing temporary tables results in binlog divergence +# + +--source include/galera_cluster.inc +--source include/have_binlog_format_row.inc + +--connection node_1 +SET GLOBAL wsrep_on=OFF; +RESET MASTER; +SET GLOBAL wsrep_on=ON; + +--connection node_2 +SET GLOBAL wsrep_on=OFF; +RESET MASTER; +SET GLOBAL wsrep_on=ON; + +--connection node_1 + +# +# Straightforward temporary table +# + +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +DROP TABLE t1; +--let $local_uuid = `SELECT LEFT(@@global.gtid_executed, 36)` + +# +# A mix of normal and temporary tables +# + +# Temp table first, normal table second + +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t2 VALUES (2); + +DROP TABLE t1, t2; + +# Normal table first, temporary table second + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t2 VALUES (2); + +DROP TABLE t1, t2; + +# Temporary table first, normal table second, temp table third + +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t2 VALUES (2); + +CREATE TEMPORARY TABLE t3 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t3 VALUES (3); + +DROP TABLE t1, t2, t3; + +# Normal table first, temporary table second, normal table third + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t2 VALUES (2); + +CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t3 VALUES (3); + +DROP TABLE t1, t2, t3; + +# +# A temporary table masking a normal one +# + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (2); + +DROP TABLE t1; +DROP TABLE t1; + +--connection node_2 +--let $cluster_uuid = `SELECT LEFT(@@global.gtid_executed, 36)` + +--connection node_1 +--replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/ +--replace_result $local_uuid $cluster_uuid +SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; + +--connection node_2 +--replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/ +--replace_result $local_uuid $cluster_uuid +SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; diff --git a/mysql-test/suite/galera/t/galera_ddl_multiline.test b/mysql-test/suite/galera/t/galera_ddl_multiline.test new file mode 100644 index 00000000000..c7155d066fa --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ddl_multiline.test @@ -0,0 +1,54 @@ +# +# Test that Galera works correctly with multiline statements, in particular involving DDLs +# + +--source include/galera_cluster.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; + +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; + +--connection node_2 +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; + +--connection node_1 +--send CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t4 (f1 INTEGER) ENGINE=InnoDB; +--reap + +SHOW CREATE TABLE t3; +SHOW CREATE TABLE t4; + +--connection node_2 +SHOW CREATE TABLE t3; +SHOW CREATE TABLE t4; + +--connection node_1 +INSERT INTO t1 VALUES (1); CREATE TABLE t5 (f1 INTEGER) ENGINE=InnoDB; + +SELECT COUNT(*) = 1 FROM t1; +SHOW CREATE TABLE t5; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; +SHOW CREATE TABLE t5; + +--connection node_1 +--send CREATE TABLE t6 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t2 VALUES (1); +--reap + +SELECT COUNT(*) = 1 FROM t2; +SHOW CREATE TABLE t6; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t2; +SHOW CREATE TABLE t6; + +--let $diff_servers = 1 2 +--source include/diff_servers.inc + +--connection node_1 +DROP TABLE t1, t2, t3, t4, t5, t6; + From 62cd7553d9d8ffa02485ae050b7a760f461a5017 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 13 Mar 2017 15:35:04 +0100 Subject: [PATCH 023/101] MW-86 Additional wsrep_sync_wait coverage The following commands are now subject to wsrep_sync_wait with bitmask value 8: SHOW BINARY LOGS SHOW BINLOG EVENTS SHOW GRANTS --- sql/sql_parse.cc | 12 +++++++++--- sql/sql_parse.h | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 38d53b6c5c6..c82ae8f0f5c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2805,11 +2805,14 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_COLLATIONS: case SQLCOM_SHOW_STORAGE_ENGINES: case SQLCOM_SHOW_PROFILE: - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); case SQLCOM_SELECT: { - if (lex->sql_command == SQLCOM_SELECT) - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ); +#ifdef WITH_WSREP + if (lex->sql_command == SQLCOM_SELECT) + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ) + else + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW) +#endif /* WITH_WSREP */ thd->status_var.last_query_cost= 0.0; @@ -2933,6 +2936,7 @@ case SQLCOM_PREPARE: case SQLCOM_SHOW_RELAYLOG_EVENTS: /* fall through */ case SQLCOM_SHOW_BINLOG_EVENTS: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (check_global_access(thd, REPL_SLAVE_ACL)) goto error; res = mysql_show_binlog_events(thd); @@ -3495,6 +3499,7 @@ end_with_restore_list: { if (check_global_access(thd, SUPER_ACL | REPL_CLIENT_ACL)) goto error; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res = show_binlogs(thd); break; } @@ -4778,6 +4783,7 @@ end_with_restore_list: if (!grant_user) goto error; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res = mysql_show_grants(thd, grant_user); break; } diff --git a/sql/sql_parse.h b/sql/sql_parse.h index e9c82b9df48..c3844bcc83f 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -226,8 +226,8 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; #define WSREP_SYNC_WAIT(thd_, before_) \ - if (WSREP_CLIENT(thd_) && \ - wsrep_sync_wait(thd_, before_)) goto error; + { if (WSREP_CLIENT(thd_) && \ + wsrep_sync_wait(thd_, before_)) goto error; } #else From fae7d85600dbf343df55bf197e46a2dcbb874da0 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 13 Mar 2017 08:45:42 -0700 Subject: [PATCH 024/101] Galera MTR Tests: Extend test for MW-86 with additional SHOW commands --- mysql-test/suite/galera/t/MW-86-master.opt | 1 + 1 file changed, 1 insertion(+) create mode 100644 mysql-test/suite/galera/t/MW-86-master.opt diff --git a/mysql-test/suite/galera/t/MW-86-master.opt b/mysql-test/suite/galera/t/MW-86-master.opt new file mode 100644 index 00000000000..8a755e98b00 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-86-master.opt @@ -0,0 +1 @@ +--log-bin --log-slave-updates From df5b90e18b47fd69563f49c099938b9b1ab32a27 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 13 Mar 2017 08:52:09 -0700 Subject: [PATCH 025/101] Galera MTR Tests: Extend test for MW-86 with additional SHOW commands (part #2) --- mysql-test/suite/galera/r/MW-86.result | 57 +++++++++- mysql-test/suite/galera/t/MW-86.test | 147 ++++++++++++++++++++++++- 2 files changed, 196 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/galera/r/MW-86.result b/mysql-test/suite/galera/r/MW-86.result index d0799a0a708..b29175216a8 100644 --- a/mysql-test/suite/galera/r/MW-86.result +++ b/mysql-test/suite/galera/r/MW-86.result @@ -1,18 +1,65 @@ SET SESSION wsrep_sync_wait = 1; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; CREATE DATABASE db1; +SHOW BINARY LOGS; +SHOW BINLOG EVENTS; +SHOW COLUMNS FROM t1; SHOW CREATE DATABASE db1; -ERROR 42000: Unknown database 'db1' +SHOW CREATE EVENT e1; +SHOW CREATE FUNCTION f1; +SHOW CREATE PROCEDURE p1; +SHOW CREATE TABLE t1; +SHOW CREATE TRIGGER tr1; +SHOW CREATE VIEW v1; +SHOW DATABASES; +SHOW ENGINE InnoDB STATUS; +SHOW FUNCTION CODE f1; +SHOW FUNCTION STATUS; +SHOW GRANTS FOR 'root'@'localhost'; +SHOW INDEX FROM t1; +SHOW OPEN TABLES; +SHOW PROCEDURE CODE p1; +SHOW PROCEDURE STATUS; +SHOW PRIVILEGES; +SHOW STATUS LIKE 'wsrep_cluster_size'; +SHOW TABLE STATUS; +SHOW TABLES; +SHOW TRIGGERS; +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; +SHOW WARNINGS; SET GLOBAL DEBUG = ""; SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; SET SESSION wsrep_sync_wait = 8; DROP DATABASE db1; +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; SET SESSION wsrep_sync_wait = 8; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; -CREATE DATABASE db1; +CREATE TABLE q (f1 INTEGER) ENGINE=InnoDB; +SHOW BINARY LOGS; +SHOW BINLOG EVENTS; +SHOW COLUMNS FROM t1; SHOW CREATE DATABASE db1; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SHOW CREATE EVENT e1; +SHOW CREATE FUNCTION f1; +SHOW CREATE PROCEDURE p1; +SHOW CREATE TABLE t1; +SHOW CREATE TRIGGER tr1; +SHOW CREATE VIEW v1; +SHOW DATABASES; +SHOW ENGINE InnoDB STATUS; +SHOW FUNCTION CODE f1; +SHOW FUNCTION STATUS; +SHOW GRANTS FOR 'root'@'localhost'; +SHOW INDEX FROM t1; +SHOW OPEN TABLES; +SHOW PROCEDURE CODE p1; +SHOW PROCEDURE STATUS; +SHOW PRIVILEGES; +SHOW STATUS LIKE 'wsrep_cluster_size'; +SHOW TABLE STATUS; +SHOW TABLES; +SHOW TRIGGERS; +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; +SHOW WARNINGS; SET GLOBAL DEBUG = ""; SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; -DROP DATABASE db1; diff --git a/mysql-test/suite/galera/t/MW-86.test b/mysql-test/suite/galera/t/MW-86.test index cc92dbbd818..c6550ecdaaa 100644 --- a/mysql-test/suite/galera/t/MW-86.test +++ b/mysql-test/suite/galera/t/MW-86.test @@ -1,4 +1,5 @@ --source include/galera_cluster.inc +--source include/have_binlog_format_row.inc # # Test 1: SHOW commands no longer obey wsrep_sync_wait = 1 @@ -7,13 +8,76 @@ --connection node_2 SET SESSION wsrep_sync_wait = 1; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; +--disable_result_log --connection node_1 CREATE DATABASE db1; --connection node_2 +SHOW BINARY LOGS; + +SHOW BINLOG EVENTS; + +--error ER_NO_SUCH_TABLE +SHOW COLUMNS FROM t1; + --error ER_BAD_DB_ERROR SHOW CREATE DATABASE db1; + +--error ER_EVENT_DOES_NOT_EXIST +SHOW CREATE EVENT e1; + +--error ER_SP_DOES_NOT_EXIST +SHOW CREATE FUNCTION f1; + +--error ER_SP_DOES_NOT_EXIST +SHOW CREATE PROCEDURE p1; + +--error ER_NO_SUCH_TABLE +SHOW CREATE TABLE t1; + +--error ER_TRG_DOES_NOT_EXIST +SHOW CREATE TRIGGER tr1; + +--error ER_NO_SUCH_TABLE +SHOW CREATE VIEW v1; + +SHOW DATABASES; + +SHOW ENGINE InnoDB STATUS; + +--error ER_SP_DOES_NOT_EXIST +SHOW FUNCTION CODE f1; + +SHOW FUNCTION STATUS; + +SHOW GRANTS FOR 'root'@'localhost'; + +--error ER_NO_SUCH_TABLE +SHOW INDEX FROM t1; + +SHOW OPEN TABLES; + +--error ER_SP_DOES_NOT_EXIST +SHOW PROCEDURE CODE p1; + +SHOW PROCEDURE STATUS; + +SHOW PRIVILEGES; + +SHOW STATUS LIKE 'wsrep_cluster_size'; + +SHOW TABLE STATUS; + +SHOW TABLES; + +SHOW TRIGGERS; + +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; + +--error 0 +SHOW WARNINGS; + SET GLOBAL DEBUG = ""; SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; @@ -27,20 +91,97 @@ DROP DATABASE db1; --connection node_2 --let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; SET SESSION wsrep_sync_wait = 8; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; --connection node_1 -CREATE DATABASE db1; +CREATE TABLE q (f1 INTEGER) ENGINE=InnoDB; --connection node_2 +--error ER_LOCK_WAIT_TIMEOUT +SHOW BINARY LOGS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW BINLOG EVENTS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW COLUMNS FROM t1; + --error ER_LOCK_WAIT_TIMEOUT SHOW CREATE DATABASE db1; +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE EVENT e1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE FUNCTION f1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE PROCEDURE p1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE TABLE t1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE TRIGGER tr1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE VIEW v1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW DATABASES; + +--error 0 +SHOW ENGINE InnoDB STATUS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW FUNCTION CODE f1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW FUNCTION STATUS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW GRANTS FOR 'root'@'localhost'; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW INDEX FROM t1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW OPEN TABLES; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW PROCEDURE CODE p1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW PROCEDURE STATUS; + +--error 0 +SHOW PRIVILEGES; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW STATUS LIKE 'wsrep_cluster_size'; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW TABLE STATUS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW TABLES; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW TRIGGERS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; + +--error 0 +SHOW WARNINGS; + SET GLOBAL DEBUG = ""; SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; -DROP DATABASE db1; --disable_query_log --eval SET GLOBAL wsrep_provider_options = "$wsrep_provider_options_orig" + +SET SESSION wsrep_sync_wait = 15; +DROP TABLE q; From f81d9ef108b147209403cfe1be54a6f8176aacfe Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 13 Mar 2017 22:45:42 +0100 Subject: [PATCH 026/101] MW-86 Removed unnecessary wsrep_sync_wait before processing SQLCOM_REPLACE Sync waiting before processing SQLCOM_REPLACE was not necessary given that this case falls through to processing of SQLCOM_INSERT. In case of SQLCOM_REPLACE, wsrep_sync_wait would be called twice. --- sql/sql_parse.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c82ae8f0f5c..c487835c84e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3697,7 +3697,6 @@ end_with_restore_list: break; } case SQLCOM_REPLACE: - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); #ifndef DBUG_OFF if (mysql_bin_log.is_open()) { From a7f010a34362d751bac2b26c28836eeae1fc4f1c Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 14 Mar 2017 12:41:22 -0700 Subject: [PATCH 027/101] Galera MTR Tests: Test case for GAL-501 Improved URI parsing for IPv6 addresses --- .../suite/galera_3nodes/r/GAL-501.result | 14 +++++++ mysql-test/suite/galera_3nodes/t/GAL-501.cnf | 26 +++++++++++++ mysql-test/suite/galera_3nodes/t/GAL-501.test | 38 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 mysql-test/suite/galera_3nodes/r/GAL-501.result create mode 100644 mysql-test/suite/galera_3nodes/t/GAL-501.cnf create mode 100644 mysql-test/suite/galera_3nodes/t/GAL-501.test diff --git a/mysql-test/suite/galera_3nodes/r/GAL-501.result b/mysql-test/suite/galera_3nodes/r/GAL-501.result new file mode 100644 index 00000000000..a2bf5f4d98c --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/GAL-501.result @@ -0,0 +1,14 @@ +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +VARIABLE_VALUE LIKE '%[::1]%' +1 +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 3 +1 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/t/GAL-501.cnf b/mysql-test/suite/galera_3nodes/t/GAL-501.cnf new file mode 100644 index 00000000000..7002cb5bdfd --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/GAL-501.cnf @@ -0,0 +1,26 @@ +!include ../galera_3nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + + +[mysqld.1] +wsrep-cluster-address=gcomm:// +wsrep_node_address=[::1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.1.#galera_port;ist.recv_addr=[::1]' +wsrep_sst_receive_address='[::1]:@mysqld.1.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.1.port' + +[mysqld.2] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_node_address=[::1] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.2.#galera_port;ist.recv_addr=[::1]' +wsrep_sst_receive_address='[::1]:@mysqld.2.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.2.port' + +[mysqld.3] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_node_address=[::1] +wsrep_provider_options='base_port=@mysqld.3.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.3.#galera_port;ist.recv_addr=[::1]' +wsrep_sst_receive_address='[::1]:@mysqld.3.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.3.port' diff --git a/mysql-test/suite/galera_3nodes/t/GAL-501.test b/mysql-test/suite/galera_3nodes/t/GAL-501.test new file mode 100644 index 00000000000..60ed5989227 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/GAL-501.test @@ -0,0 +1,38 @@ +# +# Test GAL-501 Improved URI parsing for IPv6 addresses +# The .cnf file contains +# wsrep_node_address=[::1] +# ist.recv_addr=[::1] + +--source include/galera_cluster.inc +--source include/have_ipv6.inc + +# Confirm that initial handshake happened over ipv6 + +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# Force IST + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; + +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; From ea197c0f7d44a2e5cccb1543212787f33cc16776 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 24 Mar 2017 02:15:01 -0700 Subject: [PATCH 028/101] Galera MTR Tests: Stability fixes --- mysql-test/suite/galera/disabled.def | 4 ---- mysql-test/suite/galera/r/MW-329.result | 1 + .../suite/galera/r/galera_as_slave_autoinc.result | 4 +--- .../suite/galera/r/galera_ist_restart_joiner.result | 5 ++--- mysql-test/suite/galera/r/mysql-wsrep#198.result | 3 +++ mysql-test/suite/galera/t/MW-329.test | 3 +++ .../suite/galera/t/galera_as_slave_autoinc.test | 2 +- mysql-test/suite/galera/t/galera_gcs_fc_limit.test | 6 +++--- .../suite/galera/t/galera_ist_restart_joiner.test | 11 ++++++----- mysql-test/suite/galera/t/mysql-wsrep#198.test | 3 +++ 10 files changed, 23 insertions(+), 19 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index d96eb005eed..59f1ec37986 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -36,13 +36,9 @@ GAL-480 : Investigate galera_fk_no_pk :Investigate galera_account_management : Investigate galera.galera_var_retry_autocommit : MDEV-12319 #Sparodic Faliure -galera.galera_gcs_fc_limit : MDEV-12319 #Sparodic Faliure galera.galera_toi_ddl_nonconflicting : MDEV-12319 #Sparodic Faliure -galera.mysql-wsrep#198 : MDEV-12319 #Sparodic Faliure galera.galera_pc_ignore_sb : MDEV-12319 #Sparodic Faliure -galera.MW-329 : MDEV-12319 #Sparodic Faliure galera.galera_ist_recv_bind : MDEV-12319 #Failed to start mysqld -galera.galera_ist_restart_joiner : MDEV-12319 #Failed to start mysqld galera.galera_ssl_compression : MDEV-12319 #Failed to start mysqld galera.galera_wan : MDEV-12319 #Failed to start mysqld galera.rpl_row_annotate : MDEV-12319 #Failed to start mysqld diff --git a/mysql-test/suite/galera/r/MW-329.result b/mysql-test/suite/galera/r/MW-329.result index 655d8e9e291..a79ba598d69 100644 --- a/mysql-test/suite/galera/r/MW-329.result +++ b/mysql-test/suite/galera/r/MW-329.result @@ -18,3 +18,4 @@ VARIABLE_VALUE > 0 1 DROP PROCEDURE proc_insert; DROP TABLE t1; +CALL mtr.add_suppression("conflict state 3 after post commit"); diff --git a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result index b6314b862c2..3c5319a6126 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result +++ b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result @@ -35,11 +35,9 @@ i c show variables like 'binlog_format'; Variable_name Value binlog_format STATEMENT -show variables like '%auto_increment%'; +show variables like 'auto_increment_increment'; Variable_name Value auto_increment_increment 7 -auto_increment_offset 5 -wsrep_auto_increment_control ON select * from t1; i c 1 dummy_text diff --git a/mysql-test/suite/galera/r/galera_ist_restart_joiner.result b/mysql-test/suite/galera/r/galera_ist_restart_joiner.result index f7a1386e7f8..298105213ea 100644 --- a/mysql-test/suite/galera/r/galera_ist_restart_joiner.result +++ b/mysql-test/suite/galera/r/galera_ist_restart_joiner.result @@ -7,9 +7,8 @@ UPDATE t1 SET f2 = 'c' WHERE f1 > 2; SET GLOBAL wsrep_provider_options = 'dbug=d,recv_IST_after_apply_trx'; SET SESSION wsrep_sync_wait = 0; Loading wsrep_provider ... -SHOW STATUS LIKE 'wsrep_debug_sync_waiters'; -Variable_name Value -wsrep_debug_sync_waiters recv_IST_after_apply_trx +SET SESSION wsrep_on=OFF; +SET SESSION wsrep_on=ON; UPDATE t1 SET f2 = 'd' WHERE f1 > 3; CREATE TABLE t2 (f1 INTEGER); UPDATE t1 SET f2 = 'e' WHERE f1 > 4; diff --git a/mysql-test/suite/galera/r/mysql-wsrep#198.result b/mysql-test/suite/galera/r/mysql-wsrep#198.result index 25ba2cb615c..a278c492372 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#198.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#198.result @@ -1,5 +1,8 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; +SELECT 1 FROM DUAL; +1 +1 LOCK TABLE t2 WRITE; OPTIMIZE TABLE t1,t2;; REPAIR TABLE t1,t2;; diff --git a/mysql-test/suite/galera/t/MW-329.test b/mysql-test/suite/galera/t/MW-329.test index acf6763b396..d9f9a787442 100644 --- a/mysql-test/suite/galera/t/MW-329.test +++ b/mysql-test/suite/galera/t/MW-329.test @@ -80,3 +80,6 @@ SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --connection node_1 DROP PROCEDURE proc_insert; DROP TABLE t1; + +# Due to MW-330, Multiple "conflict state 3 after post commit" warnings if table is dropped while SP is running +CALL mtr.add_suppression("conflict state 3 after post commit"); diff --git a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test index 9292badc480..59483d0591c 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test +++ b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test @@ -48,7 +48,7 @@ insert into t1(i) values(null), (null), (null); select * from t1; show variables like 'binlog_format'; -show variables like '%auto_increment%'; +show variables like 'auto_increment_increment'; --connection node_2 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; diff --git a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test index dc65a452d7c..61576a39316 100644 --- a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test +++ b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test @@ -21,11 +21,11 @@ LOCK TABLE t1 WRITE; --connection node_1 --sleep 1 INSERT INTO t1 VALUES (2); ---sleep 1 +--sleep 2 INSERT INTO t1 VALUES (3); ---sleep 1 +--sleep 2 INSERT INTO t1 VALUES (4); ---sleep 1 +--sleep 2 # This query will hang because flow control will kick in --send diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test index 931daaad30d..f43a347f5bb 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -48,15 +48,16 @@ SET SESSION wsrep_sync_wait = 0; # ... and restart provider to force IST --echo Loading wsrep_provider ... --disable_query_log +# base_port setting is lost for some reason when unloading provider, so we need to restore it +--eval SET GLOBAL wsrep_provider_options= 'base_port=$NODE_GALERAPORT_2'; --eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig'; --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; --enable_query_log -# We can not use a wait_condition on SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS as such queries are blocked during IST -# so we perform a simple sleep and SHOW instead - ---sleep 5 -SHOW STATUS LIKE 'wsrep_debug_sync_waiters'; +SET SESSION wsrep_on=OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = '' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters'; +--source include/wait_condition.inc +SET SESSION wsrep_on=ON; --connection node_1 # Perform DML and DDL while IST is in progress diff --git a/mysql-test/suite/galera/t/mysql-wsrep#198.test b/mysql-test/suite/galera/t/mysql-wsrep#198.test index 2b05c4ff4d9..a80d030a8b0 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#198.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#198.test @@ -5,6 +5,9 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; --connection node_2 +# Ensure that the tables have been created on node #2 +SELECT 1 FROM DUAL; + LOCK TABLE t2 WRITE; --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 From 7f66fcc3fc26cb126ca15df1f82cc9c5dc71bf72 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 27 Mar 2017 02:22:18 -0700 Subject: [PATCH 029/101] Galera MTR Tests: Fortify galera_ist_restart_joiner.test - remove DDLs, fix sync point handling --- .../galera/r/galera_ist_restart_joiner.result | 12 +--------- .../galera/t/galera_ist_restart_joiner.test | 23 ++++++------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_ist_restart_joiner.result b/mysql-test/suite/galera/r/galera_ist_restart_joiner.result index 298105213ea..ca6848fb925 100644 --- a/mysql-test/suite/galera/r/galera_ist_restart_joiner.result +++ b/mysql-test/suite/galera/r/galera_ist_restart_joiner.result @@ -4,15 +4,11 @@ Unloading wsrep provider ... SET GLOBAL wsrep_provider = 'none'; UPDATE t1 SET f2 = 'b' WHERE f1 > 1; UPDATE t1 SET f2 = 'c' WHERE f1 > 2; -SET GLOBAL wsrep_provider_options = 'dbug=d,recv_IST_after_apply_trx'; -SET SESSION wsrep_sync_wait = 0; Loading wsrep_provider ... SET SESSION wsrep_on=OFF; SET SESSION wsrep_on=ON; UPDATE t1 SET f2 = 'd' WHERE f1 > 3; -CREATE TABLE t2 (f1 INTEGER); UPDATE t1 SET f2 = 'e' WHERE f1 > 4; -CREATE TABLE t3 (f1 INTEGER); Performing --wsrep-recover ... Starting server ... Using --wsrep-start-position when starting mysqld ... @@ -33,10 +29,4 @@ f1 f2 4 d 5 e 6 f -SELECT COUNT(*) = 0 FROM t2; -COUNT(*) = 0 -1 -SELECT COUNT(*) = 0 FROM t3; -COUNT(*) = 0 -1 -DROP TABLE t1, t2, t3; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test index f43a347f5bb..e007e71f1ee 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -31,13 +31,6 @@ UPDATE t1 SET f2 = 'b' WHERE f1 > 1; UPDATE t1 SET f2 = 'c' WHERE f1 > 2; --connection node_2 -# Make sure IST will block ... ---let $galera_sync_point = recv_IST_after_apply_trx ---source include/galera_set_sync_point.inc - -SET SESSION wsrep_sync_wait = 0; - - # Write file to make mysql-test-run.pl expect the crash, but don't start it --let $_server_id= `SELECT @@server_id` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect @@ -51,19 +44,20 @@ SET SESSION wsrep_sync_wait = 0; # base_port setting is lost for some reason when unloading provider, so we need to restore it --eval SET GLOBAL wsrep_provider_options= 'base_port=$NODE_GALERAPORT_2'; --eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig'; +# Make sure IST will block ... +--let $galera_sync_point = recv_IST_after_apply_trx +--source include/galera_set_sync_point.inc --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; --enable_query_log SET SESSION wsrep_on=OFF; ---let $wait_condition = SELECT VARIABLE_VALUE = '' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters'; +--let $wait_condition = SELECT VARIABLE_VALUE = 'recv_IST_after_apply_trx' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters'; --source include/wait_condition.inc SET SESSION wsrep_on=ON; --connection node_1 -# Perform DML and DDL while IST is in progress ---connection node_1 +# Perform DML while IST is in progress UPDATE t1 SET f2 = 'd' WHERE f1 > 3; -CREATE TABLE t2 (f1 INTEGER); # Kill node #2 while IST is in progress --connection node_2 @@ -86,9 +80,8 @@ EOF --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' --source include/wait_condition.inc -# Perform DML and DDL while node #2 is down +# Perform DML while node #2 is down UPDATE t1 SET f2 = 'e' WHERE f1 > 4; -CREATE TABLE t3 (f1 INTEGER); --connection node_2 @@ -107,11 +100,9 @@ SELECT * FROM t1; --connection node_2 SELECT * FROM t1; -SELECT COUNT(*) = 0 FROM t2; -SELECT COUNT(*) = 0 FROM t3; --connection node_1 -DROP TABLE t1, t2, t3; +DROP TABLE t1; # Restore original auto_increment_offset values. --source include/auto_increment_offset_restore.inc From 20c21152dbdc1912d592cccd97e95f10fafe5f58 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 5 Apr 2017 10:51:42 +0300 Subject: [PATCH 030/101] Refs: MW-369 * added MTR test, which causes a crash in slave applying, due to FK constraint violation * mtr test is not deterministic, but can surface the crash, at least in my laptop --- mysql-test/suite/galera/t/MW-369.test | 82 +++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 mysql-test/suite/galera/t/MW-369.test diff --git a/mysql-test/suite/galera/t/MW-369.test b/mysql-test/suite/galera/t/MW-369.test new file mode 100644 index 00000000000..d27df96dadb --- /dev/null +++ b/mysql-test/suite/galera/t/MW-369.test @@ -0,0 +1,82 @@ +# +# This test tests the operation of transaction replay for a transaction which operates on FK parent table. +# If a potentially conflicting remote transaction arrives at just the right time during the commit of a +# local transaction, the local transaction will be aborted and replayed. +# The replaying should be possible and honor the FK constraints. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +--let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` + +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, + CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; + +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); + +--connection node_1 +SET AUTOCOMMIT=ON; +START TRANSACTION; + +DELETE FROM p WHERE f1 = 1; +SELECT * FROM p WHERE f1 = 2 FOR UPDATE; + +# Block the commit +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--let $galera_sync_point = commit_monitor_enter_sync +--source include/galera_set_sync_point.inc + +# +# insert client row, which will make it impossible to replay the delete on parent +# +--connection node_2 +INSERT INTO c values (1,1); + +--connection node_1 +--send COMMIT; + +# Wait until commit is blocked +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--source include/galera_wait_sync_point.inc + +# +# send conflicting delete which will make node1 trx to abort and replay +# +--connection node_2 +DELETE FROM p WHERE f1=2; + +# Wait for both transactions to be blocked +--connection node_1a +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'System lock'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT'; +--source include/wait_condition.inc + +# Unblock the commit +--connection node_1a +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc + +# Commit succeeds +--connection node_1 +--reap + +# wsrep_local_replays has increased by 1 +--let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` +--disable_query_log +--eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays; +--enable_query_log + +--connection node_2 +SELECT COUNT(*) = 2 FROM p; +SELECT COUNT(*) = 1 FROM c; + +DROP TABLE c; +DROP TABLE p; From cc3bee92b68b7cd39dd157938e13b8bf495043e0 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 5 Apr 2017 12:08:06 +0300 Subject: [PATCH 031/101] Refs: MW-369 * changed insert for a FK child table to take exclusive lock on FK parent table --- storage/innobase/row/row0ins.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 07a3b192a14..b8a94af63ac 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -1640,7 +1640,7 @@ run_again: foreign, rec, check_index, - check_ref, TRUE); + check_ref, FALSE); #endif /* WITH_WSREP */ goto end_scan; } else if (foreign->type != 0) { From 41fac0a54c3250cc7e8da8b2a21d4d03f425c49d Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 5 Apr 2017 12:08:06 +0300 Subject: [PATCH 032/101] Refs: MW-369 * changed insert for a FK child table to take exclusive lock on FK parent table --- storage/xtradb/row/row0ins.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index 2d6b57221bd..ac59d78596b 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -1652,7 +1652,7 @@ run_again: foreign, rec, check_index, - check_ref, TRUE); + check_ref, FALSE); #endif /* WITH_WSREP */ goto end_scan; } else if (foreign->type != 0) { From 7c07f456a1316854f2e346cbdb5748c18a12dbd0 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 6 Apr 2017 09:23:30 +0300 Subject: [PATCH 033/101] MW-369 MTR tests for foreign key conflicts Tests MW-369C, MW-369D haven't been recorded yet since the outcome from the tests is not what is desired. --- mysql-test/suite/galera/r/MW-369A.result | 30 +++++++++++ mysql-test/suite/galera/r/MW-369B.result | 31 +++++++++++ mysql-test/suite/galera/t/MW-369.inc | 67 ++++++++++++++++++++++++ mysql-test/suite/galera/t/MW-369A.test | 50 ++++++++++++++++++ mysql-test/suite/galera/t/MW-369B.test | 48 +++++++++++++++++ mysql-test/suite/galera/t/MW-369C.test | 49 +++++++++++++++++ mysql-test/suite/galera/t/MW-369D.test | 48 +++++++++++++++++ 7 files changed, 323 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-369A.result create mode 100644 mysql-test/suite/galera/r/MW-369B.result create mode 100644 mysql-test/suite/galera/t/MW-369.inc create mode 100644 mysql-test/suite/galera/t/MW-369A.test create mode 100644 mysql-test/suite/galera/t/MW-369B.test create mode 100644 mysql-test/suite/galera/t/MW-369C.test create mode 100644 mysql-test/suite/galera/t/MW-369D.test diff --git a/mysql-test/suite/galera/r/MW-369A.result b/mysql-test/suite/galera/r/MW-369A.result new file mode 100644 index 00000000000..9e8ed8fc100 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-369A.result @@ -0,0 +1,30 @@ +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, +CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +SET AUTOCOMMIT=ON; +START TRANSACTION; +DELETE FROM p WHERE f1 = 1; +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +INSERT INTO c VALUES (1, 1); +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; +COMMIT; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SELECT * FROM p; +f1 f2 +1 0 +2 0 +SELECT * FROM c; +f1 p_id +1 1 +DROP TABLE c; +DROP TABLE p; diff --git a/mysql-test/suite/galera/r/MW-369B.result b/mysql-test/suite/galera/r/MW-369B.result new file mode 100644 index 00000000000..b8916a5fc4e --- /dev/null +++ b/mysql-test/suite/galera/r/MW-369B.result @@ -0,0 +1,31 @@ +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, +f2 INTEGER, +CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1, 0); +SET AUTOCOMMIT=ON; +START TRANSACTION; +UPDATE p SET f2 = 1 WHERE f1 = 1; +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +UPDATE c SET f2 = 1 WHERE f1 = 1; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; +COMMIT; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; +SELECT * FROM p; +f1 f2 +1 1 +2 0 +SELECT * FROM c; +f1 p_id f2 +1 1 1 +DROP TABLE c; +DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369.inc b/mysql-test/suite/galera/t/MW-369.inc new file mode 100644 index 00000000000..ed750de93e4 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-369.inc @@ -0,0 +1,67 @@ +# +# This file should be included from tests for MW-369 to run concurrent +# transaction from node_1 with autocommit query from node_2. +# +# The parameters: +# * $mw_369_parent_query - the parent query to be run inside transaction +# * $mw_369_child_query - the child query +# +# The operations are the following: +# +# node_1: +# START TRANSACTION; +# $mw_369_parent_query +# node_2 +# $mw_369_child_query - will be blocked on node_1 in apply monitor +# node_1: +# COMMIT; - will be blocked on node_1 in local monitor +# +# The $mw_369_child_query is always expected to succeed. The caller is +# responsible for checking if the final COMMIT on connection node_1 +# succeeds. +# + +--connection node_1 +SET AUTOCOMMIT=ON; +START TRANSACTION; + +--eval $mw_369_parent_query + +# +# Block the $mw_369_child_query from node_2 +# +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET SESSION wsrep_sync_wait = 0; +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_set_sync_point.inc + +# +# insert client row, which will make it impossible to replay the +# delete on parent +# +--connection node_2 +--eval $mw_369_child_query + +# +# Wait until $mw_369_child_query from node_2 reaches the sync point and +# block the 'COMMIT' from node_1 before it certifies. +# +--connection node_1a +--source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc +--let $galera_sync_point = local_monitor_enter_sync +--source include/galera_set_sync_point.inc + +--connection node_1 +--send COMMIT + +# +# Wait until both sync points have been reached +# +--connection node_1a +--let $galera_sync_point = apply_monitor_slave_enter_sync local_monitor_enter_sync +--source include/galera_wait_sync_point.inc +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_signal_sync_point.inc +--let $galera_sync_point = local_monitor_enter_sync +--source include/galera_signal_sync_point.inc diff --git a/mysql-test/suite/galera/t/MW-369A.test b/mysql-test/suite/galera/t/MW-369A.test new file mode 100644 index 00000000000..707d3df3b14 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-369A.test @@ -0,0 +1,50 @@ +# +# Test Outline: +# ============ +# +# This test tests the scenario for MW-369 where a new child table +# row referring to parent table row is inserted concurrently from +# another node while the transaction which tries to delete a +# referred row from the parent table is committing. +# +# The p table will originally have rows (1, 0), (2, 0). +# The c table will be empty. +# +# A new row (1, 1) pointing to parent row (1, 0) is inserted from +# connection node_2, the transaction which tries to remove the +# parent row (1, 0) is run from connection node_1. +# +# Expected outcome: +# ================ +# +# The transaction on node_1 will fail. The parent table will contain +# rows (1, 0), (2, 0) and the child table will contain row (1, 1). +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, + CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; + +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); + +--let $mw_369_parent_query = DELETE FROM p WHERE f1 = 1 +--let $mw_369_child_query = INSERT INTO c VALUES (1, 1) +--source MW-369.inc + +# Commit fails +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +--connection node_2 +SELECT * FROM p; +SELECT * FROM c; + +DROP TABLE c; +DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369B.test b/mysql-test/suite/galera/t/MW-369B.test new file mode 100644 index 00000000000..98de9aa9c43 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-369B.test @@ -0,0 +1,48 @@ +# +# Test Outline: +# ============ +# +# This test tests the scenario for MW-369 where a existing +# child table row is updated concurrently from another node +# with a transaction which updates the parent table. +# +# The p table will originally have rows (1, 0), (2, 0). +# The c table will originally have rows (1, 1, 0) which points +# to parent table row (1, 0). +# +# Expected outcome: +# ================ +# +# Both updates should succeed since they are done to separate tables and +# rows. The parent table will contain rows (1, 1), (2, 0). The child +# table will contain row (1, 1, 1). +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, + f2 INTEGER, + CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; + +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1, 0); + +--let mw_369_parent_query = UPDATE p SET f2 = 1 WHERE f1 = 1 +--let $mw_369_child_query = UPDATE c SET f2 = 1 WHERE f1 = 1 +--source MW-369.inc + +# Commit succeeds +--connection node_1 +--reap + +--connection node_2 +SELECT * FROM p; +SELECT * FROM c; + +DROP TABLE c; +DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369C.test b/mysql-test/suite/galera/t/MW-369C.test new file mode 100644 index 00000000000..903eda6bf7d --- /dev/null +++ b/mysql-test/suite/galera/t/MW-369C.test @@ -0,0 +1,49 @@ +# +# Test Outline: +# ============ +# +# This test tests the scenario for MW-369 where a child table row is +# deleted concurrently from the other node while a transaction updates +# the parent table referred by the child table row. +# +# The p table will originally have rows (1, 0), (2, 0) +# The c table will originally have row (1, 1) which points to parent +# table row (1, 0). +# +# A row (1, 1) pointing to parent row (1, 0) is deleted from +# connection node_2, the transaction which tries to update the +# parent row (1, 0) is run from connection node_1. +# +# Expected Outcome: +# ================ +# Both operations on node_1 and node_2 should succeed without conflicts. +# The parent table should contain values (1, 1), (2, 0) and the child +# table should be empty. + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, + CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; + +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1); + +--let $mw_369_parent_query = UPDATE p SET f2 = 1 WHERE f1 = 1 +--let $mw_369_child_query = DELETE FROM c WHERE f1 = 1 +--source MW-369.inc + +# Commit succeeds +--connection node_1 +--reap + +--connection node_2 +SELECT * FROM p; +SELECT * FROM c; + +DROP TABLE c; +DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369D.test b/mysql-test/suite/galera/t/MW-369D.test new file mode 100644 index 00000000000..6b86da1da6a --- /dev/null +++ b/mysql-test/suite/galera/t/MW-369D.test @@ -0,0 +1,48 @@ +# +# Test Outline: +# ============ +# +# This test tests the scenario for MW-369 where a child table row is +# inserted concurrently from the other node while a transaction updates +# the parent table referred by the newly inserted child table row. +# +# The p table will originally have rows (1, 0), (2, 0). +# The c table will originally be empty. +# +# A row (1, 1) pointing to parent row (1, 0) is inserted from +# connection node_2, the transaction which tries to update the +# parent row (1, 0) is run from connection node_1. +# +# Expected Outcome: +# ================ +# Both operations on node_1 and node_2 should succeed without conflicts. +# The parent table should contain values (1, 1), (2, 0) and the child +# table should contain a row (1, 1) +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, + CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; + +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); + +--let $mw_369_parent_query = UPDATE p SET f2 = 1 WHERE f1 = 1 +--let $mw_369_child_query = INSERT INTO c VALUES (1, 1) +--source MW-369.inc + +# Commit succeeds +--connection node_1 +--reap + +--connection node_2 +SELECT * FROM p; +SELECT * FROM c; + +DROP TABLE c; +DROP TABLE p; From 396770fb6772b8ad7d543ec23a5e414a11bc35ed Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 7 Apr 2017 00:18:30 +0300 Subject: [PATCH 034/101] Refs: MW-369 * changed parent row key type to S(hared), when FK child table is being updated or deleted --- storage/innobase/row/row0ins.cc | 15 ++++++++++----- storage/xtradb/row/row0ins.cc | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index b8a94af63ac..0c1755e538d 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -930,7 +930,7 @@ row_ins_invalidate_query_cache( mem_free(buf); } #ifdef WITH_WSREP -dberr_t wsrep_append_foreign_key(trx_t *trx, +dberr_t wsrep_append_foreign_key(trx_t *trx, dict_foreign_t* foreign, const rec_t* clust_rec, dict_index_t* clust_index, @@ -1294,7 +1294,8 @@ row_ins_foreign_check_on_constraint( foreign, clust_rec, clust_index, - FALSE, FALSE); + FALSE, + (node) ? TRUE : FALSE); if (err != DB_SUCCESS) { fprintf(stderr, "WSREP: foreign key append failed: %d\n", err); @@ -1455,6 +1456,9 @@ row_ins_check_foreign_constraint( ulint* offsets = offsets_; rec_offs_init(offsets_); +#ifdef WITH_WSREP + upd_node= NULL; +#endif /* WITH_WSREP */ run_again: #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_SHARED)); @@ -1638,9 +1642,10 @@ run_again: err = wsrep_append_foreign_key( thr_get_trx(thr), foreign, - rec, - check_index, - check_ref, FALSE); + rec, + check_index, + check_ref, + (upd_node) ? TRUE : FALSE); #endif /* WITH_WSREP */ goto end_scan; } else if (foreign->type != 0) { diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index ac59d78596b..ce7f7d7a94b 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -936,7 +936,7 @@ row_ins_invalidate_query_cache( mem_free(buf); } #ifdef WITH_WSREP -dberr_t wsrep_append_foreign_key(trx_t *trx, +dberr_t wsrep_append_foreign_key(trx_t *trx, dict_foreign_t* foreign, const rec_t* clust_rec, dict_index_t* clust_index, @@ -1300,7 +1300,8 @@ row_ins_foreign_check_on_constraint( foreign, clust_rec, clust_index, - FALSE, FALSE); + FALSE, + (node) ? TRUE : FALSE); if (err != DB_SUCCESS) { fprintf(stderr, "WSREP: foreign key append failed: %d\n", err); @@ -1461,6 +1462,9 @@ row_ins_check_foreign_constraint( ulint* offsets = offsets_; rec_offs_init(offsets_); +#ifdef WITH_WSREP + upd_node= NULL; +#endif /* WITH_WSREP */ run_again: #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_SHARED)); @@ -1650,9 +1654,10 @@ run_again: err = wsrep_append_foreign_key( thr_get_trx(thr), foreign, - rec, - check_index, - check_ref, FALSE); + rec, + check_index, + check_ref, + (upd_node) ? TRUE : FALSE); #endif /* WITH_WSREP */ goto end_scan; } else if (foreign->type != 0) { From 0d5c605b60f8fa6eea77c78ce02d7aec056f95d0 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Mon, 10 Apr 2017 13:09:20 +0300 Subject: [PATCH 035/101] MW-369 Fixed test MW-369D, recorded MW-369C, MW-369D --- mysql-test/suite/galera/r/MW-369A.result | 1 + mysql-test/suite/galera/r/MW-369B.result | 1 + mysql-test/suite/galera/r/MW-369C.result | 30 +++++++++++++++++++++++ mysql-test/suite/galera/r/MW-369D.result | 31 ++++++++++++++++++++++++ mysql-test/suite/galera/t/MW-369.inc | 1 + mysql-test/suite/galera/t/MW-369C.test | 2 ++ mysql-test/suite/galera/t/MW-369D.test | 8 +++--- 7 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/galera/r/MW-369C.result create mode 100644 mysql-test/suite/galera/r/MW-369D.result diff --git a/mysql-test/suite/galera/r/MW-369A.result b/mysql-test/suite/galera/r/MW-369A.result index 9e8ed8fc100..50215a1f2a8 100644 --- a/mysql-test/suite/galera/r/MW-369A.result +++ b/mysql-test/suite/galera/r/MW-369A.result @@ -16,6 +16,7 @@ SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; COMMIT; SET SESSION wsrep_on = 0; SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction diff --git a/mysql-test/suite/galera/r/MW-369B.result b/mysql-test/suite/galera/r/MW-369B.result index b8916a5fc4e..c368f00ec90 100644 --- a/mysql-test/suite/galera/r/MW-369B.result +++ b/mysql-test/suite/galera/r/MW-369B.result @@ -18,6 +18,7 @@ SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; COMMIT; SET SESSION wsrep_on = 0; SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; SELECT * FROM p; diff --git a/mysql-test/suite/galera/r/MW-369C.result b/mysql-test/suite/galera/r/MW-369C.result new file mode 100644 index 00000000000..56656ad75f0 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-369C.result @@ -0,0 +1,30 @@ +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, +CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1); +SET AUTOCOMMIT=ON; +START TRANSACTION; +UPDATE p SET f2 = 1 WHERE f1 = 1; +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +DELETE FROM c WHERE f1 = 1; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; +COMMIT; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; +SELECT * FROM p; +f1 f2 +1 1 +2 0 +SELECT * FROM c; +f1 p_id +DROP TABLE c; +DROP TABLE p; diff --git a/mysql-test/suite/galera/r/MW-369D.result b/mysql-test/suite/galera/r/MW-369D.result new file mode 100644 index 00000000000..2ab5b5ac262 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-369D.result @@ -0,0 +1,31 @@ +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, +CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +SET AUTOCOMMIT=ON; +START TRANSACTION; +UPDATE p SET f2 = 1 WHERE f1 = 1; +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +INSERT INTO c VALUES (1, 1); +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; +COMMIT; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SELECT * FROM p; +f1 f2 +1 0 +2 0 +SELECT * FROM c; +f1 p_id +1 1 +DROP TABLE c; +DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369.inc b/mysql-test/suite/galera/t/MW-369.inc index ed750de93e4..fdc26823cca 100644 --- a/mysql-test/suite/galera/t/MW-369.inc +++ b/mysql-test/suite/galera/t/MW-369.inc @@ -61,6 +61,7 @@ SET SESSION wsrep_sync_wait = 0; --connection node_1a --let $galera_sync_point = apply_monitor_slave_enter_sync local_monitor_enter_sync --source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc --let $galera_sync_point = apply_monitor_slave_enter_sync --source include/galera_signal_sync_point.inc --let $galera_sync_point = local_monitor_enter_sync diff --git a/mysql-test/suite/galera/t/MW-369C.test b/mysql-test/suite/galera/t/MW-369C.test index 903eda6bf7d..d4b1a08df84 100644 --- a/mysql-test/suite/galera/t/MW-369C.test +++ b/mysql-test/suite/galera/t/MW-369C.test @@ -16,9 +16,11 @@ # # Expected Outcome: # ================ +# # Both operations on node_1 and node_2 should succeed without conflicts. # The parent table should contain values (1, 1), (2, 0) and the child # table should be empty. +# --source include/galera_cluster.inc --source include/have_innodb.inc diff --git a/mysql-test/suite/galera/t/MW-369D.test b/mysql-test/suite/galera/t/MW-369D.test index 6b86da1da6a..db2bfcd09c0 100644 --- a/mysql-test/suite/galera/t/MW-369D.test +++ b/mysql-test/suite/galera/t/MW-369D.test @@ -15,9 +15,10 @@ # # Expected Outcome: # ================ -# Both operations on node_1 and node_2 should succeed without conflicts. -# The parent table should contain values (1, 1), (2, 0) and the child -# table should contain a row (1, 1) +# +# The parent operation on connection node_1 will conflict with an insert +# to node_2. The parent table will contain rows (1, 0), (2, 0) and +# the child table will contain row (1, 1). # --source include/galera_cluster.inc @@ -38,6 +39,7 @@ INSERT INTO p VALUES (2, 0); # Commit succeeds --connection node_1 +--error ER_LOCK_DEADLOCK --reap --connection node_2 From 7a1a5e473e5e53de3b45286c2684bdca6dae03fd Mon Sep 17 00:00:00 2001 From: sjaakola Date: Sat, 15 Apr 2017 02:20:36 +0300 Subject: [PATCH 036/101] Refs: MW-369 * fixed sync point usage in MW-369.inc, which made it impossible to run this test with --repeat option * moved all MW-369*.test tests into MW-369.test file, each as one separate test phase * added two more test phases, in MW-369.test file * tests MW-369A, MW-369B and MW-369C are obsolete after this commit --- mysql-test/suite/galera/r/MW-369.result | 155 ++++++++++++++ mysql-test/suite/galera/t/MW-369.inc | 11 +- mysql-test/suite/galera/t/MW-369.test | 262 +++++++++++++++++++----- 3 files changed, 377 insertions(+), 51 deletions(-) create mode 100644 mysql-test/suite/galera/r/MW-369.result diff --git a/mysql-test/suite/galera/r/MW-369.result b/mysql-test/suite/galera/r/MW-369.result new file mode 100644 index 00000000000..516904d1b2a --- /dev/null +++ b/mysql-test/suite/galera/r/MW-369.result @@ -0,0 +1,155 @@ +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, +CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +SET AUTOCOMMIT=ON; +START TRANSACTION; +DELETE FROM p WHERE f1 = 1; +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +INSERT INTO c VALUES (1, 1); +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; +COMMIT; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; +SET GLOBAL wsrep_provider_options = 'dbug='; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SELECT * FROM p; +f1 f2 +1 0 +2 0 +SELECT * FROM c; +f1 p_id +1 1 +DROP TABLE c; +DROP TABLE p; +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, +f2 INTEGER, +CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1, 0); +SET AUTOCOMMIT=ON; +START TRANSACTION; +UPDATE p SET f2 = 1 WHERE f1 = 1; +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +UPDATE c SET f2 = 1 WHERE f1 = 1; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; +COMMIT; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; +SET GLOBAL wsrep_provider_options = 'dbug='; +SELECT * FROM p; +f1 f2 +1 1 +2 0 +SELECT * FROM c; +f1 p_id f2 +1 1 1 +DROP TABLE c; +DROP TABLE p; +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, +CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1); +SET AUTOCOMMIT=ON; +START TRANSACTION; +UPDATE p SET f2 = 1 WHERE f1 = 1; +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +DELETE FROM c WHERE f1 = 1; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; +COMMIT; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; +SET GLOBAL wsrep_provider_options = 'dbug='; +SELECT * FROM p; +f1 f2 +1 1 +2 0 +SELECT * FROM c; +f1 p_id +DROP TABLE c; +DROP TABLE p; +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER UNIQUE KEY) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, +CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f2)) ; +INSERT INTO p VALUES (1, 0); +SET AUTOCOMMIT=ON; +START TRANSACTION; +UPDATE p SET f2 = 1 WHERE f1 = 1; +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +INSERT INTO c VALUES (1, 0);; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; +COMMIT; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; +SET GLOBAL wsrep_provider_options = 'dbug='; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SELECT * FROM p; +f1 f2 +1 0 +SELECT * FROM c; +f1 p_id +1 0 +DROP TABLE c; +DROP TABLE p; +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, f2 INTEGER, +CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1) +ON DELETE CASCADE) ; +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1, 0); +SET AUTOCOMMIT=ON; +START TRANSACTION; +DELETE FROM p WHERE f1 = 1; +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +UPDATE c SET f2 = 1 WHERE f1 = 1; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; +COMMIT; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; +SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; +SET GLOBAL wsrep_provider_options = 'dbug='; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SELECT * FROM p; +f1 f2 +1 0 +2 0 +SELECT * FROM c; +f1 p_id f2 +1 1 1 +DROP TABLE c; +DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369.inc b/mysql-test/suite/galera/t/MW-369.inc index fdc26823cca..5fd9ef150ae 100644 --- a/mysql-test/suite/galera/t/MW-369.inc +++ b/mysql-test/suite/galera/t/MW-369.inc @@ -30,7 +30,8 @@ START TRANSACTION; # # Block the $mw_369_child_query from node_2 # ---connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +# --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a SET SESSION wsrep_sync_wait = 0; --let $galera_sync_point = apply_monitor_slave_enter_sync --source include/galera_set_sync_point.inc @@ -49,6 +50,7 @@ SET SESSION wsrep_sync_wait = 0; --connection node_1a --source include/galera_wait_sync_point.inc --source include/galera_clear_sync_point.inc + --let $galera_sync_point = local_monitor_enter_sync --source include/galera_set_sync_point.inc @@ -61,8 +63,13 @@ SET SESSION wsrep_sync_wait = 0; --connection node_1a --let $galera_sync_point = apply_monitor_slave_enter_sync local_monitor_enter_sync --source include/galera_wait_sync_point.inc ---source include/galera_clear_sync_point.inc + +# +# both threads are now parked in sync points, signal them to continue +# --let $galera_sync_point = apply_monitor_slave_enter_sync --source include/galera_signal_sync_point.inc + --let $galera_sync_point = local_monitor_enter_sync --source include/galera_signal_sync_point.inc +--source include/galera_clear_sync_point.inc diff --git a/mysql-test/suite/galera/t/MW-369.test b/mysql-test/suite/galera/t/MW-369.test index d27df96dadb..720d6daf518 100644 --- a/mysql-test/suite/galera/t/MW-369.test +++ b/mysql-test/suite/galera/t/MW-369.test @@ -1,8 +1,24 @@ # -# This test tests the operation of transaction replay for a transaction which operates on FK parent table. -# If a potentially conflicting remote transaction arrives at just the right time during the commit of a -# local transaction, the local transaction will be aborted and replayed. -# The replaying should be possible and honor the FK constraints. +# Test A Outline: +# =============== +# +# This test tests the scenario for MW-369 where a new child table +# row referring to parent table row is inserted concurrently from +# another node while the transaction which tries to delete a +# referred row from the parent table is committing. +# +# The p table will originally have rows (1, 0), (2, 0). +# The c table will be empty. +# +# A new row (1, 1) pointing to parent row (1, 0) is inserted from +# connection node_2, the transaction which tries to remove the +# parent row (1, 0) is run from connection node_1. +# +# Expected outcome: +# ================ +# +# The transaction on node_1 will fail. The parent table will contain +# rows (1, 0), (2, 0) and the child table will contain row (1, 1). # --source include/galera_cluster.inc @@ -10,8 +26,6 @@ --source include/have_debug_sync.inc --source suite/galera/include/galera_have_debug_sync.inc ---let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` - CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; @@ -19,64 +33,214 @@ CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, INSERT INTO p VALUES (1, 0); INSERT INTO p VALUES (2, 0); ---connection node_1 -SET AUTOCOMMIT=ON; -START TRANSACTION; +--let $mw_369_parent_query = DELETE FROM p WHERE f1 = 1 +--let $mw_369_child_query = INSERT INTO c VALUES (1, 1) -DELETE FROM p WHERE f1 = 1; -SELECT * FROM p WHERE f1 = 2 FOR UPDATE; - -# Block the commit +# +# we must open connection node_1a here, MW-369.inc will use it later +# --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 ---let $galera_sync_point = commit_monitor_enter_sync ---source include/galera_set_sync_point.inc +--source MW-369.inc + +# Commit fails +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +--connection node_2 +SELECT * FROM p; +SELECT * FROM c; + +DROP TABLE c; +DROP TABLE p; # -# insert client row, which will make it impossible to replay the delete on parent +# Test B Outline: +# =============== +# +# This test tests the scenario for MW-369 where a existing +# child table row is updated concurrently from another node +# with a transaction which updates the parent table. +# +# The p table will originally have rows (1, 0), (2, 0). +# The c table will originally have rows (1, 1, 0) which points +# to parent table row (1, 0). +# +# Expected outcome: +# ================ +# +# Both updates should succeed since they are done to separate tables and +# rows. The parent table will contain rows (1, 1), (2, 0). The child +# table will contain row (1, 1, 1). # ---connection node_2 -INSERT INTO c values (1,1); --connection node_1 ---send COMMIT; +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, + f2 INTEGER, + CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; -# Wait until commit is blocked ---connection node_1a -SET SESSION wsrep_sync_wait = 0; ---source include/galera_wait_sync_point.inc +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1, 0); -# -# send conflicting delete which will make node1 trx to abort and replay -# ---connection node_2 -DELETE FROM p WHERE f1=2; - -# Wait for both transactions to be blocked ---connection node_1a ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'System lock'; ---source include/wait_condition.inc - ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT'; ---source include/wait_condition.inc - -# Unblock the commit ---connection node_1a ---source include/galera_clear_sync_point.inc ---source include/galera_signal_sync_point.inc +--let mw_369_parent_query = UPDATE p SET f2 = 1 WHERE f1 = 1 +--let $mw_369_child_query = UPDATE c SET f2 = 1 WHERE f1 = 1 +--source MW-369.inc # Commit succeeds --connection node_1 --reap -# wsrep_local_replays has increased by 1 ---let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` ---disable_query_log ---eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays; ---enable_query_log - --connection node_2 -SELECT COUNT(*) = 2 FROM p; -SELECT COUNT(*) = 1 FROM c; +SELECT * FROM p; +SELECT * FROM c; DROP TABLE c; DROP TABLE p; + +# +# Test C Outline: +# =============== +# +# This test tests the scenario for MW-369 where a child table row is +# deleted concurrently from the other node while a transaction updates +# the parent table referred by the child table row. +# +# The p table will originally have rows (1, 0), (2, 0) +# The c table will originally have row (1, 1) which points to parent +# table row (1, 0). +# +# A row (1, 1) pointing to parent row (1, 0) is deleted from +# connection node_2, the transaction which tries to update the +# parent row (1, 0) is run from connection node_1. +# +# Expected Outcome: +# ================ +# Both operations on node_1 and node_2 should succeed without conflicts. +# The parent table should contain values (1, 1), (2, 0) and the child +# table should be empty. + +--connection node_1 +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, + CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; + +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1); + +--let $mw_369_parent_query = UPDATE p SET f2 = 1 WHERE f1 = 1 +--let $mw_369_child_query = DELETE FROM c WHERE f1 = 1 +--source MW-369.inc + +# Commit succeeds +--connection node_1 +--reap + +--connection node_2 +SELECT * FROM p; +SELECT * FROM c; + +DROP TABLE c; +DROP TABLE p; + + +# +# Test D Outline: +# =============== +# +# This test is similar to test A, where parent row is deleted while a child row +# is inserted simultaneously on node 2. However, in this test case the FK +# constraint's target column is a unique key, and parent row is not delete, +# but this key value is changed so that insert on node 2 will cause FK +# violation +# +# The p table will originally have rows (1, 0) +# The c table will originally be empty +# +# in node_1, parent row is updated to value (1,1) +# A row (1, 0) pointing to the old version of parent row (1, 0) is inserted +# in connection node_2 +# +# Expected Outcome: +# ================ +# This is a true conflict and one transaciton must abort. In this case it is node_1 +# transaction, which was scheduled later. +# Parent table should have row (1,0) +# child table should have row (1,0) +# + +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER UNIQUE KEY) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, + CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f2)) ; + +INSERT INTO p VALUES (1, 0); + +--let $mw_369_parent_query = UPDATE p SET f2 = 1 WHERE f1 = 1 +--let $mw_369_child_query = INSERT INTO c VALUES (1, 0); +--source MW-369.inc + +# Commit fails +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +--connection node_2 +SELECT * FROM p; +SELECT * FROM c; + +DROP TABLE c; +DROP TABLE p; + +# +# Test E Outline: +# =============== +# +# This test is similar to test B, where parent row is deleted while a child row +# is updated simultaneously on node 2. However, in this test case the FK +# constraint has ON DELETE CASCADE option, and the delete on parent row will +# cascade a delete on child row as well. This will cause true conflict with +# connection node_2, which tries to update unrelated column on child table. +# +# The p table will originally have rows (1, 0), (2,0) +# The c table will originally have row (1,1,0) +# +# in node_1, parent row (1,0) is deleted and cascaded delete will happen on +# child table row (1,1,0). +# in connection node_2 child table row is update to value (1,1,1) +# +# Expected Outcome: +# ================ +# This is a true conflict and one transaciton must abort. In this case it is node_1 +# transaction, which was scheduled later. +# Parent table should have rows (1,0), (2,0) +# child table should have row (1,1,1) +# + + +CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; +CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, f2 INTEGER, + CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1) + ON DELETE CASCADE) ; + +INSERT INTO p VALUES (1, 0); +INSERT INTO p VALUES (2, 0); +INSERT INTO c VALUES (1, 1, 0); + +--let $mw_369_parent_query = DELETE FROM p WHERE f1 = 1 +--let $mw_369_child_query = UPDATE c SET f2 = 1 WHERE f1 = 1 +--source MW-369.inc + +# Commit fails +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +--connection node_2 +SELECT * FROM p; +SELECT * FROM c; + +DROP TABLE c; +DROP TABLE p; + From d43a12bf2f3d1cda2abbf9e7dff788b266e6eac3 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Mon, 8 May 2017 16:23:25 +0300 Subject: [PATCH 037/101] MW-369 Removing obsoleted tests --- mysql-test/suite/galera/r/MW-369A.result | 31 -------------- mysql-test/suite/galera/r/MW-369B.result | 32 --------------- mysql-test/suite/galera/r/MW-369C.result | 30 -------------- mysql-test/suite/galera/r/MW-369D.result | 31 -------------- mysql-test/suite/galera/t/MW-369A.test | 50 ----------------------- mysql-test/suite/galera/t/MW-369B.test | 48 ---------------------- mysql-test/suite/galera/t/MW-369C.test | 51 ------------------------ mysql-test/suite/galera/t/MW-369D.test | 50 ----------------------- 8 files changed, 323 deletions(-) delete mode 100644 mysql-test/suite/galera/r/MW-369A.result delete mode 100644 mysql-test/suite/galera/r/MW-369B.result delete mode 100644 mysql-test/suite/galera/r/MW-369C.result delete mode 100644 mysql-test/suite/galera/r/MW-369D.result delete mode 100644 mysql-test/suite/galera/t/MW-369A.test delete mode 100644 mysql-test/suite/galera/t/MW-369B.test delete mode 100644 mysql-test/suite/galera/t/MW-369C.test delete mode 100644 mysql-test/suite/galera/t/MW-369D.test diff --git a/mysql-test/suite/galera/r/MW-369A.result b/mysql-test/suite/galera/r/MW-369A.result deleted file mode 100644 index 50215a1f2a8..00000000000 --- a/mysql-test/suite/galera/r/MW-369A.result +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; -CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, -CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; -INSERT INTO p VALUES (1, 0); -INSERT INTO p VALUES (2, 0); -SET AUTOCOMMIT=ON; -START TRANSACTION; -DELETE FROM p WHERE f1 = 1; -SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; -INSERT INTO c VALUES (1, 1); -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; -COMMIT; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction -SELECT * FROM p; -f1 f2 -1 0 -2 0 -SELECT * FROM c; -f1 p_id -1 1 -DROP TABLE c; -DROP TABLE p; diff --git a/mysql-test/suite/galera/r/MW-369B.result b/mysql-test/suite/galera/r/MW-369B.result deleted file mode 100644 index c368f00ec90..00000000000 --- a/mysql-test/suite/galera/r/MW-369B.result +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; -CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, -f2 INTEGER, -CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; -INSERT INTO p VALUES (1, 0); -INSERT INTO p VALUES (2, 0); -INSERT INTO c VALUES (1, 1, 0); -SET AUTOCOMMIT=ON; -START TRANSACTION; -UPDATE p SET f2 = 1 WHERE f1 = 1; -SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; -UPDATE c SET f2 = 1 WHERE f1 = 1; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; -COMMIT; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; -SELECT * FROM p; -f1 f2 -1 1 -2 0 -SELECT * FROM c; -f1 p_id f2 -1 1 1 -DROP TABLE c; -DROP TABLE p; diff --git a/mysql-test/suite/galera/r/MW-369C.result b/mysql-test/suite/galera/r/MW-369C.result deleted file mode 100644 index 56656ad75f0..00000000000 --- a/mysql-test/suite/galera/r/MW-369C.result +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; -CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, -CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; -INSERT INTO p VALUES (1, 0); -INSERT INTO p VALUES (2, 0); -INSERT INTO c VALUES (1, 1); -SET AUTOCOMMIT=ON; -START TRANSACTION; -UPDATE p SET f2 = 1 WHERE f1 = 1; -SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; -DELETE FROM c WHERE f1 = 1; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; -COMMIT; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; -SELECT * FROM p; -f1 f2 -1 1 -2 0 -SELECT * FROM c; -f1 p_id -DROP TABLE c; -DROP TABLE p; diff --git a/mysql-test/suite/galera/r/MW-369D.result b/mysql-test/suite/galera/r/MW-369D.result deleted file mode 100644 index 2ab5b5ac262..00000000000 --- a/mysql-test/suite/galera/r/MW-369D.result +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; -CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, -CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; -INSERT INTO p VALUES (1, 0); -INSERT INTO p VALUES (2, 0); -SET AUTOCOMMIT=ON; -START TRANSACTION; -UPDATE p SET f2 = 1 WHERE f1 = 1; -SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; -INSERT INTO c VALUES (1, 1); -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_enter_sync'; -COMMIT; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_enter_sync'; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction -SELECT * FROM p; -f1 f2 -1 0 -2 0 -SELECT * FROM c; -f1 p_id -1 1 -DROP TABLE c; -DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369A.test b/mysql-test/suite/galera/t/MW-369A.test deleted file mode 100644 index 707d3df3b14..00000000000 --- a/mysql-test/suite/galera/t/MW-369A.test +++ /dev/null @@ -1,50 +0,0 @@ -# -# Test Outline: -# ============ -# -# This test tests the scenario for MW-369 where a new child table -# row referring to parent table row is inserted concurrently from -# another node while the transaction which tries to delete a -# referred row from the parent table is committing. -# -# The p table will originally have rows (1, 0), (2, 0). -# The c table will be empty. -# -# A new row (1, 1) pointing to parent row (1, 0) is inserted from -# connection node_2, the transaction which tries to remove the -# parent row (1, 0) is run from connection node_1. -# -# Expected outcome: -# ================ -# -# The transaction on node_1 will fail. The parent table will contain -# rows (1, 0), (2, 0) and the child table will contain row (1, 1). -# - ---source include/galera_cluster.inc ---source include/have_innodb.inc ---source include/have_debug_sync.inc ---source suite/galera/include/galera_have_debug_sync.inc - -CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; -CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, - CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; - -INSERT INTO p VALUES (1, 0); -INSERT INTO p VALUES (2, 0); - ---let $mw_369_parent_query = DELETE FROM p WHERE f1 = 1 ---let $mw_369_child_query = INSERT INTO c VALUES (1, 1) ---source MW-369.inc - -# Commit fails ---connection node_1 ---error ER_LOCK_DEADLOCK ---reap - ---connection node_2 -SELECT * FROM p; -SELECT * FROM c; - -DROP TABLE c; -DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369B.test b/mysql-test/suite/galera/t/MW-369B.test deleted file mode 100644 index 98de9aa9c43..00000000000 --- a/mysql-test/suite/galera/t/MW-369B.test +++ /dev/null @@ -1,48 +0,0 @@ -# -# Test Outline: -# ============ -# -# This test tests the scenario for MW-369 where a existing -# child table row is updated concurrently from another node -# with a transaction which updates the parent table. -# -# The p table will originally have rows (1, 0), (2, 0). -# The c table will originally have rows (1, 1, 0) which points -# to parent table row (1, 0). -# -# Expected outcome: -# ================ -# -# Both updates should succeed since they are done to separate tables and -# rows. The parent table will contain rows (1, 1), (2, 0). The child -# table will contain row (1, 1, 1). -# - ---source include/galera_cluster.inc ---source include/have_innodb.inc ---source include/have_debug_sync.inc ---source suite/galera/include/galera_have_debug_sync.inc - -CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; -CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, - f2 INTEGER, - CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; - -INSERT INTO p VALUES (1, 0); -INSERT INTO p VALUES (2, 0); -INSERT INTO c VALUES (1, 1, 0); - ---let mw_369_parent_query = UPDATE p SET f2 = 1 WHERE f1 = 1 ---let $mw_369_child_query = UPDATE c SET f2 = 1 WHERE f1 = 1 ---source MW-369.inc - -# Commit succeeds ---connection node_1 ---reap - ---connection node_2 -SELECT * FROM p; -SELECT * FROM c; - -DROP TABLE c; -DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369C.test b/mysql-test/suite/galera/t/MW-369C.test deleted file mode 100644 index d4b1a08df84..00000000000 --- a/mysql-test/suite/galera/t/MW-369C.test +++ /dev/null @@ -1,51 +0,0 @@ -# -# Test Outline: -# ============ -# -# This test tests the scenario for MW-369 where a child table row is -# deleted concurrently from the other node while a transaction updates -# the parent table referred by the child table row. -# -# The p table will originally have rows (1, 0), (2, 0) -# The c table will originally have row (1, 1) which points to parent -# table row (1, 0). -# -# A row (1, 1) pointing to parent row (1, 0) is deleted from -# connection node_2, the transaction which tries to update the -# parent row (1, 0) is run from connection node_1. -# -# Expected Outcome: -# ================ -# -# Both operations on node_1 and node_2 should succeed without conflicts. -# The parent table should contain values (1, 1), (2, 0) and the child -# table should be empty. -# - ---source include/galera_cluster.inc ---source include/have_innodb.inc ---source include/have_debug_sync.inc ---source suite/galera/include/galera_have_debug_sync.inc - -CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; -CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, - CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; - -INSERT INTO p VALUES (1, 0); -INSERT INTO p VALUES (2, 0); -INSERT INTO c VALUES (1, 1); - ---let $mw_369_parent_query = UPDATE p SET f2 = 1 WHERE f1 = 1 ---let $mw_369_child_query = DELETE FROM c WHERE f1 = 1 ---source MW-369.inc - -# Commit succeeds ---connection node_1 ---reap - ---connection node_2 -SELECT * FROM p; -SELECT * FROM c; - -DROP TABLE c; -DROP TABLE p; diff --git a/mysql-test/suite/galera/t/MW-369D.test b/mysql-test/suite/galera/t/MW-369D.test deleted file mode 100644 index db2bfcd09c0..00000000000 --- a/mysql-test/suite/galera/t/MW-369D.test +++ /dev/null @@ -1,50 +0,0 @@ -# -# Test Outline: -# ============ -# -# This test tests the scenario for MW-369 where a child table row is -# inserted concurrently from the other node while a transaction updates -# the parent table referred by the newly inserted child table row. -# -# The p table will originally have rows (1, 0), (2, 0). -# The c table will originally be empty. -# -# A row (1, 1) pointing to parent row (1, 0) is inserted from -# connection node_2, the transaction which tries to update the -# parent row (1, 0) is run from connection node_1. -# -# Expected Outcome: -# ================ -# -# The parent operation on connection node_1 will conflict with an insert -# to node_2. The parent table will contain rows (1, 0), (2, 0) and -# the child table will contain row (1, 1). -# - ---source include/galera_cluster.inc ---source include/have_innodb.inc ---source include/have_debug_sync.inc ---source suite/galera/include/galera_have_debug_sync.inc - -CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; -CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, - CONSTRAINT fk_1 FOREIGN KEY (p_id) REFERENCES p (f1)) ; - -INSERT INTO p VALUES (1, 0); -INSERT INTO p VALUES (2, 0); - ---let $mw_369_parent_query = UPDATE p SET f2 = 1 WHERE f1 = 1 ---let $mw_369_child_query = INSERT INTO c VALUES (1, 1) ---source MW-369.inc - -# Commit succeeds ---connection node_1 ---error ER_LOCK_DEADLOCK ---reap - ---connection node_2 -SELECT * FROM p; -SELECT * FROM c; - -DROP TABLE c; -DROP TABLE p; From f3c5928cffcde30d87579ad6ecc0c7d9db74ce09 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 8 May 2017 23:03:01 +0300 Subject: [PATCH 038/101] MW-369 FK fixes Skipping wsrep extra FK checking for applier and replayer threads --- storage/innobase/row/row0upd.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 720a5c049b9..db844597fde 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1979,7 +1979,9 @@ row_upd_sec_index_entry( index, offsets, thr, &mtr); } #ifdef WITH_WSREP - if (err == DB_SUCCESS && !referenced && + if (wsrep_on(trx->mysql_thd) && + !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && + err == DB_SUCCESS && !referenced && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && From 318af3f3b8bb0a0cbf14e4d5cbf760b02dbd8881 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 8 May 2017 23:03:01 +0300 Subject: [PATCH 039/101] MW-369 FK fixes Skipping wsrep extra FK checking for applier and replayer threads --- storage/innobase/row/row0upd.cc | 7 ++++--- storage/xtradb/row/row0upd.cc | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index db844597fde..7326074a57b 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -2267,7 +2267,7 @@ err_exit: } } #ifdef WITH_WSREP - if (!referenced && + if (wsrep_on(trx->mysql_thd) && !referenced && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && foreign @@ -2532,10 +2532,11 @@ row_upd_del_mark_clust_rec( node, pcur, index->table, index, offsets, thr, mtr); } #ifdef WITH_WSREP - if (err == DB_SUCCESS && !referenced && + trx_t* trx = thr_get_trx(thr) ; + + if (err == DB_SUCCESS && !referenced && trx && wsrep_on(trx->mysql_thd) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && - thr_get_trx(thr) && foreign ) { err = wsrep_row_upd_check_foreign_constraints( diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc index 3881fe410ec..74a1acfa5c9 100644 --- a/storage/xtradb/row/row0upd.cc +++ b/storage/xtradb/row/row0upd.cc @@ -1984,7 +1984,9 @@ row_upd_sec_index_entry( index, offsets, thr, &mtr); } #ifdef WITH_WSREP - if (err == DB_SUCCESS && !referenced && + if (wsrep_on(trx->mysql_thd) && + !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && + err == DB_SUCCESS && !referenced && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && @@ -2273,7 +2275,7 @@ err_exit: } } #ifdef WITH_WSREP - if (!referenced && + if (wsrep_on(trx->mysql_thd) && !referenced && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && foreign @@ -2541,10 +2543,11 @@ row_upd_del_mark_clust_rec( node, pcur, index->table, index, offsets, thr, mtr); } #ifdef WITH_WSREP - if (err == DB_SUCCESS && !referenced && + trx_t* trx = thr_get_trx(thr) ; + + if (err == DB_SUCCESS && !referenced && trx && wsrep_on(trx->mysql_thd) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && - thr_get_trx(thr) && foreign ) { err = wsrep_row_upd_check_foreign_constraints( From 7ee47ef456f5b462187e299b7d5af539e107a1e5 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 10 May 2017 15:59:52 +0300 Subject: [PATCH 040/101] MW-378 enabling build with WITH_WSREP=OFF only one fix here, enables build of mysqld however, building embedded server fails in linking phase --- sql/handler.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/handler.cc b/sql/handler.cc index 19f648219ac..6072a828ab6 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1690,6 +1690,11 @@ int ha_rollback_trans(THD *thd, bool all) { // cannot happen my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); error=1; +#ifdef WITH_WSREP + WSREP_WARN("handlerton rollback failed, thd %lu %lld conf %d SQL %s", + thd->thread_id, thd->query_id, thd->wsrep_conflict_state, + thd->query()); +#endif /* WITH_WSREP */ } status_var_increment(thd->status_var.ha_rollback_count); ha_info_next= ha_info->next(); From 224ae5770f82a77274d2046477585ea5a6b8b960 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 22 Feb 2017 10:57:39 +0200 Subject: [PATCH 041/101] Refs: MW-363 * enabling binlog file copying even for binlog files with basename "0" * mtr suite uses binlog files with names: 0.000001, 0.000002.. and so on --- sql/wsrep_sst.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 331185e2cf3..818cb3f28fd 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -364,8 +364,7 @@ static int generate_binlog_opt_val(char** ret) if (opt_bin_log) { assert(opt_bin_logname); - *ret= strcmp(opt_bin_logname, "0") ? - my_strdup(opt_bin_logname, MYF(0)) : my_strdup("", MYF(0)); + *ret= my_strdup(opt_bin_logname, MYF(0)); } else { From dd72d66c452923fb171ab3fc36322589eae25e46 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Mon, 24 Apr 2017 18:39:38 +0300 Subject: [PATCH 042/101] MW-373 Wait for wsrep_ready at startup when provider is loaded Conflicts: mysql-test/include/kill_and_restart_mysqld.inc --- mysql-test/include/restart_mysqld.inc | 3 +++ mysql-test/include/start_mysqld.inc | 3 +++ mysql-test/include/wait_wsrep_ready.inc | 15 +++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 mysql-test/include/wait_wsrep_ready.inc diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc index dcaf47c55a2..c817694e57a 100644 --- a/mysql-test/include/restart_mysqld.inc +++ b/mysql-test/include/restart_mysqld.inc @@ -50,6 +50,9 @@ if (!$restart_parameters) # Call script that will poll the server waiting for it to be back online again --source include/wait_until_connected_again.inc +# Wait for wsrep +--source include/wait_wsrep_ready.inc + # Turn off reconnect again --disable_reconnect diff --git a/mysql-test/include/start_mysqld.inc b/mysql-test/include/start_mysqld.inc index e31f26aad8c..04dff714d49 100644 --- a/mysql-test/include/start_mysqld.inc +++ b/mysql-test/include/start_mysqld.inc @@ -16,6 +16,9 @@ if (!$restart_parameters) # Call script that will poll the server waiting for it to be back online again --source include/wait_until_connected_again.inc +# Wait for wsrep +--source include/wait_wsrep_ready.inc + # Turn off reconnect again --disable_reconnect diff --git a/mysql-test/include/wait_wsrep_ready.inc b/mysql-test/include/wait_wsrep_ready.inc new file mode 100644 index 00000000000..0e666afa33d --- /dev/null +++ b/mysql-test/include/wait_wsrep_ready.inc @@ -0,0 +1,15 @@ +# +# If the wsrep plugin is loaded, wait until the wsrep provider becomes +# ready for use. +# + +--disable_query_log +--disable_result_log + +if (`SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'wsrep' AND PLUGIN_STATUS='ACTIVE'`) +{ + --source include/galera_wait_ready.inc +} + +--enable_query_log +--enable_result_log From b5323054af2375cf5595c7d18fb2f22849f4e844 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Wed, 24 May 2017 14:55:13 +0300 Subject: [PATCH 043/101] MW-383 Bumped wsrep patch version --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index a8b1bea3bbb..1bd1ca51b35 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -18,7 +18,7 @@ # so WSREP_VERSION is produced regardless # Set the patch version -SET(WSREP_PATCH_VERSION "19") +SET(WSREP_PATCH_VERSION "20") # MariaDB addition: Revision number of the last revision merged from # codership branch visible in @@visible_comment. From 5017c261d4b6332ffff70919080a99fd5e459ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 15 Aug 2017 13:57:15 +0300 Subject: [PATCH 044/101] Fix test failure on test MW-86 and remove MW-360 test. Merged from mysql-wsrep-bugs following: GCF-1058 MTR test galera.MW-86 fails on repeated runs Wait for the sync point sync.wsrep_apply_cb to be reached before executing the test and clearing the debug flag sync.wsrep_apply_cb. The race scenario: Intended behavior: node2: set sync.wsrep_apply_cb in order to start waiting in the background INSERT node1: INSERT start node2 (background): INSERT start node1: INSERT end node2: send signal to background INSERT: "stop waiting and continue executing" node2: clear sync.wsrep_apply_cb as no longer needed node2 (background): consume the signal node2 (background): INSERT end node2: DROP TABLE node2: check no pending signals are left - ok What happens occasionally (unexpected): node2: set sync.wsrep_apply_cb in order to start waiting in the background INSERT node1: INSERT start node2 (background): INSERT start node1: INSERT end // The background INSERT still has _not_ reached the place where it starts // waiting for the signal: // DBUG_EXECUTE_IF("sync.wsrep_apply_cb", "now wait_for..."); node2: send signal to background INSERT: "stop waiting and continue executing" node2: clear sync.wsrep_apply_cb as no longer needed // The background INSERT reaches DBUG_EXECUTE_IF("sync.wsrep_apply_cb", ...) // but sync.wsrep_apply_cb has already been cleared and the "wait" code is not // executed. The signal remains unconsumed. node2 (background): INSERT end node2: DROP TABLE node2: check no pending signals are left - failure, signal.wsrep_apply_cb is pending (not consumed) Remove MW-360 test case as it is not intended for MariaDB (uses MySQL GTID). --- mysql-test/suite/galera/r/MW-360.result | 161 ------------------ mysql-test/suite/galera/r/MW-86-wait1.result | 48 ++++++ mysql-test/suite/galera/r/MW-86-wait8.result | 50 ++++++ mysql-test/suite/galera/r/MW-86.result | 65 ------- mysql-test/suite/galera/t/MW-360-master.opt | 2 - mysql-test/suite/galera/t/MW-360.test | 103 ----------- ...W-86-master.opt => MW-86-wait1-master.opt} | 0 mysql-test/suite/galera/t/MW-86-wait1.test | 106 ++++++++++++ .../suite/galera/t/MW-86-wait8-master.opt | 1 + .../galera/t/{MW-86.test => MW-86-wait8.test} | 125 ++++---------- sql/sql_class.cc | 6 - sql/sql_parse.cc | 4 +- sql/wsrep_applier.cc | 3 +- sql/wsrep_mysqld.cc | 2 - sql/wsrep_var.cc | 45 ++--- 15 files changed, 267 insertions(+), 454 deletions(-) delete mode 100644 mysql-test/suite/galera/r/MW-360.result create mode 100644 mysql-test/suite/galera/r/MW-86-wait1.result create mode 100644 mysql-test/suite/galera/r/MW-86-wait8.result delete mode 100644 mysql-test/suite/galera/r/MW-86.result delete mode 100644 mysql-test/suite/galera/t/MW-360-master.opt delete mode 100644 mysql-test/suite/galera/t/MW-360.test rename mysql-test/suite/galera/t/{MW-86-master.opt => MW-86-wait1-master.opt} (100%) create mode 100644 mysql-test/suite/galera/t/MW-86-wait1.test create mode 100644 mysql-test/suite/galera/t/MW-86-wait8-master.opt rename mysql-test/suite/galera/t/{MW-86.test => MW-86-wait8.test} (54%) diff --git a/mysql-test/suite/galera/r/MW-360.result b/mysql-test/suite/galera/r/MW-360.result deleted file mode 100644 index 4195b8f07bc..00000000000 --- a/mysql-test/suite/galera/r/MW-360.result +++ /dev/null @@ -1,161 +0,0 @@ -SET GLOBAL wsrep_on=OFF; -RESET MASTER; -SET GLOBAL wsrep_on=ON; -SET GLOBAL wsrep_on=OFF; -RESET MASTER; -SET GLOBAL wsrep_on=ON; -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -DROP TABLE t1; -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); -DROP TABLE t1, t2; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); -DROP TABLE t1, t2; -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); -CREATE TEMPORARY TABLE t3 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t3 VALUES (3); -DROP TABLE t1, t2, t3; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); -CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t3 VALUES (3); -DROP TABLE t1, t2, t3; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (2); -DROP TABLE t1; -DROP TABLE t1; -SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; -Log_name Pos Event_type Server_id End_log_pos Info -mysqld-bin.000001 120 Previous_gtids 1 151 -mysqld-bin.000001 151 Gtid 1 199 SET @@SESSION.GTID_NEXT= ':1' -mysqld-bin.000001 199 Query 1 339 use `test`; DROP TEMPORARY TABLE IF EXISTS `t1` /* generated by server */ -mysqld-bin.000001 339 Gtid 1 387 SET @@SESSION.GTID_NEXT= ':1' -mysqld-bin.000001 387 Query 1 503 use `test`; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 503 Gtid 1 551 SET @@SESSION.GTID_NEXT= ':2' -mysqld-bin.000001 551 Query 1 628 BEGIN -mysqld-bin.000001 628 Table_map 1 673 table_id: # (test.t2) -mysqld-bin.000001 673 Write_rows 1 713 table_id: # flags: STMT_END_F -mysqld-bin.000001 713 Xid 1 744 COMMIT /* xid=# */ -mysqld-bin.000001 744 Gtid 1 792 SET @@SESSION.GTID_NEXT= ':2' -mysqld-bin.000001 792 Query 1 927 use `test`; DROP TEMPORARY TABLE IF EXISTS `t1` /* generated by server */ -mysqld-bin.000001 927 Gtid 1 975 SET @@SESSION.GTID_NEXT= ':3' -mysqld-bin.000001 975 Query 1 1090 use `test`; DROP TABLE `t2` /* generated by server */ -mysqld-bin.000001 1090 Gtid 1 1138 SET @@SESSION.GTID_NEXT= ':4' -mysqld-bin.000001 1138 Query 1 1254 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 1254 Gtid 1 1302 SET @@SESSION.GTID_NEXT= ':5' -mysqld-bin.000001 1302 Query 1 1379 BEGIN -mysqld-bin.000001 1379 Table_map 1 1424 table_id: # (test.t1) -mysqld-bin.000001 1424 Write_rows 1 1464 table_id: # flags: STMT_END_F -mysqld-bin.000001 1464 Xid 1 1495 COMMIT /* xid=# */ -mysqld-bin.000001 1495 Gtid 1 1543 SET @@SESSION.GTID_NEXT= ':3' -mysqld-bin.000001 1543 Query 1 1678 use `test`; DROP TEMPORARY TABLE IF EXISTS `t2` /* generated by server */ -mysqld-bin.000001 1678 Gtid 1 1726 SET @@SESSION.GTID_NEXT= ':6' -mysqld-bin.000001 1726 Query 1 1841 use `test`; DROP TABLE `t1` /* generated by server */ -mysqld-bin.000001 1841 Gtid 1 1889 SET @@SESSION.GTID_NEXT= ':7' -mysqld-bin.000001 1889 Query 1 2005 use `test`; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 2005 Gtid 1 2053 SET @@SESSION.GTID_NEXT= ':8' -mysqld-bin.000001 2053 Query 1 2130 BEGIN -mysqld-bin.000001 2130 Table_map 1 2175 table_id: # (test.t2) -mysqld-bin.000001 2175 Write_rows 1 2215 table_id: # flags: STMT_END_F -mysqld-bin.000001 2215 Xid 1 2246 COMMIT /* xid=# */ -mysqld-bin.000001 2246 Gtid 1 2294 SET @@SESSION.GTID_NEXT= ':4' -mysqld-bin.000001 2294 Query 1 2434 use `test`; DROP TEMPORARY TABLE IF EXISTS `t1`,`t3` /* generated by server */ -mysqld-bin.000001 2434 Gtid 1 2482 SET @@SESSION.GTID_NEXT= ':9' -mysqld-bin.000001 2482 Query 1 2597 use `test`; DROP TABLE `t2` /* generated by server */ -mysqld-bin.000001 2597 Gtid 1 2645 SET @@SESSION.GTID_NEXT= ':10' -mysqld-bin.000001 2645 Query 1 2761 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 2761 Gtid 1 2809 SET @@SESSION.GTID_NEXT= ':11' -mysqld-bin.000001 2809 Query 1 2886 BEGIN -mysqld-bin.000001 2886 Table_map 1 2931 table_id: # (test.t1) -mysqld-bin.000001 2931 Write_rows 1 2971 table_id: # flags: STMT_END_F -mysqld-bin.000001 2971 Xid 1 3002 COMMIT /* xid=# */ -mysqld-bin.000001 3002 Gtid 1 3050 SET @@SESSION.GTID_NEXT= ':12' -mysqld-bin.000001 3050 Query 1 3166 use `test`; CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 3166 Gtid 1 3214 SET @@SESSION.GTID_NEXT= ':13' -mysqld-bin.000001 3214 Query 1 3291 BEGIN -mysqld-bin.000001 3291 Table_map 1 3336 table_id: # (test.t3) -mysqld-bin.000001 3336 Write_rows 1 3376 table_id: # flags: STMT_END_F -mysqld-bin.000001 3376 Xid 1 3407 COMMIT /* xid=# */ -mysqld-bin.000001 3407 Gtid 1 3455 SET @@SESSION.GTID_NEXT= ':5' -mysqld-bin.000001 3455 Query 1 3590 use `test`; DROP TEMPORARY TABLE IF EXISTS `t2` /* generated by server */ -mysqld-bin.000001 3590 Gtid 1 3638 SET @@SESSION.GTID_NEXT= ':14' -mysqld-bin.000001 3638 Query 1 3758 use `test`; DROP TABLE `t1`,`t3` /* generated by server */ -mysqld-bin.000001 3758 Gtid 1 3806 SET @@SESSION.GTID_NEXT= ':15' -mysqld-bin.000001 3806 Query 1 3922 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 3922 Gtid 1 3970 SET @@SESSION.GTID_NEXT= ':16' -mysqld-bin.000001 3970 Query 1 4047 BEGIN -mysqld-bin.000001 4047 Table_map 1 4092 table_id: # (test.t1) -mysqld-bin.000001 4092 Write_rows 1 4132 table_id: # flags: STMT_END_F -mysqld-bin.000001 4132 Xid 1 4163 COMMIT /* xid=# */ -mysqld-bin.000001 4163 Gtid 1 4211 SET @@SESSION.GTID_NEXT= ':6' -mysqld-bin.000001 4211 Query 1 4351 use `test`; DROP TEMPORARY TABLE IF EXISTS `t1` /* generated by server */ -mysqld-bin.000001 4351 Gtid 1 4399 SET @@SESSION.GTID_NEXT= ':17' -mysqld-bin.000001 4399 Query 1 4514 use `test`; DROP TABLE `t1` /* generated by server */ -SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; -Log_name Pos Event_type Server_id End_log_pos Info -mysqld-bin.000001 120 Previous_gtids 2 151 -mysqld-bin.000001 151 Gtid 1 199 SET @@SESSION.GTID_NEXT= ':1' -mysqld-bin.000001 199 Query 1 315 use `test`; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 315 Gtid 1 363 SET @@SESSION.GTID_NEXT= ':2' -mysqld-bin.000001 363 Query 1 431 BEGIN -mysqld-bin.000001 431 Table_map 1 476 table_id: # (test.t2) -mysqld-bin.000001 476 Write_rows 1 516 table_id: # flags: STMT_END_F -mysqld-bin.000001 516 Xid 1 547 COMMIT /* xid=# */ -mysqld-bin.000001 547 Gtid 1 595 SET @@SESSION.GTID_NEXT= ':3' -mysqld-bin.000001 595 Query 1 710 use `test`; DROP TABLE `t2` /* generated by server */ -mysqld-bin.000001 710 Gtid 1 758 SET @@SESSION.GTID_NEXT= ':4' -mysqld-bin.000001 758 Query 1 874 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 874 Gtid 1 922 SET @@SESSION.GTID_NEXT= ':5' -mysqld-bin.000001 922 Query 1 990 BEGIN -mysqld-bin.000001 990 Table_map 1 1035 table_id: # (test.t1) -mysqld-bin.000001 1035 Write_rows 1 1075 table_id: # flags: STMT_END_F -mysqld-bin.000001 1075 Xid 1 1106 COMMIT /* xid=# */ -mysqld-bin.000001 1106 Gtid 1 1154 SET @@SESSION.GTID_NEXT= ':6' -mysqld-bin.000001 1154 Query 1 1269 use `test`; DROP TABLE `t1` /* generated by server */ -mysqld-bin.000001 1269 Gtid 1 1317 SET @@SESSION.GTID_NEXT= ':7' -mysqld-bin.000001 1317 Query 1 1433 use `test`; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 1433 Gtid 1 1481 SET @@SESSION.GTID_NEXT= ':8' -mysqld-bin.000001 1481 Query 1 1549 BEGIN -mysqld-bin.000001 1549 Table_map 1 1594 table_id: # (test.t2) -mysqld-bin.000001 1594 Write_rows 1 1634 table_id: # flags: STMT_END_F -mysqld-bin.000001 1634 Xid 1 1665 COMMIT /* xid=# */ -mysqld-bin.000001 1665 Gtid 1 1713 SET @@SESSION.GTID_NEXT= ':9' -mysqld-bin.000001 1713 Query 1 1828 use `test`; DROP TABLE `t2` /* generated by server */ -mysqld-bin.000001 1828 Gtid 1 1876 SET @@SESSION.GTID_NEXT= ':10' -mysqld-bin.000001 1876 Query 1 1992 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 1992 Gtid 1 2040 SET @@SESSION.GTID_NEXT= ':11' -mysqld-bin.000001 2040 Query 1 2108 BEGIN -mysqld-bin.000001 2108 Table_map 1 2153 table_id: # (test.t1) -mysqld-bin.000001 2153 Write_rows 1 2193 table_id: # flags: STMT_END_F -mysqld-bin.000001 2193 Xid 1 2224 COMMIT /* xid=# */ -mysqld-bin.000001 2224 Gtid 1 2272 SET @@SESSION.GTID_NEXT= ':12' -mysqld-bin.000001 2272 Query 1 2388 use `test`; CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 2388 Gtid 1 2436 SET @@SESSION.GTID_NEXT= ':13' -mysqld-bin.000001 2436 Query 1 2504 BEGIN -mysqld-bin.000001 2504 Table_map 1 2549 table_id: # (test.t3) -mysqld-bin.000001 2549 Write_rows 1 2589 table_id: # flags: STMT_END_F -mysqld-bin.000001 2589 Xid 1 2620 COMMIT /* xid=# */ -mysqld-bin.000001 2620 Gtid 1 2668 SET @@SESSION.GTID_NEXT= ':14' -mysqld-bin.000001 2668 Query 1 2788 use `test`; DROP TABLE `t1`,`t3` /* generated by server */ -mysqld-bin.000001 2788 Gtid 1 2836 SET @@SESSION.GTID_NEXT= ':15' -mysqld-bin.000001 2836 Query 1 2952 use `test`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 2952 Gtid 1 3000 SET @@SESSION.GTID_NEXT= ':16' -mysqld-bin.000001 3000 Query 1 3068 BEGIN -mysqld-bin.000001 3068 Table_map 1 3113 table_id: # (test.t1) -mysqld-bin.000001 3113 Write_rows 1 3153 table_id: # flags: STMT_END_F -mysqld-bin.000001 3153 Xid 1 3184 COMMIT /* xid=# */ -mysqld-bin.000001 3184 Gtid 1 3232 SET @@SESSION.GTID_NEXT= ':17' -mysqld-bin.000001 3232 Query 1 3347 use `test`; DROP TABLE `t1` /* generated by server */ diff --git a/mysql-test/suite/galera/r/MW-86-wait1.result b/mysql-test/suite/galera/r/MW-86-wait1.result new file mode 100644 index 00000000000..a38255eff8f --- /dev/null +++ b/mysql-test/suite/galera/r/MW-86-wait1.result @@ -0,0 +1,48 @@ +SELECT @@debug_sync; +@@debug_sync +ON - current signal: '' +SET SESSION wsrep_sync_wait = 1; +SET GLOBAL debug = "+d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +CREATE TABLE t_wait1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t_wait1 VALUES (1); +SET SESSION debug_sync = "now WAIT_FOR sync.wsrep_apply_cb_reached"; +SHOW BINARY LOGS; +SHOW BINLOG EVENTS; +SHOW COLUMNS FROM t1; +SHOW CREATE EVENT e1; +SHOW CREATE FUNCTION f1; +SHOW CREATE PROCEDURE p1; +SHOW CREATE TABLE t1; +SHOW CREATE TRIGGER tr1; +SHOW CREATE VIEW v1; +SHOW DATABASES; +SHOW ENGINE InnoDB STATUS; +SHOW FUNCTION CODE f1; +SHOW FUNCTION STATUS; +SHOW GRANTS FOR 'root'@'localhost'; +SHOW INDEX FROM t1; +SHOW OPEN TABLES; +SHOW PROCEDURE CODE p1; +SHOW PROCEDURE STATUS; +SHOW PRIVILEGES; +SHOW STATUS LIKE 'wsrep_cluster_size'; +SHOW TABLE STATUS; +SHOW TABLES; +SHOW TRIGGERS; +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; +SHOW WARNINGS; +SET GLOBAL debug = "-d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET SESSION debug_sync = "now SIGNAL signal.wsrep_apply_cb"; +SET SESSION wsrep_sync_wait = default; +DROP TABLE t_wait1; +SET GLOBAL debug = NULL; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET debug_sync='RESET'; +SELECT @@debug_sync; +@@debug_sync +ON - current signal: '' diff --git a/mysql-test/suite/galera/r/MW-86-wait8.result b/mysql-test/suite/galera/r/MW-86-wait8.result new file mode 100644 index 00000000000..04c93e9a9f2 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-86-wait8.result @@ -0,0 +1,50 @@ +SELECT @@debug_sync; +@@debug_sync +ON - current signal: '' +SET SESSION wsrep_sync_wait = 8; +SET GLOBAL debug = "+d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +CREATE TABLE t_wait8 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t_wait8 VALUES (1); +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; +SET SESSION debug_sync = "now WAIT_FOR sync.wsrep_apply_cb_reached"; +SHOW BINARY LOGS; +SHOW BINLOG EVENTS; +SHOW COLUMNS FROM t1; +SHOW CREATE DATABASE db1; +SHOW CREATE EVENT e1; +SHOW CREATE FUNCTION f1; +SHOW CREATE PROCEDURE p1; +SHOW CREATE TABLE t1; +SHOW CREATE TRIGGER tr1; +SHOW CREATE VIEW v1; +SHOW DATABASES; +SHOW ENGINE InnoDB STATUS; +SHOW FUNCTION CODE f1; +SHOW FUNCTION STATUS; +SHOW GRANTS FOR 'root'@'localhost'; +SHOW INDEX FROM t1; +SHOW OPEN TABLES; +SHOW PROCEDURE CODE p1; +SHOW PROCEDURE STATUS; +SHOW PRIVILEGES; +SHOW STATUS LIKE 'wsrep_cluster_size'; +SHOW TABLE STATUS; +SHOW TABLES; +SHOW TRIGGERS; +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; +SHOW WARNINGS; +SET GLOBAL debug = "-d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +SET SESSION wsrep_sync_wait = default; +DROP TABLE t_wait8; +SET GLOBAL debug = NULL; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET debug_sync='RESET'; +SELECT @@debug_sync; +@@debug_sync +ON - current signal: '' diff --git a/mysql-test/suite/galera/r/MW-86.result b/mysql-test/suite/galera/r/MW-86.result deleted file mode 100644 index b29175216a8..00000000000 --- a/mysql-test/suite/galera/r/MW-86.result +++ /dev/null @@ -1,65 +0,0 @@ -SET SESSION wsrep_sync_wait = 1; -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -CREATE DATABASE db1; -SHOW BINARY LOGS; -SHOW BINLOG EVENTS; -SHOW COLUMNS FROM t1; -SHOW CREATE DATABASE db1; -SHOW CREATE EVENT e1; -SHOW CREATE FUNCTION f1; -SHOW CREATE PROCEDURE p1; -SHOW CREATE TABLE t1; -SHOW CREATE TRIGGER tr1; -SHOW CREATE VIEW v1; -SHOW DATABASES; -SHOW ENGINE InnoDB STATUS; -SHOW FUNCTION CODE f1; -SHOW FUNCTION STATUS; -SHOW GRANTS FOR 'root'@'localhost'; -SHOW INDEX FROM t1; -SHOW OPEN TABLES; -SHOW PROCEDURE CODE p1; -SHOW PROCEDURE STATUS; -SHOW PRIVILEGES; -SHOW STATUS LIKE 'wsrep_cluster_size'; -SHOW TABLE STATUS; -SHOW TABLES; -SHOW TRIGGERS; -SHOW GLOBAL VARIABLES LIKE 'foo_bar'; -SHOW WARNINGS; -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; -SET SESSION wsrep_sync_wait = 8; -DROP DATABASE db1; -SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; -SET SESSION wsrep_sync_wait = 8; -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -CREATE TABLE q (f1 INTEGER) ENGINE=InnoDB; -SHOW BINARY LOGS; -SHOW BINLOG EVENTS; -SHOW COLUMNS FROM t1; -SHOW CREATE DATABASE db1; -SHOW CREATE EVENT e1; -SHOW CREATE FUNCTION f1; -SHOW CREATE PROCEDURE p1; -SHOW CREATE TABLE t1; -SHOW CREATE TRIGGER tr1; -SHOW CREATE VIEW v1; -SHOW DATABASES; -SHOW ENGINE InnoDB STATUS; -SHOW FUNCTION CODE f1; -SHOW FUNCTION STATUS; -SHOW GRANTS FOR 'root'@'localhost'; -SHOW INDEX FROM t1; -SHOW OPEN TABLES; -SHOW PROCEDURE CODE p1; -SHOW PROCEDURE STATUS; -SHOW PRIVILEGES; -SHOW STATUS LIKE 'wsrep_cluster_size'; -SHOW TABLE STATUS; -SHOW TABLES; -SHOW TRIGGERS; -SHOW GLOBAL VARIABLES LIKE 'foo_bar'; -SHOW WARNINGS; -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; diff --git a/mysql-test/suite/galera/t/MW-360-master.opt b/mysql-test/suite/galera/t/MW-360-master.opt deleted file mode 100644 index 6cfaed135e4..00000000000 --- a/mysql-test/suite/galera/t/MW-360-master.opt +++ /dev/null @@ -1,2 +0,0 @@ ---gtid-mode=ON --log-bin --log-slave-updates --enforce-gtid-consistency - diff --git a/mysql-test/suite/galera/t/MW-360.test b/mysql-test/suite/galera/t/MW-360.test deleted file mode 100644 index 7ea743cdb3d..00000000000 --- a/mysql-test/suite/galera/t/MW-360.test +++ /dev/null @@ -1,103 +0,0 @@ -# -# MW-360 DROP TABLE containing temporary tables results in binlog divergence -# - ---source include/galera_cluster.inc ---source include/have_binlog_format_row.inc - ---connection node_1 -SET GLOBAL wsrep_on=OFF; -RESET MASTER; -SET GLOBAL wsrep_on=ON; - ---connection node_2 -SET GLOBAL wsrep_on=OFF; -RESET MASTER; -SET GLOBAL wsrep_on=ON; - ---connection node_1 - -# -# Straightforward temporary table -# - -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -DROP TABLE t1; ---let $local_uuid = `SELECT LEFT(@@global.gtid_executed, 36)` - -# -# A mix of normal and temporary tables -# - -# Temp table first, normal table second - -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); - -DROP TABLE t1, t2; - -# Normal table first, temporary table second - -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); - -DROP TABLE t1, t2; - -# Temporary table first, normal table second, temp table third - -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); - -CREATE TEMPORARY TABLE t3 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t3 VALUES (3); - -DROP TABLE t1, t2, t3; - -# Normal table first, temporary table second, normal table third - -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); - -CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t3 VALUES (3); - -DROP TABLE t1, t2, t3; - -# -# A temporary table masking a normal one -# - -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (2); - -DROP TABLE t1; -DROP TABLE t1; - ---connection node_2 ---let $cluster_uuid = `SELECT LEFT(@@global.gtid_executed, 36)` - ---connection node_1 ---replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/ ---replace_result $local_uuid $cluster_uuid -SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; - ---connection node_2 ---replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/ ---replace_result $local_uuid $cluster_uuid -SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; diff --git a/mysql-test/suite/galera/t/MW-86-master.opt b/mysql-test/suite/galera/t/MW-86-wait1-master.opt similarity index 100% rename from mysql-test/suite/galera/t/MW-86-master.opt rename to mysql-test/suite/galera/t/MW-86-wait1-master.opt diff --git a/mysql-test/suite/galera/t/MW-86-wait1.test b/mysql-test/suite/galera/t/MW-86-wait1.test new file mode 100644 index 00000000000..6c0982ad8b3 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-86-wait1.test @@ -0,0 +1,106 @@ +# +# SHOW commands no longer obey wsrep_sync_wait = 1 (WSREP_SYNC_WAIT_BEFORE_READ) +# (they do not wait for the background INSERT in the applier in node_2 to +# complete) +# +--source include/galera_cluster.inc +--source include/have_binlog_format_row.inc +--source include/have_debug_sync.inc + +--connection node_2 +# Make sure no signals have been leftover from previous tests to surprise us. +SELECT @@debug_sync; + +SET SESSION wsrep_sync_wait = 1; +SET GLOBAL debug = "+d,sync.wsrep_apply_cb"; + +--connection node_1 +CREATE TABLE t_wait1 (f1 INTEGER) ENGINE=InnoDB; +# This will complete in node_1 but will start a background apply in node_2 +# which will stop because of sync.wsrep_apply_cb we set above. +INSERT INTO t_wait1 VALUES (1); + +--connection node_2 + +SET SESSION debug_sync = "now WAIT_FOR sync.wsrep_apply_cb_reached"; + +--disable_result_log + +SHOW BINARY LOGS; + +SHOW BINLOG EVENTS; + +--error ER_NO_SUCH_TABLE +SHOW COLUMNS FROM t1; + +--error ER_EVENT_DOES_NOT_EXIST +SHOW CREATE EVENT e1; + +--error ER_SP_DOES_NOT_EXIST +SHOW CREATE FUNCTION f1; + +--error ER_SP_DOES_NOT_EXIST +SHOW CREATE PROCEDURE p1; + +--error ER_NO_SUCH_TABLE +SHOW CREATE TABLE t1; + +--error ER_TRG_DOES_NOT_EXIST +SHOW CREATE TRIGGER tr1; + +--error ER_NO_SUCH_TABLE +SHOW CREATE VIEW v1; + +SHOW DATABASES; + +SHOW ENGINE InnoDB STATUS; + +--error ER_SP_DOES_NOT_EXIST +SHOW FUNCTION CODE f1; + +SHOW FUNCTION STATUS; + +SHOW GRANTS FOR 'root'@'localhost'; + +--error ER_NO_SUCH_TABLE +SHOW INDEX FROM t1; + +SHOW OPEN TABLES; + +--error ER_SP_DOES_NOT_EXIST +SHOW PROCEDURE CODE p1; + +SHOW PROCEDURE STATUS; + +SHOW PRIVILEGES; + +SHOW STATUS LIKE 'wsrep_cluster_size'; + +SHOW TABLE STATUS; + +SHOW TABLES; + +SHOW TRIGGERS; + +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; + +--error 0 +SHOW WARNINGS; + +--enable_result_log + +# Unblock the background INSERT and remove the sync point. +SET GLOBAL debug = "-d,sync.wsrep_apply_cb"; +SET SESSION debug_sync = "now SIGNAL signal.wsrep_apply_cb"; + +SET SESSION wsrep_sync_wait = default; + +# This will wait for the background INSERT to complete before we quit +# from the test. +DROP TABLE t_wait1; + +SET GLOBAL debug = NULL; +SET debug_sync='RESET'; + +# Make sure no pending signals are leftover to surprise subsequent tests. +SELECT @@debug_sync; diff --git a/mysql-test/suite/galera/t/MW-86-wait8-master.opt b/mysql-test/suite/galera/t/MW-86-wait8-master.opt new file mode 100644 index 00000000000..8a755e98b00 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-86-wait8-master.opt @@ -0,0 +1 @@ +--log-bin --log-slave-updates diff --git a/mysql-test/suite/galera/t/MW-86.test b/mysql-test/suite/galera/t/MW-86-wait8.test similarity index 54% rename from mysql-test/suite/galera/t/MW-86.test rename to mysql-test/suite/galera/t/MW-86-wait8.test index c6550ecdaaa..65e612c5c8e 100644 --- a/mysql-test/suite/galera/t/MW-86.test +++ b/mysql-test/suite/galera/t/MW-86-wait8.test @@ -1,104 +1,32 @@ +# +# SHOW commands now obey wsrep_sync_wait = 8 (WSREP_SYNC_WAIT_BEFORE_SHOW) +# --source include/galera_cluster.inc --source include/have_binlog_format_row.inc - -# -# Test 1: SHOW commands no longer obey wsrep_sync_wait = 1 -# +--source include/have_debug_sync.inc --connection node_2 -SET SESSION wsrep_sync_wait = 1; -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; ---disable_result_log - ---connection node_1 -CREATE DATABASE db1; - ---connection node_2 -SHOW BINARY LOGS; - -SHOW BINLOG EVENTS; - ---error ER_NO_SUCH_TABLE -SHOW COLUMNS FROM t1; - ---error ER_BAD_DB_ERROR -SHOW CREATE DATABASE db1; - ---error ER_EVENT_DOES_NOT_EXIST -SHOW CREATE EVENT e1; - ---error ER_SP_DOES_NOT_EXIST -SHOW CREATE FUNCTION f1; - ---error ER_SP_DOES_NOT_EXIST -SHOW CREATE PROCEDURE p1; - ---error ER_NO_SUCH_TABLE -SHOW CREATE TABLE t1; - ---error ER_TRG_DOES_NOT_EXIST -SHOW CREATE TRIGGER tr1; - ---error ER_NO_SUCH_TABLE -SHOW CREATE VIEW v1; - -SHOW DATABASES; - -SHOW ENGINE InnoDB STATUS; - ---error ER_SP_DOES_NOT_EXIST -SHOW FUNCTION CODE f1; - -SHOW FUNCTION STATUS; - -SHOW GRANTS FOR 'root'@'localhost'; - ---error ER_NO_SUCH_TABLE -SHOW INDEX FROM t1; - -SHOW OPEN TABLES; - ---error ER_SP_DOES_NOT_EXIST -SHOW PROCEDURE CODE p1; - -SHOW PROCEDURE STATUS; - -SHOW PRIVILEGES; - -SHOW STATUS LIKE 'wsrep_cluster_size'; - -SHOW TABLE STATUS; - -SHOW TABLES; - -SHOW TRIGGERS; - -SHOW GLOBAL VARIABLES LIKE 'foo_bar'; - ---error 0 -SHOW WARNINGS; - -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +# Make sure no signals have been leftover from previous tests to surprise us. +SELECT @@debug_sync; SET SESSION wsrep_sync_wait = 8; -DROP DATABASE db1; +SET GLOBAL debug = "+d,sync.wsrep_apply_cb"; - -# -# Test 2: SHOW commands now obey wsrep_sync_wait = 8 -# +--connection node_1 +CREATE TABLE t_wait8 (f1 INTEGER) ENGINE=InnoDB; +# This will complete in node_1 but will start a background apply in node_2 +# which will stop because of sync.wsrep_apply_cb we set above. +INSERT INTO t_wait8 VALUES (1); --connection node_2 + --let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; -SET SESSION wsrep_sync_wait = 8; -SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; ---connection node_1 -CREATE TABLE q (f1 INTEGER) ENGINE=InnoDB; +SET SESSION debug_sync = "now WAIT_FOR sync.wsrep_apply_cb_reached"; + +--disable_result_log ---connection node_2 --error ER_LOCK_WAIT_TIMEOUT SHOW BINARY LOGS; @@ -177,11 +105,24 @@ SHOW GLOBAL VARIABLES LIKE 'foo_bar'; --error 0 SHOW WARNINGS; -SET GLOBAL DEBUG = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +--enable_result_log --disable_query_log --eval SET GLOBAL wsrep_provider_options = "$wsrep_provider_options_orig" +--enable_query_log -SET SESSION wsrep_sync_wait = 15; -DROP TABLE q; +# Unblock the background INSERT and remove the sync point. +SET GLOBAL debug = "-d,sync.wsrep_apply_cb"; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +SET SESSION wsrep_sync_wait = default; + +# This will wait for the background INSERT to complete before we quit +# from the test. +DROP TABLE t_wait8; + +SET GLOBAL debug = NULL; +SET debug_sync='RESET'; + +# Make sure no pending signals are leftover to surprise subsequent tests. +SELECT @@debug_sync; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5964f4475a4..83cdaadb3b9 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1635,12 +1635,6 @@ void THD::init(void) wsrep_affected_rows = 0; wsrep_replicate_GTID = false; wsrep_skip_wsrep_GTID = false; - /* - @@wsrep_causal_reads is now being handled via wsrep_sync_wait, update it - appropriately. - */ - if (variables.wsrep_causal_reads) - variables.wsrep_sync_wait|= WSREP_SYNC_WAIT_BEFORE_READ; #endif /* WITH_WSREP */ if (variables.sql_log_bin) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c487835c84e..e561aa521e2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2756,6 +2756,7 @@ mysql_execute_command(THD *thd) #endif case SQLCOM_SHOW_STATUS: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); execute_show_status(thd, all_tables); break; } @@ -5808,11 +5809,10 @@ static bool execute_show_status(THD *thd, TABLE_LIST *all_tables) bool res; system_status_var old_status_var= thd->status_var; thd->initial_status_var= &old_status_var; - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (!(res= check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE))) res= execute_sqlcom_select(thd, all_tables); -error: + /* Don't log SHOW STATUS commands to slow query log */ thd->server_status&= ~(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED); diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 49087d09224..db92878dbe5 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -224,7 +224,8 @@ wsrep_cb_status_t wsrep_apply_cb(void* const ctx, { const char act[]= "now " - "wait_for signal.wsrep_apply_cb"; + "SIGNAL sync.wsrep_apply_cb_reached " + "WAIT_FOR signal.wsrep_apply_cb"; DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); };); diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 6e847a33dfb..49988287933 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -809,8 +809,6 @@ bool wsrep_must_sync_wait (THD* thd, uint mask) { return (thd->variables.wsrep_sync_wait & mask) && thd->variables.wsrep_on && - !(thd->variables.wsrep_dirty_reads && - !is_update_query(thd->lex->sql_command)) && !thd->in_active_multi_stmt_transaction() && thd->wsrep_conflict_state != REPLAYING && thd->wsrep_sync_wait_gtid.seqno == WSREP_SEQNO_UNDEFINED; diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 9a5c7b86068..20091a3893e 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -64,19 +64,21 @@ bool wsrep_on_update (sys_var *self, THD* thd, enum_var_type var_type) bool wsrep_causal_reads_update (sys_var *self, THD* thd, enum_var_type var_type) { - // wsrep_sync_wait should also be updated. - if (var_type == OPT_GLOBAL) { - if (global_system_variables.wsrep_causal_reads) { - global_system_variables.wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ; - } else { - global_system_variables.wsrep_sync_wait &= ~WSREP_SYNC_WAIT_BEFORE_READ; - } + // global setting should not affect session setting. + // if (var_type == OPT_GLOBAL) { + // thd->variables.wsrep_causal_reads = global_system_variables.wsrep_causal_reads; + // } + if (thd->variables.wsrep_causal_reads) { + thd->variables.wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ; } else { - if (thd->variables.wsrep_causal_reads) { - thd->variables.wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ; - } else { - thd->variables.wsrep_sync_wait &= ~WSREP_SYNC_WAIT_BEFORE_READ; - } + thd->variables.wsrep_sync_wait &= ~WSREP_SYNC_WAIT_BEFORE_READ; + } + + // update global settings too. + if (global_system_variables.wsrep_causal_reads) { + global_system_variables.wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ; + } else { + global_system_variables.wsrep_sync_wait &= ~WSREP_SYNC_WAIT_BEFORE_READ; } return false; @@ -84,14 +86,17 @@ bool wsrep_causal_reads_update (sys_var *self, THD* thd, enum_var_type var_type) bool wsrep_sync_wait_update (sys_var* self, THD* thd, enum_var_type var_type) { - // wsrep_causal_reads should also be updated. - if (var_type == OPT_GLOBAL) { - global_system_variables.wsrep_causal_reads= - global_system_variables.wsrep_sync_wait & WSREP_SYNC_WAIT_BEFORE_READ; - } else { - thd->variables.wsrep_causal_reads= - thd->variables.wsrep_sync_wait & WSREP_SYNC_WAIT_BEFORE_READ; - } + // global setting should not affect session setting. + // if (var_type == OPT_GLOBAL) { + // thd->variables.wsrep_sync_wait = global_system_variables.wsrep_sync_wait; + // } + thd->variables.wsrep_causal_reads = thd->variables.wsrep_sync_wait & + WSREP_SYNC_WAIT_BEFORE_READ; + + // update global settings too + global_system_variables.wsrep_causal_reads = global_system_variables.wsrep_sync_wait & + WSREP_SYNC_WAIT_BEFORE_READ; + return false; } From 81fd8ff6761109546f14cc8f8a5dfb27b0da8a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 16 Aug 2017 07:49:19 +0300 Subject: [PATCH 045/101] Fix test failures. --- mysql-test/suite/galera/r/GAL-401.result | 1 + .../galera/r/galera_suspend_slave.result | 3 + .../galera/r/galera_var_dirty_reads.result | 80 ++++-------------- mysql-test/suite/galera/t/GAL-401.test | 1 + .../suite/galera/t/galera_suspend_slave.test | 3 + .../galera/t/galera_var_dirty_reads.test | 82 ++++--------------- .../sys_vars/r/wsrep_sync_wait_basic.result | 4 +- 7 files changed, 39 insertions(+), 135 deletions(-) diff --git a/mysql-test/suite/galera/r/GAL-401.result b/mysql-test/suite/galera/r/GAL-401.result index fbdb2d39a28..03509cb0e29 100644 --- a/mysql-test/suite/galera/r/GAL-401.result +++ b/mysql-test/suite/galera/r/GAL-401.result @@ -1,6 +1,7 @@ SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; SET @@global.wsrep_desync = 1; SET SESSION wsrep_dirty_reads=1; +SET SESSION wsrep_sync_wait=0; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; diff --git a/mysql-test/suite/galera/r/galera_suspend_slave.result b/mysql-test/suite/galera/r/galera_suspend_slave.result index 02904812dd5..357a0d4f78e 100644 --- a/mysql-test/suite/galera/r/galera_suspend_slave.result +++ b/mysql-test/suite/galera/r/galera_suspend_slave.result @@ -3,8 +3,11 @@ Suspending node_2 ... INSERT INTO t1 VALUES (1); Got one of the listed errors Resuming node_2 ... +SET SESSION wsrep_sync_wait = 1; INSERT INTO t1 VALUES (1); +SET SESSION wsrep_sync_wait = 1; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +SET SESSION wsrep_sync_wait = 15; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_dirty_reads.result b/mysql-test/suite/galera/r/galera_var_dirty_reads.result index 8a3175912c7..405d86b3027 100644 --- a/mysql-test/suite/galera/r/galera_var_dirty_reads.result +++ b/mysql-test/suite/galera/r/galera_var_dirty_reads.result @@ -3,10 +3,6 @@ INSERT INTO t1 VALUES(1); SELECT * FROM t1; i 1 -create user user1; -grant all privileges on *.* to user1; -create user user2; -grant all privileges on *.* to user2; SET @@global.wsrep_cluster_address = ''; SET @@session.wsrep_dirty_reads=OFF; SET SESSION wsrep_sync_wait=0; @@ -18,78 +14,32 @@ Variable_name Value wsrep_cluster_status non-Primary SELECT * FROM t1; ERROR 08S01: WSREP has not yet prepared node for application use +SELECT 1 FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use SET @@session.wsrep_dirty_reads=ON; SELECT * FROM t1; i 1 -connect con1, localhost, user1,,test,$NODE_MYPORT_2,$NODE_MYSOCK_2; -SET SESSION wsrep_sync_wait=0; -set session wsrep_dirty_reads=1; -prepare stmt_show from 'select 1'; -prepare stmt_select from 'select * from t1'; -prepare stmt_insert from 'insert into t1 values(1)'; -set session wsrep_dirty_reads=0; -execute stmt_show; +SELECT 1 FROM t1; +1 +1 +SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; +i variable_name variable_value +1 WSREP_DIRTY_READS ON +SET @@session.wsrep_dirty_reads=OFF; +SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; ERROR 08S01: WSREP has not yet prepared node for application use -execute stmt_select; +SELECT 1; ERROR 08S01: WSREP has not yet prepared node for application use -execute stmt_insert; +USE information_schema; ERROR 08S01: WSREP has not yet prepared node for application use -SET wsrep_dirty_reads=ON; -select @@session.wsrep_dirty_reads; -@@session.wsrep_dirty_reads -1 -execute stmt_show; -1 -1 -execute stmt_select; -i -1 -execute stmt_insert; +SELECT * FROM information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads"; ERROR 08S01: WSREP has not yet prepared node for application use -SET @@global.wsrep_dirty_reads=ON; -connect con2, localhost, user2,,test,$NODE_MYPORT_2,$NODE_MYSOCK_2; -select @@session.wsrep_dirty_reads; -@@session.wsrep_dirty_reads -1 -prepare stmt_show from 'select 1'; -prepare stmt_select from 'select * from t1'; -prepare stmt_insert from 'insert into t1 values(1)'; -execute stmt_show; -1 -1 -execute stmt_select; -i -1 -execute stmt_insert; +SELECT COUNT(*) >= 10 FROM performance_schema.events_statements_history; ERROR 08S01: WSREP has not yet prepared node for application use -SET SESSION wsrep_sync_wait=1; -execute stmt_show; -1 -1 -execute stmt_select; -i -1 -execute stmt_insert; -ERROR 08S01: WSREP has not yet prepared node for application use -SET SESSION wsrep_sync_wait=7; -execute stmt_show; -1 -1 -execute stmt_select; -i -1 -execute stmt_insert; -ERROR 08S01: WSREP has not yet prepared node for application use -connection node_2; -SET @@global.wsrep_dirty_reads=OFF; -connection node_1; +USE test; SELECT * FROM t1; i 1 DROP TABLE t1; -drop user user1; -drop user user2; -disconnect node_2; -disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/t/GAL-401.test b/mysql-test/suite/galera/t/GAL-401.test index 25ab9502bec..06ce37dc81f 100644 --- a/mysql-test/suite/galera/t/GAL-401.test +++ b/mysql-test/suite/galera/t/GAL-401.test @@ -10,6 +10,7 @@ SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; --connection node_2 SET @@global.wsrep_desync = 1; SET SESSION wsrep_dirty_reads=1; +SET SESSION wsrep_sync_wait=0; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; --let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --source include/wait_condition.inc diff --git a/mysql-test/suite/galera/t/galera_suspend_slave.test b/mysql-test/suite/galera/t/galera_suspend_slave.test index 5c622085804..fd8bc362d02 100644 --- a/mysql-test/suite/galera/t/galera_suspend_slave.test +++ b/mysql-test/suite/galera/t/galera_suspend_slave.test @@ -41,6 +41,7 @@ INSERT INTO t1 VALUES (1); exit(0); EOF +SET SESSION wsrep_sync_wait = 1; --sleep 10 --source include/wait_until_ready.inc INSERT INTO t1 VALUES (1); @@ -50,9 +51,11 @@ INSERT INTO t1 VALUES (1); --source include/galera_connect.inc --connection node_2a +SET SESSION wsrep_sync_wait = 1; --source include/wait_until_ready.inc SELECT COUNT(*) = 1 FROM t1; +SET SESSION wsrep_sync_wait = 15; DROP TABLE t1; # Restore original auto_increment_offset values. diff --git a/mysql-test/suite/galera/t/galera_var_dirty_reads.test b/mysql-test/suite/galera/t/galera_var_dirty_reads.test index bcdb1574a3d..183c60753ad 100644 --- a/mysql-test/suite/galera/t/galera_var_dirty_reads.test +++ b/mysql-test/suite/galera/t/galera_var_dirty_reads.test @@ -5,11 +5,6 @@ --source include/galera_cluster.inc --source include/have_innodb.inc -# Save original auto_increment_offset values. ---let $node_1=node_1 ---let $node_2=node_2 ---source include/auto_increment_offset_save.inc - --connection node_2 --let $wsrep_cluster_address_saved = `SELECT @@global.wsrep_cluster_address` @@ -17,15 +12,10 @@ CREATE TABLE t1(i INT) ENGINE=INNODB; INSERT INTO t1 VALUES(1); SELECT * FROM t1; -create user user1; -grant all privileges on *.* to user1; -create user user2; -grant all privileges on *.* to user2; - SET @@global.wsrep_cluster_address = ''; SET @@session.wsrep_dirty_reads=OFF; -# Set wsrep_sync_wait to avoid ER_LOCK_WAIT_TIMEOUT (MDEV-6832). +# Set wsrep_sync_wait to avoid ER_LOCK_WAIT_TIMEOUT. SET SESSION wsrep_sync_wait=0; # Must return 'OFF' @@ -37,70 +27,32 @@ SHOW STATUS LIKE 'wsrep_cluster_status'; --error ER_UNKNOWN_COM_ERROR SELECT * FROM t1; +--error ER_UNKNOWN_COM_ERROR +SELECT 1 FROM t1; + SET @@session.wsrep_dirty_reads=ON; SELECT * FROM t1; +SELECT 1 FROM t1; ---enable_connect_log ---connect (con1, localhost, user1,,test,$NODE_MYPORT_2,$NODE_MYSOCK_2) -#Just test the session behavior -SET SESSION wsrep_sync_wait=0; +SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; -set session wsrep_dirty_reads=1; -#Prepared statement creation should be allowed MDEV-11479 -prepare stmt_show from 'select 1'; -prepare stmt_select from 'select * from t1'; -prepare stmt_insert from 'insert into t1 values(1)'; -set session wsrep_dirty_reads=0; +SET @@session.wsrep_dirty_reads=OFF; -#No Preapare stmt/proceure will be allowed --error ER_UNKNOWN_COM_ERROR -execute stmt_show; +SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; + --error ER_UNKNOWN_COM_ERROR -execute stmt_select; +SELECT 1; + --error ER_UNKNOWN_COM_ERROR -execute stmt_insert; +USE information_schema; -SET wsrep_dirty_reads=ON; -select @@session.wsrep_dirty_reads; -#Only prepare statement which does not change data should be allowed -execute stmt_show; -execute stmt_select; --error ER_UNKNOWN_COM_ERROR -execute stmt_insert; -SET @@global.wsrep_dirty_reads=ON; +SELECT * FROM information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads"; ---connect (con2, localhost, user2,,test,$NODE_MYPORT_2,$NODE_MYSOCK_2) -#Just test the session behavior -select @@session.wsrep_dirty_reads; - -prepare stmt_show from 'select 1'; -prepare stmt_select from 'select * from t1'; -prepare stmt_insert from 'insert into t1 values(1)'; - -#Only prepare statement which does not change data should be allowed -execute stmt_show; -execute stmt_select; --error ER_UNKNOWN_COM_ERROR -execute stmt_insert; - -#wsrep_dirty_read should work when wsrep_sync_wait is 1 or non zero -#because we already are disconnected , So It does not make any sense -#to wait for other nodes -SET SESSION wsrep_sync_wait=1; -execute stmt_show; -execute stmt_select; ---error ER_UNKNOWN_COM_ERROR -execute stmt_insert; - -SET SESSION wsrep_sync_wait=7; -execute stmt_show; -execute stmt_select; ---error ER_UNKNOWN_COM_ERROR -execute stmt_insert; - ---connection node_2 -SET @@global.wsrep_dirty_reads=OFF; +SELECT COUNT(*) >= 10 FROM performance_schema.events_statements_history; --disable_query_log --eval SET @@global.wsrep_cluster_address = '$wsrep_cluster_address_saved' @@ -108,14 +60,10 @@ SET @@global.wsrep_dirty_reads=OFF; --source include/wait_until_connected_again.inc --connection node_1 +USE test; SELECT * FROM t1; # Cleanup DROP TABLE t1; -drop user user1; -drop user user2; - -# Restore original auto_increment_offset values. ---source include/auto_increment_offset_restore.inc --source include/galera_end.inc --echo # End of test diff --git a/mysql-test/suite/sys_vars/r/wsrep_sync_wait_basic.result b/mysql-test/suite/sys_vars/r/wsrep_sync_wait_basic.result index 1e7b9364570..0df3dff8990 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_sync_wait_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_sync_wait_basic.result @@ -34,11 +34,9 @@ SELECT @@session.wsrep_sync_wait; @@session.wsrep_sync_wait 7 SET @@session.wsrep_sync_wait=8; -Warnings: -Warning 1292 Truncated incorrect wsrep_sync_wait value: '8' SELECT @@session.wsrep_sync_wait; @@session.wsrep_sync_wait -7 +8 # invalid values SET @@global.wsrep_sync_wait=NULL; From 7ce37d97574963a852e398142eb4b5090740f1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 16 Aug 2017 10:14:19 +0300 Subject: [PATCH 046/101] Move galera_ist_progress and galera_ist_restart_joiner tests under big_test. This is because they could cause out of storage if run on /dev/shm. --- mysql-test/suite/galera/t/galera_ist_progress.test | 2 ++ mysql-test/suite/galera/t/galera_ist_restart_joiner.test | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/suite/galera/t/galera_ist_progress.test b/mysql-test/suite/galera/t/galera_ist_progress.test index a4d331b37d7..3ba63415c28 100644 --- a/mysql-test/suite/galera/t/galera_ist_progress.test +++ b/mysql-test/suite/galera/t/galera_ist_progress.test @@ -3,6 +3,8 @@ # --source include/galera_cluster.inc +# This could cause out of storage if run /dev/shm +--source include/big_test.inc # Isolate node #2 --connection node_2 diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test index e007e71f1ee..633318629a6 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -8,6 +8,8 @@ --source include/have_innodb.inc --source include/have_debug_sync.inc --source suite/galera/include/galera_have_debug_sync.inc +# This could cause out of storage if run /dev/shm +--source include/big_test.inc # Save original auto_increment_offset values. --let $node_1=node_1 From 0a479f786020d3c1431a25523661759748404770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 16 Aug 2017 13:10:01 +0300 Subject: [PATCH 047/101] More test failure fixes. --- mysql-test/suite/galera/disabled.def | 1 + mysql-test/suite/galera/r/galera_var_node_address.result | 1 + mysql-test/suite/galera/r/pxc-421.result | 3 +++ mysql-test/suite/galera/t/galera_var_node_address.test | 2 ++ mysql-test/suite/galera/t/pxc-421.test | 5 +++++ 5 files changed, 12 insertions(+) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 59f1ec37986..84d2b1c54bf 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -44,3 +44,4 @@ galera.galera_wan : MDEV-12319 #Failed to start mysqld galera.rpl_row_annotate : MDEV-12319 #Failed to start mysqld galera.MW-44 : MDEV-12319 galera.galera_var_slave_threads : MDEV-12319 +MW-336: MDEV-13549 Galera test failures diff --git a/mysql-test/suite/galera/r/galera_var_node_address.result b/mysql-test/suite/galera/r/galera_var_node_address.result index b562883176a..cf36e964f93 100644 --- a/mysql-test/suite/galera/r/galera_var_node_address.result +++ b/mysql-test/suite/galera/r/galera_var_node_address.result @@ -1,4 +1,5 @@ call mtr.add_suppression("WSREP: Stray state UUID msg: .* current group state WAIT_STATE_UUID .*"); +call mtr.add_suppression("WSREP: Protocol violation. JOIN message sender .* is not in state transfer (.*). Message ignored."); SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 4 1 diff --git a/mysql-test/suite/galera/r/pxc-421.result b/mysql-test/suite/galera/r/pxc-421.result index 1822201f338..f5c0fabcd6e 100644 --- a/mysql-test/suite/galera/r/pxc-421.result +++ b/mysql-test/suite/galera/r/pxc-421.result @@ -6,6 +6,7 @@ set GLOBAL wsrep_slave_threads=16; SET GLOBAL wsrep_provider='none'; INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (3); +set SESSION wsrep_sync_wait=0; INSERT INTO t1 VALUES (4); set GLOBAL wsrep_slave_threads=5; SELECT COUNT(*) = 5 FROM t1; @@ -25,6 +26,7 @@ SET GLOBAL wsrep_slave_threads = 1; SELECT COUNT(*) FROM t1; COUNT(*) 16 +SET GLOBAL auto_increment_offset = 2; SELECT COUNT(*) FROM t1; COUNT(*) 15 @@ -33,3 +35,4 @@ Variable_name Value wsrep_slave_threads 12 SET GLOBAL wsrep_slave_threads = 1; DROP TABLE t1; +SET GLOBAL auto_increment_offset = 1; diff --git a/mysql-test/suite/galera/t/galera_var_node_address.test b/mysql-test/suite/galera/t/galera_var_node_address.test index c2105823326..3353652d8b9 100644 --- a/mysql-test/suite/galera/t/galera_var_node_address.test +++ b/mysql-test/suite/galera/t/galera_var_node_address.test @@ -7,6 +7,8 @@ --source include/have_innodb.inc call mtr.add_suppression("WSREP: Stray state UUID msg: .* current group state WAIT_STATE_UUID .*"); +call mtr.add_suppression("WSREP: Protocol violation. JOIN message sender .* is not in state transfer (.*). Message ignored."); + SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --connection node_1 diff --git a/mysql-test/suite/galera/t/pxc-421.test b/mysql-test/suite/galera/t/pxc-421.test index 8a360b12f4c..381f9bb4494 100644 --- a/mysql-test/suite/galera/t/pxc-421.test +++ b/mysql-test/suite/galera/t/pxc-421.test @@ -31,6 +31,7 @@ INSERT INTO t1 VALUES (3); --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; --enable_query_log +set SESSION wsrep_sync_wait=0; --source include/wait_until_connected_again.inc --source include/galera_wait_ready.inc @@ -53,8 +54,12 @@ show global variables like 'wsrep_slave_threads'; --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_2 SELECT COUNT(*) FROM t1; +SET GLOBAL auto_increment_offset = 2; + --connection node_1 SELECT COUNT(*) FROM t1; show global variables like 'wsrep_slave_threads'; --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_1 DROP TABLE t1; + +SET GLOBAL auto_increment_offset = 1; From 109b8582583296c4bb4ee41bc7649f6cd2254124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 17 Aug 2017 07:19:12 +0300 Subject: [PATCH 048/101] MDEV-13432: Assertion failure in buf0rea.cc line 577 Page read could return DB_PAGE_CORRUPTED error that should be reported and passed to upper layer. In case of unknown error code we should print both number and string. --- storage/innobase/buf/buf0rea.cc | 23 +++++++++++++---------- storage/xtradb/buf/buf0rea.cc | 20 ++++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 5525d8dd534..d2a48975905 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -378,13 +378,14 @@ read_ahead: space, i); break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Random readahead failed to decrypt page " - ULINTPF "." ULINTPF " .", + "Random readahead failed to decrypt page or page corrupted " + ULINTPF ":" ULINTPF " .", space, i); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in random readahead", err, ut_strerr(err)); } } } @@ -514,15 +515,15 @@ buf_read_page_async( " in nonexisting or being-dropped tablespace", space, offset); break; - case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Async page read failed to decrypt page " + "Async page read failed to decrypt page or page corrupted " ULINTPF ":" ULINTPF ".", space, offset); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in async page read", err, ut_strerr(err)); } srv_stats.buf_pool_reads.add(count); @@ -798,13 +799,14 @@ buf_read_ahead_linear( space, i); break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Linear readahead failed to decrypt page " + "Linear readahead failed to decrypt page or page corrupted" ULINTPF ":" ULINTPF ".", space, i); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in linear readahead", err, ut_strerr(err)); } } } @@ -901,13 +903,14 @@ tablespace_deleted: zip_size, FALSE); break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Failed to decrypt insert buffer page " + "Failed to decrypt insert buffer page or page corrupted " ULINTPF ":" ULINTPF ".", space_ids[i], page_nos[i]); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in insert buffer read", err, ut_strerr(err)); } } diff --git a/storage/xtradb/buf/buf0rea.cc b/storage/xtradb/buf/buf0rea.cc index b2b737b8d40..76b71550710 100644 --- a/storage/xtradb/buf/buf0rea.cc +++ b/storage/xtradb/buf/buf0rea.cc @@ -428,13 +428,14 @@ read_ahead: space, i); break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Random readahead failed to decrypt page " + "Random readahead failed to decrypt page or page corrupted " ULINTPF ":" ULINTPF ".", i, space); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in random readahead", err, ut_strerr(err)); } } } @@ -570,13 +571,14 @@ buf_read_page_async( break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Async page read failed to decrypt page " + "Async page read failed to decrypt page or page corrupted " ULINTPF ":" ULINTPF ".", space, offset); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in async page read", err, ut_strerr(err)); } srv_stats.buf_pool_reads.add(count); @@ -863,13 +865,14 @@ buf_read_ahead_linear( break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Linear readahead failed to decrypt page " + "Linear readahead failed to decrypt page or page corrupted" ULINTPF ":" ULINTPF ".", i, space); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in linear readahead", err, ut_strerr(err)); } } } @@ -963,13 +966,14 @@ tablespace_deleted: ibuf_delete_for_discarded_space(space_ids[i]); break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Failed to decrypt insert buffer page " + "Failed to decrypt insert buffer page or page corrupted " ULINTPF ":" ULINTPF ".", space_ids[i], page_nos[i]); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in insert buffer read", err, ut_strerr(err)); } } From 06106c01481401b6d7ef4309391ca2f66242cc85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 17 Aug 2017 16:13:32 +0300 Subject: [PATCH 049/101] MDEV-12988 backup fails if innodb_undo_tablespaces>0 srv_undo_tablespaces_init(): In Mariabackup backup mode, do initialize the array of undo_tablespace_ids[]. --- storage/xtradb/srv/srv0start.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index fdb136ef67e..aab0bc9282b 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -1491,6 +1491,18 @@ srv_undo_tablespaces_init( n_undo_tablespaces = n_conf_tablespaces; undo_tablespace_ids[n_conf_tablespaces] = ULINT_UNDEFINED; + + if (backup_mode) { + ut_ad(!create_new_db); + /* MDEV-13561 FIXME: Determine srv_undo_space_id_start + from the undo001 file. */ + srv_undo_space_id_start = 1; + + for (i = 0; i < n_undo_tablespaces; i++) { + undo_tablespace_ids[i] + = i + srv_undo_space_id_start; + } + } } /* Open all the undo tablespaces that are currently in use. If we From ce6c0e584e35b516297f2afdaea5b31e508b7570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 27 Jul 2017 13:17:13 +0300 Subject: [PATCH 050/101] MDEV-8960: Can't refer the same column twice in one ALTER TABLE Problem was that if column was created in alter table when it was refered again it was not tried to find from list of current columns. mysql_prepare_alter_table: There is two cases (1) If alter table adds a new column and then later alter changes the field definition, there was no check from list of new columns, instead an incorrect error was given. (2) If alter table adds a new column and then later alter changes the default, there was no check from list of new columns, instead an incorrect error was given. --- mysql-test/r/alter_table.result | 52 +++++++++++++++++++++++++++++++++ mysql-test/t/alter_table.test | 42 ++++++++++++++++++++++++++ sql/sql_table.cc | 45 ++++++++++++++++++++++++++-- 3 files changed, 136 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index cac4c477b5a..5f5e813a302 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -2112,3 +2112,55 @@ t1 CREATE TABLE `t1` ( `b` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 DROP TABLE t1; +# +# MDEV-8960 Can't refer the same column twice in one ALTER TABLE +# +CREATE TABLE t1 ( +`a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL, +ALTER COLUMN `consultant_id` DROP DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `consultant_id` int(11) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; +CREATE TABLE t1 ( +`a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL, +ALTER COLUMN `consultant_id` SET DEFAULT 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `consultant_id` int(11) NOT NULL DEFAULT '2' +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; +CREATE TABLE t1 ( +`a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL DEFAULT 2, +ALTER COLUMN `consultant_id` DROP DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `consultant_id` int(11) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; +CREATE TABLE t1 ( +`a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL DEFAULT 2, +ALTER COLUMN `consultant_id` DROP DEFAULT, +MODIFY COLUMN `consultant_id` BIGINT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `consultant_id` bigint(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 3670e871bb0..e252b606860 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -1767,3 +1767,45 @@ SHOW CREATE TABLE t1; ALTER TABLE t1 CONVERT TO CHARACTER SET utf8; SHOW CREATE TABLE t1; DROP TABLE t1; + +--echo # +--echo # MDEV-8960 Can't refer the same column twice in one ALTER TABLE +--echo # + +CREATE TABLE t1 ( + `a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; + +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL, +ALTER COLUMN `consultant_id` DROP DEFAULT; + +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 ( + `a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; + +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL, +ALTER COLUMN `consultant_id` SET DEFAULT 2; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 ( + `a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; + +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL DEFAULT 2, +ALTER COLUMN `consultant_id` DROP DEFAULT; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 ( + `a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; + +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL DEFAULT 2, +ALTER COLUMN `consultant_id` DROP DEFAULT, +MODIFY COLUMN `consultant_id` BIGINT; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2eff8fd5e2f..3ba3ec6847e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7503,9 +7503,25 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, { if (def->change && ! def->field) { - my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, - table->s->table_name.str); - goto err; + /* + Check if there is modify for newly added field. + */ + Create_field *find; + find_it.rewind(); + while((find=find_it++)) + { + if (!my_strcasecmp(system_charset_info,find->field_name, def->field_name)) + break; + } + + if (find && !find->field) + find_it.remove(); + else + { + my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, + table->s->table_name.str); + goto err; + } } /* Check that the DATE/DATETIME not null field we are going to add is @@ -7571,6 +7587,29 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, find_it.after(def); // Put column after this } } + /* + Check if there is alter for newly added field. + */ + alter_it.rewind(); + Alter_column *alter; + while ((alter=alter_it++)) + { + if (!my_strcasecmp(system_charset_info,def->field_name, alter->name)) + break; + } + if (alter) + { + if (def->sql_type == MYSQL_TYPE_BLOB) + { + my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), def->change); + goto err; + } + if ((def->def=alter->def)) // Use new default + def->flags&= ~NO_DEFAULT_VALUE_FLAG; + else + def->flags|= NO_DEFAULT_VALUE_FLAG; + alter_it.remove(); + } } if (alter_info->alter_list.elements) { From f7e1b99895d2f23164a995c89b4b9e9c9a9c5a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 16 Aug 2017 13:29:38 +0300 Subject: [PATCH 051/101] Galera test fixes and add remaining test failures as disabled. --- mysql-test/suite/galera/disabled.def | 90 +++++++++---------- mysql-test/suite/galera/r/galera#414.result | 2 + .../galera/r/galera_var_dirty_reads.result | 2 + .../r/galera_wsrep_provider_unset_set.result | 1 + mysql-test/suite/galera/suite.pm | 6 ++ mysql-test/suite/galera/t/galera#414.test | 6 ++ .../suite/galera/t/galera_ist_mysqldump.cnf | 1 + .../suite/galera/t/galera_ist_recv_bind.test | 1 + .../suite/galera/t/galera_ist_rsync.cnf | 2 + .../suite/galera/t/galera_ist_rsync.test | 5 ++ .../t/galera_restart_on_unknown_option.test | 7 ++ mysql-test/suite/galera/t/galera_ssl.test | 1 + .../galera/t/galera_ssl_compression.test | 1 + .../galera/t/galera_var_dirty_reads.test | 4 + .../t/galera_wsrep_provider_unset_set.test | 9 ++ mysql-test/suite/galera_3nodes/disabled.def | 7 +- mysql-test/suite/wsrep/disabled.def | 2 +- 17 files changed, 93 insertions(+), 54 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 84d2b1c54bf..22fb3c4f12d 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -1,47 +1,43 @@ -galera_wsrep_provider_unset_set : lp1379204 'Unsupported protocol downgrade: incremental data collection disabled. Expect abort.' -galera_kill_nochanges : mysql-wsrep#24 Galera server does not restart properly if killed -galera_bf_abort_for_update : mysql-wsrep#26 SELECT FOR UPDATE sometimes allowed to proceed in the face of a concurrent update -galera_toi_ddl_fk_insert : qa#39 galera_toi_ddl_fk_insert fails sporadically -galera_binlog_row_image : MDEV-7471 - Enable binlog_row_image parameter in MariaDB -galera_binlog_rows_query_log_events : Unknown system variable 'binlog_rows_query_log_events' (see annotate_rows_log_event) - -galera_ist_mysqldump : Lost connection to MySQL server during query -galera_ist_xtrabackup-v2 : mysqltest failed but provided no output -galera_ist_innodb_flush_logs : mysqltest failed but provided no output -galera_sst_mysqldump : query 'show status' failed with wrong errno 1927 -galera_as_master_gtid : Needs to be re-worked -galera_as_master_gtid_change_master : Needs to be re-worked -galera_migrate : query 'let $success= `$wait_condition`' failed: 1146 -galera_var_notify_cmd : Result content mismatch -query_cache : Fails intermittently due to content mismatch. Needs to be investigated -basic : Fails intermittently without providing any output. Needs to be investigated -galera_var_auto_inc_control_on : Failing sporadically with content mismatch -galera_parallel_simple : Failing sporadically -galera_bf_abort : Failing sporadically -galera_log_output_csv : Failing sporadically -galera_as_slave_preordered : wsrep-preordered is not available in MariaDB Galera cluster -galera_gra_log : TODO: investigate -galera_as_slave_replication_bundle : TODO: investigate -galera_ssl_upgrade : TODO: investigate -mysql-wsrep#90 : TODO: investigate -galera_flush : mysql-wsrep/issues/229 -galera_transaction_read_only : mysql-wsrep/issues/229 -galera_gcs_fragment : Incorrect arguments to SET -galera_flush_local : Fails sporadically -galera_binlog_stmt_autoinc : TODO: investigate -galera_concurrent_ctas : Test times out, investigate -galera_sst_xtrabackup-v2-options : TODO: Fix test case -mysql-wsrep#33 : TODO: investigate -GAL-480 : Investigate -galera_fk_no_pk :Investigate -galera_account_management : Investigate -galera.galera_var_retry_autocommit : MDEV-12319 #Sparodic Faliure -galera.galera_toi_ddl_nonconflicting : MDEV-12319 #Sparodic Faliure -galera.galera_pc_ignore_sb : MDEV-12319 #Sparodic Faliure -galera.galera_ist_recv_bind : MDEV-12319 #Failed to start mysqld -galera.galera_ssl_compression : MDEV-12319 #Failed to start mysqld -galera.galera_wan : MDEV-12319 #Failed to start mysqld -galera.rpl_row_annotate : MDEV-12319 #Failed to start mysqld -galera.MW-44 : MDEV-12319 -galera.galera_var_slave_threads : MDEV-12319 -MW-336: MDEV-13549 Galera test failures +############################################################################## +# +# List the test cases that are to be disabled temporarily. +# +# Separate the test case name and the comment with ':'. +# +# : MDEV- +# +# Do not use any TAB characters for whitespace. +# +############################################################################## +MW-336 : MDEV-13549 Galera test failures +galera_gra_log : MDEV-13549 Galera test failures +galera_flush_local : MDEV-13549 Galera test failures +galera_flush : MDEV-13549 Galera test failures +MW-329 : MDEV-13549 Galera test failures +galera_account_management : MariaDB 10.0 does not support ALTER USER +galera_binlog_row_image : MariaDB 10.0 does not support binlog_row_image +galera_binlog_rows_query_log_events: MariaDB does not support binlog_rows_query_log_events +GAL-419 : MDEV-13549 Galera test failures +galera_toi_ddl_fk_insert : MDEV-13549 Galera test failures +galera_var_notify_cmd : MDEV-13549 Galera test failures +galera_var_slave_threads : MDEV-13549 Galera test failures +mysql-wsrep#90 : MDEV-13549 Galera test failures +galera_as_master_gtid : Requires MySQL GTID +galera_as_master_gtid_change_master : Requires MySQL GTID +galera_as_slave_replication_bundle : MDEV-13549 Galera test failures +galera_as_slave_preordered : wsrep-preordered feature not merged to MariaDB +galera_gcs_fragment : MDEV-13549 Galera test failures +galera_gcache_recover : MDEV-13549 Galera test failures +galera_gcache_recover_full_gcache : MDEV-13549 Galera test failures +galera_gcache_recover_manytrx : MDEV-13549 Galera test failures +galera_ist_mysqldump : MDEV-13549 Galera test failures +mysql-wsrep#31 : MDEV-13549 Galera test failures +galera_migrate : MariaDB 10.0 does not support START SLAVE USER +galera_concurrent_ctas : MDEV-13549 Galera test failures +galera_bf_abort_for_update : MDEV-13549 Galera test failures +galera_wsrep_desync_wsrep_on : MDEV-13549 Galera test failures +galera_ssl_upgrade : MDEV-13549 Galera test failures +mysql-wsrep#33 : MDEV-13549 Galera test failures +galera_var_auto_inc_control_on : MDEV-13549 Galera test failures +MW-44 : MDEV-13549 Galera test failures +galera_var_retry_autocommit : MDEV-13549 Galera test failures \ No newline at end of file diff --git a/mysql-test/suite/galera/r/galera#414.result b/mysql-test/suite/galera/r/galera#414.result index 029961f9463..5bb22587241 100644 --- a/mysql-test/suite/galera/r/galera#414.result +++ b/mysql-test/suite/galera/r/galera#414.result @@ -2,4 +2,6 @@ SET SESSION wsrep_sync_wait = 0; SET SESSION wsrep_on = OFF; SET SESSION wsrep_on = ON; CALL mtr.add_suppression("Failed to set packet size"); +set GLOBAL auto_increment_offset = 1; CALL mtr.add_suppression("Failed to set packet size"); +set GLOBAL auto_increment_offset = 2; diff --git a/mysql-test/suite/galera/r/galera_var_dirty_reads.result b/mysql-test/suite/galera/r/galera_var_dirty_reads.result index 405d86b3027..c469e49731d 100644 --- a/mysql-test/suite/galera/r/galera_var_dirty_reads.result +++ b/mysql-test/suite/galera/r/galera_var_dirty_reads.result @@ -42,4 +42,6 @@ SELECT * FROM t1; i 1 DROP TABLE t1; +set GLOBAL auto_increment_offset = 1; +set GLOBAL auto_increment_offset = 2; # End of test diff --git a/mysql-test/suite/galera/r/galera_wsrep_provider_unset_set.result b/mysql-test/suite/galera/r/galera_wsrep_provider_unset_set.result index 681e4606b38..89110b48def 100644 --- a/mysql-test/suite/galera/r/galera_wsrep_provider_unset_set.result +++ b/mysql-test/suite/galera/r/galera_wsrep_provider_unset_set.result @@ -3,6 +3,7 @@ INSERT INTO t1 VALUES (1); SET GLOBAL wsrep_provider='none'; INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (3); +SET SESSION wsrep_sync_wait = 0; INSERT INTO t1 VALUES (4); SELECT COUNT(*) = 4 FROM t1; COUNT(*) = 4 diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index 5b69ff26615..c366ec7c136 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -19,6 +19,9 @@ $ENV{WSREP_PROVIDER} = $provider; my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$::bindir/scripts", $::path_client_bindir; return "No SST scripts" unless $spath; +my ($cpath) = grep { -f "$_/mysql"; } "$::bindir/scripts", $::path_client_bindir; +return "No scritps" unless $cpath; + my ($epath) = grep { -f "$_/my_print_defaults"; } "$::bindir/extra", $::path_client_bindir; return "No my_print_defaults" unless $epath; @@ -67,6 +70,8 @@ push @::global_suppressions, qr(WSREP: TO isolation failed for: .*), qr|WSREP: gcs_caused\(\) returned .*|, qr|WSREP: Protocol violation. JOIN message sender .* is not in state transfer \(SYNCED\). Message ignored.|, + qr|WSREP: Protocol violation. JOIN message sender .* is not in state transfer \(JOINED\). Message ignored.|, + qr|WSREP: Unsupported protocol downgrade: incremental data collection disabled. Expect abort.|, qr(WSREP: Action message in non-primary configuration from member [0-9]*), qr(WSREP: discarding established .*), ); @@ -74,6 +79,7 @@ push @::global_suppressions, $ENV{PATH}="$epath:$ENV{PATH}"; $ENV{PATH}="$spath:$ENV{PATH}" unless $epath eq $spath; +$ENV{PATH}="$cpath:$ENV{PATH}" unless $cpath eq $spath; bless { }; diff --git a/mysql-test/suite/galera/t/galera#414.test b/mysql-test/suite/galera/t/galera#414.test index dccb28e4054..de10898df42 100644 --- a/mysql-test/suite/galera/t/galera#414.test +++ b/mysql-test/suite/galera/t/galera#414.test @@ -6,6 +6,11 @@ --source include/have_innodb.inc --source include/galera_cluster.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + # We perform the shutdown/restart sequence in here. If there was a crash during shutdown, MTR will detect it --connection node_2 @@ -35,3 +40,4 @@ CALL mtr.add_suppression("Failed to set packet size"); --source include/wait_condition.inc CALL mtr.add_suppression("Failed to set packet size"); +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf b/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf index db6b7d5e129..357c8678658 100644 --- a/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf +++ b/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf @@ -9,3 +9,4 @@ wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' [mysqld.2] wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_ist_recv_bind.test b/mysql-test/suite/galera/t/galera_ist_recv_bind.test index cb7329073ad..a339684c158 100644 --- a/mysql-test/suite/galera/t/galera_ist_recv_bind.test +++ b/mysql-test/suite/galera/t/galera_ist_recv_bind.test @@ -5,6 +5,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/big_test.inc --connection node_1 SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; diff --git a/mysql-test/suite/galera/t/galera_ist_rsync.cnf b/mysql-test/suite/galera/t/galera_ist_rsync.cnf index bbe0f6047fb..797e3651967 100644 --- a/mysql-test/suite/galera/t/galera_ist_rsync.cnf +++ b/mysql-test/suite/galera/t/galera_ist_rsync.cnf @@ -5,7 +5,9 @@ wsrep_sst_method=rsync [mysqld.1] wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' +wsrep_sync_wait=1 [mysqld.2] wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' +wsrep_sync_wait=1 diff --git a/mysql-test/suite/galera/t/galera_ist_rsync.test b/mysql-test/suite/galera/t/galera_ist_rsync.test index 41d1a0c1fc2..1da79cd4214 100644 --- a/mysql-test/suite/galera/t/galera_ist_rsync.test +++ b/mysql-test/suite/galera/t/galera_ist_rsync.test @@ -2,7 +2,12 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --source suite/galera/include/galera_st_disconnect_slave.inc --source suite/galera/include/galera_st_shutdown_slave.inc --source suite/galera/include/galera_st_kill_slave.inc --source suite/galera/include/galera_st_kill_slave_ddl.inc +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test index 2f27678b547..a8ea639415d 100644 --- a/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test +++ b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test @@ -6,6 +6,11 @@ CALL mtr.add_suppression("Aborting"); CALL mtr.add_suppression("unknown option '--galera-unknown-option'"); +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + # # We should count the number of "Assertion failed" warnings # in the log file before and after testing. To do this we need @@ -148,3 +153,5 @@ DROP TABLE t1; } EOF --remove_file $TEST_LOG.copy + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_ssl.test b/mysql-test/suite/galera/t/galera_ssl.test index 8dc94dc1966..e6346aa2151 100644 --- a/mysql-test/suite/galera/t/galera_ssl.test +++ b/mysql-test/suite/galera/t/galera_ssl.test @@ -8,6 +8,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/big_test.inc SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; diff --git a/mysql-test/suite/galera/t/galera_ssl_compression.test b/mysql-test/suite/galera/t/galera_ssl_compression.test index cdecf4807d4..75f92c5b2f4 100644 --- a/mysql-test/suite/galera/t/galera_ssl_compression.test +++ b/mysql-test/suite/galera/t/galera_ssl_compression.test @@ -7,6 +7,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/big_test.inc SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; diff --git a/mysql-test/suite/galera/t/galera_var_dirty_reads.test b/mysql-test/suite/galera/t/galera_var_dirty_reads.test index 183c60753ad..152c875a946 100644 --- a/mysql-test/suite/galera/t/galera_var_dirty_reads.test +++ b/mysql-test/suite/galera/t/galera_var_dirty_reads.test @@ -64,6 +64,10 @@ USE test; SELECT * FROM t1; # Cleanup DROP TABLE t1; +set GLOBAL auto_increment_offset = 1; + +--connection node_2 +set GLOBAL auto_increment_offset = 2; --source include/galera_end.inc --echo # End of test diff --git a/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test b/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test index fe4c358bd89..7f91495fcc4 100644 --- a/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test +++ b/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test @@ -6,6 +6,11 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + --connection node_1 CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); @@ -26,6 +31,8 @@ INSERT INTO t1 VALUES (3); --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; --enable_query_log +SET SESSION wsrep_sync_wait = 0; + --source include/wait_until_connected_again.inc --source include/galera_wait_ready.inc @@ -39,3 +46,5 @@ SELECT COUNT(*) = 4 FROM t1; SELECT COUNT(*) = 3 FROM t1; DROP TABLE t1; + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index 502e7bfba68..a9b9b00b40c 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -1,8 +1,3 @@ -galera_garbd : Fix the test case -galera_evs_suspect_timeout : TODO: investigate -galera_innobackupex_backup : TODO: investigate galera_slave_options_do :MDEV-8798 galera_slave_options_ignore : MDEV-8798 -galera_pc_bootstrap : TODO: Investigate: Timeout in wait_condition.inc -galera_pc_weight : Test times out -galera_safe_to_bootstrap : I Really dont know :( + diff --git a/mysql-test/suite/wsrep/disabled.def b/mysql-test/suite/wsrep/disabled.def index 605f063f967..8b137891791 100644 --- a/mysql-test/suite/wsrep/disabled.def +++ b/mysql-test/suite/wsrep/disabled.def @@ -1 +1 @@ -foreign_key : MDEV-7915 + From 449a996c6ae5a92818e375ff10f8bc7217d5ffb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Sat, 19 Aug 2017 07:52:31 +0300 Subject: [PATCH 052/101] Add more disabled tests and one ignored warning. --- mysql-test/suite/galera/disabled.def | 5 ++++- mysql-test/suite/galera/suite.pm | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 22fb3c4f12d..9abc06f235e 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -40,4 +40,7 @@ galera_ssl_upgrade : MDEV-13549 Galera test failures mysql-wsrep#33 : MDEV-13549 Galera test failures galera_var_auto_inc_control_on : MDEV-13549 Galera test failures MW-44 : MDEV-13549 Galera test failures -galera_var_retry_autocommit : MDEV-13549 Galera test failures \ No newline at end of file +galera_var_retry_autocommit : MDEV-13549 Galera test failures +pxc-421 : MDEV-13549 Galera test failures +lp1376747-2 : MDEV-13549 Galera test failures +lp1376747 : MDEV-13549 Galera test failures \ No newline at end of file diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index c366ec7c136..501fe842298 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -74,6 +74,7 @@ push @::global_suppressions, qr|WSREP: Unsupported protocol downgrade: incremental data collection disabled. Expect abort.|, qr(WSREP: Action message in non-primary configuration from member [0-9]*), qr(WSREP: discarding established .*), + qr(WSREP: gcs\/src\/gcs_core.cpp:core_handle_uuid_msg\(\):.*: STATE EXCHANGE: failed for: .*: .* \(Transport endpoint is not connected\)), ); From d20923debb231cf26e0fb6a6dddbf4e02bb1fc86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Sun, 20 Aug 2017 07:49:07 +0300 Subject: [PATCH 053/101] Add more disabled test. --- mysql-test/suite/galera/disabled.def | 4 +++- mysql-test/suite/galera/suite.pm | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 9abc06f235e..38421dbd2ea 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -43,4 +43,6 @@ MW-44 : MDEV-13549 Galera test failures galera_var_retry_autocommit : MDEV-13549 Galera test failures pxc-421 : MDEV-13549 Galera test failures lp1376747-2 : MDEV-13549 Galera test failures -lp1376747 : MDEV-13549 Galera test failures \ No newline at end of file +lp1376747 : MDEV-13549 Galera test failures +galera_toi_ddl_nonconflicting : MDEV-13549 Galera test failures +galera_parallel_simple : MDEV-13549 Galera test failures diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index 501fe842298..d5de3628f75 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -74,7 +74,7 @@ push @::global_suppressions, qr|WSREP: Unsupported protocol downgrade: incremental data collection disabled. Expect abort.|, qr(WSREP: Action message in non-primary configuration from member [0-9]*), qr(WSREP: discarding established .*), - qr(WSREP: gcs\/src\/gcs_core.cpp:core_handle_uuid_msg\(\):.*: STATE EXCHANGE: failed for: .*: .* \(Transport endpoint is not connected\)), + qr(WSREP: gcs\/src\/gcs_core.cpp:core_handle_uuid_msg\(\):.*), ); From f1af2114993f884b1a6dc34fb1d972ead08f1966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 21 Aug 2017 07:11:04 +0300 Subject: [PATCH 054/101] Add galera_admin to disabled. --- mysql-test/suite/galera/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 38421dbd2ea..f9909914089 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -46,3 +46,4 @@ lp1376747-2 : MDEV-13549 Galera test failures lp1376747 : MDEV-13549 Galera test failures galera_toi_ddl_nonconflicting : MDEV-13549 Galera test failures galera_parallel_simple : MDEV-13549 Galera test failures +galera_admin : MDEV-13549 Galera test failures From 0aeff8c36add46db1de4287a9461d084b148c31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 21 Aug 2017 14:48:30 +0300 Subject: [PATCH 055/101] Fix compiler error. --- sql/sql_parse.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 81b71f71760..f5721d2ca2f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3663,13 +3663,12 @@ end_with_restore_list: #endif /* EMBEDDED_LIBRARY */ case SQLCOM_SHOW_CREATE: { - DBUG_ASSERT(first_table == all_tables && first_table != 0); + DBUG_ASSERT(first_table == all_tables && first_table != 0); #ifdef DONT_ALLOW_SHOW_COMMANDS my_message(ER_NOT_ALLOWED_COMMAND, ER_THD(thd, ER_NOT_ALLOWED_COMMAND), MYF(0)); /* purecov: inspected */ goto error; #else - { WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); /* @@ -3892,7 +3891,6 @@ end_with_restore_list: DBUG_PRINT("debug", ("Just after generate_incident()")); } #endif - } /* fall through */ case SQLCOM_INSERT: { From 9af7561eb44a7465a8a72789678546b37da96eb8 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 21 Aug 2017 17:16:12 +0000 Subject: [PATCH 056/101] MDEV-13608 : set client plugin directory with mysql_options() if plugin_dir is specified. Also, allow to specify protocol (e.g pipe) --- extra/mariabackup/backup_mysql.cc | 5 +++ extra/mariabackup/xtrabackup.cc | 14 +++++++-- extra/mariabackup/xtrabackup.h | 2 ++ .../suite/mariabackup/auth_plugin_win.opt | 1 + .../suite/mariabackup/auth_plugin_win.result | 5 +++ .../suite/mariabackup/auth_plugin_win.test | 31 +++++++++++++++++++ 6 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/mariabackup/auth_plugin_win.opt create mode 100644 mysql-test/suite/mariabackup/auth_plugin_win.result create mode 100644 mysql-test/suite/mariabackup/auth_plugin_win.test diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 00fed457304..6f425e9419f 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -112,6 +112,11 @@ xb_mysql_connect() (char *) &opt_secure_auth); } + if (xb_plugin_dir && *xb_plugin_dir){ + mysql_options(connection, MYSQL_PLUGIN_DIR, xb_plugin_dir); + } + mysql_options(connection, MYSQL_OPT_PROTOCOL, &opt_protocol); + msg_ts("Connecting to MySQL server host: %s, user: %s, password: %s, " "port: %s, socket: %s\n", opt_host ? opt_host : "localhost", opt_user ? opt_user : "not set", diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 6a373f0cfd6..c746b469329 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -123,6 +123,7 @@ my_bool xtrabackup_apply_log_only = FALSE; longlong xtrabackup_use_memory = 100*1024*1024L; my_bool xtrabackup_create_ib_logfile = FALSE; +uint opt_protocol; long xtrabackup_throttle = 0; /* 0:unlimited */ lint io_ticket; os_event_t wait_throttle = NULL; @@ -560,6 +561,7 @@ enum options_xtrabackup OPT_XTRA_TABLES_EXCLUDE, OPT_XTRA_DATABASES_EXCLUDE, + OPT_PROTOCOL }; struct my_option xb_client_options[] = @@ -799,6 +801,9 @@ struct my_option xb_client_options[] = 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"protocol", OPT_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe, memory).", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"socket", 'S', "This option specifies the socket to use when " "connecting to the local database server with a UNIX domain socket. " "The option accepts a string argument. See mysql --help for details.", @@ -1364,8 +1369,13 @@ xb_get_one_option(int optid, start[1]=0 ; } break; - - + case OPT_PROTOCOL: + if (argument) + { + opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, + opt->name); + } + break; #include "sslopt-case.h" case '?': diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h index 455b85c4abc..3b2a25d451b 100644 --- a/extra/mariabackup/xtrabackup.h +++ b/extra/mariabackup/xtrabackup.h @@ -55,6 +55,8 @@ extern char *xtrabackup_incremental_dir; extern char *xtrabackup_incremental_basedir; extern char *innobase_data_home_dir; extern char *innobase_buffer_pool_filename; +extern char *xb_plugin_dir; +extern uint opt_protocol; extern ds_ctxt_t *ds_meta; extern ds_ctxt_t *ds_data; diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.opt b/mysql-test/suite/mariabackup/auth_plugin_win.opt new file mode 100644 index 00000000000..9e700db5f6f --- /dev/null +++ b/mysql-test/suite/mariabackup/auth_plugin_win.opt @@ -0,0 +1 @@ +--enable-named-pipe diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.result b/mysql-test/suite/mariabackup/auth_plugin_win.result new file mode 100644 index 00000000000..7a623be147f --- /dev/null +++ b/mysql-test/suite/mariabackup/auth_plugin_win.result @@ -0,0 +1,5 @@ +INSTALL SONAME 'auth_named_pipe'; +CREATE USER 'USERNAME' IDENTIFIED WITH named_pipe; +GRANT ALL PRIVILEGES ON *.* to USERNAME; +DROP USER 'USERNAME'; +UNINSTALL SONAME 'auth_named_pipe'; diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.test b/mysql-test/suite/mariabackup/auth_plugin_win.test new file mode 100644 index 00000000000..9c8cd5ad411 --- /dev/null +++ b/mysql-test/suite/mariabackup/auth_plugin_win.test @@ -0,0 +1,31 @@ +--source include/windows.inc +--source include/not_embedded.inc + +if (!$AUTH_NAMED_PIPE_SO) { + skip No named pipe plugin; +} + +if (!$USERNAME) { + skip USERNAME variable is undefined; +} + +if (`SELECT count(*) <> 0 FROM mysql.user WHERE user = '$USERNAME'`) { + skip \$USER=$USER which exists in mysql.user; +} + +INSTALL SONAME 'auth_named_pipe'; + +--replace_result $USERNAME USERNAME +eval CREATE USER '$USERNAME' IDENTIFIED WITH named_pipe; +--replace_result $USERNAME USERNAME +eval GRANT ALL PRIVILEGES ON *.* to $USERNAME; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf -u $USERNAME --backup --protocol=pipe --target-dir=$targetdir; +--enable_result_log +--replace_result $USERNAME USERNAME +eval DROP USER '$USERNAME'; +rmdir $targetdir; +UNINSTALL SONAME 'auth_named_pipe'; + From a00b74d994c43220ff6158c24064dfe90ff40e9a Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 22 Aug 2017 13:03:40 +0000 Subject: [PATCH 057/101] fix auth_plugin_win test prepend enable-named-pipe (windows-only) option in auth_plugin_win.opt with loose- prefix, to avoid warning on non-Windows. --- mysql-test/suite/mariabackup/auth_plugin_win.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.opt b/mysql-test/suite/mariabackup/auth_plugin_win.opt index 9e700db5f6f..e534ae1eae5 100644 --- a/mysql-test/suite/mariabackup/auth_plugin_win.opt +++ b/mysql-test/suite/mariabackup/auth_plugin_win.opt @@ -1 +1 @@ ---enable-named-pipe +--loose-enable-named-pipe From 97f9d3c08056f8b532118c0fb1b988df18db4f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Aug 2017 10:01:48 +0300 Subject: [PATCH 058/101] MDEV-13167 InnoDB key rotation is not skipping unused pages In key rotation, we must initialize unallocated but previously initialized pages, so that if encryption is enabled on a table, all clear-text data for the page will eventually be overwritten. But we should not rotate keys on pages that were never allocated after the data file was created. According to the latching order rules, after acquiring the tablespace latch, no page latches of previously allocated user pages may be acquired. So, key rotation should check the page allocation status after acquiring the page latch, not before. But, the latching order rules also prohibit accessing pages that were not allocated first, and then acquiring the tablespace latch. Such behaviour would indeed result in a deadlock when running the following tests: encryption.innodb_encryption-page-compression encryption.innodb-checksum-algorithm Because the key rotation is accessing potentially unallocated pages, it cannot reliably check if these pages were allocated. It can only check the page header. If the page number is zero, we can assume that the page is unallocated. fil_crypt_rotate_page(): Detect uninitialized pages by FIL_PAGE_OFFSET. Page 0 is never encrypted, and on other pages that are initialized, FIL_PAGE_OFFSET must contain the page number. fil_crypt_is_page_uninitialized(): Remove. It suffices to check the page number field in fil_crypt_rotate_page(). --- storage/innobase/fil/fil0crypt.cc | 68 +++++++++++++++---------------- storage/xtradb/fil/fil0crypt.cc | 68 +++++++++++++++---------------- 2 files changed, 64 insertions(+), 72 deletions(-) diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index b5b762c2cd9..683974d8920 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1649,20 +1649,6 @@ fil_crypt_find_page_to_rotate( return found; } -/*********************************************************************** -Check if a page is uninitialized (doesn't need to be rotated) -@param[in] frame Page to check -@param[in] zip_size zip_size or 0 -@return true if page is uninitialized, false if not. */ -static inline -bool -fil_crypt_is_page_uninitialized( - const byte *frame, - uint zip_size) -{ - return (buf_page_is_zeroes(frame, zip_size)); -} - #define fil_crypt_get_page_throttle(state,offset,mtr,sleeptime_ms) \ fil_crypt_get_page_throttle_func(state, offset, mtr, \ sleeptime_ms, __FILE__, __LINE__) @@ -1823,6 +1809,7 @@ fil_crypt_rotate_page( fil_space_crypt_t *crypt_data = space->crypt_data; ut_ad(space->n_pending_ops > 0); + ut_ad(offset > 0); /* In fil_crypt_thread where key rotation is done we have acquired space and checked that this space is not yet @@ -1851,31 +1838,40 @@ fil_crypt_rotate_page( byte* frame = buf_block_get_frame(block); uint kv = mach_read_from_4(frame+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - /* check if tablespace is closing after reading page */ - if (!space->is_stopping()) { + if (space->is_stopping()) { + /* The tablespace is closing (in DROP TABLE or + TRUNCATE TABLE or similar): avoid further access */ + } else if (!*reinterpret_cast(FIL_PAGE_OFFSET + + frame)) { + /* It looks like this page was never + allocated. Because key rotation is accessing + pages in a pattern that is unlike the normal + B-tree and undo log access pattern, we cannot + invoke fseg_page_is_free() here, because that + could result in a deadlock. If we invoked + fseg_page_is_free() and released the + tablespace latch before acquiring block->lock, + then the fseg_page_is_free() information + could be stale already. */ + ut_ad(kv == 0); + ut_ad(page_get_space_id(frame) == 0); + } else if (fil_crypt_needs_rotation( + crypt_data->encryption, + kv, key_state->key_version, + key_state->rotate_key_age)) { - if (kv == 0 && - fil_crypt_is_page_uninitialized(frame, zip_size)) { - ; - } else if (fil_crypt_needs_rotation( - crypt_data->encryption, - kv, key_state->key_version, - key_state->rotate_key_age)) { + modified = true; - modified = true; + /* force rotation by dummy updating page */ + mlog_write_ulint(frame + FIL_PAGE_SPACE_ID, + space_id, MLOG_4BYTES, &mtr); - /* force rotation by dummy updating page */ - mlog_write_ulint(frame + - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, - space_id, MLOG_4BYTES, &mtr); - - /* statistics */ - state->crypt_stat.pages_modified++; - } else { - if (crypt_data->is_encrypted()) { - if (kv < state->min_key_version_found) { - state->min_key_version_found = kv; - } + /* statistics */ + state->crypt_stat.pages_modified++; + } else { + if (crypt_data->is_encrypted()) { + if (kv < state->min_key_version_found) { + state->min_key_version_found = kv; } } diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index b5b762c2cd9..683974d8920 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -1649,20 +1649,6 @@ fil_crypt_find_page_to_rotate( return found; } -/*********************************************************************** -Check if a page is uninitialized (doesn't need to be rotated) -@param[in] frame Page to check -@param[in] zip_size zip_size or 0 -@return true if page is uninitialized, false if not. */ -static inline -bool -fil_crypt_is_page_uninitialized( - const byte *frame, - uint zip_size) -{ - return (buf_page_is_zeroes(frame, zip_size)); -} - #define fil_crypt_get_page_throttle(state,offset,mtr,sleeptime_ms) \ fil_crypt_get_page_throttle_func(state, offset, mtr, \ sleeptime_ms, __FILE__, __LINE__) @@ -1823,6 +1809,7 @@ fil_crypt_rotate_page( fil_space_crypt_t *crypt_data = space->crypt_data; ut_ad(space->n_pending_ops > 0); + ut_ad(offset > 0); /* In fil_crypt_thread where key rotation is done we have acquired space and checked that this space is not yet @@ -1851,31 +1838,40 @@ fil_crypt_rotate_page( byte* frame = buf_block_get_frame(block); uint kv = mach_read_from_4(frame+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - /* check if tablespace is closing after reading page */ - if (!space->is_stopping()) { + if (space->is_stopping()) { + /* The tablespace is closing (in DROP TABLE or + TRUNCATE TABLE or similar): avoid further access */ + } else if (!*reinterpret_cast(FIL_PAGE_OFFSET + + frame)) { + /* It looks like this page was never + allocated. Because key rotation is accessing + pages in a pattern that is unlike the normal + B-tree and undo log access pattern, we cannot + invoke fseg_page_is_free() here, because that + could result in a deadlock. If we invoked + fseg_page_is_free() and released the + tablespace latch before acquiring block->lock, + then the fseg_page_is_free() information + could be stale already. */ + ut_ad(kv == 0); + ut_ad(page_get_space_id(frame) == 0); + } else if (fil_crypt_needs_rotation( + crypt_data->encryption, + kv, key_state->key_version, + key_state->rotate_key_age)) { - if (kv == 0 && - fil_crypt_is_page_uninitialized(frame, zip_size)) { - ; - } else if (fil_crypt_needs_rotation( - crypt_data->encryption, - kv, key_state->key_version, - key_state->rotate_key_age)) { + modified = true; - modified = true; + /* force rotation by dummy updating page */ + mlog_write_ulint(frame + FIL_PAGE_SPACE_ID, + space_id, MLOG_4BYTES, &mtr); - /* force rotation by dummy updating page */ - mlog_write_ulint(frame + - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, - space_id, MLOG_4BYTES, &mtr); - - /* statistics */ - state->crypt_stat.pages_modified++; - } else { - if (crypt_data->is_encrypted()) { - if (kv < state->min_key_version_found) { - state->min_key_version_found = kv; - } + /* statistics */ + state->crypt_stat.pages_modified++; + } else { + if (crypt_data->is_encrypted()) { + if (kv < state->min_key_version_found) { + state->min_key_version_found = kv; } } From b8b3ba632b8596bb483420dc6da46925f1c9b094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Aug 2017 13:03:13 +0300 Subject: [PATCH 059/101] MDEV-13606 XA PREPARE transactions should survive innodb_force_recovery=1 or 2 When MySQL 5.0.3 introduced InnoDB support for two-phase commit, it also introduced the questionable logic to roll back XA PREPARE transactions on startup when innodb_force_recovery is 1 or 2. Remove this logic in order to avoid unwanted side effects when innodb_force_recovery is being set for other reasons. That is, XA PREPARE transactions will always remain in that state until InnoDB receives an explicit XA ROLLBACK or XA COMMIT request from the upper layer. At the time the logic was introduced in MySQL 5.0.3, there already was a startup parameter that is the preferred way of achieving the behaviour: --tc-heuristic-recover=ROLLBACK. --- mysql-test/suite/innodb/r/xa_recovery.result | 2 +- mysql-test/suite/innodb/t/xa_recovery.test | 5 +++ storage/innobase/trx/trx0trx.cc | 36 ++++++-------------- storage/xtradb/trx/trx0trx.cc | 36 ++++++-------------- 4 files changed, 26 insertions(+), 53 deletions(-) diff --git a/mysql-test/suite/innodb/r/xa_recovery.result b/mysql-test/suite/innodb/r/xa_recovery.result index 4441701f961..3b560b79657 100644 --- a/mysql-test/suite/innodb/r/xa_recovery.result +++ b/mysql-test/suite/innodb/r/xa_recovery.result @@ -4,7 +4,7 @@ XA START 'x'; UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x'; -# Kill and restart +# Kill and restart: --innodb-force-recovery=2 SELECT * FROM t1 LOCK IN SHARE MODE; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT * FROM t1; diff --git a/mysql-test/suite/innodb/t/xa_recovery.test b/mysql-test/suite/innodb/t/xa_recovery.test index f5c2b655545..d4f957c7bf4 100644 --- a/mysql-test/suite/innodb/t/xa_recovery.test +++ b/mysql-test/suite/innodb/t/xa_recovery.test @@ -15,7 +15,12 @@ connect (con1,localhost,root); XA START 'x'; UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x'; connection default; +# innodb_force_recovery=2 prevents the purge and tests that the fix of +# MDEV-13606 XA PREPARE transactions should survive innodb_force_recovery=1 or 2 +# is present. +--let $restart_parameters= --innodb-force-recovery=2 --source include/kill_and_restart_mysqld.inc +--let $restart_parameters= disconnect con1; connect (con1,localhost,root); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index f06d8c33183..c38c9bf7188 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -536,18 +537,9 @@ trx_resurrect_insert( "InnoDB: Transaction " TRX_ID_FMT " was in the" " XA prepared state.\n", trx->id); - if (srv_force_recovery == 0) { - - trx->state = TRX_STATE_PREPARED; - trx_sys->n_prepared_trx++; - trx_sys->n_prepared_recovered_trx++; - } else { - fprintf(stderr, - "InnoDB: Since innodb_force_recovery" - " > 0, we will rollback it anyway.\n"); - - trx->state = TRX_STATE_ACTIVE; - } + trx->state = TRX_STATE_PREPARED; + trx_sys->n_prepared_trx++; + trx_sys->n_prepared_recovered_trx++; } else { trx->state = TRX_STATE_COMMITTED_IN_MEMORY; } @@ -605,22 +597,14 @@ trx_resurrect_update_in_prepared_state( "InnoDB: Transaction " TRX_ID_FMT " was in the XA prepared state.\n", trx->id); - if (srv_force_recovery == 0) { - if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) { - trx_sys->n_prepared_trx++; - trx_sys->n_prepared_recovered_trx++; - } else { - ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED)); - } - - trx->state = TRX_STATE_PREPARED; + if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) { + trx_sys->n_prepared_trx++; + trx_sys->n_prepared_recovered_trx++; } else { - fprintf(stderr, - "InnoDB: Since innodb_force_recovery" - " > 0, we will rollback it anyway.\n"); - - trx->state = TRX_STATE_ACTIVE; + ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED)); } + + trx->state = TRX_STATE_PREPARED; } else { trx->state = TRX_STATE_COMMITTED_IN_MEMORY; } diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc index fd620ae6659..d3b1f1da054 100644 --- a/storage/xtradb/trx/trx0trx.cc +++ b/storage/xtradb/trx/trx0trx.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -714,18 +715,9 @@ trx_resurrect_insert( "InnoDB: Transaction " TRX_ID_FMT " was in the" " XA prepared state.\n", trx->id); - if (srv_force_recovery == 0) { - - trx->state = TRX_STATE_PREPARED; - trx_sys->n_prepared_trx++; - trx_sys->n_prepared_recovered_trx++; - } else { - fprintf(stderr, - "InnoDB: Since innodb_force_recovery" - " > 0, we will rollback it anyway.\n"); - - trx->state = TRX_STATE_ACTIVE; - } + trx->state = TRX_STATE_PREPARED; + trx_sys->n_prepared_trx++; + trx_sys->n_prepared_recovered_trx++; } else { trx->state = TRX_STATE_COMMITTED_IN_MEMORY; } @@ -783,22 +775,14 @@ trx_resurrect_update_in_prepared_state( "InnoDB: Transaction " TRX_ID_FMT " was in the XA prepared state.\n", trx->id); - if (srv_force_recovery == 0) { - if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) { - trx_sys->n_prepared_trx++; - trx_sys->n_prepared_recovered_trx++; - } else { - ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED)); - } - - trx->state = TRX_STATE_PREPARED; + if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) { + trx_sys->n_prepared_trx++; + trx_sys->n_prepared_recovered_trx++; } else { - fprintf(stderr, - "InnoDB: Since innodb_force_recovery" - " > 0, we will rollback it anyway.\n"); - - trx->state = TRX_STATE_ACTIVE; + ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED)); } + + trx->state = TRX_STATE_PREPARED; } else { trx->state = TRX_STATE_COMMITTED_IN_MEMORY; } From 5077cc0b1a0d82c55ce6b6ec643f04099d0e8416 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Wed, 23 Aug 2017 16:49:42 +0530 Subject: [PATCH 060/101] Fix Merge Error --- mysql-test/include/wait_wsrep_ready.inc | 5 ++++- mysql-test/suite/sys_vars/r/sysvars_wsrep.result | 2 +- mysql-test/suite/wsrep/t/mdev_6832.opt | 2 +- mysql-test/suite/wsrep/t/mdev_7798.opt | 2 +- plugin/wsrep_info/mysql-test/wsrep_info/my.cnf | 2 -- sql/sql_parse.cc | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mysql-test/include/wait_wsrep_ready.inc b/mysql-test/include/wait_wsrep_ready.inc index 0e666afa33d..2dd1ef7f1ab 100644 --- a/mysql-test/include/wait_wsrep_ready.inc +++ b/mysql-test/include/wait_wsrep_ready.inc @@ -8,7 +8,10 @@ if (`SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'wsrep' AND PLUGIN_STATUS='ACTIVE'`) { - --source include/galera_wait_ready.inc + if (`SELECT @@GLOBAL.WSREP_ON`) + { + --source include/galera_wait_ready.inc + } } --enable_query_log diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result index 69df8c0f19e..0c206975c29 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result +++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result @@ -598,7 +598,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE INT UNSIGNED VARIABLE_COMMENT Ensure "synchronous" read view before executing an operation of the type specified by bitmask: 1 - READ(includes SELECT, SHOW and BEGIN/START TRANSACTION); 2 - UPDATE and DELETE; 4 - INSERT and REPLACE NUMERIC_MIN_VALUE 0 -NUMERIC_MAX_VALUE 7 +NUMERIC_MAX_VALUE 15 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO diff --git a/mysql-test/suite/wsrep/t/mdev_6832.opt b/mysql-test/suite/wsrep/t/mdev_6832.opt index 459a9702707..16f8962dba2 100644 --- a/mysql-test/suite/wsrep/t/mdev_6832.opt +++ b/mysql-test/suite/wsrep/t/mdev_6832.opt @@ -1 +1 @@ ---wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 --wsrep_causal_reads=ON +--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 diff --git a/mysql-test/suite/wsrep/t/mdev_7798.opt b/mysql-test/suite/wsrep/t/mdev_7798.opt index 459a9702707..1007d5c0b78 100644 --- a/mysql-test/suite/wsrep/t/mdev_7798.opt +++ b/mysql-test/suite/wsrep/t/mdev_7798.opt @@ -1 +1 @@ ---wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 --wsrep_causal_reads=ON +--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 diff --git a/plugin/wsrep_info/mysql-test/wsrep_info/my.cnf b/plugin/wsrep_info/mysql-test/wsrep_info/my.cnf index 4af933f1633..70682178ca1 100644 --- a/plugin/wsrep_info/mysql-test/wsrep_info/my.cnf +++ b/plugin/wsrep_info/mysql-test/wsrep_info/my.cnf @@ -8,8 +8,6 @@ innodb-autoinc-lock-mode=2 innodb-locks-unsafe-for-binlog=1 wsrep-cluster-address=gcomm:// wsrep_provider=@ENV.WSREP_PROVIDER -# enforce read-committed characteristics across the cluster -wsrep_causal_reads=ON [mysqld.1] #galera_port=@OPT.port diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f5721d2ca2f..6f9e4677c0b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4225,7 +4225,7 @@ end_with_restore_list: */ if (thd->slave_thread && !thd->slave_expected_error && slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) - lex->check_exists= 1; + lex->create_info.set(DDL_options_st::OPT_IF_EXISTS); if (WSREP(thd)) { From db51ad1e014c3a67b35adcbb90ec6a38d32a6571 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 23 Aug 2017 18:11:24 +0000 Subject: [PATCH 061/101] Remove workaround for ancient and already fixed CMake bug in MSI creation. The workaround, an extra cmake calls, somehow makes the connect/cmake_install.cmake to lose installation of connect-engine's specific jar files. --- win/packaging/create_msi.cmake.in | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/win/packaging/create_msi.cmake.in b/win/packaging/create_msi.cmake.in index 1f847a39695..62ce5f1edd2 100644 --- a/win/packaging/create_msi.cmake.in +++ b/win/packaging/create_msi.cmake.in @@ -78,13 +78,6 @@ ELSE() ENDIF() SET(ENV{VS_UNICODE_OUTPUT}) -# Workaround for CMake bug#11452 -# Switch off the monolithic install -EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=0 ${CMAKE_BINARY_DIR} - OUTPUT_QUIET -) - INCLUDE(${CMAKE_BINARY_DIR}/CPackConfig.cmake) @@ -441,11 +434,4 @@ ENDIF() CONFIGURE_FILE(${CPACK_PACKAGE_FILE_NAME}.msi ${CMAKE_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}.msi COPYONLY) - -# Workaround for CMake bug#11452 -# Switch monolithic install on again -EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=1 ${CMAKE_BINARY_DIR} - OUTPUT_QUIET -) From 7b36395ee962e7272d2544c61bf6142df2aba0b4 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 23 Aug 2017 23:29:59 +0000 Subject: [PATCH 062/101] MDEV-13630 : dont install connect-specific JAR files if connect is not built. --- storage/connect/CMakeLists.txt | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 81441892215..8df552505d1 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -266,13 +266,6 @@ IF(CONNECT_WITH_JDBC) JdbcInterface.java ApacheInterface.java MariadbInterface.java MysqlInterface.java OracleInterface.java PostgresqlInterface.java JavaWrappers.jar) - # TODO: Find how to compile and install the java wrapper classes - # Find required libraries and include directories - SET (JAVA_SOURCES JdbcInterface.java) - add_jar(JdbcInterface ${JAVA_SOURCES}) - INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/JavaWrappers.jar - ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar - DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) add_definitions(-DJDBC_SUPPORT) ELSE() SET(JDBC_LIBRARY "") @@ -313,3 +306,18 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES} LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY}) +IF(NOT TARGET connect) + RETURN() +ENDIF() + +IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND) + # TODO: Find how to compile and install the java wrapper classes + # Find required libraries and include directories + SET (JAVA_SOURCES JdbcInterface.java) + add_jar(JdbcInterface ${JAVA_SOURCES}) + INSTALL(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/JavaWrappers.jar + ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar + DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) +ENDIF() + From 7aa846e9e30293e0bac7613abfd254405cfe9e09 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 23 Aug 2017 23:30:51 +0000 Subject: [PATCH 063/101] CONNECT engine: install ha_connect.lib --- storage/connect/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 8df552505d1..9f42b7a87dd 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -310,12 +310,25 @@ IF(NOT TARGET connect) RETURN() ENDIF() +# Install some extra files that belong to connect engine +IF(WIN32) + # install ha_connect.lib + GET_TARGET_PROPERTY(CONNECT_LOCATION connect LOCATION) + STRING(REPLACE "dll" "lib" CONNECT_LIB ${CONNECT_LOCATION}) + IF(CMAKE_CONFIGURATION_TYPES) + STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" + CONNECT_LIB ${CONNECT_LIB}) + ENDIF() + INSTALL(FILES ${CONNECT_LIB} + DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) +ENDIF(WIN32) + IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND) # TODO: Find how to compile and install the java wrapper classes # Find required libraries and include directories SET (JAVA_SOURCES JdbcInterface.java) add_jar(JdbcInterface ${JAVA_SOURCES}) - INSTALL(FILES + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/JavaWrappers.jar ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) From dd229430a977e07b7bd65c1513b266f6cb8333f3 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 24 Aug 2017 08:05:11 +0000 Subject: [PATCH 064/101] Windows compile : make compilation fail on "uninitialized variable used" warning C4700 This is a genuine error, and will crash debug buildd in runtime checks if not fixed. it is better to fail during compile. --- cmake/os/Windows.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index 84276115723..e4221227d91 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -115,8 +115,8 @@ IF(MSVC) ENDIF() #TODO: update the code and remove the disabled warnings - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996 /we4700") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099 /we4700") IF(CMAKE_SIZEOF_VOID_P MATCHES 8) # _WIN64 is defined by the compiler itself. From cd35dd6a0546c31449d1c4c43bc03fe351d0dcf4 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 24 Aug 2017 15:49:50 +0000 Subject: [PATCH 065/101] Windows : Do not use CRT routine to dump memory leaks. Its output is useless,and, in case of large output, it also may prevent with search_pattern_in_file.inc from working. --- mysys/my_init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mysys/my_init.c b/mysys/my_init.c index dee41e1202a..a0f8e21322e 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -200,7 +200,6 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR ); _CrtCheckMemory(); - _CrtDumpMemoryLeaks(); #endif } From 582545a38421ea0e43f326db84550773411c3261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 24 Aug 2017 15:38:05 +0300 Subject: [PATCH 066/101] MDEV-13637 InnoDB change buffer housekeeping can cause redo log overrun and possibly deadlocks The function ibuf_remove_free_page() may be called while the caller is holding several mutexes or rw-locks. Because of this, this housekeeping loop may cause performance glitches for operations that involve tables that are stored in the InnoDB system tablespace. Also deadlocks might be possible. The worst impact of all is that due to the mutexes being held, calls to log_free_check() had to be skipped during this housekeeping. This means that the cyclic InnoDB redo log may be overwritten. If the system crashes during this, it would be unable to recover. The entry point to the problematic code is ibuf_free_excess_pages(). It would make sense to call it before acquiring any mutexes or rw-locks, in any 'pessimistic' operation that involves the system tablespace. fseg_create_general(), fseg_alloc_free_page_general(): Do not call ibuf_free_excess_pages() while potentially holding some latches. ibuf_remove_free_page(): Do call log_free_check(), like every operation that is about to generate redo log should do. ibuf_free_excess_pages(): Remove some assertions that are replaced by stricter assertions in the log_free_check() that is now called by ibuf_remove_free_page(). row_ins_sec_index_entry(), row_undo_ins_remove_sec_low(), row_undo_mod_del_mark_or_remove_sec_low(), row_undo_mod_del_unmark_sec_and_undo_update(): Call ibuf_free_excess_pages() if the operation may involve allocating pages and change buffering in the system tablespace. --- storage/innobase/fsp/fsp0fsp.cc | 19 +------------------ storage/innobase/ibuf/ibuf0ibuf.cc | 19 +++---------------- storage/innobase/row/row0ins.cc | 6 ++++++ storage/innobase/row/row0uins.cc | 5 +++++ storage/innobase/row/row0umod.cc | 12 ++++++++++++ storage/xtradb/fsp/fsp0fsp.cc | 19 +------------------ storage/xtradb/ibuf/ibuf0ibuf.cc | 19 +++---------------- storage/xtradb/row/row0ins.cc | 6 ++++++ storage/xtradb/row/row0uins.cc | 5 +++++ storage/xtradb/row/row0umod.cc | 12 ++++++++++++ 10 files changed, 54 insertions(+), 68 deletions(-) diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index d04cd7168ed..66f4ada8485 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -2032,15 +2033,6 @@ fseg_create_general( mtr_x_lock(latch, mtr); - if (rw_lock_get_x_lock_count(latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - if (!has_done_reservation) { success = fsp_reserve_free_extents(&n_reserved, space, 2, FSP_NORMAL, mtr); @@ -2612,15 +2604,6 @@ fseg_alloc_free_page_general( mtr_x_lock(latch, mtr); - if (rw_lock_get_x_lock_count(latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - inode = fseg_inode_get(seg_header, space, zip_size, mtr); if (!has_done_reservation diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 49c1d1a4227..99be552c967 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2147,6 +2147,8 @@ ibuf_remove_free_page(void) page_t* root; page_t* bitmap_page; + log_free_check(); + mtr_start(&mtr); /* Acquire the fsp latch before the ibuf header, obeying the latching @@ -2258,22 +2260,7 @@ ibuf_free_excess_pages(void) { ulint i; -#ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(fil_space_get_latch(IBUF_SPACE_ID, NULL), - RW_LOCK_EX)); -#endif /* UNIV_SYNC_DEBUG */ - - ut_ad(rw_lock_get_x_lock_count( - fil_space_get_latch(IBUF_SPACE_ID, NULL)) == 1); - - /* NOTE: We require that the thread did not own the latch before, - because then we know that we can obey the correct latching order - for ibuf latches */ - - if (!ibuf) { - /* Not yet initialized; not sure if this is possible, but - does no harm to check for it. */ - + if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { return; } diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 5cfa21c1fa2..d2e9e8f1940 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -38,6 +38,7 @@ Created 4/20/1996 Heikki Tuuri #include "btr0btr.h" #include "btr0cur.h" #include "mach0data.h" +#include "ibuf0ibuf.h" #include "que0que.h" #include "row0upd.h" #include "row0sel.h" @@ -2940,6 +2941,11 @@ row_ins_sec_index_entry( if (err == DB_FAIL) { mem_heap_empty(heap); + if (index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } + /* Try then pessimistic descent to the B-tree */ log_free_check(); diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index 651042fb820..a9733f435b7 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -201,6 +202,10 @@ row_undo_ins_remove_sec_low( mtr_s_lock(dict_index_get_lock(index), &mtr); } else { ut_ad(mode == BTR_MODIFY_TREE); + if (index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } mtr_x_lock(dict_index_get_lock(index), &mtr); } diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index 2e66bc494d4..77fa3cada2b 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -35,6 +36,7 @@ Created 2/27/1997 Heikki Tuuri #include "trx0roll.h" #include "btr0btr.h" #include "mach0data.h" +#include "ibuf0ibuf.h" #include "row0undo.h" #include "row0vers.h" #include "row0log.h" @@ -432,6 +434,11 @@ row_undo_mod_del_mark_or_remove_sec_low( log_free_check(); mtr_start_trx(&mtr, thr_get_trx(thr)); + if (mode == BTR_MODIFY_TREE + && index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } if (*index->name == TEMP_INDEX_PREFIX) { /* The index->online_status may change if the @@ -604,6 +611,11 @@ row_undo_mod_del_unmark_sec_and_undo_update( log_free_check(); mtr_start_trx(&mtr, thr_get_trx(thr)); + if (mode == BTR_MODIFY_TREE + && index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } if (*index->name == TEMP_INDEX_PREFIX) { /* The index->online_status may change if the diff --git a/storage/xtradb/fsp/fsp0fsp.cc b/storage/xtradb/fsp/fsp0fsp.cc index cf6fa4211ca..d441d710671 100644 --- a/storage/xtradb/fsp/fsp0fsp.cc +++ b/storage/xtradb/fsp/fsp0fsp.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -2041,15 +2042,6 @@ fseg_create_general( mtr_x_lock(latch, mtr); - if (rw_lock_get_x_lock_count(latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - if (!has_done_reservation) { success = fsp_reserve_free_extents(&n_reserved, space, 2, FSP_NORMAL, mtr); @@ -2621,15 +2613,6 @@ fseg_alloc_free_page_general( mtr_x_lock(latch, mtr); - if (rw_lock_get_x_lock_count(latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - inode = fseg_inode_get(seg_header, space, zip_size, mtr); if (!has_done_reservation diff --git a/storage/xtradb/ibuf/ibuf0ibuf.cc b/storage/xtradb/ibuf/ibuf0ibuf.cc index 414d7fc39be..d542e488dba 100644 --- a/storage/xtradb/ibuf/ibuf0ibuf.cc +++ b/storage/xtradb/ibuf/ibuf0ibuf.cc @@ -2188,6 +2188,8 @@ ibuf_remove_free_page(void) page_t* root; page_t* bitmap_page; + log_free_check(); + mtr_start(&mtr); /* Acquire the fsp latch before the ibuf header, obeying the latching @@ -2299,22 +2301,7 @@ ibuf_free_excess_pages(void) { ulint i; -#ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(fil_space_get_latch(IBUF_SPACE_ID, NULL), - RW_LOCK_EX)); -#endif /* UNIV_SYNC_DEBUG */ - - ut_ad(rw_lock_get_x_lock_count( - fil_space_get_latch(IBUF_SPACE_ID, NULL)) == 1); - - /* NOTE: We require that the thread did not own the latch before, - because then we know that we can obey the correct latching order - for ibuf latches */ - - if (!ibuf) { - /* Not yet initialized; not sure if this is possible, but - does no harm to check for it. */ - + if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { return; } diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index ec9f74cd4ad..20a68e7eca2 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -38,6 +38,7 @@ Created 4/20/1996 Heikki Tuuri #include "btr0btr.h" #include "btr0cur.h" #include "mach0data.h" +#include "ibuf0ibuf.h" #include "que0que.h" #include "row0upd.h" #include "row0sel.h" @@ -3013,6 +3014,11 @@ row_ins_sec_index_entry( if (err == DB_FAIL) { mem_heap_empty(heap); + if (index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } + /* Try then pessimistic descent to the B-tree */ log_free_check(); diff --git a/storage/xtradb/row/row0uins.cc b/storage/xtradb/row/row0uins.cc index 651042fb820..a9733f435b7 100644 --- a/storage/xtradb/row/row0uins.cc +++ b/storage/xtradb/row/row0uins.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -201,6 +202,10 @@ row_undo_ins_remove_sec_low( mtr_s_lock(dict_index_get_lock(index), &mtr); } else { ut_ad(mode == BTR_MODIFY_TREE); + if (index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } mtr_x_lock(dict_index_get_lock(index), &mtr); } diff --git a/storage/xtradb/row/row0umod.cc b/storage/xtradb/row/row0umod.cc index c8a229ea640..bd0a36e2240 100644 --- a/storage/xtradb/row/row0umod.cc +++ b/storage/xtradb/row/row0umod.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -35,6 +36,7 @@ Created 2/27/1997 Heikki Tuuri #include "trx0roll.h" #include "btr0btr.h" #include "mach0data.h" +#include "ibuf0ibuf.h" #include "row0undo.h" #include "row0vers.h" #include "row0log.h" @@ -402,6 +404,11 @@ row_undo_mod_del_mark_or_remove_sec_low( log_free_check(); mtr_start_trx(&mtr, thr_get_trx(thr)); + if (mode == BTR_MODIFY_TREE + && index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } if (*index->name == TEMP_INDEX_PREFIX) { /* The index->online_status may change if the @@ -574,6 +581,11 @@ row_undo_mod_del_unmark_sec_and_undo_update( log_free_check(); mtr_start_trx(&mtr, thr_get_trx(thr)); + if (mode == BTR_MODIFY_TREE + && index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } if (*index->name == TEMP_INDEX_PREFIX) { /* The index->online_status may change if the From f87cb652ac34ff195431fcd7185f00af8675827e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 28 Aug 2017 08:57:51 +0300 Subject: [PATCH 067/101] MDEV-13637 InnoDB change buffer housekeeping can cause redo log overrun and possibly deadlocks The function ibuf_remove_free_page() may be called while the caller is holding several mutexes or rw-locks. Because of this, this housekeeping loop may cause performance glitches for operations that involve tables that are stored in the InnoDB system tablespace. Also deadlocks might be possible. The worst impact of all is that due to the mutexes being held, calls to log_free_check() had to be skipped during this housekeeping. This means that the cyclic InnoDB redo log may be overwritten. If the system crashes during this, it would be unable to recover. The entry point to the problematic code is ibuf_free_excess_pages(). It would make sense to call it before acquiring any mutexes or rw-locks, in any 'pessimistic' operation that involves the system tablespace. fseg_create_general(), fseg_alloc_free_page_general(): Do not call ibuf_free_excess_pages() while potentially holding some latches. ibuf_remove_free_page(): Do call log_free_check(), like every operation that is about to generate redo log should do. ibuf_free_excess_pages(): Remove some assertions that are replaced by stricter assertions in the log_free_check() that is now called by ibuf_remove_free_page(). row_mtr_start(): New function, to perform necessary preparations when starting a mini-transaction for row operations. For pessimistic operations on secondary indexes that are located in the system tablespace, this includes calling ibuf_free_excess_pages(). row_undo_ins_remove_sec_low(), row_undo_mod_del_mark_or_remove_sec_low(), row_undo_mod_del_unmark_sec_and_undo_update(): Call row_mtr_start(). row_ins_sec_index_entry(): Call ibuf_free_excess_pages() if the operation may involve allocating pages and change buffering in the system tablespace. row_upd_sec_index_entry(): Slightly refactor the code. The delete-marking of the old entry is done in-place. It could be change-buffered, but the old code should be unlikely to have invoked ibuf_free_excess_pages() in this case. --- storage/innobase/fsp/fsp0fsp.cc | 18 ----------------- storage/innobase/ibuf/ibuf0ibuf.cc | 16 +++------------ storage/innobase/include/row0row.h | 31 +++++++++++++++++++++++++++++- storage/innobase/row/row0ins.cc | 6 ++++++ storage/innobase/row/row0uins.cc | 13 +++++-------- storage/innobase/row/row0umod.cc | 22 +++++---------------- storage/innobase/row/row0upd.cc | 19 +++++++++--------- 7 files changed, 59 insertions(+), 66 deletions(-) diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 77b28d2c01b..ca0c712f608 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -2107,15 +2107,6 @@ fseg_create_general( fil_block_check_type(block, type, mtr); } - if (rw_lock_get_x_lock_count(&space->latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space_id == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - if (!has_done_reservation && !fsp_reserve_free_extents(&n_reserved, space_id, 2, FSP_NORMAL, mtr)) { @@ -2699,15 +2690,6 @@ fseg_alloc_free_page_general( space = mtr_x_lock_space(space_id, mtr); const page_size_t page_size(space->flags); - if (rw_lock_get_x_lock_count(&space->latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space_id == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - inode = fseg_inode_get(seg_header, space_id, page_size, mtr, &iblock); fil_block_check_type(iblock, FIL_PAGE_INODE, mtr); diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index d021f8c0085..eda6684e69f 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2104,6 +2104,8 @@ ibuf_remove_free_page(void) page_t* root; page_t* bitmap_page; + log_free_check(); + mtr_start(&mtr); fil_space_t* space = mtr.set_sys_modified(); const page_size_t page_size(space->flags); @@ -2211,19 +2213,7 @@ void ibuf_free_excess_pages(void) /*========================*/ { - ut_ad(rw_lock_own(fil_space_get_latch(IBUF_SPACE_ID, NULL), RW_LOCK_X)); - - ut_ad(rw_lock_get_x_lock_count( - fil_space_get_latch(IBUF_SPACE_ID, NULL)) == 1); - - /* NOTE: We require that the thread did not own the latch before, - because then we know that we can obey the correct latching order - for ibuf latches */ - - if (!ibuf) { - /* Not yet initialized; not sure if this is possible, but - does no harm to check for it. */ - + if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { return; } diff --git a/storage/innobase/include/row0row.h b/storage/innobase/include/row0row.h index 60f256fb200..d24ae37b13d 100644 --- a/storage/innobase/include/row0row.h +++ b/storage/innobase/include/row0row.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, MariaDB Corporation. +Copyright (c) 2016, 2017, MariaDB Corporation. 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 @@ -30,6 +30,7 @@ Created 4/20/1996 Heikki Tuuri #include "univ.i" #include "data0data.h" #include "dict0types.h" +#include "ibuf0ibuf.h" #include "trx0types.h" #include "que0types.h" #include "mtr0mtr.h" @@ -387,6 +388,34 @@ row_raw_format( in bytes */ MY_ATTRIBUTE((nonnull, warn_unused_result)); +/** Prepare to start a mini-transaction to modify an index. +@param[in,out] mtr mini-transaction +@param[in,out] index possibly secondary index +@param[in] pessimistic whether this is a pessimistic operation */ +inline +void +row_mtr_start(mtr_t* mtr, dict_index_t* index, bool pessimistic) +{ + mtr->start(); + + switch (index->space) { + case IBUF_SPACE_ID: + if (pessimistic + && !(index->type & (DICT_UNIQUE | DICT_SPATIAL))) { + ibuf_free_excess_pages(); + } + break; + case SRV_TMP_SPACE_ID: + mtr->set_log_mode(MTR_LOG_NO_REDO); + break; + default: + mtr->set_named_space(index->space); + break; + } + + log_free_check(); +} + #include "row0row.ic" #endif diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 936b96d5176..11785dbeb8e 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -34,6 +34,7 @@ Created 4/20/1996 Heikki Tuuri #include "btr0btr.h" #include "btr0cur.h" #include "mach0data.h" +#include "ibuf0ibuf.h" #include "que0que.h" #include "row0upd.h" #include "row0sel.h" @@ -3267,6 +3268,11 @@ row_ins_sec_index_entry( if (err == DB_FAIL) { mem_heap_empty(heap); + if (index->space == IBUF_SPACE_ID + && !(index->type & (DICT_UNIQUE | DICT_SPATIAL))) { + ibuf_free_excess_pages(); + } + /* Try then pessimistic descent to the B-tree */ log_free_check(); diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index ef0c3ed9cc3..0fce0731307 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. 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 @@ -193,19 +194,15 @@ row_undo_ins_remove_sec_low( dberr_t err = DB_SUCCESS; mtr_t mtr; enum row_search_result search_result; - ibool modify_leaf = false; + const bool modify_leaf = mode == BTR_MODIFY_LEAF; - log_free_check(); memset(&pcur, 0, sizeof(pcur)); - mtr_start(&mtr); - mtr.set_named_space(index->space); - dict_disable_redo_if_temporary(index->table, &mtr); + row_mtr_start(&mtr, index, !modify_leaf); - if (mode == BTR_MODIFY_LEAF) { + if (modify_leaf) { mode = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED; mtr_s_lock(dict_index_get_lock(index), &mtr); - modify_leaf = true; } else { ut_ad(mode == (BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE)); mtr_sx_lock(dict_index_get_lock(index), &mtr); @@ -216,7 +213,7 @@ row_undo_ins_remove_sec_low( } if (dict_index_is_spatial(index)) { - if (mode & BTR_MODIFY_LEAF) { + if (modify_leaf) { mode |= BTR_RTREE_DELETE_MARK; } btr_pcur_get_btr_cur(&pcur)->thr = thr; diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index a0c69fb97f9..3df68ecb94d 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -422,23 +422,15 @@ row_undo_mod_del_mark_or_remove_sec_low( mtr_t mtr; mtr_t mtr_vers; row_search_result search_result; - ibool modify_leaf = false; + const bool modify_leaf = mode == BTR_MODIFY_LEAF; - log_free_check(); - //mtr_start_trx(&mtr, thr_get_trx(thr)); - mtr_start(&mtr); - mtr.set_named_space(index->space); - dict_disable_redo_if_temporary(index->table, &mtr); - - if (mode == BTR_MODIFY_LEAF) { - modify_leaf = true; - } + row_mtr_start(&mtr, index, !modify_leaf); if (!index->is_committed()) { /* The index->online_status may change if the index is or was being created online, but not committed yet. It is protected by index->lock. */ - if (mode == BTR_MODIFY_LEAF) { + if (modify_leaf) { mode = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED; mtr_s_lock(dict_index_get_lock(index), &mtr); } else { @@ -459,7 +451,7 @@ row_undo_mod_del_mark_or_remove_sec_low( btr_cur = btr_pcur_get_btr_cur(&pcur); if (dict_index_is_spatial(index)) { - if (mode & BTR_MODIFY_LEAF) { + if (modify_leaf) { btr_cur->thr = thr; mode |= BTR_RTREE_DELETE_MARK; } @@ -631,11 +623,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( } try_again: - log_free_check(); - //mtr_start_trx(&mtr, thr_get_trx(thr)); - mtr_start(&mtr); - mtr.set_named_space(index->space); - dict_disable_redo_if_temporary(index->table, &mtr); + row_mtr_start(&mtr, index, !(mode & BTR_MODIFY_LEAF)); if (!index->is_committed()) { /* The index->online_status may change if the index is diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index e163440678e..4468b0660f0 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2016, MariaDB Corporation. +Copyright (c) 2015, 2017, MariaDB Corporation. 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 @@ -2300,17 +2300,18 @@ row_upd_sec_index_entry( "before_row_upd_sec_index_entry"); mtr_start_trx(&mtr, trx); - mtr.set_named_space(index->space); - /* Disable REDO logging as lifetime of temp-tables is limited to - server or connection lifetime and so REDO information is not needed - on restart for recovery. - Disable locking as temp-tables are not shared across connection. */ - if (dict_table_is_temporary(index->table)) { - flags = BTR_NO_LOCKING_FLAG; + switch (index->space) { + case SRV_TMP_SPACE_ID: mtr.set_log_mode(MTR_LOG_NO_REDO); - } else { + flags = BTR_NO_LOCKING_FLAG; + break; + default: + mtr.set_named_space(index->space); + /* fall through */ + case IBUF_SPACE_ID: flags = 0; + break; } if (!index->is_committed()) { From 882f4566e55694b4f68f61ee723678b49d7e0d8f Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Sat, 19 Aug 2017 02:52:35 +0300 Subject: [PATCH 068/101] Combinations with innodb-undo-tablespaces to use in test files --- mysql-test/include/innodb_undo_tablespaces.combinations | 5 +++++ mysql-test/include/innodb_undo_tablespaces.inc | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 mysql-test/include/innodb_undo_tablespaces.combinations create mode 100644 mysql-test/include/innodb_undo_tablespaces.inc diff --git a/mysql-test/include/innodb_undo_tablespaces.combinations b/mysql-test/include/innodb_undo_tablespaces.combinations new file mode 100644 index 00000000000..0ac7a6e2d05 --- /dev/null +++ b/mysql-test/include/innodb_undo_tablespaces.combinations @@ -0,0 +1,5 @@ +[undo0] +innodb-undo-tablespaces=0 + +[undo3] +innodb-undo-tablespaces=3 diff --git a/mysql-test/include/innodb_undo_tablespaces.inc b/mysql-test/include/innodb_undo_tablespaces.inc new file mode 100644 index 00000000000..b109fcc4f0e --- /dev/null +++ b/mysql-test/include/innodb_undo_tablespaces.inc @@ -0,0 +1,3 @@ +# The goal of including this file is to enable innodb_undo_tablespaces combinations +# (see include/innodb_undo_tablespaces.combinations) + From 61096ff214dec68a66efb811aa3a70ef49f06a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 28 Aug 2017 09:45:54 +0300 Subject: [PATCH 069/101] MDEV-13591: InnoDB: Database page corruption on disk or a failed file read and assertion failure Problem is that page 0 and its possible enrryption information is not read for undo tablespaces. fil_crypt_get_latest_key_version(): Do not send event to encryption threads if event does not yet exists. Seen on regression testing. fil_read_first_page: Add new parameter does page belong to undo tablespace and if it does, we do not read FSP_HEADER. srv_undo_tablespace_open : Read first page of the tablespace to get crypt_data if it exists and pass it to fil_space_create. Tested using innodb_encryption with combinations with innodb-undo-tablespaces. --- .../encryption/r/innodb_encryption.result | 2 + .../suite/encryption/t/innodb_encryption.test | 4 ++ storage/innobase/fil/fil0crypt.cc | 7 ++- storage/innobase/fil/fil0fil.cc | 49 +++++++++++-------- storage/innobase/include/fil0fil.h | 5 +- storage/innobase/srv/srv0start.cc | 29 ++++++++--- storage/xtradb/fil/fil0crypt.cc | 7 ++- storage/xtradb/fil/fil0fil.cc | 49 +++++++++++-------- storage/xtradb/include/fil0fil.h | 9 ++-- storage/xtradb/srv/srv0start.cc | 29 ++++++++--- 10 files changed, 130 insertions(+), 60 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb_encryption.result b/mysql-test/suite/encryption/r/innodb_encryption.result index 26c77499d25..ce494098d44 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption.result +++ b/mysql-test/suite/encryption/r/innodb_encryption.result @@ -1,3 +1,5 @@ +call mtr.add_suppression("InnoDB: New log files created"); +call mtr.add_suppression("InnoDB: Creating foreign key constraint system tables."); SET @start_global_value = @@global.innodb_encryption_threads; SHOW VARIABLES LIKE 'innodb_encrypt%'; Variable_name Value diff --git a/mysql-test/suite/encryption/t/innodb_encryption.test b/mysql-test/suite/encryption/t/innodb_encryption.test index 50aca2a7260..6e9f80aac0c 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption.test +++ b/mysql-test/suite/encryption/t/innodb_encryption.test @@ -3,10 +3,14 @@ # -- source include/have_innodb.inc -- source include/have_example_key_management_plugin.inc +-- source include/innodb_undo_tablespaces.inc # embedded does not support restart -- source include/not_embedded.inc +call mtr.add_suppression("InnoDB: New log files created"); +call mtr.add_suppression("InnoDB: Creating foreign key constraint system tables."); + SET @start_global_value = @@global.innodb_encryption_threads; SHOW VARIABLES LIKE 'innodb_encrypt%'; diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 683974d8920..ef39aabb8c2 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -191,7 +191,12 @@ fil_crypt_get_latest_key_version( crypt_data->min_key_version, key_version, srv_fil_crypt_rotate_key_age)) { - os_event_set(fil_crypt_threads_event); + /* Below event seen as NULL-pointer at startup + when new database was created and we create a + checkpoint. Only seen when debugging. */ + if (fil_crypt_threads_inited) { + os_event_set(fil_crypt_threads_event); + } } } diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 6abc7f0e1c2..559ba26542f 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -2322,8 +2322,10 @@ the first page of a first data file at database startup. data files @param[out] flushed_lsn flushed lsn value @param[out] crypt_data encryption crypt data -@retval NULL on success, or if innodb_force_recovery is set -@return pointer to an error message string */ +@param[in] check_first_page true if first page contents + should be checked +@return NULL on success, or if innodb_force_recovery is set +@retval pointer to an error message string */ UNIV_INTERN const char* fil_read_first_page( @@ -2336,7 +2338,8 @@ fil_read_first_page( ulint* max_arch_log_no, #endif /* UNIV_LOG_ARCHIVE */ lsn_t* flushed_lsn, - fil_space_crypt_t** crypt_data) + fil_space_crypt_t** crypt_data, + bool check_first_page) { byte* buf; byte* page; @@ -2358,27 +2361,31 @@ fil_read_first_page( *flags and *space_id as they were read from the first file and do not validate the first page. */ if (!one_read_already) { - *space_id = fsp_header_get_space_id(page); - *flags = fsp_header_get_flags(page); + /* Undo tablespace does not contain correct FSP_HEADER, + and actually we really need to read only crypt_data. */ + if (check_first_page) { + *space_id = fsp_header_get_space_id(page); + *flags = fsp_header_get_flags(page); - if (flushed_lsn) { - *flushed_lsn = mach_read_from_8(page + - FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - } - - if (!fsp_flags_is_valid(*flags, *space_id)) { - ulint cflags = fsp_flags_convert_from_101(*flags); - if (cflags == ULINT_UNDEFINED) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Invalid flags 0x%x in tablespace %u", - unsigned(*flags), unsigned(*space_id)); - return "invalid tablespace flags"; - } else { - *flags = cflags; + if (flushed_lsn) { + *flushed_lsn = mach_read_from_8(page + + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); } - } - check_msg = fil_check_first_page(page, *space_id, *flags); + if (!fsp_flags_is_valid(*flags, *space_id)) { + ulint cflags = fsp_flags_convert_from_101(*flags); + if (cflags == ULINT_UNDEFINED) { + ib_logf(IB_LOG_LEVEL_ERROR, + "Invalid flags 0x%x in tablespace %u", + unsigned(*flags), unsigned(*space_id)); + return "invalid tablespace flags"; + } else { + *flags = cflags; + } + } + + check_msg = fil_check_first_page(page, *space_id, *flags); + } /* Possible encryption crypt data is also stored only to first page of the first datafile. */ diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index e481ea3a8aa..38250949380 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -802,6 +802,8 @@ the first page of a first data file at database startup. data files @param[out] flushed_lsn flushed lsn value @param[out] crypt_data encryption crypt data +@param[in] check_first_page true if first page contents + should be checked @retval NULL on success, or if innodb_force_recovery is set @return pointer to an error message string */ UNIV_INTERN @@ -816,7 +818,8 @@ fil_read_first_page( ulint* max_arch_log_no, #endif /* UNIV_LOG_ARCHIVE */ lsn_t* flushed_lsn, - fil_space_crypt_t** crypt_data) + fil_space_crypt_t** crypt_data, + bool check_first_page=true) MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 0880f93c7fa..703ab0c9dca 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -850,7 +850,7 @@ open_or_create_data_files( ibool one_created = FALSE; os_offset_t size; ulint flags; - ulint space; + ulint space=0; ulint rounded_size_pages; char name[10000]; fil_space_crypt_t* crypt_data=NULL; @@ -1332,11 +1332,30 @@ srv_undo_tablespace_open( size = os_file_get_size(fh); ut_a(size != (os_offset_t) -1); + /* Load the tablespace into InnoDB's internal + data structures. */ + + const char* check_msg; + fil_space_crypt_t* crypt_data = NULL; + + /* Set the compressed page size to 0 (non-compressed) */ + flags = FSP_FLAGS_PAGE_SSIZE(); + + /* Read first page to find out does the crypt_info + exists on undo tablespace. */ + check_msg = fil_read_first_page( + fh, FALSE, &flags, &space, + NULL, &crypt_data, false); + ret = os_file_close(fh); ut_a(ret); - /* Load the tablespace into InnoDB's internal - data structures. */ + if (check_msg) { + ib_logf(IB_LOG_LEVEL_ERROR, + "%s in data file %s", + check_msg, name); + return (err); + } /* We set the biggest space id to the undo tablespace because InnoDB hasn't opened any other tablespace apart @@ -1344,10 +1363,8 @@ srv_undo_tablespace_open( fil_set_max_space_id_if_bigger(space); - /* Set the compressed page size to 0 (non-compressed) */ - flags = FSP_FLAGS_PAGE_SSIZE(); fil_space_create(name, space, flags, FIL_TABLESPACE, - NULL /* no encryption */, + crypt_data, true /* create */); ut_a(fil_validate()); diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index 683974d8920..ef39aabb8c2 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -191,7 +191,12 @@ fil_crypt_get_latest_key_version( crypt_data->min_key_version, key_version, srv_fil_crypt_rotate_key_age)) { - os_event_set(fil_crypt_threads_event); + /* Below event seen as NULL-pointer at startup + when new database was created and we create a + checkpoint. Only seen when debugging. */ + if (fil_crypt_threads_inited) { + os_event_set(fil_crypt_threads_event); + } } } diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index dbf6501b183..2c3d26d6302 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -2372,8 +2372,10 @@ the first page of a first data file at database startup. @param[out] space_id tablepspace ID @param[out] flushed_lsn flushed lsn value @param[out] crypt_data encryption crypt data -@retval NULL on success, or if innodb_force_recovery is set -@return pointer to an error message string */ +@param[in] check_first_page true if first page contents + should be checked +@return NULL on success, or if innodb_force_recovery is set +@retval pointer to an error message string */ UNIV_INTERN const char* fil_read_first_page( @@ -2382,7 +2384,8 @@ fil_read_first_page( ulint* flags, ulint* space_id, lsn_t* flushed_lsn, - fil_space_crypt_t** crypt_data) + fil_space_crypt_t** crypt_data, + bool check_first_page) { byte* buf; byte* page; @@ -2418,28 +2421,32 @@ fil_read_first_page( *flags and *space_id as they were read from the first file and do not validate the first page. */ if (!one_read_already) { - *space_id = fsp_header_get_space_id(page); - *flags = fsp_header_get_flags(page); + /* Undo tablespace does not contain correct FSP_HEADER, + and actually we really need to read only crypt_data. */ + if (check_first_page) { + *space_id = fsp_header_get_space_id(page); + *flags = fsp_header_get_flags(page); - if (flushed_lsn) { - *flushed_lsn = mach_read_from_8(page + + if (flushed_lsn) { + *flushed_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - } - - if (!fsp_flags_is_valid(*flags, *space_id)) { - ulint cflags = fsp_flags_convert_from_101(*flags); - if (cflags == ULINT_UNDEFINED) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Invalid flags 0x%x in tablespace %u", - unsigned(*flags), unsigned(*space_id)); - return "invalid tablespace flags"; - } else { - *flags = cflags; } - } - if (!(IS_XTRABACKUP() && srv_backup_mode)) { - check_msg = fil_check_first_page(page, *space_id, *flags); + if (!fsp_flags_is_valid(*flags, *space_id)) { + ulint cflags = fsp_flags_convert_from_101(*flags); + if (cflags == ULINT_UNDEFINED) { + ib_logf(IB_LOG_LEVEL_ERROR, + "Invalid flags 0x%x in tablespace %u", + unsigned(*flags), unsigned(*space_id)); + return "invalid tablespace flags"; + } else { + *flags = cflags; + } + } + + if (!(IS_XTRABACKUP() && srv_backup_mode)) { + check_msg = fil_check_first_page(page, *space_id, *flags); + } } /* Possible encryption crypt data is also stored only to first page diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index 6eab5db6883..a33cec65ed5 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -804,8 +804,10 @@ the first page of a first data file at database startup. @param[out] space_id tablepspace ID @param[out] flushed_lsn flushed lsn value @param[out] crypt_data encryption crypt data -@retval NULL on success, or if innodb_force_recovery is set -@return pointer to an error message string */ +@param[in] check_first_page true if first page contents + should be checked +@return NULL on success, or if innodb_force_recovery is set +@retval pointer to an error message string */ UNIV_INTERN const char* fil_read_first_page( @@ -814,7 +816,8 @@ fil_read_first_page( ulint* flags, ulint* space_id, lsn_t* flushed_lsn, - fil_space_crypt_t** crypt_data) + fil_space_crypt_t** crypt_data, + bool check_first_page=true) MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index aab0bc9282b..7bcb0b1b1ce 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -891,7 +891,7 @@ open_or_create_data_files( bool one_created = false; os_offset_t size; ulint flags; - ulint space; + ulint space = 0; ulint rounded_size_pages; char name[10000]; fil_space_crypt_t* crypt_data=NULL; @@ -1369,11 +1369,30 @@ srv_undo_tablespace_open( size = os_file_get_size(fh); ut_a(size != (os_offset_t) -1); + /* Load the tablespace into InnoDB's internal + data structures. */ + + const char* check_msg; + fil_space_crypt_t* crypt_data = NULL; + + /* Set the compressed page size to 0 (non-compressed) */ + flags = FSP_FLAGS_PAGE_SSIZE(); + + /* Read first page to find out does the crypt_info + exists on undo tablespace. */ + check_msg = fil_read_first_page( + fh, FALSE, &flags, &space, + NULL, &crypt_data, false); + ret = os_file_close(fh); ut_a(ret); - /* Load the tablespace into InnoDB's internal - data structures. */ + if (check_msg) { + ib_logf(IB_LOG_LEVEL_ERROR, + "%s in data file %s", + check_msg, name); + return (err); + } /* We set the biggest space id to the undo tablespace because InnoDB hasn't opened any other tablespace apart @@ -1381,10 +1400,8 @@ srv_undo_tablespace_open( fil_set_max_space_id_if_bigger(space); - /* Set the compressed page size to 0 (non-compressed) */ - flags = FSP_FLAGS_PAGE_SSIZE(); fil_space_create(name, space, flags, FIL_TABLESPACE, - NULL /* no encryption */, + crypt_data, true /* create */); ut_a(fil_validate()); From bbfd53cd32c1cf8be30f1d18225adb7fc5f6faf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 24 Aug 2017 11:46:23 +0300 Subject: [PATCH 070/101] Add galera suite to default suites and disable failing test cases. --- mysql-test/mysql-test-run.pl | 1 + mysql-test/suite/galera/disabled.def | 5 +++++ mysql-test/suite/galera/r/galera_defaults.result | 2 +- mysql-test/suite/galera/suite.pm | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 2cd5d2ae922..0c142dc15b6 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -195,6 +195,7 @@ my @DEFAULT_SUITES= qw( unit- vcol- wsrep- + galera- ); my $opt_suites; diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 1e628b99644..cd19fccd483 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -49,3 +49,8 @@ galera_parallel_simple : MDEV-13549 Galera test failures galera_admin : MDEV-13549 Galera test failures galera_var_max_ws_rows : MDEV-13549 Galera test failures 10.1 MW-286 : MDEV-13549 Galera test failures 10.1 +galera_as_master: MDEV-13549 Galera test failures 10.1 +galera_pc_ignore_sb : MDEV-13549 Galera test failures 10.1 +galera_lock_table : MDEV-13549 Galera test failures 10.1 +MW-284 : MDEV-13549 Galera test failures 10.1 +galera_as_slave : MDEV-13549 Galera test failures 10.1 diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index d8f4698a48d..28c3f4dd104 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -51,7 +51,7 @@ WSREP_SST_DONOR WSREP_SST_DONOR_REJECTS_QUERIES OFF WSREP_SST_METHOD rsync WSREP_SYNC_WAIT 15 -; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.recover = no; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; +; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.recover = no; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index 31593b654ea..361743f1243 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -72,8 +72,9 @@ push @::global_suppressions, qr|WSREP: Unsupported protocol downgrade: incremental data collection disabled. Expect abort.|, qr(WSREP: Action message in non-primary configuration from member [0-9]*), qr(WSREP: discarding established .*), - qr(WSREP: gcs\/src\/gcs_core.cpp:core_handle_uuid_msg\(\):.*), + qr|WSREP: .*core_handle_uuid_msg.*|, qr(WSREP: --wsrep-causal-reads=ON takes precedence over --wsrep-sync-wait=0. WSREP_SYNC_WAIT_BEFORE_READ is on), + qr|WSREP: JOIN message from member .* in non-primary configuration. Ignored.|, ); From 309fe35f295cad9302dcf272d8ac0719f011eddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 28 Aug 2017 13:46:31 +0300 Subject: [PATCH 071/101] Correct a mtr.add_suppression() expression --- mysql-test/suite/encryption/r/innodb-redo-badkey.result | 2 +- mysql-test/suite/encryption/t/innodb-redo-badkey.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb-redo-badkey.result b/mysql-test/suite/encryption/r/innodb-redo-badkey.result index 8c441d64d9c..ee803261b90 100644 --- a/mysql-test/suite/encryption/r/innodb-redo-badkey.result +++ b/mysql-test/suite/encryption/r/innodb-redo-badkey.result @@ -1,6 +1,6 @@ call mtr.add_suppression("Plugin 'file_key_management'"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); -call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file test/t[1-4] cannot be decrypted"); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file .*test/t[1-4]\\.ibd cannot be decrypted"); call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t1\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]"); call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\]"); call mtr.add_suppression("InnoDB: Plugin initialization aborted"); diff --git a/mysql-test/suite/encryption/t/innodb-redo-badkey.test b/mysql-test/suite/encryption/t/innodb-redo-badkey.test index 7f855cba5a9..be8555584bb 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-badkey.test +++ b/mysql-test/suite/encryption/t/innodb-redo-badkey.test @@ -5,7 +5,7 @@ call mtr.add_suppression("Plugin 'file_key_management'"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); -call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file test/t[1-4] cannot be decrypted"); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file .*test/t[1-4]\\.ibd cannot be decrypted"); call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t1\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]"); call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\]"); call mtr.add_suppression("InnoDB: Plugin initialization aborted"); From 71931fdf837b88e003998d12442a41c4f2c08c4a Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Mon, 28 Aug 2017 19:41:13 +0300 Subject: [PATCH 072/101] Fix results for parts/repair_table test after enabling it for MyISAM --- mysql-test/suite/storage_engine/parts/repair_table.opt | 1 + mysql-test/suite/storage_engine/parts/repair_table.result | 1 + .../mysql-test/storage_engine/parts/repair_table.rdiff | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 mysql-test/suite/storage_engine/parts/repair_table.opt diff --git a/mysql-test/suite/storage_engine/parts/repair_table.opt b/mysql-test/suite/storage_engine/parts/repair_table.opt new file mode 100644 index 00000000000..759bf0b6429 --- /dev/null +++ b/mysql-test/suite/storage_engine/parts/repair_table.opt @@ -0,0 +1 @@ +--myisam-recover-options=DEFAULT diff --git a/mysql-test/suite/storage_engine/parts/repair_table.result b/mysql-test/suite/storage_engine/parts/repair_table.result index d9ac215797b..727c648ef6f 100644 --- a/mysql-test/suite/storage_engine/parts/repair_table.result +++ b/mysql-test/suite/storage_engine/parts/repair_table.result @@ -88,6 +88,7 @@ call mtr.add_suppression("Got an error from thread_id=.*"); call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table"); call mtr.add_suppression(" '\..test.t1'"); call mtr.add_suppression("Couldn't repair table: test.t1"); +call mtr.add_suppression("Table 't1' is marked as crashed.*"); CREATE TABLE t1 (a , b , (a)) ENGINE= PARTITION BY HASH(a) PARTITIONS 2; REPAIR TABLE t1; Table Op Msg_type Msg_text diff --git a/storage/myisammrg/mysql-test/storage_engine/parts/repair_table.rdiff b/storage/myisammrg/mysql-test/storage_engine/parts/repair_table.rdiff index 4346545abcf..35d4f6b63d6 100644 --- a/storage/myisammrg/mysql-test/storage_engine/parts/repair_table.rdiff +++ b/storage/myisammrg/mysql-test/storage_engine/parts/repair_table.rdiff @@ -1,6 +1,6 @@ ---- suite/storage_engine/parts/repair_table.result 2017-05-20 03:58:19.451939791 +0300 -+++ ../storage/myisammrg/mysql-test/storage_engine/parts/repair_table.reject 2017-05-24 02:42:31.130318292 +0300 -@@ -1,234 +1,115 @@ +--- suite/storage_engine/parts/repair_table.result 2017-08-28 19:29:20.491633306 +0300 ++++ suite/storage_engine/parts/repair_table.reject 2017-08-28 19:34:41.723633059 +0300 +@@ -1,235 +1,115 @@ call mtr.add_suppression("Table '.*t1.*' is marked as crashed and should be repaired"); DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (a , b ) ENGINE= PARTITION BY HASH(a) PARTITIONS 2; @@ -144,7 +144,7 @@ call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table"); call mtr.add_suppression(" '\..test.t1'"); call mtr.add_suppression("Couldn't repair table: test.t1"); -+call mtr.add_suppression("Table 't1' is marked as crashed.*"); + call mtr.add_suppression("Table 't1' is marked as crashed.*"); CREATE TABLE t1 (a , b , (a)) ENGINE= PARTITION BY HASH(a) PARTITIONS 2; +ERROR HY000: Engine cannot be used in partitioned tables +# ERROR: Statement ended with errno 1572, errname ER_PARTITION_MERGE_ERROR (expected to succeed) From 05e7d35e898a1827464627ebfb815f4707ac6ac1 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Thu, 24 Aug 2017 23:15:55 +0300 Subject: [PATCH 073/101] MDEV-13583 Improvements for MTR rebootstrap introduced in MDEV-12042 - make re-bootstrap run with all extra options, not only InnoDB ones - re-use previously created bootstrap.sql - add --console - fix debian patch to keep it applicable --- debian/patches/50_mysql-test__db_test.dpatch | 18 +- mysql-test/mysql-test-run.pl | 173 ++++++++++--------- mysql-test/r/mysqld--help.result | 2 +- 3 files changed, 99 insertions(+), 94 deletions(-) diff --git a/debian/patches/50_mysql-test__db_test.dpatch b/debian/patches/50_mysql-test__db_test.dpatch index 670afbf14ac..14c0fc4acf6 100755 --- a/debian/patches/50_mysql-test__db_test.dpatch +++ b/debian/patches/50_mysql-test__db_test.dpatch @@ -11,14 +11,14 @@ --- old/mysql-test/mysql-test-run.pl 2009-06-16 14:24:09.000000000 +0200 +++ new/mysql-test/mysql-test-run.pl 2009-07-04 00:03:34.000000000 +0200 @@ -3578,6 +3578,11 @@ sub mysql_install_db { - mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql", - $bootstrap_sql_file); + mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql", + $bootstrap_sql_file); -+ mtr_tofile($bootstrap_sql_file, "-- Debian removed the default privileges on the 'test' database\n"); -+ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n"); -+ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test\\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n"); -+ ++ mtr_tofile($bootstrap_sql_file, "-- Debian removed the default privileges on the 'test' database\n"); ++ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n"); ++ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test\\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n"); + - # Add test data for timezone - this is just a subset, on a real - # system these tables will be populated either by mysql_tzinfo_to_sql - # or by downloading the timezone table package from our website ++ + # Add test data for timezone - this is just a subset, on a real + # system these tables will be populated either by mysql_tzinfo_to_sql + # or by downloading the timezone table package from our website diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 6b0c3b370de..c5c22893988 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3509,14 +3509,16 @@ sub mysql_install_db { mtr_add_arg($args, "--bootstrap"); mtr_add_arg($args, "--basedir=%s", $install_basedir); mtr_add_arg($args, "--datadir=%s", $install_datadir); + mtr_add_arg($args, "--plugin-dir=%s", $plugindir); mtr_add_arg($args, "--default-storage-engine=myisam"); - mtr_add_arg($args, "--skip-plugin-$_") for @optional_plugins; + mtr_add_arg($args, "--loose-skip-plugin-$_") for @optional_plugins; # starting from 10.0 bootstrap scripts require InnoDB mtr_add_arg($args, "--loose-innodb"); mtr_add_arg($args, "--loose-innodb-log-file-size=5M"); mtr_add_arg($args, "--disable-sync-frm"); mtr_add_arg($args, "--tmpdir=%s", "$opt_vardir/tmp/"); mtr_add_arg($args, "--core-file"); + mtr_add_arg($args, "--console"); if ( $opt_debug ) { @@ -3535,13 +3537,6 @@ sub mysql_install_db { mtr_add_arg($args, $extra_opt); } } - # InnoDB options can come not only from the command line, but also - # from option files or combinations - foreach my $extra_opt ( @$extra_opts ) { - if ($extra_opt =~ /--innodb/) { - mtr_add_arg($args, $extra_opt); - } - } # If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g., # configure --disable-grant-options), mysqld will not recognize the @@ -3556,98 +3551,108 @@ sub mysql_install_db { # ---------------------------------------------------------------------- $ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args); - + # Extra options can come not only from the command line, but also + # from option files or combinations. We want them on a command line + # that is executed now, because otherwise the datadir might be + # incompatible with the test settings, but not on the general + # $MYSQLD_BOOTSTRAP_CMD line + foreach my $extra_opt ( @$extra_opts ) { + mtr_add_arg($args, $extra_opt); + } # ---------------------------------------------------------------------- # Create the bootstrap.sql file # ---------------------------------------------------------------------- - my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql"; + my $bootstrap_sql_file= "$opt_vardir/log/bootstrap.sql"; - if ($opt_boot_gdb) { - gdb_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), - $bootstrap_sql_file); - } - if ($opt_boot_dbx) { - dbx_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), - $bootstrap_sql_file); - } - if ($opt_boot_ddd) { - ddd_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), - $bootstrap_sql_file); - } - - my $path_sql= my_find_file($install_basedir, - ["mysql", "sql/share", "share/mariadb", - "share/mysql", "share", "scripts"], - "mysql_system_tables.sql", - NOT_REQUIRED); - - if (-f $path_sql ) + if (! -e $bootstrap_sql_file) { - my $sql_dir= dirname($path_sql); - # Use the mysql database for system tables - mtr_tofile($bootstrap_sql_file, "use mysql;\n"); + if ($opt_boot_gdb) { + gdb_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + if ($opt_boot_dbx) { + dbx_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + if ($opt_boot_ddd) { + ddd_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } - # Add the offical mysql system tables - # for a production system - mtr_appendfile_to_file("$sql_dir/mysql_system_tables.sql", - $bootstrap_sql_file); + my $path_sql= my_find_file($install_basedir, + ["mysql", "sql/share", "share/mariadb", + "share/mysql", "share", "scripts"], + "mysql_system_tables.sql", + NOT_REQUIRED); - # Add the performance tables - # for a production system - mtr_appendfile_to_file("$sql_dir/mysql_performance_tables.sql", - $bootstrap_sql_file); + if (-f $path_sql ) + { + my $sql_dir= dirname($path_sql); + # Use the mysql database for system tables + mtr_tofile($bootstrap_sql_file, "use mysql;\n"); - # Add the mysql system tables initial data - # for a production system - mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql", - $bootstrap_sql_file); + # Add the offical mysql system tables + # for a production system + mtr_appendfile_to_file("$sql_dir/mysql_system_tables.sql", + $bootstrap_sql_file); - # Add test data for timezone - this is just a subset, on a real - # system these tables will be populated either by mysql_tzinfo_to_sql - # or by downloading the timezone table package from our website - mtr_appendfile_to_file("$sql_dir/mysql_test_data_timezone.sql", - $bootstrap_sql_file); + # Add the performance tables + # for a production system + mtr_appendfile_to_file("$sql_dir/mysql_performance_tables.sql", + $bootstrap_sql_file); - # Fill help tables, just an empty file when running from bk repo - # but will be replaced by a real fill_help_tables.sql when - # building the source dist - mtr_appendfile_to_file("$sql_dir/fill_help_tables.sql", - $bootstrap_sql_file); + # Add the mysql system tables initial data + # for a production system + mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql", + $bootstrap_sql_file); - # mysql.gtid_slave_pos was created in InnoDB, but many tests - # run without InnoDB. Alter it to MyISAM now - mtr_tofile($bootstrap_sql_file, "ALTER TABLE gtid_slave_pos ENGINE=MyISAM;\n"); - } - else - { - # Install db from init_db.sql that exist in early 5.1 and 5.0 - # versions of MySQL - my $init_file= "$install_basedir/mysql-test/lib/init_db.sql"; - mtr_report(" - from '$init_file'"); - my $text= mtr_grab_file($init_file) or - mtr_error("Can't open '$init_file': $!"); + # Add test data for timezone - this is just a subset, on a real + # system these tables will be populated either by mysql_tzinfo_to_sql + # or by downloading the timezone table package from our website + mtr_appendfile_to_file("$sql_dir/mysql_test_data_timezone.sql", + $bootstrap_sql_file); + # Fill help tables, just an empty file when running from bk repo + # but will be replaced by a real fill_help_tables.sql when + # building the source dist + mtr_appendfile_to_file("$sql_dir/fill_help_tables.sql", + $bootstrap_sql_file); + + # mysql.gtid_slave_pos was created in InnoDB, but many tests + # run without InnoDB. Alter it to MyISAM now + mtr_tofile($bootstrap_sql_file, "ALTER TABLE gtid_slave_pos ENGINE=MyISAM;\n"); + } + else + { + # Install db from init_db.sql that exist in early 5.1 and 5.0 + # versions of MySQL + my $init_file= "$install_basedir/mysql-test/lib/init_db.sql"; + mtr_report(" - from '$init_file'"); + my $text= mtr_grab_file($init_file) or + mtr_error("Can't open '$init_file': $!"); + + mtr_tofile($bootstrap_sql_file, + sql_to_bootstrap($text)); + } + + # Remove anonymous users mtr_tofile($bootstrap_sql_file, - sql_to_bootstrap($text)); + "DELETE FROM mysql.user where user= '';\n"); + + # Create mtr database + mtr_tofile($bootstrap_sql_file, + "CREATE DATABASE mtr CHARSET=latin1;\n"); + + # Add help tables and data for warning detection and supression + mtr_tofile($bootstrap_sql_file, + sql_to_bootstrap(mtr_grab_file("include/mtr_warnings.sql"))); + + # Add procedures for checking server is restored after testcase + mtr_tofile($bootstrap_sql_file, + sql_to_bootstrap(mtr_grab_file("include/mtr_check.sql"))); } - # Remove anonymous users - mtr_tofile($bootstrap_sql_file, - "DELETE FROM mysql.user where user= '';\n"); - - # Create mtr database - mtr_tofile($bootstrap_sql_file, - "CREATE DATABASE mtr CHARSET=latin1;\n"); - - # Add help tables and data for warning detection and supression - mtr_tofile($bootstrap_sql_file, - sql_to_bootstrap(mtr_grab_file("include/mtr_warnings.sql"))); - - # Add procedures for checking server is restored after testcase - mtr_tofile($bootstrap_sql_file, - sql_to_bootstrap(mtr_grab_file("include/mtr_check.sql"))); - # Log bootstrap command my $path_bootstrap_log= "$opt_vardir/log/bootstrap.log"; mtr_tofile($path_bootstrap_log, diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index 014547b63a9..79a00a568b2 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -1083,7 +1083,7 @@ character-sets-dir MYSQL_CHARSETSDIR/ chroot (No default value) completion-type NO_CHAIN concurrent-insert AUTO -console FALSE +console TRUE date-format %Y-%m-%d datetime-format %Y-%m-%d %H:%i:%s deadlock-search-depth-long 15 From dda40b930498b70bb5546f857b27744039a5649d Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 28 Aug 2017 18:28:07 +0000 Subject: [PATCH 074/101] AWS Key Management : Introduce "mock" variable, available in debug build. If this variable is set, skip actual AWS calls, and fake/mock both generation and encryption of the keys. The advantage of having a mock mode is that more aws_key_management tests can be enabled on buildbot. --- client/mysqltest.cc | 18 ++ .../mariabackup/xb_aws_key_management.opt | 2 +- .../mariabackup/xb_aws_key_management.result | 5 + .../mariabackup/xb_aws_key_management.test | 6 +- plugin/aws_key_management/CMakeLists.txt | 1 + .../aws_key_management_plugin.cc | 202 ++++++++++++++---- 6 files changed, 189 insertions(+), 45 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 99e4e4dfc66..155d0c4c092 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -4024,7 +4024,25 @@ static int rmtree(const char *dir) strxnmov(path, sizeof(path), dir, sep, file->name, NULL); if (!MY_S_ISDIR(file->mystat->st_mode)) + { err= my_delete(path, 0); +#ifdef _WIN32 + /* + On Windows, check and possible reset readonly attribute. + my_delete(), or DeleteFile does not remove theses files. + */ + if (err) + { + DWORD attr= GetFileAttributes(path); + if (attr != INVALID_FILE_ATTRIBUTES && + (attr & FILE_ATTRIBUTE_READONLY)) + { + SetFileAttributes(path, attr &~ FILE_ATTRIBUTE_READONLY); + err= my_delete(path, 0); + } + } +#endif + } else err= rmtree(path); diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.opt b/mysql-test/suite/mariabackup/xb_aws_key_management.opt index 62d4f864073..fceff3be28d 100644 --- a/mysql-test/suite/mariabackup/xb_aws_key_management.opt +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.opt @@ -1,3 +1,3 @@ --plugin-load-add=$AWS_KEY_MANAGEMENT_SO --loose-aws-key-management ---loose-aws-key-management-master-key-id=$AWS_KEY_MANAGEMENT_MASTER_KEY_ID +--loose-aws-key-management-mock=ON diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.result b/mysql-test/suite/mariabackup/xb_aws_key_management.result index ccad423f631..6efc76a8be3 100644 --- a/mysql-test/suite/mariabackup/xb_aws_key_management.result +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.result @@ -1,4 +1,7 @@ CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes; +Warnings: +Note 1105 AWS KMS plugin: generated encrypted datakey for key id=1, version=1 +Note 1105 AWS KMS plugin: loaded key 1, version 1, key length 128 bit INSERT INTO t VALUES('foobar1'); # xtrabackup backup # shutdown server @@ -8,4 +11,6 @@ INSERT INTO t VALUES('foobar1'); SELECT * from t; c foobar1 +Warnings: +Note 1105 AWS KMS plugin: loaded key 1, version 1, key length 128 bit DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.test b/mysql-test/suite/mariabackup/xb_aws_key_management.test index ca01be607c7..149e422c058 100644 --- a/mysql-test/suite/mariabackup/xb_aws_key_management.test +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.test @@ -1,13 +1,9 @@ +--source include/have_debug.inc if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'aws_key_management' AND PLUGIN_STATUS='ACTIVE'`) { --skip needs aws_key_management plugin plugin } -if (`SELECT @@aws_key_management_master_key_id=''`) -{ - --skip Test requires AWS_KEY_MANAGEMEMENT_MASTER_KEY_ID env. variable -} - CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes; INSERT INTO t VALUES('foobar1'); echo # xtrabackup backup; diff --git a/plugin/aws_key_management/CMakeLists.txt b/plugin/aws_key_management/CMakeLists.txt index 00e788ffbd5..9221b54ef7e 100644 --- a/plugin/aws_key_management/CMakeLists.txt +++ b/plugin/aws_key_management/CMakeLists.txt @@ -20,6 +20,7 @@ MACRO(SKIP_AWS_PLUGIN msg) ENDIF() RETURN() ENDMACRO() +SET(CMAKE_CXX_STANDARD 11) MYSQL_ADD_PLUGIN(aws_key_management aws_key_management_plugin.cc DISABLED COMPONENT aws-key-management) diff --git a/plugin/aws_key_management/aws_key_management_plugin.cc b/plugin/aws_key_management/aws_key_management_plugin.cc index 365c5caf198..60ca6fd1ff3 100644 --- a/plugin/aws_key_management/aws_key_management_plugin.cc +++ b/plugin/aws_key_management/aws_key_management_plugin.cc @@ -82,9 +82,20 @@ static unsigned long log_level; static int rotate_key; static int request_timeout; +#ifndef DBUG_OFF +#define WITH_AWS_MOCK 1 +#else +#define WITH_AWS_MOCK 0 +#endif + +#if WITH_AWS_MOCK +static char mock; +#endif + + /* AWS functionality*/ -static int aws_decrypt_key(const char *path, KEY_INFO *info); -static int aws_generate_datakey(uint key_id, uint version); +static int read_and_decrypt_key(const char *path, KEY_INFO *info); +static int generate_and_save_datakey(uint key_id, uint version); static int extract_id_and_version(const char *name, uint *id, uint *ver); static unsigned int get_latest_key_version(unsigned int key_id); @@ -95,6 +106,35 @@ static std::mutex mtx; static Aws::KMS::KMSClient *client; +#if WITH_AWS_MOCK +/* + Mock routines to test plugin without actual AWS KMS interaction + we only need to mock 2 functions - generating encrypted key, and decrypt + + This mock functions do no-op encryption, i.e encrypt and decrypt of + a buffer return the buffer itself. +*/ + +/* + Generate random "encrypted" key. We do not encrypt anything in mock mode. +*/ +static int mock_generate_encrypted_key(Aws::Utils::ByteBuffer *result) +{ + size_t len = key_spec == 0?16 : 32; + *result = Aws::Utils::ByteBuffer(len); + my_random_bytes(result->GetUnderlyingData(), (int)len); + return 0; +} + + +static int mock_decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output, Aws::String *errmsg) +{ + /* We do not encrypt or decrypt in mock mode.*/ + *output = input; + return 0; +} +#endif + /* Redirect AWS trace to error log */ class MySQLLogSystem : public Aws::Utils::Logging::FormattedLogSystem { @@ -163,13 +203,7 @@ static vector traverse_current_directory() Aws::SDKOptions sdkOptions; -/* - Plugin initialization. - - Create KMS client and scan datadir to find out which keys and versions - are present. -*/ -static int plugin_init(void *p) +static int aws_init() { #ifdef HAVE_YASSL @@ -198,7 +232,29 @@ static int plugin_init(void *p) my_printf_error(ER_UNKNOWN_ERROR, "Can not initialize KMS client", ME_ERROR_LOG | ME_WARNING); return -1; } - + return 0; +} + +static int init() +{ +#if WITH_AWS_MOCK + if(mock) + return 0; +#endif + return aws_init(); +} + +/* + Plugin initialization. + + Create KMS client and scan datadir to find out which keys and versions + are present. +*/ +static int plugin_init(void *p) +{ + if (init()) + return -1; + vector files= traverse_current_directory(); for (size_t i=0; i < files.size(); i++) { @@ -214,14 +270,29 @@ static int plugin_init(void *p) } +static void aws_shutdown() +{ + delete client; + ShutdownAWSLogging(); + Aws::ShutdownAPI(sdkOptions); +} + + +static void shutdown() +{ +#if WITH_AWS_MOCK + if(mock) + return; +#endif + aws_shutdown(); +} + + static int plugin_deinit(void *p) { latest_version_cache.clear(); key_info_cache.clear(); - delete client; - ShutdownAWSLogging(); - - Aws::ShutdownAPI(sdkOptions); + shutdown(); return 0; } @@ -251,7 +322,7 @@ static int load_key(KEY_INFO *info) char path[256]; format_keyfile_name(path, sizeof(path), info->key_id, info->key_version); - ret= aws_decrypt_key(path, info); + ret= read_and_decrypt_key(path, info); if (ret) info->load_failed= true; @@ -317,14 +388,7 @@ static unsigned int get_latest_key_version_nolock(unsigned int key_id) else // (ver == 0) { /* Generate a new key, version 1 */ - if (!master_key_id[0]) - { - my_printf_error(ER_UNKNOWN_ERROR, - "Can't generate encryption key %u, because 'aws_key_management_master_key_id' parameter is not set", - MYF(0), key_id); - return(ENCRYPTION_KEY_VERSION_INVALID); - } - if (aws_generate_datakey(key_id, 1) != 0) + if (generate_and_save_datakey(key_id, 1) != 0) return(ENCRYPTION_KEY_VERSION_INVALID); info.key_id= key_id; info.key_version= 1; @@ -336,11 +400,35 @@ static unsigned int get_latest_key_version_nolock(unsigned int key_id) return(info.key_version); } +/* Decrypt Byte buffer with AWS. */ +static int aws_decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output, Aws::String *errmsg) +{ + DecryptRequest request; + request.SetCiphertextBlob(input); + DecryptOutcome outcome = client->Decrypt(request); + if (!outcome.IsSuccess()) + { + *errmsg = outcome.GetError().GetMessage(); + return -1; + } + *output= outcome.GetResult().GetPlaintext(); + return 0; +} + + +static int decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output, Aws::String *errmsg) +{ +#if WITH_AWS_MOCK + if(mock) + return mock_decrypt(input,output, errmsg); +#endif + return aws_decrypt(input, output, errmsg); +} /* Decrypt a file with KMS */ -static int aws_decrypt_key(const char *path, KEY_INFO *info) +static int read_and_decrypt_key(const char *path, KEY_INFO *info) { /* Read file content into memory */ @@ -361,20 +449,21 @@ static int aws_decrypt_key(const char *path, KEY_INFO *info) ifs.read(&contents[0], pos); /* Decrypt data the with AWS */ - DecryptRequest request; - Aws::Utils::ByteBuffer byteBuffer((unsigned char *)contents.data(), pos); - request.SetCiphertextBlob(byteBuffer); - DecryptOutcome outcome = client->Decrypt(request); - if (!outcome.IsSuccess()) + + Aws::Utils::ByteBuffer input((unsigned char *)contents.data(), pos); + Aws::Utils::ByteBuffer plaintext; + Aws::String errmsg; + + if (decrypt(input, &plaintext, &errmsg)) { - my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin: Decrypt failed for %s : %s", ME_ERROR_LOG, path, - outcome.GetError().GetMessage().c_str()); - return(-1); + my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin: Decrypt failed for %s : %s", ME_ERROR_LOG, path, + errmsg.c_str()); + return -1; } - Aws::Utils::ByteBuffer plaintext = outcome.GetResult().GetPlaintext(); + size_t len = plaintext.GetLength(); - if (len > (int)sizeof(info->data)) + if (len > sizeof(info->data)) { my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin: encoding key too large for %s", ME_ERROR_LOG, path); return(ENCRYPTION_KEY_BUFFER_TOO_SMALL); @@ -385,9 +474,15 @@ static int aws_decrypt_key(const char *path, KEY_INFO *info) } -/* Generate a new datakey and store it a file */ -static int aws_generate_datakey(uint keyid, uint version) +int aws_generate_encrypted_key(Aws::Utils::ByteBuffer *result) { + if (!master_key_id[0]) + { + my_printf_error(ER_UNKNOWN_ERROR, + "Can't generate encryption key, because 'aws_key_management_master_key_id' parameter is not set", + MYF(0)); + return(-1); + } GenerateDataKeyWithoutPlaintextRequest request; request.SetKeyId(master_key_id); request.SetKeySpec(DataKeySpecMapper::GetDataKeySpecForName(key_spec_names[key_spec])); @@ -401,11 +496,30 @@ static int aws_generate_datakey(uint keyid, uint version) outcome.GetError().GetMessage().c_str()); return(-1); } + *result = outcome.GetResult().GetCiphertextBlob(); + return 0; +} + + +static int generate_encrypted_key(Aws::Utils::ByteBuffer *output) +{ +#if WITH_AWS_MOCK + if(mock) + return mock_generate_encrypted_key(output); +#endif + return aws_generate_encrypted_key(output); +} + +/* Generate a new datakey and store it a file */ +static int generate_and_save_datakey(uint keyid, uint version) +{ + Aws::Utils::ByteBuffer byteBuffer; + + if (generate_encrypted_key(&byteBuffer)) + return -1; string out; char filename[20]; - Aws::Utils::ByteBuffer byteBuffer = outcome.GetResult().GetCiphertextBlob(); - format_keyfile_name(filename, sizeof(filename), keyid, version); int fd= open(filename, O_WRONLY |O_CREAT|O_BINARY, IF_WIN(_S_IREAD, S_IRUSR| S_IRGRP| S_IROTH)); if (fd < 0) @@ -438,7 +552,7 @@ static int rotate_single_key(uint key_id) my_printf_error(ER_UNKNOWN_ERROR, "key %u does not exist", MYF(ME_JUST_WARNING), key_id); return -1; } - else if (aws_generate_datakey(key_id, ver + 1)) + else if (generate_and_save_datakey(key_id, ver + 1)) { my_printf_error(ER_UNKNOWN_ERROR, "Could not generate datakey for key id= %u, ver= %u", MYF(ME_JUST_WARNING), key_id, ver); @@ -594,6 +708,13 @@ static MYSQL_SYSVAR_STR(region, region, "AWS region. For example us-east-1, or eu-central-1. If no value provided, SDK default is used.", NULL, NULL, ""); +#if WITH_AWS_MOCK +static MYSQL_SYSVAR_BOOL(mock, mock, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Mock AWS KMS calls (for testing).", + NULL, NULL, 0); +#endif + static struct st_mysql_sys_var* settings[]= { MYSQL_SYSVAR(master_key_id), MYSQL_SYSVAR(key_spec), @@ -601,6 +722,9 @@ static struct st_mysql_sys_var* settings[]= { MYSQL_SYSVAR(log_level), MYSQL_SYSVAR(request_timeout), MYSQL_SYSVAR(region), +#if WITH_AWS_MOCK + MYSQL_SYSVAR(mock), +#endif NULL }; From 888a8b69bd12ea979024448ba6893af770478bb2 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Tue, 29 Aug 2017 10:52:52 +0300 Subject: [PATCH 075/101] MDEV-13437 InnoDB fails to return error for XA COMMIT or XA ROLLBACK in read-only mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assertions failed due to incorrect handling of the --tc-heuristic-recover option when InnoDB is in read-only mode either due to innodb_read_only=1 or innodb_force_recovery>3. InnoDB failed to refuse a XA COMMIT or XA ROLLBACK operation, and there were errors in the error handling in the upper layer. This was fixed by making InnoDB XA operations respect the high_level_read_only flag. The InnoDB part of the fix and parts of the test main.tc_heuristic_recover were provided by Marko Mäkelä. LOCK_log mutex lock/unlock had to be added to fix MDEV-13438. The measure is confirmed by mysql sources as well. For testing of the conflicting option combination, mysql-test-run is made to export a new $MYSQLD_LAST_CMD. It holds the very last value generated by mtr.mysqld_start(). Even though the options have been also always stored in $mysqld->{'started_opts'} there were no access to them beyond the automatic server restart by mtr through the expect file interface. Effectively therefore $MYSQLD_LAST_CMD represents a more general interface to $mysqld->{'started_opts'} which can be used in wider scopes including server launch with incompatible options. Notice another existing method to restart the server with incompatible options relying on $MYSQLD_CMD is is aware of $mysqld->{'started_opts'} (the actual options that the server is launched by mtr). In order to use this method they would have to be provided manually. NOTE: When merging to 10.2, the file search_pattern_in_file++.inc should be replaced with the pre-existing search_pattern_in_file.inc. --- mysql-test/include/fail_start_mysqld.inc | 18 +++ mysql-test/include/restart_mysqld.inc | 2 +- .../include/search_pattern_in_file++.inc | 80 +++++++++++++ mysql-test/include/shutdown_mysqld.inc | 16 ++- mysql-test/mysql-test-run.pl | 5 + mysql-test/r/tc_heuristic_recover.result | 37 ++++++ mysql-test/t/tc_heuristic_recover.test | 106 ++++++++++++++++++ sql/handler.cc | 43 +++++-- sql/log.cc | 2 + storage/innobase/handler/ha_innodb.cc | 9 +- storage/xtradb/handler/ha_innodb.cc | 9 +- 11 files changed, 314 insertions(+), 13 deletions(-) create mode 100644 mysql-test/include/fail_start_mysqld.inc create mode 100644 mysql-test/include/search_pattern_in_file++.inc create mode 100644 mysql-test/r/tc_heuristic_recover.result create mode 100644 mysql-test/t/tc_heuristic_recover.test diff --git a/mysql-test/include/fail_start_mysqld.inc b/mysql-test/include/fail_start_mysqld.inc new file mode 100644 index 00000000000..bb1085b5dd7 --- /dev/null +++ b/mysql-test/include/fail_start_mysqld.inc @@ -0,0 +1,18 @@ +# ==== Usage ==== +# +# [--let $restart_parameters= --innodb-force-recovery=0 --innodb-read-only=1] +# [--let $mysqld_stub_cmd= $MYSQLD_LAST_CMD] +# [--let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err] +# --source include/fail_restart_mysqld.inc + +# Evaluate the default of $error_log +if (!$error_log) +{ + --let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err +} + +--error 1 +--exec $mysqld_stub_cmd $restart_parameters >> $error_log 2>&1 + +# As the server is stopped +--disable_reconnect diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc index dcaf47c55a2..940e081c431 100644 --- a/mysql-test/include/restart_mysqld.inc +++ b/mysql-test/include/restart_mysqld.inc @@ -31,7 +31,7 @@ if ($shutdown_timeout == 0) --exec echo "wait" > $_expect_file_name # Send shutdown to the connected server and give -# it 10 seconds to die before zapping it +# it an opted number of seconds to die before zapping it shutdown_server $server_shutdown_timeout; # Write file to make mysql-test-run.pl start up the server again diff --git a/mysql-test/include/search_pattern_in_file++.inc b/mysql-test/include/search_pattern_in_file++.inc new file mode 100644 index 00000000000..3c5529989bb --- /dev/null +++ b/mysql-test/include/search_pattern_in_file++.inc @@ -0,0 +1,80 @@ +# Purpose: +# Simple search with Perl for a pattern in some file. +# +# The advantages compared to thinkable auxiliary constructs using the +# mysqltest language and SQL are: +# 1. We do not need a running MySQL server. +# 2. SQL causes "noise" during debugging and increases the size of logs. +# Perl code does not disturb at all. +# +# The environment variables SEARCH_FILE and SEARCH_PATTERN must be set +# before sourcing this routine. +# +# Optionally, SEARCH_RANGE can be set to the max number of bytes of the file +# to search. If negative, it will search that many bytes at the end of the +# file. By default the search happens from the last CURRENT_TEST: +# marker till the end of file (appropriate for searching error logs). +# +# Optionally, SEARCH_ABORT can be set to "FOUND" or "NOT FOUND" and this +# will abort if the search result doesn't match the requested one. +# +# In case of +# - SEARCH_FILE and/or SEARCH_PATTERN is not set +# - SEARCH_FILE cannot be opened +# the test will abort immediate. +# +# Typical use case (check invalid server startup options): +# let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err; +# --error 0,1 +# --remove_file $error_log +# let SEARCH_FILE= $error_log; +# # Stop the server +# let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; +# --exec echo "wait" > $restart_file +# --shutdown_server 10 +# --source include/wait_until_disconnected.inc +# +# --error 1 +# --exec $MYSQLD_CMD > $error_log 2>&1 +# # The server restart aborts +# let SEARCH_PATTERN= \[ERROR\] Aborting; +# --source include/search_pattern_in_file.inc +# +# Created: 2011-11-11 mleich +# + +perl; + use strict; + die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE}; + my @search_files= glob($ENV{SEARCH_FILE}); + my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set"; + my $search_range= $ENV{SEARCH_RANGE}; + my $content; + foreach my $search_file (@search_files) { + open(FILE, '<', $search_file) || die("Can't open file $search_file: $!"); + my $file_content; + if ($search_range > 0) { + read(FILE, $file_content, $search_range, 0); + } elsif ($search_range < 0) { + my $size= -s $search_file; + $search_range = -$size if $size > -$search_range; + seek(FILE, $search_range, 2); + read(FILE, $file_content, -$search_range, 0); + } else { + while() { # error log + if (/^CURRENT_TEST:/) { + $content=''; + } else { + $content.=$_; + } + } + } + close(FILE); + $content.= $file_content; + } + my @matches=($content =~ m/$search_pattern/gs); + my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND"; + $ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1}; + print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n"; + exit $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/; +EOF diff --git a/mysql-test/include/shutdown_mysqld.inc b/mysql-test/include/shutdown_mysqld.inc index 54bba1318e7..e28f3c244ca 100644 --- a/mysql-test/include/shutdown_mysqld.inc +++ b/mysql-test/include/shutdown_mysqld.inc @@ -1,3 +1,17 @@ +# ==== Usage ==== +# +# [--let $shutdown_timeout= 30] +# [--let $allow_rpl_inited= 1] +# --source include/shutdown_mysqld.inc + +# The default value is empty +--let $server_shutdown_timeout= + +if ($shutdown_timeout) +{ + --let $server_shutdown_timeout= $shutdown_timeout +} + # This is the first half of include/restart_mysqld.inc. if ($rpl_inited) { @@ -13,6 +27,6 @@ if ($rpl_inited) --exec echo "wait" > $_expect_file_name # Send shutdown to the connected server ---shutdown_server +--shutdown_server $server_shutdown_timeout --source include/wait_until_disconnected.inc diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index c5c22893988..1848b74eb0f 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -5573,6 +5573,11 @@ sub mysqld_start ($$) { # Remember options used when starting $mysqld->{'started_opts'}= $extra_opts; + # "Dynamic" version of MYSQLD_CMD is reevaluated with each mysqld_start. + # Use it to restart the server at testing a failing server start (e.g + # due to incompatible options). + $ENV{'MYSQLD_LAST_CMD'}= "$exe @$args"; + return; } diff --git a/mysql-test/r/tc_heuristic_recover.result b/mysql-test/r/tc_heuristic_recover.result new file mode 100644 index 00000000000..f5a295cbd9f --- /dev/null +++ b/mysql-test/r/tc_heuristic_recover.result @@ -0,0 +1,37 @@ +call mtr.add_suppression("Can't init tc log"); +call mtr.add_suppression("Found 1 prepared transactions!"); +call mtr.add_suppression("Aborting"); +set debug_sync='RESET'; +CREATE TABLE t1 (i INT) ENGINE=InnoDB; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +FLUSH TABLES; +set debug_sync='ha_commit_trans_after_prepare WAIT_FOR go'; +INSERT INTO t1 VALUES (1);; +# Prove that no COMMIT or ROLLBACK occurred yet. +SELECT * FROM t1; +i +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; +i +1 +# Kill the server +FOUND 1 /was in the XA prepared state/ in mysqld.1.err +FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err +NOT FOUND /\[ERROR\] Can\'t init tc log/ in mysqld.1.err +FOUND 2 /was in the XA prepared state/ in mysqld.1.err +FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err +FOUND 1 /\[ERROR\] Can\'t init tc log/ in mysqld.1.err +FOUND 1 /Please restart mysqld without --tc-heuristic-recover/ in mysqld.1.err +FOUND 3 /was in the XA prepared state/ in mysqld.1.err +FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err +FOUND 2 /\[ERROR\] Can\'t init tc log/ in mysqld.1.err +FOUND 2 /Please restart mysqld without --tc-heuristic-recover/ in mysqld.1.err +FOUND 3 /was in the XA prepared state/ in mysqld.1.err +FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SELECT * FROM t1; +i +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; +i +DROP TABLE t1; diff --git a/mysql-test/t/tc_heuristic_recover.test b/mysql-test/t/tc_heuristic_recover.test new file mode 100644 index 00000000000..5766f9b5e85 --- /dev/null +++ b/mysql-test/t/tc_heuristic_recover.test @@ -0,0 +1,106 @@ +# The test verifies a few server/engine recovery option combinations. +# Specifically, MDEV-13437,13438 are concerned with no crashes +# due to InnoDB being read-only during --tc-heuristic-recover=ROLLBACK|COMMIT. +# +# Initially the test commits a transaction and in the following proceeds +# throughout some phases. +# Within them the server is shut down and attempted to restart, to succeed +# that in the end. +# All this proves no crashes and effective rollback of the transaction. +# +--source include/have_innodb.inc +# The test logics really requires --log-bin. +--source include/have_binlog_format_mixed.inc +--source include/have_debug_sync.inc +--source include/not_embedded.inc + +call mtr.add_suppression("Can't init tc log"); +call mtr.add_suppression("Found 1 prepared transactions!"); +call mtr.add_suppression("Aborting"); + +# Now take a shapshot of the last time server options. +# +# The "restart" expect-file facility can't be engaged because the server +# having conflicting options may not succeed to boot up. +# Also notice $MYSQLD_CMD is too "static" being unaware of the actual options +# of the last (before shutdown or kill) server run. +# That's why $MYSQLD_LAST_CMD that allows for the server new start +# with more options appended to a stub set which is settled at this very point. +--let $mysqld_stub_cmd= $MYSQLD_LAST_CMD +--let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err +--let SEARCH_FILE= $error_log +set debug_sync='RESET'; + +CREATE TABLE t1 (i INT) ENGINE=InnoDB; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +FLUSH TABLES; # we need the table post crash-restart, see MDEV-8841. + +# Run transaction in a separate "prey" connection +--connect (con1,localhost,root,,) +# The signal won't arrive though +set debug_sync='ha_commit_trans_after_prepare WAIT_FOR go'; +--send INSERT INTO t1 VALUES (1); + +--connection default + +--let $table= information_schema.processlist +--let $where= where state = 'debug sync point: ha_commit_trans_after_prepare' +--let $wait_condition= SELECT count(*) = 1 FROM $table $where +--source include/wait_condition.inc + +--echo # Prove that no COMMIT or ROLLBACK occurred yet. +SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; + +# TODO: MDEV-12700 Allow innodb_read_only startup without prior slow shutdown. +--source include/kill_mysqld.inc +--let $restart_parameters= --innodb-force-recovery=4 +--source include/fail_start_mysqld.inc + +--let SEARCH_PATTERN= was in the XA prepared state +--source include/search_pattern_in_file++.inc +--let SEARCH_PATTERN= Found 1 prepared transactions! +--source include/search_pattern_in_file++.inc +--let SEARCH_PATTERN= \\[ERROR\\] Can\\'t init tc log +--source include/search_pattern_in_file++.inc + +--let $restart_parameters= --innodb-force-recovery=4 --tc-heuristic-recover=COMMIT +--source include/fail_start_mysqld.inc +--let SEARCH_PATTERN= was in the XA prepared state +--source include/search_pattern_in_file++.inc +--let SEARCH_PATTERN= Found 1 prepared transactions! +--source include/search_pattern_in_file++.inc +--let SEARCH_PATTERN= \\[ERROR\\] Can\\'t init tc log +--source include/search_pattern_in_file++.inc +--let SEARCH_PATTERN= Please restart mysqld without --tc-heuristic-recover +--source include/search_pattern_in_file++.inc + +--let $restart_parameters= --tc-heuristic-recover=ROLLBACK +--source include/fail_start_mysqld.inc + +--let SEARCH_PATTERN= was in the XA prepared state +--source include/search_pattern_in_file++.inc +--let SEARCH_PATTERN= Found 1 prepared transactions! +--source include/search_pattern_in_file++.inc +--let SEARCH_PATTERN= \\[ERROR\\] Can\\'t init tc log +--source include/search_pattern_in_file++.inc +--let SEARCH_PATTERN= Please restart mysqld without --tc-heuristic-recover +--source include/search_pattern_in_file++.inc + +--let $restart_parameters= +--source include/start_mysqld.inc + +--let SEARCH_PATTERN= was in the XA prepared state +--source include/search_pattern_in_file++.inc +--let SEARCH_PATTERN= Found 1 prepared transactions! +--source include/search_pattern_in_file++.inc + +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; +# +# Cleanup +# +DROP TABLE t1; diff --git a/sql/handler.cc b/sql/handler.cc index 2696d69bfcf..174034a7eb5 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -69,6 +69,14 @@ KEY_CREATE_INFO default_key_create_info= ulong total_ha= 0; /* number of storage engines (from handlertons[]) that support 2pc */ ulong total_ha_2pc= 0; +#ifndef DBUG_OFF +/* + Number of non-mandatory 2pc handlertons whose initialization failed + to estimate total_ha_2pc value under supposition of the failures + have not occcured. +*/ +ulong failed_ha_2pc= 0; +#endif /* size of savepoint storage area (see ha_init) */ ulong savepoint_alloc_size= 0; @@ -641,6 +649,10 @@ err_deinit: (void) plugin->plugin->deinit(NULL); err: +#ifndef DBUG_OFF + if (hton->prepare && hton->state == SHOW_OPTION_YES) + failed_ha_2pc++; +#endif my_free(hton); err_no_hton_memory: plugin->data= NULL; @@ -1823,7 +1835,7 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, { #ifndef DBUG_OFF char buf[XIDDATASIZE*4+6]; // see xid_to_str - sql_print_information("ignore xid %s", xid_to_str(buf, info->list+i)); + DBUG_PRINT("info", ("ignore xid %s", xid_to_str(buf, info->list+i))); #endif xid_cache_insert(info->list+i, XA_PREPARED); info->found_foreign_xids++; @@ -1840,19 +1852,31 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT) { #ifndef DBUG_OFF - char buf[XIDDATASIZE*4+6]; // see xid_to_str - sql_print_information("commit xid %s", xid_to_str(buf, info->list+i)); + int rc= +#endif + hton->commit_by_xid(hton, info->list+i); +#ifndef DBUG_OFF + if (rc == 0) + { + char buf[XIDDATASIZE*4+6]; // see xid_to_str + DBUG_PRINT("info", ("commit xid %s", xid_to_str(buf, info->list+i))); + } #endif - hton->commit_by_xid(hton, info->list+i); } else { #ifndef DBUG_OFF - char buf[XIDDATASIZE*4+6]; // see xid_to_str - sql_print_information("rollback xid %s", - xid_to_str(buf, info->list+i)); + int rc= +#endif + hton->rollback_by_xid(hton, info->list+i); +#ifndef DBUG_OFF + if (rc == 0) + { + char buf[XIDDATASIZE*4+6]; // see xid_to_str + DBUG_PRINT("info", ("rollback xid %s", + xid_to_str(buf, info->list+i))); + } #endif - hton->rollback_by_xid(hton, info->list+i); } } if (got < info->len) @@ -1874,7 +1898,8 @@ int ha_recover(HASH *commit_list) /* commit_list and tc_heuristic_recover cannot be set both */ DBUG_ASSERT(info.commit_list==0 || tc_heuristic_recover==0); /* if either is set, total_ha_2pc must be set too */ - DBUG_ASSERT(info.dry_run || total_ha_2pc>(ulong)opt_bin_log); + DBUG_ASSERT(info.dry_run || + (failed_ha_2pc + total_ha_2pc) > (ulong)opt_bin_log); if (total_ha_2pc <= (ulong)opt_bin_log) DBUG_RETURN(0); diff --git a/sql/log.cc b/sql/log.cc index ee92f22adb8..7a24e3743c0 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -8960,8 +8960,10 @@ int TC_LOG_BINLOG::open(const char *opt_name) if (using_heuristic_recover()) { + mysql_mutex_lock(&LOCK_log); /* generate a new binlog to mask a corrupted one */ open(opt_name, LOG_BIN, 0, WRITE_CACHE, max_binlog_size, 0, TRUE); + mysql_mutex_unlock(&LOCK_log); cleanup(); return 1; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 526836646d2..b9a89b289f8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -14446,6 +14446,10 @@ innobase_commit_by_xid( DBUG_ASSERT(hton == innodb_hton_ptr); + if (high_level_read_only) { + return(XAER_RMFAIL); + } + trx = trx_get_trx_by_xid(xid); if (trx) { @@ -14473,8 +14477,11 @@ innobase_rollback_by_xid( DBUG_ASSERT(hton == innodb_hton_ptr); - trx = trx_get_trx_by_xid(xid); + if (high_level_read_only) { + return(XAER_RMFAIL); + } + trx = trx_get_trx_by_xid(xid); if (trx) { int ret = innobase_rollback_trx(trx); trx_free_for_background(trx); diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index e4238af7747..68664562f97 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -15395,6 +15395,10 @@ innobase_commit_by_xid( DBUG_ASSERT(hton == innodb_hton_ptr); + if (high_level_read_only) { + return(XAER_RMFAIL); + } + trx = trx_get_trx_by_xid(xid); if (trx) { @@ -15422,8 +15426,11 @@ innobase_rollback_by_xid( DBUG_ASSERT(hton == innodb_hton_ptr); - trx = trx_get_trx_by_xid(xid); + if (high_level_read_only) { + return(XAER_RMFAIL); + } + trx = trx_get_trx_by_xid(xid); if (trx) { int ret = innobase_rollback_trx(trx); trx_free_for_background(trx); From 352d27ce36bc807f0c3c803e192ad1851f7f86a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 29 Aug 2017 14:23:34 +0300 Subject: [PATCH 076/101] MDEV-13557: Startup failure, unable to decrypt ibdata1 Fixes also MDEV-13488: InnoDB writes CRYPT_INFO even though encryption is not enabled. Problem was that we created encryption metadata (crypt_data) for system tablespace even when no encryption was enabled and too early. System tablespace can be encrypted only using key rotation. Test innodb-key-rotation-disable, innodb_encryption, innodb_lotoftables require adjustment because INFORMATION_SCHEMA INNODB_TABLESPACES_ENCRYPTION contain row only if tablespace really has encryption metadata. fil_crypt_set_thread_cnt: Send message to background encryption threads if they exits when they are ready. This is required to find tablespaces requiring key rotation if no other changes happen. fil_crypt_find_space_to_rotate: Decrease the amount of time waiting when nothing happens to better enable key rotation on startup. fsp_header_init: Write encryption metadata to page 0 only if tablespace is encrypted or encryption is disabled by table option. i_s_dict_fill_tablespaces_encryption : Skip tablespaces that do not contain encryption metadata. This is required to avoid too early wait condition trigger in encrypted -> unencrypted state transfer. open_or_create_data_files: Do not create encryption metadata by default to system tablespace. --- .../r/innodb-first-page-read.result | 61 +- .../r/innodb-key-rotation-disable.result | 3 - .../encryption/r/innodb_encryption.result | 58 +- .../encryption/r/innodb_lotoftables.result | 1182 ++++++++++++++++- .../encryption/t/innodb-first-page-read.test | 32 +- .../suite/encryption/t/innodb_encryption.test | 165 +-- .../encryption/t/innodb_lotoftables.test | 91 +- storage/innobase/fil/fil0crypt.cc | 17 +- storage/innobase/fil/fil0fil.cc | 2 +- storage/innobase/fsp/fsp0fsp.cc | 6 +- storage/innobase/handler/i_s.cc | 7 + storage/innobase/srv/srv0start.cc | 5 - storage/xtradb/fil/fil0crypt.cc | 17 +- storage/xtradb/fil/fil0fil.cc | 6 +- storage/xtradb/fsp/fsp0fsp.cc | 6 +- storage/xtradb/handler/i_s.cc | 7 + storage/xtradb/srv/srv0start.cc | 5 - 17 files changed, 1326 insertions(+), 344 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb-first-page-read.result b/mysql-test/suite/encryption/r/innodb-first-page-read.result index 4a55612af27..6df80e8223d 100644 --- a/mysql-test/suite/encryption/r/innodb-first-page-read.result +++ b/mysql-test/suite/encryption/r/innodb-first-page-read.result @@ -1,5 +1,6 @@ SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; +FLUSH STATUS; create database innodb_test; use innodb_test; create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb; @@ -50,40 +51,48 @@ insert into innodb_datadir1 select * from innodb_normal; insert into innodb_datadir2 select * from innodb_normal; insert into innodb_datadir3 select * from innodb_normal; commit; +FLUSH STATUS; # Restart server and see how many page 0's are read -# result should be less than actual number of tables -# i.e. < 23 + 3 = 26 -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 19 +# result should actual number of tables except remote tables could be read twice +# i.e. < 23 + 3*2 = 29 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 19 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 19 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 set global innodb_encrypt_tables=OFF; # wait until tables are decrypted -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 29 +# result should be actual number of tables except remote tables could be read twice +# i.e. < 23 + 3*2 = 29 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 29 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 +FLUSH STATUS; # restart and see number read page 0 -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 19 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 19 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 drop database innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 29 +FLUSH STATUS; diff --git a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result index 89677490d92..6c09e015a1e 100644 --- a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result +++ b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result @@ -2,9 +2,6 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ NAME SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; NAME -mysql/innodb_table_stats -mysql/innodb_index_stats -./ibdata1 create database enctests; use enctests; create table t1(a int not null primary key, b char(200)) engine=innodb; diff --git a/mysql-test/suite/encryption/r/innodb_encryption.result b/mysql-test/suite/encryption/r/innodb_encryption.result index ce494098d44..9194412133d 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption.result +++ b/mysql-test/suite/encryption/r/innodb_encryption.result @@ -8,25 +8,22 @@ innodb_encrypt_tables ON innodb_encryption_rotate_key_age 15 innodb_encryption_rotation_iops 100 innodb_encryption_threads 4 -DESCRIBE INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; -Field Type Null Key Default Extra -SPACE int(11) unsigned NO 0 -NAME varchar(655) YES NULL -ENCRYPTION_SCHEME int(11) unsigned NO 0 -KEYSERVER_REQUESTS int(11) unsigned NO 0 -MIN_KEY_VERSION int(11) unsigned NO 0 -CURRENT_KEY_VERSION int(11) unsigned NO 0 -KEY_ROTATION_PAGE_NUMBER bigint(21) unsigned YES NULL -KEY_ROTATION_MAX_PAGE_NUMBER bigint(21) unsigned YES NULL -CURRENT_KEY_ID int(11) unsigned NO 0 -ROTATING_OR_FLUSHING int(1) unsigned NO 0 -# Wait max 5 min for key encryption threads to encrypt one space -# Success! -# Wait max 10 min for key encryption threads to encrypt all space +SET GLOBAL innodb_encrypt_tables = ON; +# Wait max 10 min for key encryption threads to encrypt all spaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +./ibdata1 # Success! # Now turn off encryption and wait for threads to decrypt everything SET GLOBAL innodb_encrypt_tables = off; -# Wait max 10 min for key encryption threads to decrypt all space +# Wait max 10 min for key encryption threads to encrypt all spaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +./ibdata1 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME # Success! # Shutdown innodb_encryption_threads SET GLOBAL innodb_encryption_threads=0; @@ -34,16 +31,20 @@ SET GLOBAL innodb_encryption_threads=0; # since threads are off tables should remain unencrypted SET GLOBAL innodb_encrypt_tables = on; # Wait 15s to check that nothing gets encrypted +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +./ibdata1 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME # Success! # Startup innodb_encryption_threads SET GLOBAL innodb_encryption_threads=@start_global_value; -# Wait 1 min to check that it start encrypting again -# Success! -# -# Check that restart with encryption turned off works -# even if spaces are encrypted -# -# First wait max 10 min for key encryption threads to encrypt all spaces +# Wait max 10 min for key encryption threads to encrypt all spaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +./ibdata1 # Success! # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 SHOW VARIABLES LIKE 'innodb_encrypt%'; @@ -53,9 +54,8 @@ innodb_encrypt_tables OFF innodb_encryption_rotate_key_age 15 innodb_encryption_rotation_iops 100 innodb_encryption_threads 0 -SELECT COUNT(*) > 0 as should_be_1 -FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION -WHERE MIN_KEY_VERSION <> 0; -should_be_1 -1 -# Restart mysqld again...with default options +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +./ibdata1 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME diff --git a/mysql-test/suite/encryption/r/innodb_lotoftables.result b/mysql-test/suite/encryption/r/innodb_lotoftables.result index 86ab60e7836..c8b6e1a368e 100644 --- a/mysql-test/suite/encryption/r/innodb_lotoftables.result +++ b/mysql-test/suite/encryption/r/innodb_lotoftables.result @@ -19,10 +19,9 @@ commit work; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 +# should be empty +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; +NAME create database innodb_encrypted_2; use innodb_encrypted_2; show status like 'innodb_pages0_read%'; @@ -34,14 +33,112 @@ set autocommit=1; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 +# should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +# should contain 0 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME create database innodb_encrypted_3; use innodb_encrypted_3; show status like 'innodb_pages0_read%'; @@ -53,33 +150,626 @@ set autocommit=1; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -# should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 +# should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +# should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 use test; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 SET GLOBAL innodb_encrypt_tables = on; SET GLOBAL innodb_encryption_threads=4; -# Wait until all encrypted tables have been encrypted -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 @@ -129,26 +819,416 @@ Innodb_pages0_read 203 show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 303 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 SET GLOBAL innodb_encrypt_tables = off; SET GLOBAL innodb_encryption_threads=4; -# Wait until all default encrypted tables have been decrypted -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -# should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 303 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 use test; drop database innodb_encrypted_1; drop database innodb_encrypted_2; diff --git a/mysql-test/suite/encryption/t/innodb-first-page-read.test b/mysql-test/suite/encryption/t/innodb-first-page-read.test index 1fc07159e05..d661e4565d2 100644 --- a/mysql-test/suite/encryption/t/innodb-first-page-read.test +++ b/mysql-test/suite/encryption/t/innodb-first-page-read.test @@ -7,6 +7,8 @@ SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; --enable_warnings +FLUSH STATUS; + create database innodb_test; use innodb_test; create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb; @@ -63,16 +65,19 @@ insert into innodb_datadir2 select * from innodb_normal; insert into innodb_datadir3 select * from innodb_normal; commit; +FLUSH STATUS; + --echo # Restart server and see how many page 0's are read --source include/restart_mysqld.inc ---echo # result should be less than actual number of tables ---echo # i.e. < 23 + 3 = 26 -show status like 'innodb_pages0_read%'; +--echo # result should actual number of tables except remote tables could be read twice +--echo # i.e. < 23 + 3*2 = 29 + +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use innodb_test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; set global innodb_encrypt_tables=OFF; @@ -80,18 +85,25 @@ set global innodb_encrypt_tables=OFF; --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 --source include/wait_condition.inc -show status like 'innodb_pages0_read%'; +--echo # result should be actual number of tables except remote tables could be read twice +--echo # i.e. < 23 + 3*2 = 29 + +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use innodb_test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; + +FLUSH STATUS; --echo # restart and see number read page 0 -- source include/restart_mysqld.inc -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use innodb_test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; drop database innodb_test; -show status like 'innodb_pages0_read%'; +FLUSH STATUS; diff --git a/mysql-test/suite/encryption/t/innodb_encryption.test b/mysql-test/suite/encryption/t/innodb_encryption.test index 6e9f80aac0c..aab8c56f072 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption.test +++ b/mysql-test/suite/encryption/t/innodb_encryption.test @@ -15,78 +15,29 @@ SET @start_global_value = @@global.innodb_encryption_threads; SHOW VARIABLES LIKE 'innodb_encrypt%'; -DESCRIBE INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; +SET GLOBAL innodb_encrypt_tables = ON; ---echo # Wait max 5 min for key encryption threads to encrypt one space -let $cnt=300; -while ($cnt) -{ - let $success=`SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} ---echo # Success! +--echo # Wait max 10 min for key encryption threads to encrypt all spaces +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >= 1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; ---echo # Wait max 10 min for key encryption threads to encrypt all space -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} --echo # Success! --echo # Now turn off encryption and wait for threads to decrypt everything SET GLOBAL innodb_encrypt_tables = off; ---echo # Wait max 10 min for key encryption threads to decrypt all space -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} +--echo # Wait max 10 min for key encryption threads to encrypt all spaces +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; + --echo # Success! --echo # Shutdown innodb_encryption_threads @@ -97,84 +48,32 @@ SET GLOBAL innodb_encryption_threads=0; SET GLOBAL innodb_encrypt_tables = on; --echo # Wait 15s to check that nothing gets encrypted -let $cnt=15; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`; - if ($success) - { - real_sleep 1; - dec $cnt; - } - if (!$success) - { - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; - -- die Failure, tablespace getting encrypted even if innodb_encryption_threads=0 - } -} +--let $wait_timeout= 15 +--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; + --echo # Success! --echo # Startup innodb_encryption_threads SET GLOBAL innodb_encryption_threads=@start_global_value; ---echo # Wait 1 min to check that it start encrypting again -let $cnt=60; -while ($cnt) -{ - let $success=`SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 OR KEY_ROTATION_PAGE_NUMBER IS NOT NULL`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} ---echo # Success! +--echo # Wait max 10 min for key encryption threads to encrypt all spaces +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >=1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; ---echo # ---echo # Check that restart with encryption turned off works ---echo # even if spaces are encrypted ---echo # ---echo # First wait max 10 min for key encryption threads to encrypt all spaces -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} --echo # Success! --echo # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 -- let $restart_parameters=--innodb_encrypt_tables=0 --innodb_encryption_threads=0 -- source include/restart_mysqld.inc SHOW VARIABLES LIKE 'innodb_encrypt%'; -SELECT COUNT(*) > 0 as should_be_1 -FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION -WHERE MIN_KEY_VERSION <> 0; ---echo # Restart mysqld again...with default options --- let $restart_parameters= --- source include/restart_mysqld.inc +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; diff --git a/mysql-test/suite/encryption/t/innodb_lotoftables.test b/mysql-test/suite/encryption/t/innodb_lotoftables.test index 8bad356a9e0..e204de3bb7b 100644 --- a/mysql-test/suite/encryption/t/innodb_lotoftables.test +++ b/mysql-test/suite/encryption/t/innodb_lotoftables.test @@ -53,9 +53,8 @@ show status like 'innodb_pages0_read%'; # # Verify # ---echo # should be 100 - -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; +--echo # should be empty +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; # # This will create 100 tables that are encrypted always @@ -89,10 +88,10 @@ show status like 'innodb_pages0_read%'; # # Verify # ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +--echo # should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +--echo # should contain 0 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; # # This will create 100 tables that are not encrypted @@ -126,45 +125,26 @@ show status like 'innodb_pages0_read%'; # # Verify # ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; ---echo # should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +--echo # should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +--echo # should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; use test; show status like 'innodb_pages0_read%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; SET GLOBAL innodb_encrypt_tables = on; SET GLOBAL innodb_encryption_threads=4; ---echo # Wait until all encrypted tables have been encrypted -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; show status like 'innodb_pages0_read%'; --echo # Success! @@ -231,40 +211,19 @@ while ($tables) show status like 'innodb_pages0_read%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; SET GLOBAL innodb_encrypt_tables = off; SET GLOBAL innodb_encryption_threads=4; ---echo # Wait until all default encrypted tables have been decrypted -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; ---echo # should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -show status like 'innodb_pages0_read%'; + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; # # Cleanup diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index ef39aabb8c2..a388ce4b604 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1403,7 +1403,7 @@ fil_crypt_realloc_iops( DBUG_PRINT("ib_crypt", ("thr_no: %u only waited %lu%% skip re-estimate.", state->thread_no, - (100 * state->cnt_waited) / state->batch)); + (100 * state->cnt_waited) / (state->batch ? state->batch : 1))); } if (state->estimated_max_iops <= state->allocated_iops) { @@ -1506,7 +1506,7 @@ fil_crypt_find_space_to_rotate( /* we need iops to start rotating */ while (!state->should_shutdown() && !fil_crypt_alloc_iops(state)) { os_event_reset(fil_crypt_threads_event); - os_event_wait_time(fil_crypt_threads_event, 1000000); + os_event_wait_time(fil_crypt_threads_event, 100000); } if (state->should_shutdown()) { @@ -2303,7 +2303,7 @@ fil_crypt_set_thread_cnt( os_thread_create(fil_crypt_thread, NULL, &rotation_thread_id); ib_logf(IB_LOG_LEVEL_INFO, - "Creating #%d thread id %lu total threads %u.", + "Creating #%d encryption thread id %lu total threads %u.", i+1, os_thread_pf(rotation_thread_id), new_cnt); } } else if (new_cnt < srv_n_fil_crypt_threads) { @@ -2315,7 +2315,13 @@ fil_crypt_set_thread_cnt( while(srv_n_fil_crypt_threads_started != srv_n_fil_crypt_threads) { os_event_reset(fil_crypt_event); - os_event_wait_time(fil_crypt_event, 1000000); + os_event_wait_time(fil_crypt_event, 100000); + } + + /* Send a message to encryption threads that there could be + something to do. */ + if (srv_n_fil_crypt_threads) { + os_event_set(fil_crypt_threads_event); } } @@ -2461,9 +2467,10 @@ fil_space_crypt_get_status( ut_ad(space->n_pending_ops > 0); fil_crypt_read_crypt_data(const_cast(space)); - status->space = space->id; + status->space = ULINT_UNDEFINED; if (fil_space_crypt_t* crypt_data = space->crypt_data) { + status->space = space->id; mutex_enter(&crypt_data->mutex); status->scheme = crypt_data->type; status->keyserver_requests = crypt_data->keyserver_requests; diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 559ba26542f..7200c3c32e2 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -2214,7 +2214,7 @@ fil_write_flushed_lsn( /* If tablespace is not encrypted, stamp flush_lsn to first page of all system tablespace datafiles to avoid unnecessary error messages on possible downgrade. */ - if (space->crypt_data->min_key_version == 0) { + if (!space->crypt_data || space->crypt_data->min_key_version == 0) { fil_node_t* node; ulint sum_of_sizes = 0; diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 0b66856d2c3..1cf37f366d7 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -726,7 +726,11 @@ fsp_header_init(ulint space_id, ulint size, mtr_t* mtr) fil_space_t* space = fil_space_acquire(space_id); ut_ad(space); - if (space->crypt_data) { + /* Write encryption metadata to page 0 if tablespace is + encrypted or encryption is disabled by table option. */ + if (space->crypt_data && + (space->crypt_data->should_encrypt() || + space->crypt_data->not_encrypted())) { space->crypt_data->write_page0(page, mtr); } diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index da790a32a11..145100c8838 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -8212,6 +8212,12 @@ i_s_dict_fill_tablespaces_encryption( fil_space_crypt_get_status(space, &status); + /* If tablespace id does not match, we did not find + encryption information for this tablespace. */ + if (!space->crypt_data || space->id != status.space) { + goto skip; + } + OK(fields[TABLESPACES_ENCRYPTION_SPACE]->store(space->id)); OK(field_store_string(fields[TABLESPACES_ENCRYPTION_NAME], @@ -8246,6 +8252,7 @@ i_s_dict_fill_tablespaces_encryption( OK(schema_table_store_record(thd, table_to_fill)); +skip: DBUG_RETURN(0); } /*******************************************************************//** diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 703ab0c9dca..e5d1a6328b4 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1191,11 +1191,6 @@ check_first_page: ut_a(ret); if (i == 0) { - if (!crypt_data) { - crypt_data = fil_space_create_crypt_data(FIL_ENCRYPTION_DEFAULT, - FIL_DEFAULT_ENCRYPTION_KEY); - } - flags = FSP_FLAGS_PAGE_SSIZE(); fil_space_create(name, 0, flags, FIL_TABLESPACE, diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index ef39aabb8c2..a388ce4b604 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -1403,7 +1403,7 @@ fil_crypt_realloc_iops( DBUG_PRINT("ib_crypt", ("thr_no: %u only waited %lu%% skip re-estimate.", state->thread_no, - (100 * state->cnt_waited) / state->batch)); + (100 * state->cnt_waited) / (state->batch ? state->batch : 1))); } if (state->estimated_max_iops <= state->allocated_iops) { @@ -1506,7 +1506,7 @@ fil_crypt_find_space_to_rotate( /* we need iops to start rotating */ while (!state->should_shutdown() && !fil_crypt_alloc_iops(state)) { os_event_reset(fil_crypt_threads_event); - os_event_wait_time(fil_crypt_threads_event, 1000000); + os_event_wait_time(fil_crypt_threads_event, 100000); } if (state->should_shutdown()) { @@ -2303,7 +2303,7 @@ fil_crypt_set_thread_cnt( os_thread_create(fil_crypt_thread, NULL, &rotation_thread_id); ib_logf(IB_LOG_LEVEL_INFO, - "Creating #%d thread id %lu total threads %u.", + "Creating #%d encryption thread id %lu total threads %u.", i+1, os_thread_pf(rotation_thread_id), new_cnt); } } else if (new_cnt < srv_n_fil_crypt_threads) { @@ -2315,7 +2315,13 @@ fil_crypt_set_thread_cnt( while(srv_n_fil_crypt_threads_started != srv_n_fil_crypt_threads) { os_event_reset(fil_crypt_event); - os_event_wait_time(fil_crypt_event, 1000000); + os_event_wait_time(fil_crypt_event, 100000); + } + + /* Send a message to encryption threads that there could be + something to do. */ + if (srv_n_fil_crypt_threads) { + os_event_set(fil_crypt_threads_event); } } @@ -2461,9 +2467,10 @@ fil_space_crypt_get_status( ut_ad(space->n_pending_ops > 0); fil_crypt_read_crypt_data(const_cast(space)); - status->space = space->id; + status->space = ULINT_UNDEFINED; if (fil_space_crypt_t* crypt_data = space->crypt_data) { + status->space = space->id; mutex_enter(&crypt_data->mutex); status->scheme = crypt_data->type; status->keyserver_requests = crypt_data->keyserver_requests; diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index 2c3d26d6302..0cd67f5b19d 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -654,7 +654,7 @@ fil_node_open_file( page = static_cast(ut_align(buf2, UNIV_PAGE_SIZE)); success = os_file_read(node->handle, page, 0, UNIV_PAGE_SIZE); - srv_stats.page0_read.add(1); + srv_stats.page0_read.inc(); const ulint space_id = fsp_header_get_space_id(page); ulint flags = fsp_header_get_flags(page); @@ -2268,7 +2268,7 @@ fil_write_flushed_lsn( /* If tablespace is not encrypted, stamp flush_lsn to first page of all system tablespace datafiles to avoid unnecessary error messages on possible downgrade. */ - if (space->crypt_data->min_key_version == 0) { + if (!space->crypt_data || space->crypt_data->min_key_version == 0) { fil_node_t* node; ulint sum_of_sizes = 0; @@ -2414,7 +2414,7 @@ fil_read_first_page( os_file_read(data_file, page, 0, UNIV_PAGE_SIZE); - srv_stats.page0_read.add(1); + srv_stats.page0_read.inc(); /* The FSP_HEADER on page 0 is only valid for the first file in a tablespace. So if this is not the first datafile, leave diff --git a/storage/xtradb/fsp/fsp0fsp.cc b/storage/xtradb/fsp/fsp0fsp.cc index 68d8413e3b7..ffed8a6edd3 100644 --- a/storage/xtradb/fsp/fsp0fsp.cc +++ b/storage/xtradb/fsp/fsp0fsp.cc @@ -729,7 +729,11 @@ fsp_header_init(ulint space_id, ulint size, mtr_t* mtr) fil_space_t* space = fil_space_acquire(space_id); ut_ad(space); - if (space->crypt_data) { + /* Write encryption metadata to page 0 if tablespace is + encrypted or encryption is disabled by table option. */ + if (space->crypt_data && + (space->crypt_data->should_encrypt() || + space->crypt_data->not_encrypted())) { space->crypt_data->write_page0(page, mtr); } diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc index 9cef04c4244..ca2c76c31ad 100644 --- a/storage/xtradb/handler/i_s.cc +++ b/storage/xtradb/handler/i_s.cc @@ -8524,6 +8524,12 @@ i_s_dict_fill_tablespaces_encryption( fil_space_crypt_get_status(space, &status); + /* If tablespace id does not match, we did not find + encryption information for this tablespace. */ + if (!space->crypt_data || space->id != status.space) { + goto skip; + } + OK(fields[TABLESPACES_ENCRYPTION_SPACE]->store(space->id)); OK(field_store_string(fields[TABLESPACES_ENCRYPTION_NAME], @@ -8558,6 +8564,7 @@ i_s_dict_fill_tablespaces_encryption( OK(schema_table_store_record(thd, table_to_fill)); +skip: DBUG_RETURN(0); } /*******************************************************************//** diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index 7bcb0b1b1ce..2653f5aa6b1 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -1228,11 +1228,6 @@ check_first_page: ut_a(ret); if (i == 0) { - if (!crypt_data) { - crypt_data = fil_space_create_crypt_data(FIL_ENCRYPTION_DEFAULT, - FIL_DEFAULT_ENCRYPTION_KEY); - } - flags = FSP_FLAGS_PAGE_SSIZE(); fil_space_create(name, 0, flags, FIL_TABLESPACE, From 8d9298167ec2251942953e6a1bdb4d4019b5957b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Aug 2017 11:27:28 +0300 Subject: [PATCH 077/101] MDEV-13625 Merge InnoDB test cases from MySQL 5.6 (part 1) Import some ALTER TABLE test cases from MySQL 5.6 without modification. The adjustments will be in a separate commit. --- mysql-test/suite/innodb/include/import.inc | 40 + .../suite/innodb/include/innodb_dict.inc | 9 + .../innodb/r/alter_rename_existing.result | 96 ++ .../innodb/r/index_tree_operation.result | 55 + .../innodb/r/innodb-alter-autoinc.result | 174 ++ mysql-test/suite/innodb/r/innodb-alter.result | 862 ++++++++++ .../suite/innodb/r/innodb-index-debug.result | 68 + .../r/innodb-index-online-delete.result | 13 + .../innodb/r/innodb-index-online-fk.result | 618 ++++++++ .../innodb/r/innodb-index-online-purge.result | 36 + .../suite/innodb/r/innodb-index-online.result | 348 ++++ .../suite/innodb/r/innodb-table-online.result | 368 +++++ .../suite/innodb/r/innodb-wl5980-alter.result | 1409 +++++++++++++++++ .../suite/innodb/t/alter_rename_existing.test | 93 ++ .../suite/innodb/t/index_tree_operation.test | 74 + .../suite/innodb/t/innodb-alter-autoinc.test | 104 ++ mysql-test/suite/innodb/t/innodb-alter.test | 484 ++++++ .../innodb/t/innodb-index-debug-master.opt | 1 + .../suite/innodb/t/innodb-index-debug.test | 83 + .../innodb/t/innodb-index-online-delete.test | 36 + .../innodb/t/innodb-index-online-fk.test | 483 ++++++ .../innodb/t/innodb-index-online-master.opt | 1 + .../innodb/t/innodb-index-online-purge.test | 73 + .../suite/innodb/t/innodb-index-online.test | 403 +++++ .../innodb/t/innodb-table-online-master.opt | 1 + .../suite/innodb/t/innodb-table-online.test | 379 +++++ .../suite/innodb/t/innodb-wl5980-alter.test | 593 +++++++ 27 files changed, 6904 insertions(+) create mode 100644 mysql-test/suite/innodb/include/import.inc create mode 100644 mysql-test/suite/innodb/include/innodb_dict.inc create mode 100644 mysql-test/suite/innodb/r/alter_rename_existing.result create mode 100644 mysql-test/suite/innodb/r/index_tree_operation.result create mode 100644 mysql-test/suite/innodb/r/innodb-alter-autoinc.result create mode 100644 mysql-test/suite/innodb/r/innodb-alter.result create mode 100644 mysql-test/suite/innodb/r/innodb-index-debug.result create mode 100644 mysql-test/suite/innodb/r/innodb-index-online-delete.result create mode 100644 mysql-test/suite/innodb/r/innodb-index-online-fk.result create mode 100644 mysql-test/suite/innodb/r/innodb-index-online-purge.result create mode 100644 mysql-test/suite/innodb/r/innodb-index-online.result create mode 100644 mysql-test/suite/innodb/r/innodb-table-online.result create mode 100644 mysql-test/suite/innodb/r/innodb-wl5980-alter.result create mode 100644 mysql-test/suite/innodb/t/alter_rename_existing.test create mode 100644 mysql-test/suite/innodb/t/index_tree_operation.test create mode 100644 mysql-test/suite/innodb/t/innodb-alter-autoinc.test create mode 100644 mysql-test/suite/innodb/t/innodb-alter.test create mode 100644 mysql-test/suite/innodb/t/innodb-index-debug-master.opt create mode 100644 mysql-test/suite/innodb/t/innodb-index-debug.test create mode 100644 mysql-test/suite/innodb/t/innodb-index-online-delete.test create mode 100644 mysql-test/suite/innodb/t/innodb-index-online-fk.test create mode 100644 mysql-test/suite/innodb/t/innodb-index-online-master.opt create mode 100644 mysql-test/suite/innodb/t/innodb-index-online-purge.test create mode 100644 mysql-test/suite/innodb/t/innodb-index-online.test create mode 100644 mysql-test/suite/innodb/t/innodb-table-online-master.opt create mode 100644 mysql-test/suite/innodb/t/innodb-table-online.test create mode 100644 mysql-test/suite/innodb/t/innodb-wl5980-alter.test diff --git a/mysql-test/suite/innodb/include/import.inc b/mysql-test/suite/innodb/include/import.inc new file mode 100644 index 00000000000..e8265cb3db6 --- /dev/null +++ b/mysql-test/suite/innodb/include/import.inc @@ -0,0 +1,40 @@ +# Export Table and Import from saved files .cfg and .ibd +# Caller should create t1 table definition and populate table + +let $MYSQLD_DATADIR = `SELECT @@datadir`; + +if(!$source_db) { + let $source_db = test; +} + +if(!$dest_db) { + let $dest_db = test; +} + +eval FLUSH TABLES $source_db.t1 FOR EXPORT; + +--copy_file $MYSQLD_DATADIR/$source_db/t1.cfg $MYSQLD_DATADIR/t1.cfg_back +--copy_file $MYSQLD_DATADIR/$source_db/t1.ibd $MYSQLD_DATADIR/t1.ibd_back + +UNLOCK TABLES; + +if($source_db != $dest_db) { + eval USE $dest_db; + let $create1 = query_get_value(SHOW CREATE TABLE $source_db.t1, Create Table, 1); + eval $create1; +} + +eval ALTER TABLE $dest_db.t1 DISCARD TABLESPACE; + +--move_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/$dest_db/t1.cfg +--move_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/$dest_db/t1.ibd + +eval ALTER TABLE $dest_db.t1 IMPORT TABLESPACE; + +eval CHECK TABLE $dest_db.t1; +eval SHOW CREATE TABLE $dest_db.t1; +eval SELECT * FROM $dest_db.t1; + +if($source_db != $dest_db) { + eval DROP TABLE $dest_db.t1; +} diff --git a/mysql-test/suite/innodb/include/innodb_dict.inc b/mysql-test/suite/innodb/include/innodb_dict.inc new file mode 100644 index 00000000000..1e05181272d --- /dev/null +++ b/mysql-test/suite/innodb/include/innodb_dict.inc @@ -0,0 +1,9 @@ +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; diff --git a/mysql-test/suite/innodb/r/alter_rename_existing.result b/mysql-test/suite/innodb/r/alter_rename_existing.result new file mode 100644 index 00000000000..7eeeef7203d --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_rename_existing.result @@ -0,0 +1,96 @@ +# +# Show what happens during ALTER TABLE when an existing file +# exists in the target location. +# +# Bug #19218794: IF TABLESPACE EXISTS, CAN'T CREATE TABLE, +# BUT CAN ALTER ENGINE=INNODB +# +CREATE TABLE t1 (a SERIAL, b CHAR(10)) ENGINE=Memory; +INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); +# +# Create a file called MYSQLD_DATADIR/test/t1.ibd +# Directory listing of test/*.ibd +# +t1.ibd +ALTER TABLE t1 ENGINE = InnoDB; +ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 - Tablespace already exists) +# +# Move the file to InnoDB as t2 +# +ALTER TABLE t1 RENAME TO t2, ENGINE = INNODB; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `b` char(10) DEFAULT NULL, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +SELECT * from t2; +a b +1 one +2 two +3 three +ALTER TABLE t2 RENAME TO t1; +ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 - Tablespace already exists) +# +# Create another t1, but in the system tablespace. +# +SET GLOBAL innodb_file_per_table=OFF; +CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB; +INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `b` char(20) DEFAULT NULL, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; +name space=0 +test/t1 1 +# +# ALTER TABLE from system tablespace to system tablespace +# +ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=INPLACE; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY; +# +# Try to move t1 from the system tablespace to a file-per-table +# while a blocking t1.ibd file exists. +# +SET GLOBAL innodb_file_per_table=ON; +ALTER TABLE t1 ADD COLUMN e1 INT, ALGORITHM=INPLACE; +ERROR HY000: Tablespace for table 'test/t1' exists. Please DISCARD the tablespace before IMPORT. +ALTER TABLE t1 ADD COLUMN e2 INT, ALGORITHM=COPY; +ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 - Tablespace already exists) +# +# Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd +# Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd. +# +ALTER TABLE t1 ADD COLUMN e INT, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `b` char(20) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` int(11) DEFAULT NULL, + `e` int(11) DEFAULT NULL, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; +name space=0 +test/t1 0 +DROP TABLE t1; +# +# Rename t2.ibd to t1.ibd. +# +ALTER TABLE t2 RENAME TO t1; +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; +name space=0 +test/t1 0 +SELECT * from t1; +a b +1 one +2 two +3 three +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/index_tree_operation.result b/mysql-test/suite/innodb/r/index_tree_operation.result new file mode 100644 index 00000000000..29660962e0c --- /dev/null +++ b/mysql-test/suite/innodb/r/index_tree_operation.result @@ -0,0 +1,55 @@ +# +# Bug#15923864 (Bug#67718): +# INNODB DRASTICALLY UNDER-FILLS PAGES IN CERTAIN CONDITIONS +# +SET GLOBAL innodb_file_per_table=ON; +CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (0, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1000, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1001, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1002, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (2, REPEAT('a', 4096)); +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; +page_number number_records +3 2 +4 3 +5 3 +INSERT INTO t1 VALUES (999, REPEAT('a', 4096)); +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; +page_number number_records +3 3 +4 3 +5 3 +6 1 +INSERT INTO t1 VALUES (998, REPEAT('a', 4096)); +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; +page_number number_records +3 3 +4 3 +5 3 +6 2 +INSERT INTO t1 VALUES (997, REPEAT('a', 4096)); +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; +page_number number_records +3 3 +4 3 +5 3 +6 3 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-alter-autoinc.result b/mysql-test/suite/innodb/r/innodb-alter-autoinc.result new file mode 100644 index 00000000000..8b4909917b3 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-alter-autoinc.result @@ -0,0 +1,174 @@ +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(347),(33101),(123),(45),(6); +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +ALTER TABLE t1 ADD PRIMARY KEY(a); +SET @@sql_mode = @old_sql_mode; +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED. +ALTER TABLE t1 ADD id INT AUTO_INCREMENT; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id); +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a); +SELECT * FROM t1; +a id +6 0 +45 0 +123 0 +347 0 +33101 0 +SET AUTO_INCREMENT_INCREMENT = 5, AUTO_INCREMENT_OFFSET = 30; +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 +BEGIN; +INSERT INTO t1 VALUES(7,0); +SELECT * FROM t1; +a id +6 45 +45 50 +123 55 +347 60 +33101 65 +7 70 +ROLLBACK; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1 +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED. +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE; +SELECT * FROM t1; +a id +6 45 +45 50 +123 55 +347 60 +33101 65 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 +INSERT INTO t1 SET a=123; +INSERT INTO t1 VALUES(-123,-45); +ALTER TABLE t1 AUTO_INCREMENT = 75; +INSERT INTO t1 SET a=123; +SELECT * FROM t1; +a id +-123 -45 +6 45 +45 50 +123 55 +347 60 +33101 65 +123 70 +123 75 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(347),(33101),(123),(45),(6); +ALTER TABLE t1 ADD PRIMARY KEY(a); +ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a); +SELECT * FROM t1; +a id +6 0 +45 0 +123 0 +347 0 +33101 0 +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 +BEGIN; +INSERT INTO t1 VALUES(7,0); +SELECT * FROM t1; +a id +6 45 +45 50 +123 55 +347 60 +33101 65 +7 70 +ROLLBACK; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1 +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY; +SELECT * FROM t1; +a id +6 45 +45 50 +123 55 +347 60 +33101 65 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 +INSERT INTO t1 SET a=123; +INSERT INTO t1 VALUES(-123,-45); +ALTER TABLE t1 AUTO_INCREMENT = 75; +INSERT INTO t1 SET a=123; +SELECT * FROM t1; +a id +-123 -45 +6 45 +45 50 +123 55 +347 60 +33101 65 +123 70 +123 75 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result new file mode 100644 index 00000000000..47fc97206c9 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -0,0 +1,862 @@ +SET NAMES utf8; +CREATE TABLE t1 ( +c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, +INDEX(c2)) +ENGINE=InnoDB; +INSERT INTO t1 SET c1=1; +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME LIKE 'test/t%'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE t1p LIKE t1; +CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3), +CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2), +CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2)) +ENGINE=InnoDB; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i +WHERE FOR_NAME LIKE 'test/t%'; +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT '1', + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1 ALTER c2 DROP DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11), + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1; +ALTER TABLE t1 CHANGE c1 c1 INT FIRST; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE C2 c3 INT; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE c3 C INT; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +C 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 C +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 C 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT; +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 Cöŀumň_TWO 0 +test/t1c3 c3 c2 0 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +Cöŀumň_TWO 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 Cöŀumň_TWO +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 Cöŀumň_TWO 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT; +ERROR 42S22: Unknown column 'cöĿǖmň_two' in 't1' +ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3; +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t3 +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c3` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t3` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t3 CHANGE c3 +`12345678901234567890123456789012345678901234567890123456789012345` INT; +ERROR 42000: Identifier name '12345678901234567890123456789012345678901234567890123456789012345' is too long +ALTER TABLE t3 CHANGE c3 +`1234567890123456789012345678901234567890123456789012345678901234` INT; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int(11) NOT NULL DEFAULT '0', + `1234567890123456789012345678901234567890123456789012345678901234` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`1234567890123456789012345678901234567890123456789012345678901234`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿偀` INT; +ERROR 42000: Identifier name '倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠' is too long +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿ä` INT; +ERROR 42000: Identifier name '倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠' is too long +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾ä` INT; +ALTER TABLE t3 CHANGE +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾Ä` +c3 INT; +ALTER TABLE t3 CHANGE c3 𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌇𐌈𐌉𐌊𐌋𐌌𐌍𐌎𐌏𐌐𐌑𐌒𐌓𐌔𐌕𐌖𐌗𐌘𐌙𐌚𐌛𐌜 INT; +ERROR HY000: Invalid utf8 character string: '\xF0\x90\x8C\x80\xF0\x90\x8C\x81\xF0\x90\x8C\x82\xF0\x90\x8C\x83' +ALTER TABLE t3 CHANGE c3 😲 INT; +ERROR HY000: Invalid utf8 character string: '\xF0\x9F\x98\xB2' +ALTER TABLE t3 RENAME TO t2; +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t2 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c3` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +RENAME TABLE t2 TO t1; +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 DROP INDEX c2; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1 DROP INDEX c4; +ERROR 42000: Can't DROP 'c4'; check that column/key exists +ALTER TABLE t1c DROP FOREIGN KEY c2; +ERROR 42000: Can't DROP 'c2'; check that column/key exists +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2; +ERROR 42000: Can't DROP 'c2'; check that column/key exists +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2; +ERROR 42000: Can't DROP 'c2'; check that column/key exists +ALTER TABLE t1c DROP INDEX c2; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2; +ERROR 42000: Can't DROP 'ẗ1C2'; check that column/key exists +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SET foreign_key_checks=0; +DROP TABLE t1p; +SET foreign_key_checks=1; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) ENGINE=InnoDB; +ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1c DROP INDEX C3; +ERROR HY000: Cannot drop index 'c3': needed in a foreign key constraint +SET foreign_key_checks=0; +ALTER TABLE t1c DROP INDEX C3; +SET foreign_key_checks=1; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1c DROP FOREIGN KEY t1C3; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +CREATE TABLE t1o LIKE t1; +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED. +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=SHARED; +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +SHOW CREATE TABLE tt; +Table Create Table +tt CREATE TABLE `tt` ( + `pk` int(11) NOT NULL DEFAULT '0', + `c2` int(11) DEFAULT '42', + `ct` text, + PRIMARY KEY (`pk`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'dB_row_Id' +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'DB_ROW_ID' +ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT; +ERROR 42000: Incorrect column name 'DB_TRX_ID' +ALTER TABLE t1o CHANGE c1 db_roll_ptr INT; +ERROR 42000: Incorrect column name 'DB_ROLL_PTR' +ALTER TABLE t1o ADD COLUMN DB_TRX_ID INT; +ERROR 42000: Incorrect column name 'DB_TRX_ID' +ALTER TABLE t1o ADD COLUMN db_roll_ptr INT; +ERROR 42000: Incorrect column name 'db_roll_ptr' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT; +ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED; +ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID INT; +ERROR 42S21: Duplicate column name 'FTS_DOC_ID' +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY. +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, DROP INDEX ct, ALGORITHM=INPLACE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN cu TEXT; +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), +ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL; +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY. +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT, +ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY. +CREATE TABLE t1n LIKE t1o; +ALTER TABLE t1n ADD FULLTEXT INDEX(ct); +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'Fts_DOC_ID' +ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE; +ERROR 42S22: Unknown column 'FTS_DOC_ID' in 't1n' +ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE FTS_DOC_ÏD c1 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT, +ALGORITHM=INPLACE; +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c2` int(11) NOT NULL DEFAULT '0', + `ct` int(11) DEFAULT NULL, + `c1` text, + `cu` text, + PRIMARY KEY (`c2`), + FULLTEXT KEY `ct` (`c1`), + FULLTEXT KEY `ct_2` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT, +ALGORITHM=COPY; +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c2` int(11) DEFAULT NULL, + `ct` text, + `cu` text, + PRIMARY KEY (`c1`), + FULLTEXT KEY `ct` (`ct`), + FULLTEXT KEY `ct_2` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ERROR 42000: Key column 'c2' doesn't exist in table +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; +ERROR 42000: Key column 'c2' doesn't exist in table +ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c4` int(11) DEFAULT NULL, + `ct` text, + `cu` text, + PRIMARY KEY (`c1`), + KEY `c4` (`c4`), + FULLTEXT KEY `ct` (`ct`), + FULLTEXT KEY `ct_2` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n DROP INDEX c4; +ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +ERROR 42S21: Duplicate column name 'c1' +ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c11` int(11) DEFAULT NULL, + `ct` text, + `cu` text, + PRIMARY KEY (`c1`), + KEY `c11` (`c11`), + FULLTEXT KEY `ct` (`ct`), + FULLTEXT KEY `ct_2` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1n; +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY. +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct; +ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY. +SELECT sc.pos FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID'; +pos +0 +SHOW CREATE TABLE t1o; +Table Create Table +t1o CREATE TABLE `t1o` ( + `FTS_DOC_ID` bigint(20) unsigned NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text, + `cu` text, + PRIMARY KEY (`FTS_DOC_ID`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +DROP INDEX ct, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1o; +Table Create Table +t1o CREATE TABLE `t1o` ( + `foo_id` bigint(20) unsigned NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text, + `cu` text, + PRIMARY KEY (`foo_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign; +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME='test/t1o'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o'; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +foo_id 0 6 1800 8 +c2 1 6 1027 4 +ct 2 5 524540 10 +cu 3 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 foo_id +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(FTS_DOC_ID), +ADD FULLTEXT INDEX(ct), +CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL; +ALTER TABLE t1o DROP INDEX ct, DROP INDEX FTS_DOC_ID_INDEX, +CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ADD FULLTEXT INDEX(ct); +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY. +DROP TABLE sys_indexes; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +FTS_DOC_ID 0 6 1800 8 +c2 1 6 1027 4 +ct 2 5 524540 10 +cu 3 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 FTS_DOC_ID +FTS_DOC_ID_INDEX 0 FTS_DOC_ID +ct 0 ct +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; +CREATE TABLE t (t TEXT, FULLTEXT(t)) ENGINE=InnoDB; +DROP INDEX t ON t; +SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE '%FTS_%' ORDER BY 1, 2; +prefix name +FTS_0 test/FTS_AUX_BEING_DELETED +FTS_0 test/FTS_AUX_BEING_DELETED_CACHE +FTS_0 test/FTS_AUX_CONFIG +FTS_0 test/FTS_AUX_DELETED +FTS_0 test/FTS_AUX_DELETED_CACHE +SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t'; +pos NAME +0 t +1 FTS_DOC_ID +ALTER TABLE t ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE; +SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE '%FTS_%' ORDER BY 1, 2; +prefix name +ALTER TABLE t ADD FULLTEXT INDEX(t); +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t'; +pos NAME +0 t +1 FTS_DOC_ID +DROP TABLE t; +# +# Bug #19465984 INNODB DATA DICTIONARY IS NOT UPDATED WHILE +# RENAMING THE COLUMN +# +CREATE TABLE t1(c1 INT NOT NULL, PRIMARY KEY(c1))ENGINE=INNODB; +CREATE TABLE t2(c2 INT NOT NULL, FOREIGN KEY(c2) REFERENCES t1(c1))ENGINE=INNODB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c2` int(11) NOT NULL, + KEY `c2` (`c2`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1 CHANGE COLUMN c1 C1 INT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `C1` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`C1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c2` int(11) NOT NULL, + KEY `c2` (`c2`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`C1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1 CHANGE COLUMN C1 c5 INT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c5` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`c5`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c2` int(11) NOT NULL, + KEY `c2` (`c2`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c5`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t2, t1; +# +# BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN +# DICT_MEM_TABLE_COL_RENAME_LOW +# +CREATE TABLE parent(a INT, b INT, KEY(a, b)) ENGINE = InnoDB; +CREATE TABLE t1(a1 INT, a2 INT) ENGINE = InnoDB; +set foreign_key_checks=0; +ALTER TABLE t1 ADD CONSTRAINT fk_a FOREIGN KEY(a1, a2) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE t1 CHANGE a2 a3 INT,ADD CONSTRAINT fk_1 FOREIGN KEY(a1, a3) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `fk_1` (`a1`,`a3`), + CONSTRAINT `fk_1` FOREIGN KEY (`a1`, `a3`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_a` FOREIGN KEY (`a1`, `a3`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 CHANGE a3 a4 INT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) DEFAULT NULL, + `a4` int(11) DEFAULT NULL, + KEY `fk_1` (`a1`,`a4`), + CONSTRAINT `fk_1` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_a` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE parent CHANGE b c INT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) DEFAULT NULL, + `a4` int(11) DEFAULT NULL, + KEY `fk_1` (`a1`,`a4`), + CONSTRAINT `fk_1` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `c`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_a` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `c`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1, parent; +# +#BUG#21514135 SCHEMA MISMATCH ERROR WHEN IMPORTING TABLESPACE AFTER +#DROPPING AN INDEX +# +CREATE DATABASE source_db; +CREATE DATABASE dest_db; +CREATE TABLE source_db.t1 ( +id int(11) NOT NULL, +age int(11) DEFAULT NULL, +name varchar(20), +PRIMARY KEY (id), +KEY index1 (age) +) ENGINE=InnoDB; +ALTER TABLE source_db.t1 DROP INDEX index1, ADD INDEX index2(name, age), algorithm=inplace; +FLUSH TABLES source_db.t1 FOR EXPORT; +UNLOCK TABLES; +USE dest_db; +CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `age` int(11) DEFAULT NULL, + `name` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `index2` (`name`,`age`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +ALTER TABLE dest_db.t1 DISCARD TABLESPACE; +ALTER TABLE dest_db.t1 IMPORT TABLESPACE; +CHECK TABLE dest_db.t1; +Table Op Msg_type Msg_text +dest_db.t1 check status OK +SHOW CREATE TABLE dest_db.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `age` int(11) DEFAULT NULL, + `name` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `index2` (`name`,`age`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * FROM dest_db.t1; +id age name +DROP TABLE dest_db.t1; +ALTER TABLE source_db.t1 DROP INDEX index2, algorithm=inplace; +FLUSH TABLES source_db.t1 FOR EXPORT; +UNLOCK TABLES; +USE dest_db; +CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `age` int(11) DEFAULT NULL, + `name` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +ALTER TABLE dest_db.t1 DISCARD TABLESPACE; +ALTER TABLE dest_db.t1 IMPORT TABLESPACE; +CHECK TABLE dest_db.t1; +Table Op Msg_type Msg_text +dest_db.t1 check status OK +SHOW CREATE TABLE dest_db.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `age` int(11) DEFAULT NULL, + `name` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * FROM dest_db.t1; +id age name +DROP TABLE dest_db.t1; +DROP TABLE source_db.t1; +DROP DATABASE source_db; +DROP DATABASE dest_db; diff --git a/mysql-test/suite/innodb/r/innodb-index-debug.result b/mysql-test/suite/innodb/r/innodb-index-debug.result new file mode 100644 index 00000000000..4db96a3b092 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-debug.result @@ -0,0 +1,68 @@ +set global innodb_file_per_table=on; +set global innodb_file_format='Barracuda'; +CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5); +SET SESSION DEBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Too many active concurrent transactions +SET SESSION DEBUG=DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2)) +ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0); +SET DEBUG='+d,ib_row_merge_buf_add_two'; +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG='-d,ib_row_merge_buf_add_two'; +DROP TABLE bug13861218; +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL); +SET DEBUG='+d,ib_row_merge_buf_add_two'; +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG='-d,ib_row_merge_buf_add_two'; +DROP TABLE bug13861218; +set global innodb_file_per_table=1; +set global innodb_file_format=Antelope; +set global innodb_file_format_max=Antelope; +# +# Bug #21762319 ADDING INDEXES ON EMPTY TABLE IS SLOW +# WITH LARGE INNODB_SORT_BUFFER_SIZE. +call mtr.add_suppression("InnoDB: Cannot create temporary merge file"); +create table t480(a serial)engine=innodb; +insert into t480 +values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(), +(),(),(),(),(),(),(),(); +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +create table t1(f1 int auto_increment not null, +f2 char(200) not null, f3 char(200) not null, +f4 char(200) not null,primary key(f1))engine=innodb; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 select NULL,'aaaa','bbbb','cccc' from t480; +insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480; +insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480; +insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480; +insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480; +select count(*) from t1; +count(*) +2880 +SET DEBUG = '+d,innobase_tmpfile_creation_failure'; +alter table t1 force, algorithm=inplace; +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET DEBUG = '-d,innobase_tmpfile_creation_failure'; +drop table t1, t480; diff --git a/mysql-test/suite/innodb/r/innodb-index-online-delete.result b/mysql-test/suite/innodb/r/innodb-index-online-delete.result new file mode 100644 index 00000000000..d02d78acb32 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-online-delete.result @@ -0,0 +1,13 @@ +CREATE TABLE t (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB; +INSERT INTO t VALUES(1,2),(2,3); +SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL do WAIT_FOR m'; +SET DEBUG_SYNC='innodb_after_inplace_alter_table SIGNAL scanned WAIT_FOR done'; +CREATE INDEX tb ON t(b); +SET DEBUG_SYNC='now WAIT_FOR do'; +SET DEBUG_SYNC='row_update_for_mysql_error SIGNAL m WAIT_FOR scanned'; +UPDATE t SET a=2 WHERE a=1; +ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +call mtr.add_suppression('InnoDB: record in index .*tb was not found on rollback, trying to insert'); +SET DEBUG_SYNC='now SIGNAL done'; +SET DEBUG_SYNC='RESET'; +DROP TABLE t; diff --git a/mysql-test/suite/innodb/r/innodb-index-online-fk.result b/mysql-test/suite/innodb/r/innodb-index-online-fk.result new file mode 100644 index 00000000000..c54cf6bebb4 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-online-fk.result @@ -0,0 +1,618 @@ +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); +CREATE INDEX tb ON parent(b); +INSERT INTO parent VALUES(10,20),(20,30); +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +INSERT INTO child VALUES(10,20); +ALTER TABLE child ADD FOREIGN KEY(a2) REFERENCES parent(b), +ALGORITHM = INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Adding foreign keys needs foreign_key_checks=OFF. Try ALGORITHM=COPY. +SET foreign_key_checks = 0; +ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Duplicate foreign key constraint name 'test/fk_1' +SET foreign_key_checks = 1; +INSERT INTO child VALUES(1,2),(2,3); +INSERT INTO child VALUES(4,4); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE) +SELECT * FROM parent; +a b +1 2 +2 3 +10 20 +20 30 +SET foreign_key_checks = 0; +ALTER TABLE child ADD CONSTRAINT fk_20 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_20' in the referenced table 'parent' +SHOW WARNINGS; +Level Code Message +Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_20' in the referenced table 'parent' +SHOW ERRORS; +Level Code Message +Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_20' in the referenced table 'parent' +CREATE INDEX idx1 on parent(a, b); +ALTER TABLE child ADD CONSTRAINT fk_10 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ALTER TABLE child ADD CONSTRAINT fk_2 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ADD INDEX idx1(a1,a2), +ALGORITHM = INPLACE; +ALTER TABLE child ADD CONSTRAINT fk_3 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +SET foreign_key_checks = 1; +INSERT INTO child VALUES(5,4); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE) +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + PRIMARY KEY (`a1`), + KEY `tb` (`a2`), + KEY `idx1` (`a1`,`a2`), + CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_10` FOREIGN KEY (`a1`, `a2`) REFERENCES `parent` (`a`, `b`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_2` FOREIGN KEY (`a1`, `a2`) REFERENCES `parent` (`a`, `b`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_3` FOREIGN KEY (`a1`, `a2`) REFERENCES `parent` (`a`, `b`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DELETE FROM parent where a = 1; +SELECT * FROM child; +a1 a2 +1 NULL +2 3 +10 20 +SET foreign_key_checks = 0; +SET DEBUG = '+d,innodb_test_open_ref_fail'; +ALTER TABLE child ADD CONSTRAINT fk_4 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG = '-d,innodb_test_open_ref_fail'; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +test/fk_4 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +test/fk_4 a1 a 0 +test/fk_4 a2 b 1 +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a1 +test/child a2 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +mysql/innodb_index_stats +mysql/innodb_table_stats +mysql/slave_master_info +mysql/slave_relay_log_info +mysql/slave_worker_info +test/child +test/parent +INSERT INTO child VALUES(5,4); +SET foreign_key_checks = 1; +INSERT INTO child VALUES(6,5); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE) +SET foreign_key_checks = 0; +CREATE TABLE `#parent` (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +CREATE INDEX tb ON `#parent`(a, b); +CREATE TABLE `#child` (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON `#child`(a1, a2); +SET DEBUG = '+d,innodb_test_no_foreign_idx'; +ALTER TABLE `#child` ADD CONSTRAINT fk_40 FOREIGN KEY (a1, a2) +REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_40' in the foreign table '#child' +SET DEBUG = '-d,innodb_test_no_foreign_idx'; +SHOW ERRORS; +Level Code Message +Error 1821 Failed to add the foreign key constaint. Missing index for constraint 'fk_40' in the foreign table '#child' +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +test/fk_4 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +test/fk_4 a1 a 0 +test/fk_4 a2 b 1 +SET DEBUG = '+d,innodb_test_no_reference_idx'; +ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_42' in the referenced table 'parent' +SET DEBUG = '-d,innodb_test_no_reference_idx'; +SHOW ERRORS; +Level Code Message +Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_42' in the referenced table 'parent' +SET DEBUG = '+d,innodb_test_wrong_fk_option'; +ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constraint on table 'child'. Incorrect options in FOREIGN KEY constraint 'test/fk_42' +SET DEBUG = '-d,innodb_test_wrong_fk_option'; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +test/fk_4 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +test/fk_4 a1 a 0 +test/fk_4 a2 b 1 +SET DEBUG = '+d,innodb_test_cannot_add_fk_system'; +ALTER TABLE `#child` ADD CONSTRAINT fk_43 FOREIGN KEY (a1, a2) +REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constraint 'test/fk_43' to system tables +SET DEBUG = '-d,innodb_test_cannot_add_fk_system'; +SHOW ERRORS; +Level Code Message +Error 1823 Failed to add the foreign key constraint 'test/fk_43' to system tables +DROP TABLE `#child`; +DROP TABLE `#parent`; +SET foreign_key_checks = 0; +ALTER TABLE child ADD CONSTRAINT fk_5 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ADD CONSTRAINT fk_6 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +test/fk_4 test/child test/parent 2 5 +test/fk_5 test/child test/parent 1 6 +test/fk_6 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +test/fk_4 a1 a 0 +test/fk_4 a2 b 1 +test/fk_5 a2 b 0 +test/fk_6 a1 a 0 +test/fk_6 a2 b 1 +DROP TABLE child; +DROP TABLE parent; +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); +CREATE INDEX tb ON parent(b); +INSERT INTO parent VALUES(10,20),(20,30); +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +INSERT INTO child VALUES(10,20); +SET foreign_key_checks = 0; +ALTER TABLE child DROP INDEX tb, ADD CONSTRAINT fk_4 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + PRIMARY KEY (`a1`), + KEY `fk_4` (`a2`), + CONSTRAINT `fk_4` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_4 test/child test/parent 1 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_4 a2 b 0 +SET foreign_key_checks = 1; +DROP TABLE child; +DROP TABLE parent; +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); +CREATE INDEX tb ON parent(b); +INSERT INTO parent VALUES(10,20),(20,30); +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +SET foreign_key_checks = 0; +ALTER TABLE child CHANGE a2 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR 42000: Key column 'a2' doesn't exist in table +ALTER TABLE child CHANGE a2 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +DROP TABLE child; +DROP TABLE parent; +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); +CREATE INDEX tb ON parent(b); +INSERT INTO parent VALUES(10,20),(20,30); +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +SET foreign_key_checks = 0; +SET DEBUG = '+d,innodb_test_cannot_add_fk_system'; +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constraint 'test/fk_1' to system tables +SET DEBUG = '-d,innodb_test_cannot_add_fk_system'; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a1 +test/child a2 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +mysql/innodb_index_stats +mysql/innodb_table_stats +mysql/slave_master_info +mysql/slave_relay_log_info +mysql/slave_worker_info +test/child +test/parent +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a2 +test/child a3 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +mysql/innodb_index_stats +mysql/innodb_table_stats +mysql/slave_master_info +mysql/slave_relay_log_info +mysql/slave_worker_info +test/child +test/parent +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a3` int(11) NOT NULL DEFAULT '0', + `a2` int(11) DEFAULT NULL, + PRIMARY KEY (`a3`), + KEY `tb` (`a2`), + CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a1 +test/child a2 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +mysql/innodb_index_stats +mysql/innodb_table_stats +mysql/slave_master_info +mysql/slave_relay_log_info +mysql/slave_worker_info +test/child +test/parent +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + PRIMARY KEY (`a1`), + KEY `fk_1` (`a2`), + CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +ALTER TABLE child CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a3 b 0 +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a2 +test/child a3 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +mysql/innodb_index_stats +mysql/innodb_table_stats +mysql/slave_master_info +mysql/slave_relay_log_info +mysql/slave_worker_info +test/child +test/parent +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a3` int(11) DEFAULT NULL, + `a2` int(11) DEFAULT NULL, + KEY `fk_1` (`a3`), + CONSTRAINT `fk_1` FOREIGN KEY (`a3`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constraint on table 'child'. Incorrect options in FOREIGN KEY constraint 'test/fk_1' +DROP TABLE parent; +DROP TABLE child; +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL, c INT) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2,3),(2,3,4); +CREATE INDEX tb ON parent(b); +CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +ALTER TABLE child +ADD CONSTRAINT fk_a FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ALTER TABLE child +ADD CONSTRAINT fk_b FOREIGN KEY (a1) REFERENCES parent(a), +ALGORITHM = INPLACE; +ALTER TABLE child CHANGE a2 a2_new INT, CHANGE a1 a1_new INT; +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1_new` int(11) DEFAULT NULL, + `a2_new` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `tb` (`a2_new`), + KEY `fk_b` (`a1_new`), + CONSTRAINT `fk_a` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_b` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_a test/child test/parent 1 6 +test/fk_b test/child test/parent 1 0 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_a a2_new b 0 +test/fk_b a1_new a 0 +ALTER TABLE child +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c), +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_new_3' in the referenced table 'parent' +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1_new` int(11) DEFAULT NULL, + `a2_new` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `tb` (`a2_new`), + KEY `fk_b` (`a1_new`), + CONSTRAINT `fk_a` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_b` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_a test/child test/parent 1 6 +test/fk_b test/child test/parent 1 0 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_a a2_new b 0 +test/fk_b a1_new a 0 +ALTER TABLE child +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a), +ALGORITHM = INPLACE; +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1_new` int(11) DEFAULT NULL, + `a2_new` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `tb` (`a2_new`), + KEY `fk_new_1` (`a1_new`), + KEY `fk_new_3` (`a3`), + CONSTRAINT `fk_a` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_b` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`a`), + CONSTRAINT `fk_new_1` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`b`), + CONSTRAINT `fk_new_2` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`a`), + CONSTRAINT `fk_new_3` FOREIGN KEY (`a3`) REFERENCES `parent` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_a test/child test/parent 1 6 +test/fk_b test/child test/parent 1 0 +test/fk_new_1 test/child test/parent 1 0 +test/fk_new_2 test/child test/parent 1 0 +test/fk_new_3 test/child test/parent 1 0 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_a a2_new b 0 +test/fk_b a1_new a 0 +test/fk_new_1 a1_new b 0 +test/fk_new_2 a2_new a 0 +test/fk_new_3 a3 a 0 +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c), +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_new_3' in the referenced table 'parent' +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `tb` (`a2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a), +ALGORITHM = INPLACE; +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + PRIMARY KEY (`a1`), + KEY `tb` (`a2`), + KEY `fk_new_3` (`a3`), + CONSTRAINT `fk_new_1` FOREIGN KEY (`a1`) REFERENCES `parent` (`b`), + CONSTRAINT `fk_new_2` FOREIGN KEY (`a2`) REFERENCES `parent` (`a`), + CONSTRAINT `fk_new_3` FOREIGN KEY (`a3`) REFERENCES `parent` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_new_1 test/child test/parent 1 0 +test/fk_new_2 test/child test/parent 1 0 +test/fk_new_3 test/child test/parent 1 0 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_new_1 a1 b 0 +test/fk_new_2 a2 a 0 +test/fk_new_3 a3 a 0 +SET foreign_key_checks = 1; +DROP TABLE child; +DROP TABLE parent; +CREATE TABLE Parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO Parent VALUES(1,2),(2,3); +CREATE INDEX tb ON Parent(b); +INSERT INTO Parent VALUES(10,20),(20,30); +CREATE TABLE Child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON Child(a2); +INSERT INTO Child VALUES(10,20); +SET foreign_key_checks = 0; +ALTER TABLE Child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES Parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +DROP TABLE Child; +DROP TABLE Parent; +CREATE TABLE `t2`(a int,c int,d int) ENGINE=INNODB; +CREATE TABLE `t3`(a int,c int,d int) ENGINE=INNODB; +CREATE INDEX idx ON t3(a); +ALTER TABLE `t2` ADD CONSTRAINT `fw` FOREIGN KEY (`c`) REFERENCES t3 (a); +ALTER TABLE `t2` ADD CONSTRAINT `e` foreign key (`d`) REFERENCES t3(a); +ALTER TABLE `t3` ADD CONSTRAINT `e` foreign key (`c`) REFERENCES `t2`(`c`) ON UPDATE SET NULL; +ERROR HY000: Failed to add the foreign key constraint 'test/e' to system tables +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/e test/t2 test/t3 1 0 +test/fw test/t2 test/t3 1 0 +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/e d a 0 +test/fw c a 0 +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/suite/innodb/r/innodb-index-online-purge.result b/mysql-test/suite/innodb/r/innodb-index-online-purge.result new file mode 100644 index 00000000000..9ea7c331218 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-online-purge.result @@ -0,0 +1,36 @@ +CREATE TABLE t (a INT PRIMARY KEY, c TEXT) ENGINE=InnoDB; +CREATE TABLE u (a INT PRIMARY KEY, b INT, c INT NOT NULL) ENGINE=InnoDB; +INSERT INTO t VALUES (1,'aa'); +BEGIN; +INSERT INTO u SET a=1, c=1; +INSERT INTO u SELECT a+1,NULL,a+1 FROM u; +INSERT INTO u SELECT a+2,NULL,a+2 FROM u; +INSERT INTO u SELECT a+4,NULL,a+4 FROM u; +INSERT INTO u SELECT a+8,NULL,a+8 FROM u; +INSERT INTO u SELECT a+16,NULL,a+16 FROM u; +INSERT INTO u SELECT a+32,NULL,a+32 FROM u; +INSERT INTO u SELECT a+64,NULL,a+64 FROM u; +INSERT INTO u SELECT a+128,NULL,a+64 FROM u; +INSERT INTO u SELECT a+256,NULL,a+64 FROM u; +COMMIT; +BEGIN; +DELETE FROM u; +SET DEBUG_SYNC='row_log_apply_before SIGNAL created_u WAIT_FOR dml_done_u'; +ALTER TABLE u ADD INDEX (c); +COMMIT; +SET DEBUG_SYNC='now WAIT_FOR created_u'; +SELECT state FROM information_schema.processlist +WHERE info='ALTER TABLE u ADD INDEX (c)'; +state +debug sync point: row_log_apply_before +SET DEBUG_SYNC='row_log_apply_before SIGNAL created_t WAIT_FOR dml_done_t'; +CREATE INDEX c1 ON t (c(1)); +SET DEBUG_SYNC='now WAIT_FOR created_t'; +UPDATE t SET c='ab'; +SELECT SLEEP(10); +SLEEP(10) +0 +SET DEBUG_SYNC='now SIGNAL dml_done_u'; +SET DEBUG_SYNC='now SIGNAL dml_done_t'; +SET DEBUG_SYNC='RESET'; +DROP TABLE t,u; diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result new file mode 100644 index 00000000000..8437959e0ad --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-online.result @@ -0,0 +1,348 @@ +call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 TEXT) +ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); +SET GLOBAL innodb_monitor_enable = module_ddl; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +INSERT INTO t1 VALUES(1,2,3); +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; +SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +CREATE UNIQUE INDEX c2 ON t1(c2); +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +CREATE UNIQUE INDEX c2 ON t1(c2); +DROP INDEX c2 ON t1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` text, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL scanned WAIT_FOR rollback_done'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +COMMIT; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR 23000: Duplicate entry '4' for key 'c2' +DELETE FROM t1 WHERE c1 = 7; +ALTER TABLE t1 ADD FOREIGN KEY(c2) REFERENCES t1(c2), ALGORITHM = INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Adding foreign keys needs foreign_key_checks=OFF. Try ALGORITHM=COPY. +ALTER TABLE t1 ADD UNIQUE INDEX(c2), LOCK = EXCLUSIVE, ALGORITHM = INPLACE; +DROP INDEX c2 ON t1; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; +SET DEBUG_SYNC = 'now SIGNAL rollback_done'; +ERROR 23000: Duplicate entry '4' for key 'c2' +SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET DEBUG_SYNC = 'now WAIT_FOR created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 1 +INSERT INTO t1 VALUES(6,3,1); +SET DEBUG_SYNC = 'now SIGNAL dml_done'; +ERROR 23000: Duplicate entry for key 'c2' +DELETE FROM t1 WHERE c1=6; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +INSERT INTO t1 VALUES(6,3,1); +ERROR 23000: Duplicate entry '3' for key 'c2' +INSERT INTO t1 VALUES(7,4,2); +ERROR 23000: Duplicate entry '4' for key 'c2' +ALTER TABLE t1 STATS_PERSISTENT=1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +UPDATE mysql.innodb_index_stats SET stat_value = 5 +WHERE database_name = 'test' AND table_name= 't1' AND index_name = 'PRIMARY' +AND stat_value = 6; +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1'); +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1 +test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index +test t1 c2 LAST_UPDATE n_diff_pfx01 5 1 c2 +test t1 c2 LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1 c2 LAST_UPDATE size 1 NULL Number of pages in the index +CREATE TABLE t1_c2_stats SELECT * FROM mysql.innodb_index_stats +WHERE database_name = 'test' AND table_name = 't1' and index_name = 'c2'; +ALTER TABLE t1_c2_stats ENGINE=INNODB; +DROP INDEX c2 ON t1; +ANALYZE TABLE t1_c2_stats; +Table Op Msg_type Msg_text +test.t1_c2_stats analyze status OK +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1', 't1_c2_stats'); +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1 +test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index +test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE n_diff_pfx01 3 1 DB_ROW_ID +test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE size 1 NULL Number of pages in the index +KILL QUERY @id; +ERROR 70100: Query execution was interrupted +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2d_created WAIT_FOR kill_done'; +CREATE INDEX c2d ON t1(c2); +SET DEBUG_SYNC = 'now WAIT_FOR c2d_created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; +ERROR 70100: Query execution was interrupted +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 80 Using where +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +UPDATE t1_c2_stats SET index_name = 'c2d'; +UPDATE t1_c2_stats SET stat_value = 2 WHERE stat_name = 'n_diff_pfx01'; +INSERT INTO t1_c2_stats +SELECT database_name, table_name, index_name, last_update, 'n_diff_pfx02', 80, +sample_size, 'c2,c1' FROM t1_c2_stats +WHERE stat_name = 'n_diff_pfx01' AND stat_description = 'c2'; +INSERT INTO mysql.innodb_index_stats SELECT * FROM t1_c2_stats; +DROP TABLE t1_c2_stats; +CREATE INDEX c2d ON t1(c2); +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +t1 0 PRIMARY 1 c1 A 80 NULL NULL BTREE +t1 1 c2d 1 c2 A 10 NULL NULL YES BTREE +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c2d c2d 5 NULL 32 Using where; Using index +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` text, + PRIMARY KEY (`c1`), + KEY `c2d` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1 +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2e_created WAIT_FOR dml2_done'; +SET lock_wait_timeout = 10; +ALTER TABLE t1 CHANGE c2 c22 INT, DROP INDEX c2d, ADD INDEX c2e(c22), +ALGORITHM = INPLACE; +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +UPDATE t1 SET c2 = c2 + 1; +SET DEBUG_SYNC = 'now WAIT_FOR c2e_created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c2e'; +name pos +c2 0 +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; +ERROR HY000: Creating index 'c2e' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again. +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 1 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c2e'; +name pos +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 1 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ALTER TABLE t1 COMMENT 'testing if c2e will be dropped'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done'; +ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; +SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 160; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; +Warnings: +Note 1831 Duplicate index 'c2f' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SELECT COUNT(c22f) FROM t1; +COUNT(c22f) +320 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); +ERROR 23000: Duplicate entry 'NULL' for key 'c3p5' +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c3p5_created WAIT_FOR ins_done'; +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c3p5'; +name pos +c3 0 +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +INSERT INTO t1 VALUES(347,33101,NULL); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c3p5'; +name pos +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 1 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 1 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c22f` int(11) DEFAULT NULL, + `c3` text, + PRIMARY KEY (`c1`), + KEY `c2d` (`c22f`), + KEY `c2f` (`c22f`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1 COMMENT='testing if c2e will be dropped' +ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = INPLACE; +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = COPY; +ERROR 42000: Duplicate key name 'c2h' +SET DEBUG_SYNC = 'RESET'; +SET DEBUG = ''; +SET GLOBAL innodb_monitor_disable = module_ddl; +DROP TABLE t1; +SET GLOBAL DEBUG = ''; +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb-table-online.result b/mysql-test/suite/innodb/r/innodb-table-online.result new file mode 100644 index 00000000000..ee51c3b8239 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-table-online.result @@ -0,0 +1,368 @@ +call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); +call mtr.add_suppression("InnoDB: Error: table 'test/t1'"); +call mtr.add_suppression("MySQL is trying to open a table handle but the .ibd file for"); +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 TEXT NOT NULL) +ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); +SET GLOBAL innodb_monitor_enable = module_ddl; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +INSERT INTO t1 VALUES(1,2,3); +# Establish session con1 (user=root) +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; +# session default +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +# session con1 +SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; +SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +# session default +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +# session con1 +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR insert_done'; +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# session default +COMMIT; +# session con1 +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); +ERROR 23000: Duplicate entry '4' for key 'c2' +# session default +DELETE FROM t1 WHERE c1 = 7; +# session con1 +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ROW_FORMAT=COMPACT, +LOCK = SHARED, ALGORITHM = INPLACE; +ALTER TABLE t1 ADD UNIQUE INDEX(c2), +LOCK = EXCLUSIVE, ALGORITHM = INPLACE; +Warnings: +Note 1831 Duplicate index 'c2_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + UNIQUE KEY `c2` (`c2`), + UNIQUE KEY `c2_2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +ALTER TABLE t1 DROP INDEX c2, ALGORITHM = INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Dropping a primary key is not allowed without also adding a new primary key. Try ALGORITHM=COPY. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + UNIQUE KEY `c2` (`c2`), + UNIQUE KEY `c2_2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1); +# session default +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +BEGIN; +INSERT INTO t1 VALUES(4,7,2); +SET DEBUG_SYNC = 'now SIGNAL insert_done'; +# session con1 +ERROR 23000: Duplicate entry '4' for key 'PRIMARY' +# session default +ROLLBACK; +# session con1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + UNIQUE KEY `c2` (`c2`), + UNIQUE KEY `c2_2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ALGORITHM = INPLACE; +ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1), ALGORITHM = INPLACE; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +# session default +INSERT INTO t1 VALUES(6,3,1); +ERROR 23000: Duplicate entry '3' for key 'c2_2' +INSERT INTO t1 VALUES(7,4,2); +ERROR 23000: Duplicate entry '4' for key 'c2_2' +DROP INDEX c2_2 ON t1; +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; +# session con1 +KILL QUERY @id; +ERROR 70100: Query execution was interrupted +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt WAIT_FOR kill_done'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +# session default +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; +# session con1 +ERROR 70100: Query execution was interrupted +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +# session default +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 80 Using where +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# session con1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt2 WAIT_FOR dml2_done'; +SET lock_wait_timeout = 10; +ALTER TABLE t1 ROW_FORMAT=COMPACT, ALGORITHM = INPLACE; +# session default +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +UPDATE t1 SET c2 = c2 + 1; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt2'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; +# session con1 +ERROR HY000: Creating index 'PRIMARY' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again. +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt3 WAIT_FOR dml3_done'; +ALTER TABLE t1 ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +ERROR 42000: Multiple primary key defined +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +ERROR 23000: Duplicate entry '5' for key 'PRIMARY' +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c22f,c4(5)), +CHANGE c2 c22f INT, CHANGE c3 c3 TEXT NULL, CHANGE c1 c1 INT AFTER c22f, +ADD COLUMN c4 VARCHAR(6) DEFAULT 'Online'; +# session default +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt3'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 240; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; +# session con1 +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +SELECT COUNT(c22f) FROM t1; +COUNT(c22f) +320 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)); +ERROR 23000: Duplicate entry '' for key 'PRIMARY' +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5)); +ERROR 42000: Multiple primary key defined +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +ALTER TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)), +ALGORITHM = INPLACE; +ERROR 22004: Invalid use of NULL value +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +ERROR 22004: Invalid use of NULL value +SET @@sql_mode = @old_sql_mode; +UPDATE t1 SET c3=CONCAT(c1,REPEAT('foo',c1)) WHERE c3 IS NULL; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0'; +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL, DROP COLUMN c22f, +ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST; +# session default +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created0'; +BEGIN; +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti','YLETV2'); +INSERT INTO t1 VALUES(33101,347,NULL,''); +SET DEBUG_SYNC = 'now SIGNAL ins_done0'; +# session con1 +ERROR 22004: Invalid use of NULL value +SET @@sql_mode = @old_sql_mode; +# session default +ROLLBACK; +# session con1 +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created WAIT_FOR ins_done'; +ALTER TABLE t1 DROP PRIMARY KEY, DROP COLUMN c22f, +ADD COLUMN c6 VARCHAR(1000) DEFAULT +'I love tracking down hard-to-reproduce bugs.', +ADD PRIMARY KEY c3p5(c3(5), c6(2)); +# session default +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +INSERT INTO t1 VALUES(347,33101,NULL,''); +ERROR 23000: Column 'c3' cannot be null +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti',''); +# session con1 +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +# session default +SELECT COUNT(*) FROM t1; +COUNT(*) +321 +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SELECT * FROM t1 LIMIT 10; +c22f c1 c3 c4 +5 1 1foo Online +6 2 2foofoo Online +7 3 3foofoofoo Online +8 4 4foofoofoofoo Online +9 5 5foofoofoofoofoo Online +5 6 6foofoofoofoofoofoo Online +6 7 7foofoofoofoofoofoofoo Online +7 8 8foofoofoofoofoofoofoofoo Online +8 9 9foofoofoofoofoofoofoofoofoo Online +9 10 10foofoofoofoofoofoofoofoofoofoo Online +# session con1 +ALTER TABLE t1 DISCARD TABLESPACE; +# Disconnect session con1 +# session default +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c22f` int(11) NOT NULL DEFAULT '0', + `c1` int(11) NOT NULL DEFAULT '0', + `c3` text NOT NULL, + `c4` varchar(6) NOT NULL DEFAULT 'Online', + PRIMARY KEY (`c1`,`c22f`,`c4`(5)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT +SET DEBUG_SYNC = 'RESET'; +SET DEBUG = ''; +SET GLOBAL innodb_monitor_disable = module_ddl; +DROP TABLE t1; +SET GLOBAL DEBUG = ''; +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb-wl5980-alter.result b/mysql-test/suite/innodb/r/innodb-wl5980-alter.result new file mode 100644 index 00000000000..59d0921e31f --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-wl5980-alter.result @@ -0,0 +1,1409 @@ +# +# This is a copy of innodb-alter.test except using remote tablespaces +# and showing those files. +# +SET default_storage_engine=InnoDB; +SET GLOBAL innodb_file_per_table=ON; +SET NAMES utf8; +CREATE TABLE t1 ( +c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, +INDEX(c2)) +ENGINE=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir'; +INSERT INTO t1 SET c1=1; +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME LIKE 'test/t%'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE t1p LIKE t1; +CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3), +CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2), +CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2)) +ENGINE=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir'; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i +WHERE FOR_NAME LIKE 'test/t%'; +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT '1', + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +ALTER TABLE t1 ALTER c2 DROP DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11), + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1; +ALTER TABLE t1 CHANGE c1 c1 INT FIRST; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE C2 c3 INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE c3 C INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +C 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 C +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 C 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 Cöŀumň_TWO 0 +test/t1c3 c3 c2 0 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +Cöŀumň_TWO 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 Cöŀumň_TWO +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 Cöŀumň_TWO 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT; +ERROR 42S22: Unknown column 'cöĿǖmň_two' in 't1' +ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t3.frm +t3.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t3.ibd +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t3 +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c3` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t3` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +ALTER TABLE t3 CHANGE c3 +`12345678901234567890123456789012345678901234567890123456789012345` INT; +ERROR 42000: Identifier name '12345678901234567890123456789012345678901234567890123456789012345' is too long +ALTER TABLE t3 CHANGE c3 +`1234567890123456789012345678901234567890123456789012345678901234` INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t3.frm +t3.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t3.ibd +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int(11) NOT NULL DEFAULT '0', + `1234567890123456789012345678901234567890123456789012345678901234` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`1234567890123456789012345678901234567890123456789012345678901234`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿偀` INT; +ERROR 42000: Identifier name '倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠' is too long +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿ä` INT; +ERROR 42000: Identifier name '倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠' is too long +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾ä` INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t3.frm +t3.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t3.ibd +ALTER TABLE t3 CHANGE +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾Ä` +c3 INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t3.frm +t3.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t3.ibd +ALTER TABLE t3 CHANGE c3 𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌇𐌈𐌉𐌊𐌋𐌌𐌍𐌎𐌏𐌐𐌑𐌒𐌓𐌔𐌕𐌖𐌗𐌘𐌙𐌚𐌛𐌜 INT; +ERROR HY000: Invalid utf8 character string: '\xF0\x90\x8C\x80\xF0\x90\x8C\x81\xF0\x90\x8C\x82\xF0\x90\x8C\x83' +ALTER TABLE t3 CHANGE c3 😲 INT; +ERROR HY000: Invalid utf8 character string: '\xF0\x9F\x98\xB2' +ALTER TABLE t3 RENAME TO t2; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t2.frm +t2.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t2.ibd +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t2 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c3` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +RENAME TABLE t2 TO t1; +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t1 +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 DROP INDEX c2; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1 DROP INDEX c4; +ERROR 42000: Can't DROP 'c4'; check that column/key exists +ALTER TABLE t1c DROP FOREIGN KEY c2; +ERROR 42000: Can't DROP 'c2'; check that column/key exists +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2; +ERROR 42000: Can't DROP 'c2'; check that column/key exists +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2; +ERROR 42000: Can't DROP 'c2'; check that column/key exists +ALTER TABLE t1c DROP INDEX c2; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2; +ERROR 42000: Can't DROP 'ẗ1C2'; check that column/key exists +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SET foreign_key_checks=0; +DROP TABLE t1p; +SET foreign_key_checks=1; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) +ENGINE=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir'; +ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1c DROP INDEX C3; +ERROR HY000: Cannot drop index 'c3': needed in a foreign key constraint +SET foreign_key_checks=0; +ALTER TABLE t1c DROP INDEX C3; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +t1p.ibd +SET foreign_key_checks=1; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1c DROP FOREIGN KEY t1C3; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +t1p.ibd +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +t1p.ibd +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +t1p.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +CREATE TABLE t1o LIKE t1; +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED. +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=SHARED; +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +SHOW CREATE TABLE tt; +Table Create Table +tt CREATE TABLE `tt` ( + `pk` int(11) NOT NULL DEFAULT '0', + `c2` int(11) DEFAULT '42', + `ct` text, + PRIMARY KEY (`pk`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'dB_row_Id' +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'DB_ROW_ID' +ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT; +ERROR 42000: Incorrect column name 'DB_TRX_ID' +ALTER TABLE t1o CHANGE c1 db_roll_ptr INT; +ERROR 42000: Incorrect column name 'DB_ROLL_PTR' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=INPLACE; +ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT, +ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_Doc_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY. +CREATE TABLE t1n LIKE t1o; +ALTER TABLE t1n ADD FULLTEXT INDEX(ct); +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'Fts_DOC_ID' +ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE; +ERROR 42S22: Unknown column 'FTS_DOC_ID' in 't1n' +ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1n CHANGE FTS_DOC_ÏD c1 INT, ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT, +ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c2` int(11) NOT NULL DEFAULT '0', + `ct` int(11) DEFAULT NULL, + `c1` text, + PRIMARY KEY (`c2`), + FULLTEXT KEY `ct` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT, +ALGORITHM=COPY; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c2` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ERROR 42000: Key column 'c2' doesn't exist in table +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; +ERROR 42000: Key column 'c2' doesn't exist in table +ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c4` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c4` (`c4`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n DROP INDEX c4; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +ERROR 42S21: Duplicate column name 'c1' +ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL DEFAULT '0', + `c11` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c11` (`c11`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1n; +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try LOCK=SHARED. +SELECT sc.pos FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID'; +pos +0 +SHOW CREATE TABLE t1o; +Table Create Table +t1o CREATE TABLE `t1o` ( + `FTS_DOC_ID` bigint(20) unsigned NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`FTS_DOC_ID`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +DROP INDEX ct, LOCK=NONE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1o; +Table Create Table +t1o CREATE TABLE `t1o` ( + `foo_id` bigint(20) unsigned NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`foo_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign; +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME='test/t1o'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o'; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +foo_id 0 6 1800 8 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 foo_id +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1o.frm +t1o.ibd +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +tt.ibd +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ADD FULLTEXT INDEX(ct); +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1o.frm +t1o.ibd +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +tt.ibd +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +DROP TABLE sys_indexes; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +FTS_DOC_ID 0 6 1800 8 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 FTS_DOC_ID +FTS_DOC_ID_INDEX 0 FTS_DOC_ID +ct 0 ct +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +# +# Cleanup +# +DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; +### files in MYSQL_DATA_DIR/test +### files in MYSQL_TMP_DIR/alt_dir/test diff --git a/mysql-test/suite/innodb/t/alter_rename_existing.test b/mysql-test/suite/innodb/t/alter_rename_existing.test new file mode 100644 index 00000000000..0c8bf481969 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_rename_existing.test @@ -0,0 +1,93 @@ +--echo # +--echo # Show what happens during ALTER TABLE when an existing file +--echo # exists in the target location. +--echo # +--echo # Bug #19218794: IF TABLESPACE EXISTS, CAN'T CREATE TABLE, +--echo # BUT CAN ALTER ENGINE=INNODB +--echo # + +--source include/have_innodb.inc + +--disable_query_log +LET $MYSQLD_DATADIR = `select @@datadir`; +SET @old_innodb_file_per_table = @@innodb_file_per_table; +--enable_query_log + +CREATE TABLE t1 (a SERIAL, b CHAR(10)) ENGINE=Memory; +INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); + +--echo # +--echo # Create a file called MYSQLD_DATADIR/test/t1.ibd +--exec echo "This is not t1.ibd" > $MYSQLD_DATADIR/test/t1.ibd + +--echo # Directory listing of test/*.ibd +--echo # +--list_files $MYSQLD_DATADIR/test/ *.ibd + +--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/ +--error ER_ERROR_ON_RENAME +ALTER TABLE t1 ENGINE = InnoDB; + +--echo # +--echo # Move the file to InnoDB as t2 +--echo # +ALTER TABLE t1 RENAME TO t2, ENGINE = INNODB; +SHOW CREATE TABLE t2; +SELECT * from t2; + +--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/ +--error ER_ERROR_ON_RENAME +ALTER TABLE t2 RENAME TO t1; + +--echo # +--echo # Create another t1, but in the system tablespace. +--echo # +SET GLOBAL innodb_file_per_table=OFF; +CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB; +INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); +SHOW CREATE TABLE t1; +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; + +--echo # +--echo # ALTER TABLE from system tablespace to system tablespace +--echo # +ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=INPLACE; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY; + +--echo # +--echo # Try to move t1 from the system tablespace to a file-per-table +--echo # while a blocking t1.ibd file exists. +--echo # +SET GLOBAL innodb_file_per_table=ON; +--replace_regex /$MYSQLD_DATADIR/MYSQLD_DATADIR/ +--error ER_TABLESPACE_EXISTS +ALTER TABLE t1 ADD COLUMN e1 INT, ALGORITHM=INPLACE; +--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/ +--error ER_ERROR_ON_RENAME +ALTER TABLE t1 ADD COLUMN e2 INT, ALGORITHM=COPY; + +--echo # +--echo # Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd +--remove_file $MYSQLD_DATADIR/test/t1.ibd + +--echo # Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd. +--echo # +ALTER TABLE t1 ADD COLUMN e INT, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; + +DROP TABLE t1; + +--echo # +--echo # Rename t2.ibd to t1.ibd. +--echo # +ALTER TABLE t2 RENAME TO t1; +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; +SELECT * from t1; + +DROP TABLE t1; + +--disable_query_log +call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot rename '.*' to '.*' for space ID .* because the target file exists. Remove the target file and try again"); +SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/index_tree_operation.test b/mysql-test/suite/innodb/t/index_tree_operation.test new file mode 100644 index 00000000000..b9695db9346 --- /dev/null +++ b/mysql-test/suite/innodb/t/index_tree_operation.test @@ -0,0 +1,74 @@ +-- source include/have_innodb.inc +-- source include/have_innodb_16k.inc +--echo # +--echo # Bug#15923864 (Bug#67718): +--echo # INNODB DRASTICALLY UNDER-FILLS PAGES IN CERTAIN CONDITIONS +--echo # +# InnoDB should try to insert to the next page before split, +# if the insert record for split_and_insert is last of the page. +# Otherwise, the follwing records 999,998,997 cause each page per record. +# + +--disable_query_log +SET @old_innodb_file_per_table = @@innodb_file_per_table; +--enable_query_log + +SET GLOBAL innodb_file_per_table=ON; + +CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (0, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1000, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1001, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1002, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (2, REPEAT('a', 4096)); + +# | 0, 1, 2 | 1000, 1001, 1002| + +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; + +INSERT INTO t1 VALUES (999, REPEAT('a', 4096)); + +# try to insert '999' to the end of '0,1,2' page, but no space +# the next '1000,1001,1002' page has also no space. +# | 0, 1, 2 | 999 | 1000, 1001, 1002| + +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; + + +INSERT INTO t1 VALUES (998, REPEAT('a', 4096)); + +# try to insert to the end of '0,1,2' page, but no space +# the next '998' page has space. +# | 0, 1, 2 | 998, 999 | 1000, 1001, 1002| + +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; + +INSERT INTO t1 VALUES (997, REPEAT('a', 4096)); + +# same +# | 0, 1, 2 | 997, 998, 999 | 1000, 1001, 1002| + +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; + +DROP TABLE t1; + +--disable_query_log +SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb-alter-autoinc.test b/mysql-test/suite/innodb/t/innodb-alter-autoinc.test new file mode 100644 index 00000000000..e01c44aa26e --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter-autoinc.test @@ -0,0 +1,104 @@ +--source include/have_innodb.inc + +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(347),(33101),(123),(45),(6); +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +ALTER TABLE t1 ADD PRIMARY KEY(a); +SET @@sql_mode = @old_sql_mode; + +# We cannot assign AUTO_INCREMENT values during online index creation. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + LOCK=NONE; + +--error ER_WRONG_AUTO_KEY +ALTER TABLE t1 ADD id INT AUTO_INCREMENT; + +--error ER_WRONG_AUTO_KEY +ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id); + +ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a); + +SELECT * FROM t1; + +# Test with a non-default increment and offset +SET AUTO_INCREMENT_INCREMENT = 5, AUTO_INCREMENT_OFFSET = 30; + +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY; + +SHOW CREATE TABLE t1; + +# The autoinc next value should increase. It is not rolled back. +BEGIN; +INSERT INTO t1 VALUES(7,0); +SELECT * FROM t1; +ROLLBACK; + +SHOW CREATE TABLE t1; + +# We cannot assign AUTO_INCREMENT values during online index creation. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE; + +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE; + +SELECT * FROM t1; +SHOW CREATE TABLE t1; + +INSERT INTO t1 SET a=123; +INSERT INTO t1 VALUES(-123,-45); + +ALTER TABLE t1 AUTO_INCREMENT = 75; + +INSERT INTO t1 SET a=123; +SELECT * FROM t1; + +SHOW CREATE TABLE t1; + +DROP TABLE t1; + +# ALGORITHM=INPLACE should deliver identical results to ALGORITHM=COPY. +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(347),(33101),(123),(45),(6); +ALTER TABLE t1 ADD PRIMARY KEY(a); + +ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a); + +SELECT * FROM t1; + +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE; + +SHOW CREATE TABLE t1; + +# The autoinc next value should increase. It is not rolled back. +BEGIN; +INSERT INTO t1 VALUES(7,0); +SELECT * FROM t1; +ROLLBACK; + +SHOW CREATE TABLE t1; + +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY; + +SELECT * FROM t1; + +SHOW CREATE TABLE t1; + +INSERT INTO t1 SET a=123; +INSERT INTO t1 VALUES(-123,-45); + +ALTER TABLE t1 AUTO_INCREMENT = 75; + +INSERT INTO t1 SET a=123; +SELECT * FROM t1; + +SHOW CREATE TABLE t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test new file mode 100644 index 00000000000..ca1252fb4e4 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter.test @@ -0,0 +1,484 @@ +--source include/have_innodb.inc + +SET NAMES utf8; + +CREATE TABLE t1 ( + c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, + INDEX(c2)) +ENGINE=InnoDB; + +INSERT INTO t1 SET c1=1; + +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME LIKE 'test/t%'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +CREATE TABLE t1p LIKE t1; + +CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3), + CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2), + CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2)) +ENGINE=InnoDB; + +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i +WHERE FOR_NAME LIKE 'test/t%'; + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; + +-- source suite/innodb/include/innodb_dict.inc + +SHOW CREATE TABLE t1; +ALTER TABLE t1 ALTER c2 DROP DEFAULT; +SHOW CREATE TABLE t1; + +-- source suite/innodb/include/innodb_dict.inc + +# These should be no-op. +ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1; +ALTER TABLE t1 CHANGE c1 c1 INT FIRST; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE C2 c3 INT; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE c3 C INT; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT; + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; + +-- source suite/innodb/include/innodb_dict.inc + +-- error ER_BAD_FIELD_ERROR +ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT; + +ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3; + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +SHOW CREATE TABLE t3; +SHOW CREATE TABLE t1c; + +# The maximum column name length should be 64 characters. +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE c3 +`12345678901234567890123456789012345678901234567890123456789012345` INT; +ALTER TABLE t3 CHANGE c3 +`1234567890123456789012345678901234567890123456789012345678901234` INT; +SHOW CREATE TABLE t3; + +# Test the length limit with non-ASCII utf-8 characters. +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿偀` INT; +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿ä` INT; +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾ä` INT; + +# check that the rename is case-insensitive (note the upper-case ä at end) +ALTER TABLE t3 CHANGE +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾Ä` +c3 INT; + +# test with 4-byte UTF-8 (should be disallowed) +--error ER_INVALID_CHARACTER_STRING +ALTER TABLE t3 CHANGE c3 𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌇𐌈𐌉𐌊𐌋𐌌𐌍𐌎𐌏𐌐𐌑𐌒𐌓𐌔𐌕𐌖𐌗𐌘𐌙𐌚𐌛𐌜 INT; +--error ER_INVALID_CHARACTER_STRING +ALTER TABLE t3 CHANGE c3 😲 INT; + +ALTER TABLE t3 RENAME TO t2; + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +SHOW CREATE TABLE t2; + +RENAME TABLE t2 TO t1; + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +-- source suite/innodb/include/innodb_dict.inc + +--error ER_DROP_INDEX_FK +ALTER TABLE t1 DROP INDEX c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1 DROP INDEX c4; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2; + +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2; + +SHOW CREATE TABLE t1c; + +SET foreign_key_checks=0; +DROP TABLE t1p; +SET foreign_key_checks=1; + +SHOW CREATE TABLE t1c; + +-- source suite/innodb/include/innodb_dict.inc + +CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) ENGINE=InnoDB; + +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3; +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX C3; + +SET foreign_key_checks=0; +ALTER TABLE t1c DROP INDEX C3; +SET foreign_key_checks=1; + +SHOW CREATE TABLE t1c; +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1c DROP FOREIGN KEY t1C3; + +SHOW CREATE TABLE t1c; +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2; + +SHOW CREATE TABLE t1c; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT; + +-- source suite/innodb/include/innodb_dict.inc + +CREATE TABLE t1o LIKE t1; + +# This will implicitly add a FTS_DOC_ID column, which cannot be done online. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=NONE; + +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=SHARED; + +# The output should be empty, because index->id was reassigned. +-- source suite/innodb/include/innodb_dict.inc + +SHOW CREATE TABLE tt; + +# DB_ROW_ID, DB_TRX_ID, DB_ROLL_PTR are reserved InnoDB system column names. +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 db_roll_ptr INT; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD COLUMN DB_TRX_ID INT; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD COLUMN db_roll_ptr INT; + +--error ER_INNODB_FT_WRONG_DOCID_COLUMN +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT; +--error ER_INNODB_FT_WRONG_DOCID_COLUMN +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED; + +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL; + +--error ER_DUP_FIELDNAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID INT; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE; + +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, DROP INDEX ct, ALGORITHM=INPLACE; + +# This creates a hidden FTS_DOC_ID column. +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN cu TEXT; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT, +ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT; +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED, +ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED; + +# This would drop the hidden FTS_DOC_ID column and create +# a fulltext index on ct and another fulltext index on cu. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), +ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; + +# Replace the hidden FTS_DOC_ID column with a user-visible one. +# This used to work if there is at most one fulltext index. +# Currently, we disallow native ALTER TABLE if the table +# contains any FULLTEXT indexes. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL; +# Replace the user-visible FTS_DOC_ID column with a hidden one. +# We do not support this in-place. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE; +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID; + +# FTS_DOC_ID is the internal row identifier for full-text search. +# It should be of type BIGINT UNSIGNED NOT NULL. +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT, +ALGORITHM=INPLACE; +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +CREATE TABLE t1n LIKE t1o; + +ALTER TABLE t1n ADD FULLTEXT INDEX(ct); +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY; +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE; + +ALTER TABLE t1n CHANGE FTS_DOC_ÏD c1 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT, +ALGORITHM=INPLACE; +SHOW CREATE TABLE t1n; +ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT, +ALGORITHM=COPY; +SHOW CREATE TABLE t1n; + +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; +ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1n; +ALTER TABLE t1n DROP INDEX c4; +--error ER_DUP_FIELDNAME +ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; + +SHOW CREATE TABLE t1n; +DROP TABLE t1n; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct, +ALGORITHM=INPLACE; + +# This will copy the table, removing the hidden FTS_DOC_ID column. +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct; + +ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +# This should not show duplicates. +SELECT sc.pos FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID'; + +SHOW CREATE TABLE t1o; + +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +DROP INDEX ct, ALGORITHM=INPLACE; + +SHOW CREATE TABLE t1o; + +DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign; + +# Check the internal schemata of tt, t1o. + +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME='test/t1o'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o'; + +-- source suite/innodb/include/innodb_dict.inc + +# Ensure that there exists no hidden FTS_DOC_ID_INDEX on foo_id. + +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(FTS_DOC_ID), +ADD FULLTEXT INDEX(ct), +CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL; + +ALTER TABLE t1o DROP INDEX ct, DROP INDEX FTS_DOC_ID_INDEX, +CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; + +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); + +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ADD FULLTEXT INDEX(ct); + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +DROP TABLE sys_indexes; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +-- source suite/innodb/include/innodb_dict.inc + +DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; + +CREATE TABLE t (t TEXT, FULLTEXT(t)) ENGINE=InnoDB; +DROP INDEX t ON t; + +LET $regexp=/FTS_([0-9a-f_]+)([A-Z_]+)/FTS_AUX_\2/; +--replace_regex $regexp +SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE '%FTS_%' ORDER BY 1, 2; + +SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t'; + +ALTER TABLE t ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE; + +--replace_regex $regexp +SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE '%FTS_%' ORDER BY 1, 2; + +ALTER TABLE t ADD FULLTEXT INDEX(t); + +SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t'; + +DROP TABLE t; + +--disable_query_log +call mtr.add_suppression("deleting orphaned .ibd file"); +--enable_query_log + +--echo # +--echo # Bug #19465984 INNODB DATA DICTIONARY IS NOT UPDATED WHILE +--echo # RENAMING THE COLUMN +--echo # +CREATE TABLE t1(c1 INT NOT NULL, PRIMARY KEY(c1))ENGINE=INNODB; +CREATE TABLE t2(c2 INT NOT NULL, FOREIGN KEY(c2) REFERENCES t1(c1))ENGINE=INNODB; +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; +ALTER TABLE t1 CHANGE COLUMN c1 C1 INT; +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; +ALTER TABLE t1 CHANGE COLUMN C1 c5 INT; +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; +DROP TABLE t2, t1; + +--echo # +--echo # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN +--echo # DICT_MEM_TABLE_COL_RENAME_LOW +--echo # +CREATE TABLE parent(a INT, b INT, KEY(a, b)) ENGINE = InnoDB; +CREATE TABLE t1(a1 INT, a2 INT) ENGINE = InnoDB; + +set foreign_key_checks=0; +ALTER TABLE t1 ADD CONSTRAINT fk_a FOREIGN KEY(a1, a2) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE; + +ALTER TABLE t1 CHANGE a2 a3 INT,ADD CONSTRAINT fk_1 FOREIGN KEY(a1, a3) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE; +SHOW CREATE TABLE t1; +CHECK TABLE t1; + +ALTER TABLE t1 CHANGE a3 a4 INT; +SHOW CREATE TABLE t1; +CHECK TABLE t1; + +ALTER TABLE parent CHANGE b c INT; +SHOW CREATE TABLE t1; +CHECK TABLE t1; + +DROP TABLE t1, parent; + +--echo # +--echo #BUG#21514135 SCHEMA MISMATCH ERROR WHEN IMPORTING TABLESPACE AFTER +--echo #DROPPING AN INDEX +--echo # +let $source_db = source_db; +let $dest_db = dest_db; + +eval CREATE DATABASE $source_db; +eval CREATE DATABASE $dest_db; + +eval CREATE TABLE $source_db.t1 ( + id int(11) NOT NULL, + age int(11) DEFAULT NULL, + name varchar(20), + PRIMARY KEY (id), + KEY index1 (age) + ) ENGINE=InnoDB; + +eval ALTER TABLE $source_db.t1 DROP INDEX index1, ADD INDEX index2(name, age), algorithm=inplace; + +--source suite/innodb/include/import.inc + +eval ALTER TABLE $source_db.t1 DROP INDEX index2, algorithm=inplace; + +--source suite/innodb/include/import.inc + +eval DROP TABLE $source_db.t1; +eval DROP DATABASE $source_db; +eval DROP DATABASE $dest_db; + + + diff --git a/mysql-test/suite/innodb/t/innodb-index-debug-master.opt b/mysql-test/suite/innodb/t/innodb-index-debug-master.opt new file mode 100644 index 00000000000..778b4443d4f --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-debug-master.opt @@ -0,0 +1 @@ +--innodb-sort-buffer-size=64k diff --git a/mysql-test/suite/innodb/t/innodb-index-debug.test b/mysql-test/suite/innodb/t/innodb-index-debug.test new file mode 100644 index 00000000000..8969dc69aa4 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-debug.test @@ -0,0 +1,83 @@ +-- source include/have_debug.inc +-- source include/have_innodb.inc + +let $MYSQLD_DATADIR= `select @@datadir`; + +let $per_table=`select @@innodb_file_per_table`; +let $format=`select @@innodb_file_format`; +set global innodb_file_per_table=on; +set global innodb_file_format='Barracuda'; + +# +# Test for BUG# 12739098, check whether trx->error_status is reset on error. +# +CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5); + +SET SESSION DEBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs'; +--error ER_TOO_MANY_CONCURRENT_TRXS +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET SESSION DEBUG=DEFAULT; + +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# +# Test for Bug#13861218 Records are not fully sorted during index creation +# +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2)) +ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0); +SET DEBUG='+d,ib_row_merge_buf_add_two'; +# Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2). +# No crash here, because n_uniq for c2 includes the clustered index fields +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG='-d,ib_row_merge_buf_add_two'; +DROP TABLE bug13861218; + +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL); +SET DEBUG='+d,ib_row_merge_buf_add_two'; +# Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2). +# assertion failure: ut_ad(cmp_dtuple_rec(dtuple, rec, rec_offsets) > 0) +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG='-d,ib_row_merge_buf_add_two'; +DROP TABLE bug13861218; + +eval set global innodb_file_per_table=$per_table; +eval set global innodb_file_format=$format; +eval set global innodb_file_format_max=$format; + +--echo # +--echo # Bug #21762319 ADDING INDEXES ON EMPTY TABLE IS SLOW +--echo # WITH LARGE INNODB_SORT_BUFFER_SIZE. + +call mtr.add_suppression("InnoDB: Cannot create temporary merge file"); + +# Table with large data which is greater than sort buffer + +create table t480(a serial)engine=innodb; +insert into t480 +values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(), +(),(),(),(),(),(),(),(); +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +create table t1(f1 int auto_increment not null, + f2 char(200) not null, f3 char(200) not null, + f4 char(200) not null,primary key(f1))engine=innodb; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 select NULL,'aaaa','bbbb','cccc' from t480; +insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480; +insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480; +insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480; +insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480; +select count(*) from t1; + +SET DEBUG = '+d,innobase_tmpfile_creation_failure'; +--error ER_OUT_OF_RESOURCES +alter table t1 force, algorithm=inplace; +SET DEBUG = '-d,innobase_tmpfile_creation_failure'; +drop table t1, t480; diff --git a/mysql-test/suite/innodb/t/innodb-index-online-delete.test b/mysql-test/suite/innodb/t/innodb-index-online-delete.test new file mode 100644 index 00000000000..ec5f93731ed --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online-delete.test @@ -0,0 +1,36 @@ +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + +connect (con1,localhost,root,,); + +connection default; + +CREATE TABLE t (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB; +INSERT INTO t VALUES(1,2),(2,3); + +SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL do WAIT_FOR m'; +SET DEBUG_SYNC='innodb_after_inplace_alter_table SIGNAL scanned WAIT_FOR done'; +--send +CREATE INDEX tb ON t(b); + +connection con1; +SET DEBUG_SYNC='now WAIT_FOR do'; +SET DEBUG_SYNC='row_update_for_mysql_error SIGNAL m WAIT_FOR scanned'; +--error ER_DUP_ENTRY +UPDATE t SET a=2 WHERE a=1; +call mtr.add_suppression('InnoDB: record in index .*tb was not found on rollback, trying to insert'); +SET DEBUG_SYNC='now SIGNAL done'; + +disconnect con1; + +connection default; +reap; +SET DEBUG_SYNC='RESET'; +DROP TABLE t; + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb/t/innodb-index-online-fk.test b/mysql-test/suite/innodb/t/innodb-index-online-fk.test new file mode 100644 index 00000000000..bb8c4a323e7 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online-fk.test @@ -0,0 +1,483 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON parent(b); + +INSERT INTO parent VALUES(10,20),(20,30); + +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON child(a2); + +INSERT INTO child VALUES(10,20); + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE child ADD FOREIGN KEY(a2) REFERENCES parent(b), +ALGORITHM = INPLACE; + +SET foreign_key_checks = 0; + +ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +# duplicated foreign key name +--error ER_FK_DUP_NAME +ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SET foreign_key_checks = 1; + +INSERT INTO child VALUES(1,2),(2,3); + +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO child VALUES(4,4); + +SELECT * FROM parent; + +SET foreign_key_checks = 0; + +# This would fail. No corresponding index +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE child ADD CONSTRAINT fk_20 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SHOW WARNINGS; + +SHOW ERRORS; + +CREATE INDEX idx1 on parent(a, b); + +ALTER TABLE child ADD CONSTRAINT fk_10 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +# This should be successful, as we added the index +ALTER TABLE child ADD CONSTRAINT fk_2 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ADD INDEX idx1(a1,a2), +ALGORITHM = INPLACE; + +ALTER TABLE child ADD CONSTRAINT fk_3 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +SET foreign_key_checks = 1; + +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO child VALUES(5,4); + +SHOW CREATE TABLE child; + +DELETE FROM parent where a = 1; + +SELECT * FROM child; + +# Now test referenced table cannot be opened. This should work fine +# when foreign_key_checks is set to 0 + +SET foreign_key_checks = 0; + +# This is to test the scenario we cannot open the referenced table. +# Since foreign_key_checks is set to 0, the foreign key should still +# be added. +SET DEBUG = '+d,innodb_test_open_ref_fail'; +ALTER TABLE child ADD CONSTRAINT fk_4 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG = '-d,innodb_test_open_ref_fail'; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; + +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +# this should succeed, since we disabled the foreign key check +INSERT INTO child VALUES(5,4); + +SET foreign_key_checks = 1; + +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO child VALUES(6,5); + +SET foreign_key_checks = 0; + +# Create some table with 'funny' characters, for testing the +# error message +CREATE TABLE `#parent` (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; + +CREATE INDEX tb ON `#parent`(a, b); + +CREATE TABLE `#child` (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON `#child`(a1, a2); + +# This is to test the scenario no foreign index, alter table should fail +SET DEBUG = '+d,innodb_test_no_foreign_idx'; +--error ER_FK_NO_INDEX_CHILD, +ALTER TABLE `#child` ADD CONSTRAINT fk_40 FOREIGN KEY (a1, a2) +REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG = '-d,innodb_test_no_foreign_idx'; + +SHOW ERRORS; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +# This is to test the scenario no index on referenced table, +# alter table should fail +SET DEBUG = '+d,innodb_test_no_reference_idx'; +--error ER_FK_NO_INDEX_PARENT, +ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG = '-d,innodb_test_no_reference_idx'; + +SHOW ERRORS; + +# This is to test the scenario no index on referenced table, +# alter table should fail +SET DEBUG = '+d,innodb_test_wrong_fk_option'; +--error ER_FK_INCORRECT_OPTION +ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG = '-d,innodb_test_wrong_fk_option'; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +# This is to test the scenario cannot add fk to the system table, +# alter table should fail +SET DEBUG = '+d,innodb_test_cannot_add_fk_system'; +--error ER_FK_FAIL_ADD_SYSTEM +ALTER TABLE `#child` ADD CONSTRAINT fk_43 FOREIGN KEY (a1, a2) +REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG = '-d,innodb_test_cannot_add_fk_system'; + +SHOW ERRORS; + +DROP TABLE `#child`; +DROP TABLE `#parent`; + +# Now test add multiple foreign key constrain in a single clause +SET foreign_key_checks = 0; + +ALTER TABLE child ADD CONSTRAINT fk_5 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ADD CONSTRAINT fk_6 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +DROP TABLE child; +DROP TABLE parent; + +# Test a case where child's foreign key index is being dropped in the +# same clause of adding the foreign key. In theory, MySQL will +# automatically create a new index to meet the index requirement +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; + +INSERT INTO parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON parent(b); + +INSERT INTO parent VALUES(10,20),(20,30); + +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON child(a2); + +INSERT INTO child VALUES(10,20); + +SET foreign_key_checks = 0; + +ALTER TABLE child DROP INDEX tb, ADD CONSTRAINT fk_4 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SHOW CREATE TABLE child; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +SET foreign_key_checks = 1; + +DROP TABLE child; + +DROP TABLE parent; + +# Test ADD FOREIGN KEY together with renaming columns. +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; + +INSERT INTO parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON parent(b); + +INSERT INTO parent VALUES(10,20),(20,30); + +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON child(a2); + +SET foreign_key_checks = 0; + +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE child CHANGE a2 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +ALTER TABLE child CHANGE a2 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +DROP TABLE child; + +DROP TABLE parent; + +# Add test for add Primary key and FK on changing columns +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON parent(b); + +INSERT INTO parent VALUES(10,20),(20,30); + +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON child(a2); + +SET foreign_key_checks = 0; + +# Let's rebuild the table and add the FK, make the add FK failed. + +SET DEBUG = '+d,innodb_test_cannot_add_fk_system'; +--error ER_FK_FAIL_ADD_SYSTEM +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG = '-d,innodb_test_cannot_add_fk_system'; + +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +# This should be successful. It will also check any left over +# from previous failed operation (if dictionary entries not cleaned, +# it will have dup key error. +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +SHOW CREATE TABLE child; + +DROP TABLE child; + +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; + +# Now try primary index and FK +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +SHOW CREATE TABLE child; + +DROP TABLE child; + +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; + +ALTER TABLE child CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +SHOW CREATE TABLE child; + +DROP TABLE child; + +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +# Now try all three +--error ER_FK_INCORRECT_OPTION +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +DROP TABLE parent; +DROP TABLE child; + +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL, c INT) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2,3),(2,3,4); + +CREATE INDEX tb ON parent(b); + +CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); + +ALTER TABLE child +ADD CONSTRAINT fk_a FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +ALTER TABLE child +ADD CONSTRAINT fk_b FOREIGN KEY (a1) REFERENCES parent(a), +ALGORITHM = INPLACE; + +ALTER TABLE child CHANGE a2 a2_new INT, CHANGE a1 a1_new INT; + +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +# The third add FK will fail +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE child +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c), +ALGORITHM = INPLACE; + +# It should still have only 2 FKs +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; + +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +#Now let's make it successful +ALTER TABLE child +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a), +ALGORITHM = INPLACE; + +# It should still have 5 FKs +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; + +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); + +# Let's try this 3rd fk failure with add primary index +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c), +ALGORITHM = INPLACE; + +# It should still have no FKs, no PRIMARY +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; + +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +# make it successful +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a), +ALGORITHM = INPLACE; + +# It should have 3 FKs, a new PRIMARY +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; + +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +SET foreign_key_checks = 1; + +DROP TABLE child; +DROP TABLE parent; + +CREATE TABLE Parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO Parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON Parent(b); + +INSERT INTO Parent VALUES(10,20),(20,30); + +CREATE TABLE Child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON Child(a2); + +INSERT INTO Child VALUES(10,20); + +SET foreign_key_checks = 0; + +ALTER TABLE Child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES Parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +DROP TABLE Child; +DROP TABLE Parent; + +# This is the test for bug 14594526 - FK: ASSERTION IN +# DICT_TABLE_CHECK_FOR_DUP_INDEXES +CREATE TABLE `t2`(a int,c int,d int) ENGINE=INNODB; +CREATE TABLE `t3`(a int,c int,d int) ENGINE=INNODB; +CREATE INDEX idx ON t3(a); + +ALTER TABLE `t2` ADD CONSTRAINT `fw` FOREIGN KEY (`c`) REFERENCES t3 (a); + +ALTER TABLE `t2` ADD CONSTRAINT `e` foreign key (`d`) REFERENCES t3(a); + +--error ER_FK_FAIL_ADD_SYSTEM +ALTER TABLE `t3` ADD CONSTRAINT `e` foreign key (`c`) REFERENCES `t2`(`c`) ON UPDATE SET NULL; + +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; + +DROP TABLE t2; + +DROP TABLE t3; diff --git a/mysql-test/suite/innodb/t/innodb-index-online-master.opt b/mysql-test/suite/innodb/t/innodb-index-online-master.opt new file mode 100644 index 00000000000..9ac01ffb5ad --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online-master.opt @@ -0,0 +1 @@ +--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=64k --innodb-buffer-pool-size=5M --innodb-log-buffer-size=256k diff --git a/mysql-test/suite/innodb/t/innodb-index-online-purge.test b/mysql-test/suite/innodb/t/innodb-index-online-purge.test new file mode 100644 index 00000000000..28ff9403c0c --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online-purge.test @@ -0,0 +1,73 @@ +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + +connect (con1,localhost,root,,); + +connect (con2,localhost,root,,); +connection default; + +CREATE TABLE t (a INT PRIMARY KEY, c TEXT) ENGINE=InnoDB; +CREATE TABLE u (a INT PRIMARY KEY, b INT, c INT NOT NULL) ENGINE=InnoDB; + +INSERT INTO t VALUES (1,'aa'); +BEGIN; +INSERT INTO u SET a=1, c=1; +INSERT INTO u SELECT a+1,NULL,a+1 FROM u; +INSERT INTO u SELECT a+2,NULL,a+2 FROM u; +INSERT INTO u SELECT a+4,NULL,a+4 FROM u; +INSERT INTO u SELECT a+8,NULL,a+8 FROM u; +INSERT INTO u SELECT a+16,NULL,a+16 FROM u; +INSERT INTO u SELECT a+32,NULL,a+32 FROM u; +INSERT INTO u SELECT a+64,NULL,a+64 FROM u; +INSERT INTO u SELECT a+128,NULL,a+64 FROM u; +INSERT INTO u SELECT a+256,NULL,a+64 FROM u; +COMMIT; + +BEGIN; +DELETE FROM u; + +connection con2; +SET DEBUG_SYNC='row_log_apply_before SIGNAL created_u WAIT_FOR dml_done_u'; +--send +ALTER TABLE u ADD INDEX (c); + +connection default; +# Check that the above SELECT is blocked +let $wait_condition= + SELECT COUNT(*) = 1 from information_schema.processlist + WHERE state = 'Waiting for table metadata lock' AND + info = 'ALTER TABLE u ADD INDEX (c)'; +--source include/wait_condition.inc + +COMMIT; +SET DEBUG_SYNC='now WAIT_FOR created_u'; +SELECT state FROM information_schema.processlist +WHERE info='ALTER TABLE u ADD INDEX (c)'; + +connection con1; +SET DEBUG_SYNC='row_log_apply_before SIGNAL created_t WAIT_FOR dml_done_t'; +--send +CREATE INDEX c1 ON t (c(1)); +connection default; +SET DEBUG_SYNC='now WAIT_FOR created_t'; +UPDATE t SET c='ab'; +# Allow purge to kick in. TODO: Trigger this faster, somehow. +SELECT SLEEP(10); +SET DEBUG_SYNC='now SIGNAL dml_done_u'; +connection con2; +reap; +SET DEBUG_SYNC='now SIGNAL dml_done_t'; +disconnect con2; +connection con1; +reap; +disconnect con1; +connection default; +SET DEBUG_SYNC='RESET'; +DROP TABLE t,u; + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb/t/innodb-index-online.test b/mysql-test/suite/innodb/t/innodb-index-online.test new file mode 100644 index 00000000000..c314607e617 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online.test @@ -0,0 +1,403 @@ +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +let $innodb_metrics_select= +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; + +call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); + +# DISCARD TABLESPACE needs file-per-table +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; + +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 TEXT) +ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); + +SET GLOBAL innodb_monitor_enable = module_ddl; +eval $innodb_metrics_select; + +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +--send +INSERT INTO t1 VALUES(1,2,3); + +connect (con1,localhost,root,,); +connection con1; + +# This should block at the end because of the INSERT in connection default +# is holding a metadata lock. +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; + +connection default; +--error ER_DUP_ENTRY +reap; +eval $innodb_metrics_select; + +connection con1; +SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +--error ER_OUT_OF_RESOURCES +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; +SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +--error ER_OUT_OF_RESOURCES +CREATE UNIQUE INDEX c2 ON t1(c2); +SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +CREATE UNIQUE INDEX c2 ON t1(c2); +DROP INDEX c2 ON t1; + +connection default; +SHOW CREATE TABLE t1; +# Insert a duplicate entry (4) for the upcoming UNIQUE INDEX(c2). +BEGIN; +INSERT INTO t1 VALUES(7,4,2); + +connection con1; +# This DEBUG_SYNC should not kick in yet, because the duplicate key will be +# detected before we get a chance to apply the online log. +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL scanned WAIT_FOR rollback_done'; +# This will be a lock wait timeout on the meta-data lock, +# because the transaction inserting (7,4,2) is still active. +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +COMMIT; +connection con1; +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +DELETE FROM t1 WHERE c1 = 7; +connection con1; +# ADD FOREIGN KEY is not supported in-place +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 ADD FOREIGN KEY(c2) REFERENCES t1(c2), ALGORITHM = INPLACE; +# The previous DEBUG_SYNC should be ignored, because an exclusive lock +# has been requested and the online log is not being allocated. +ALTER TABLE t1 ADD UNIQUE INDEX(c2), LOCK = EXCLUSIVE, ALGORITHM = INPLACE; +DROP INDEX c2 ON t1; +# Now the previous DEBUG_SYNC should kick in. +--send +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +eval $innodb_metrics_select; + +# Insert a duplicate entry (4) for the already started UNIQUE INDEX(c2). +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; +SET DEBUG_SYNC = 'now SIGNAL rollback_done'; + +connection con1; +# Because the modification log will be applied in order, there will be +# a duplicate key error on the (7,4,2) even though we roll it back. +--error ER_DUP_ENTRY +reap; +# Now, create the index without any concurrent DML, while no duplicate exists. +SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done'; +--send +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR created'; +# At this point, the index has been created inside InnoDB but not yet +# in the MySQL data dictionary. +eval $innodb_metrics_select; +# A duplicate key error should now be triggered by InnoDB, but reported +# by the ALTER TABLE because the index does not 'officially' exist yet. +INSERT INTO t1 VALUES(6,3,1); +SET DEBUG_SYNC = 'now SIGNAL dml_done'; +connection con1; +# This is due to the duplicate entry (6,3,1). +--error ER_DUP_UNKNOWN_IN_INDEX +reap; +DELETE FROM t1 WHERE c1=6; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +eval $innodb_metrics_select; + +connection default; +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES(6,3,1); +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES(7,4,2); +ALTER TABLE t1 STATS_PERSISTENT=1; +ANALYZE TABLE t1; +# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7; +UPDATE mysql.innodb_index_stats SET stat_value = 5 +WHERE database_name = 'test' AND table_name= 't1' AND index_name = 'PRIMARY' +AND stat_value = 6; +--replace_column 4 LAST_UPDATE +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1'); +CREATE TABLE t1_c2_stats SELECT * FROM mysql.innodb_index_stats +WHERE database_name = 'test' AND table_name = 't1' and index_name = 'c2'; +# in Embedded mode (./mtr --embedded-server) the t1_c2_stats table gets +# created in MyISAM format by default even if we set +# default_storage_engine='innodb' +ALTER TABLE t1_c2_stats ENGINE=INNODB; +DROP INDEX c2 ON t1; +ANALYZE TABLE t1_c2_stats; +--replace_column 4 LAST_UPDATE +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1', 't1_c2_stats'); + +connection con1; +let $ID= `SELECT @id := CONNECTION_ID()`; +--error ER_QUERY_INTERRUPTED +KILL QUERY @id; + +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2d_created WAIT_FOR kill_done'; +--send +CREATE INDEX c2d ON t1(c2); + +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c2d_created'; +eval $innodb_metrics_select; +let $ignore= `SELECT @id := $ID`; +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; + +connection con1; +--error ER_QUERY_INTERRUPTED +reap; +eval $innodb_metrics_select; + +connection default; +CHECK TABLE t1; +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7; +--replace_result 81 80 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +ANALYZE TABLE t1; + +connection con1; +# Forge some statistics for c2d, and see that they will be used +UPDATE t1_c2_stats SET index_name = 'c2d'; +# Fake the statistics. The cardinality should be 5,80. +UPDATE t1_c2_stats SET stat_value = 2 WHERE stat_name = 'n_diff_pfx01'; +INSERT INTO t1_c2_stats +SELECT database_name, table_name, index_name, last_update, 'n_diff_pfx02', 80, +sample_size, 'c2,c1' FROM t1_c2_stats +WHERE stat_name = 'n_diff_pfx01' AND stat_description = 'c2'; +INSERT INTO mysql.innodb_index_stats SELECT * FROM t1_c2_stats; +DROP TABLE t1_c2_stats; + +CREATE INDEX c2d ON t1(c2); +# This should show the newly calculated stats by CREATE INDEX above, +# not the faked cardinality=4 for c2d(c2). +# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7; +--replace_result 81 80 +SHOW INDEX FROM t1; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; + +SHOW CREATE TABLE t1; + +# Exceed the configured innodb_online_alter_log_max_size. +# The actual limit is a multiple of innodb_sort_buf_size, +# because that is the size of the in-memory log buffers. +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2e_created WAIT_FOR dml2_done'; +# Ensure that the ALTER TABLE will be executed even with some concurrent DML. +SET lock_wait_timeout = 10; +--send +ALTER TABLE t1 CHANGE c2 c22 INT, DROP INDEX c2d, ADD INDEX c2e(c22), +ALGORITHM = INPLACE; + +# Generate some log (delete-mark, delete-unmark, insert etc.) +# while the index creation is blocked. Some of this may run +# in parallel with the clustered index scan. +connection default; +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +UPDATE t1 SET c2 = c2 + 1; +SET DEBUG_SYNC = 'now WAIT_FOR c2e_created'; +# At this point, the clustered index scan must have completed, +# but the modification log keeps accumulating due to the DEBUG_SYNC. +eval $innodb_metrics_select; +let $c= 2; +while ($c) +{ + BEGIN; + DELETE FROM t1; + ROLLBACK; + UPDATE t1 SET c2 = c2 + 1; + BEGIN; + UPDATE t1 SET c2 = c2 + 1; + DELETE FROM t1; + ROLLBACK; + dec $c; +} +# Incomplete index c2e should exist until the DDL thread notices the overflow. +# (The output below strips TEMP_INDEX_PREFIX from the name.) +eval $innodb_metrics_select; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c2e'; + +# Release con1. +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; + +connection con1; +# If the following fails with the wrong error, it probably means that +# you should rerun with a larger mtr --debug-sync-timeout. +--error ER_INNODB_ONLINE_LOG_TOO_BIG +reap; +# The index c2e should have been dropped from the data dictionary +# when the above error was noticed. It should still exist in the +# cache with index->online_status = ONLINE_INDEX_ABORTED_DROPPED. +eval $innodb_metrics_select; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c2e'; + +# ddl_background_drop_indexes = 1 here, because the incomplete index c2e still +# exists in the InnoDB data dictionary cache. +eval $innodb_metrics_select; + +connection default; + +ALTER TABLE t1 COMMENT 'testing if c2e will be dropped'; + +# Check that the 'zombie' index c2e was dropped. +eval $innodb_metrics_select; + +connection con1; +# Accumulate and apply some modification log. +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done'; +--send +ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; + +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; +# Generate some log (delete-mark, delete-unmark, insert etc.) +eval $innodb_metrics_select; +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 160; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +eval $innodb_metrics_select; +# Release con1. +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; + +connection con1; +reap; +eval $innodb_metrics_select; +SELECT COUNT(c22f) FROM t1; +CHECK TABLE t1; + +# Create a column prefix index. +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c3p5_created WAIT_FOR ins_done'; +--send +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); + +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; + +# Check that the index was created. +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c3p5'; + +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +--send +INSERT INTO t1 VALUES(347,33101,NULL); + +connection con1; +--error ER_LOCK_WAIT_TIMEOUT +reap; +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; + +# InnoDB should have cleaned up the index c3p5 from the data dictionary, +# but not yet from the dictionary cache. +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c3p5'; +eval $innodb_metrics_select; + +connection default; +reap; +# Index c3p5 should still exist in the data dictionary cache. +eval $innodb_metrics_select; + +--disable_parsing +# Temporarily disabled by fix for bug#14213236. Should be either +# removed or updated to take into account that locking for IMPORT/ +# DISCARD TABLESPACE happens on MDL layer. New test case is added +# to validate this at MDL layer(i_main.alter_table.test) + +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2g_created WAIT_FOR dml4_done'; +# The lock upgrade at the end of the ALTER will conflict with the DISCARD. +SET lock_wait_timeout = 1; +--send +ALTER TABLE t1 DROP INDEX c2f, ADD INDEX c2g(c22f); + +connection con1; +SET DEBUG_SYNC = 'now WAIT_FOR c2g_created'; + +connect (con2,localhost,root,,); +connection con2; + +# This will conflict with the ALTER in connection default, above. +SET lock_wait_timeout = 10; +--send +ALTER TABLE t1 DISCARD TABLESPACE; + +connection con1; +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = 'Waiting for table level lock' and + info = 'ALTER TABLE t1 DISCARD TABLESPACE'; +--source include/wait_condition.inc + +SET DEBUG_SYNC = 'now SIGNAL dml4_done'; +disconnect con1; +connection con2; +reap; +disconnect con2; +connection default; +--error ER_LOCK_WAIT_TIMEOUT +reap; +--enable_parsing +#remove below con1 disconnect if above test case is enabled +connection con1; +disconnect con1; +connection default; + +SHOW CREATE TABLE t1; +ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f; +# The ALTER TABLE should have cleaned up c3p5 from the cache. +eval $innodb_metrics_select; +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = INPLACE; +--error ER_DUP_KEYNAME +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = COPY; + +SET DEBUG_SYNC = 'RESET'; +SET DEBUG = ''; +SET GLOBAL innodb_monitor_disable = module_ddl; + +DROP TABLE t1; + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc + +SET GLOBAL DEBUG = ''; +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +--disable_warnings +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; +--enable_warnings diff --git a/mysql-test/suite/innodb/t/innodb-table-online-master.opt b/mysql-test/suite/innodb/t/innodb-table-online-master.opt new file mode 100644 index 00000000000..9ac01ffb5ad --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-table-online-master.opt @@ -0,0 +1 @@ +--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=64k --innodb-buffer-pool-size=5M --innodb-log-buffer-size=256k diff --git a/mysql-test/suite/innodb/t/innodb-table-online.test b/mysql-test/suite/innodb/t/innodb-table-online.test new file mode 100644 index 00000000000..f8bce701803 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-table-online.test @@ -0,0 +1,379 @@ +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +let $innodb_metrics_select= +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; + +call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); +# these will be triggered by DISCARD TABLESPACE +call mtr.add_suppression("InnoDB: Error: table 'test/t1'"); +call mtr.add_suppression("MySQL is trying to open a table handle but the .ibd file for"); + +# DISCARD TABLESPACE needs file-per-table +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; + +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 TEXT NOT NULL) +ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); + +SET GLOBAL innodb_monitor_enable = module_ddl; +eval $innodb_metrics_select; + +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +--send +INSERT INTO t1 VALUES(1,2,3); + +--echo # Establish session con1 (user=root) +connect (con1,localhost,root,,); +connection con1; + +# This should block at the end because of the INSERT in connection default +# is holding a metadata lock. +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; + +--echo # session default +connection default; +--error ER_DUP_ENTRY +reap; +eval $innodb_metrics_select; + +--echo # session con1 +connection con1; +SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +--error ER_OUT_OF_RESOURCES +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; +SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +--error ER_OUT_OF_RESOURCES +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; + +--echo # session default +connection default; +SHOW CREATE TABLE t1; +# Insert a duplicate entry (4) for the upcoming UNIQUE INDEX(c2). +BEGIN; +INSERT INTO t1 VALUES(7,4,2); + +--echo # session con1 +connection con1; +# This DEBUG_SYNC should not kick in yet, because the duplicate key will be +# detected before we get a chance to apply the online log. +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR insert_done'; +# This will be a lock wait timeout on the meta-data lock, +# because the transaction inserting (7,4,2) is still active. +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); + +--echo # session default +connection default; +COMMIT; + +--echo # session con1 +connection con1; +--error ER_DUP_ENTRY +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); + +--echo # session default +connection default; +DELETE FROM t1 WHERE c1 = 7; + +--echo # session con1 +connection con1; +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ROW_FORMAT=COMPACT, +LOCK = SHARED, ALGORITHM = INPLACE; + +# The previous DEBUG_SYNC should be ignored, because an exclusive lock +# has been requested and the online log is not being allocated. +ALTER TABLE t1 ADD UNIQUE INDEX(c2), +LOCK = EXCLUSIVE, ALGORITHM = INPLACE; + +SHOW CREATE TABLE t1; +# We do not support plain DROP_PK_INDEX without ADD_PK_INDEX. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 DROP INDEX c2, ALGORITHM = INPLACE; +SHOW CREATE TABLE t1; +# Now the previous DEBUG_SYNC should kick in. +--send +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1); + +--echo # session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +eval $innodb_metrics_select; + +# Insert a duplicate entry (4) for the already started UNIQUE INDEX(c1). +BEGIN; +INSERT INTO t1 VALUES(4,7,2); +SET DEBUG_SYNC = 'now SIGNAL insert_done'; + +--echo # session con1 +connection con1; +# Because the modification log will be applied in order and we did +# not roll back before the log apply, there will be a duplicate key +# error on the (4,7,2). +--error ER_DUP_ENTRY +reap; + +--echo # session default +connection default; +ROLLBACK; + +--echo # session con1 +connection con1; +SHOW CREATE TABLE t1; +# Now, rebuild the table without any concurrent DML, while no duplicate exists. +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ALGORITHM = INPLACE; +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1), ALGORITHM = INPLACE; +eval $innodb_metrics_select; + +--echo # session default +connection default; +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES(6,3,1); +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES(7,4,2); +DROP INDEX c2_2 ON t1; +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; + +--echo # session con1 +connection con1; +let $ID= `SELECT @id := CONNECTION_ID()`; +--error ER_QUERY_INTERRUPTED +KILL QUERY @id; + +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt WAIT_FOR kill_done'; +--send +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; + +--echo # session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt'; +eval $innodb_metrics_select; +let $ignore= `SELECT @id := $ID`; +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; + +--echo # session con1 +connection con1; +--error ER_QUERY_INTERRUPTED +reap; +eval $innodb_metrics_select; + +--echo # session default +connection default; +CHECK TABLE t1; +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7; +--replace_result 81 80 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +ANALYZE TABLE t1; + +--echo # session con1 +connection con1; +SHOW CREATE TABLE t1; + +# Exceed the configured innodb_online_alter_log_max_size. +# The actual limit is a multiple of innodb_sort_buf_size, +# because that is the size of the in-memory log buffers. +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt2 WAIT_FOR dml2_done'; +# Ensure that the ALTER TABLE will be executed even with some concurrent DML. +SET lock_wait_timeout = 10; +--send +ALTER TABLE t1 ROW_FORMAT=COMPACT, ALGORITHM = INPLACE; + +# Generate some log (delete-mark, delete-unmark, insert etc.) +# while the index creation is blocked. Some of this may run +# in parallel with the clustered index scan. +--echo # session default +connection default; +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +UPDATE t1 SET c2 = c2 + 1; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt2'; +# At this point, the clustered index scan must have completed, +# but the modification log keeps accumulating due to the DEBUG_SYNC. +eval $innodb_metrics_select; +let $c= 3; +while ($c) +{ + BEGIN; + DELETE FROM t1; + ROLLBACK; + UPDATE t1 SET c2 = c2 + 1; + BEGIN; + UPDATE t1 SET c2 = c2 + 1; + DELETE FROM t1; + ROLLBACK; + dec $c; +} +# Temporary table should exist until the DDL thread notices the overflow. +eval $innodb_metrics_select; + +# Release con1. +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; + +--echo # session con1 +connection con1; +# If the following fails with the wrong error, it probably means that +# you should rerun with a larger mtr --debug-sync-timeout. +--error ER_INNODB_ONLINE_LOG_TOO_BIG +reap; +# The table should have been dropped from the data dictionary +# when the above error was noticed. +eval $innodb_metrics_select; + +# Accumulate and apply some modification log. +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt3 WAIT_FOR dml3_done'; +--error ER_MULTIPLE_PRI_KEY +ALTER TABLE t1 ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +--error ER_DUP_ENTRY +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +--send +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c22f,c4(5)), +CHANGE c2 c22f INT, CHANGE c3 c3 TEXT NULL, CHANGE c1 c1 INT AFTER c22f, +ADD COLUMN c4 VARCHAR(6) DEFAULT 'Online'; + +--echo # session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt3'; +# Generate some log (delete-mark, delete-unmark, insert etc.) +eval $innodb_metrics_select; +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 240; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +eval $innodb_metrics_select; +# Release con1. +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; + +--echo # session con1 +connection con1; +reap; +eval $innodb_metrics_select; +SELECT COUNT(c22f) FROM t1; +CHECK TABLE t1; + +# Create a column prefix index. +--error ER_DUP_ENTRY +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)); +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +--error ER_MULTIPLE_PRI_KEY +ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5)); +SET @old_sql_mode = @@sql_mode; +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +# And adding a PRIMARY KEY will also add NOT NULL implicitly! +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +--error ER_INVALID_USE_OF_NULL +ALTER TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)), +ALGORITHM = INPLACE; + +--error ER_INVALID_USE_OF_NULL +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +SET @@sql_mode = @old_sql_mode; +UPDATE t1 SET c3=CONCAT(c1,REPEAT('foo',c1)) WHERE c3 IS NULL; + +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0'; +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +--send +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL, DROP COLUMN c22f, +ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST; + +--echo # session default +connection default; + +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created0'; +BEGIN; +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti','YLETV2'); +INSERT INTO t1 VALUES(33101,347,NULL,''); +SET DEBUG_SYNC = 'now SIGNAL ins_done0'; + +--echo # session con1 +connection con1; +--error ER_INVALID_USE_OF_NULL +reap; +SET @@sql_mode = @old_sql_mode; + +--echo # session default +connection default; +ROLLBACK; + +--echo # session con1 +connection con1; +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created WAIT_FOR ins_done'; +--send +ALTER TABLE t1 DROP PRIMARY KEY, DROP COLUMN c22f, +ADD COLUMN c6 VARCHAR(1000) DEFAULT +'I love tracking down hard-to-reproduce bugs.', +ADD PRIMARY KEY c3p5(c3(5), c6(2)); + +--echo # session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +--error ER_BAD_NULL_ERROR +INSERT INTO t1 VALUES(347,33101,NULL,''); +--send +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti',''); + +--echo # session con1 +connection con1; +--error ER_LOCK_WAIT_TIMEOUT +reap; +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; +eval $innodb_metrics_select; + +--echo # session default +connection default; +reap; +SELECT COUNT(*) FROM t1; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SELECT * FROM t1 LIMIT 10; + +--echo # session con1 +connection con1; +ALTER TABLE t1 DISCARD TABLESPACE; +--echo # Disconnect session con1 +disconnect con1; + +--echo # session default +connection default; +SHOW CREATE TABLE t1; +SET DEBUG_SYNC = 'RESET'; +SET DEBUG = ''; +SET GLOBAL innodb_monitor_disable = module_ddl; +DROP TABLE t1; + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc + +SET GLOBAL DEBUG = ''; +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +--disable_warnings +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; +--enable_warnings diff --git a/mysql-test/suite/innodb/t/innodb-wl5980-alter.test b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test new file mode 100644 index 00000000000..2815a6fc6d7 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test @@ -0,0 +1,593 @@ +--echo # +--echo # This is a copy of innodb-alter.test except using remote tablespaces +--echo # and showing those files. +--echo # + +--source include/have_innodb.inc + +--disable_query_log +# These values can change during the test +LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`; +LET $regexp=/FTS_([0-9a-f_]+)([A-Z0-9_]+)\.ibd/FTS_AUX_\2.ibd/; + +# Set up some variables +LET $MYSQL_DATA_DIR = `select @@datadir`; +LET $data_directory_clause = DATA DIRECTORY='$MYSQL_TMP_DIR/alt_dir'; +--enable_query_log + +SET default_storage_engine=InnoDB; +SET GLOBAL innodb_file_per_table=ON; + +SET NAMES utf8; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t1 ( + c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, + INDEX(c2)) +ENGINE=InnoDB $data_directory_clause; + +INSERT INTO t1 SET c1=1; + +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME LIKE 'test/t%'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +CREATE TABLE t1p LIKE t1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3), + CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2), + CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2)) +ENGINE=InnoDB $data_directory_clause; + +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i +WHERE FOR_NAME LIKE 'test/t%'; + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; + +-- source suite/innodb/include/innodb_dict.inc + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1; +ALTER TABLE t1 ALTER c2 DROP DEFAULT; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +# These should be no-op. +ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1; +ALTER TABLE t1 CHANGE c1 c1 INT FIRST; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE C2 c3 INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE c3 C INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; + +-- source suite/innodb/include/innodb_dict.inc + +-- error ER_BAD_FIELD_ERROR +ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT; + +ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t3; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +# The maximum column name length should be 64 characters. +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE c3 +`12345678901234567890123456789012345678901234567890123456789012345` INT; +ALTER TABLE t3 CHANGE c3 +`1234567890123456789012345678901234567890123456789012345678901234` INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t3; + +# Test the length limit with non-ASCII utf-8 characters. +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿偀` INT; + +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾倿ä` INT; + +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾ä` INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# check that the rename is case-insensitive (note the upper-case ä at end) +ALTER TABLE t3 CHANGE +`倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏倐們倒倓倔倕倖倗倘候倚倛倜倝倞借倠倡倢倣値倥倦倧倨倩倪倫倬倭倮倯倰倱倲倳倴倵倶倷倸倹债倻值倽倾Ä` +c3 INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# test with 4-byte UTF-8 (should be disallowed) +--error ER_INVALID_CHARACTER_STRING +ALTER TABLE t3 CHANGE c3 𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌇𐌈𐌉𐌊𐌋𐌌𐌍𐌎𐌏𐌐𐌑𐌒𐌓𐌔𐌕𐌖𐌗𐌘𐌙𐌚𐌛𐌜 INT; + +--error ER_INVALID_CHARACTER_STRING +ALTER TABLE t3 CHANGE c3 😲 INT; + +ALTER TABLE t3 RENAME TO t2; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t2; + +RENAME TABLE t2 TO t1; + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +--error ER_DROP_INDEX_FK +ALTER TABLE t1 DROP INDEX c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1 DROP INDEX c4; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2; + +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +SET foreign_key_checks=0; +DROP TABLE t1p; +SET foreign_key_checks=1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) + ENGINE=InnoDB $data_directory_clause; + +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3; +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX C3; + +SET foreign_key_checks=0; +ALTER TABLE t1c DROP INDEX C3; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +SET foreign_key_checks=1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1c DROP FOREIGN KEY t1C3; + +--echo ### files in MYSQL_DATA_DIR/test +--list_files $MYSQL_DATA_DIR/test +--replace_regex $regexp +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +CREATE TABLE t1o LIKE t1; + +# This will implicitly add a DOC_ID column. +# The LOCK=NONE should thus fail. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=NONE; + +# Retry with LOCK=EXCLUSIVE. +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=SHARED; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# The output should be empty, because index->id was reassigned. +-- source suite/innodb/include/innodb_dict.inc + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE tt; + +# DB_ROW_ID, DB_TRX_ID, DB_ROLL_PTR are reserved InnoDB system column names. +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 db_roll_ptr INT; + +# FTS_DOC_ID is the internal row identifier for full-text search. +# It should be of type BIGINT UNSIGNED NOT NULL. +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=COPY; + +--error ER_INNODB_FT_WRONG_DOCID_COLUMN +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT, +ALGORITHM=INPLACE; +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +CREATE TABLE t1n LIKE t1o; + +ALTER TABLE t1n ADD FULLTEXT INDEX(ct); + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY; +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +ALTER TABLE t1n CHANGE FTS_DOC_ÏD c1 INT, ALGORITHM=INPLACE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT, +ALGORITHM=INPLACE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1n; +ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT, +ALGORITHM=COPY; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1n; + +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; + +ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1n; +ALTER TABLE t1n DROP INDEX c4; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--error ER_DUP_FIELDNAME +ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1n; +DROP TABLE t1n; + +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# This would create a hidden FTS_DOC_ID column, which cannot be done online. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +LOCK=NONE; + +# This should not show duplicates. +SELECT sc.pos FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID'; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1o; + +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +DROP INDEX ct, LOCK=NONE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1o; + +DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign; + +# Check the internal schemata of tt, t1o. + +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME='test/t1o'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o'; + +-- source suite/innodb/include/innodb_dict.inc + +# Ensure that there exists no hidden FTS_DOC_ID_INDEX on foo_id. + +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ADD FULLTEXT INDEX(ct); + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--error ER_INNODB_FT_WRONG_DOCID_INDEX +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; + +DROP TABLE sys_indexes; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +-- source suite/innodb/include/innodb_dict.inc + +--echo # +--echo # Cleanup +--echo # + +DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test +--rmdir $MYSQL_TMP_DIR/alt_dir/test +--rmdir $MYSQL_TMP_DIR/alt_dir + +-- disable_query_log +eval set global innodb_file_per_table=$innodb_file_per_table_orig; +call mtr.add_suppression("deleting orphaned .ibd file"); +-- enable_query_log From f56bd70f51020c67a30415ae381ae93b9087d88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Aug 2017 15:40:37 +0300 Subject: [PATCH 078/101] Adjust the imported MySQL 5.6 tests for MariaDB FIXME: MDEV-13668 InnoDB unnecessarily rebuilds table FIXME: MDEV-13671 InnoDB should use case-insensitive column name comparisons like the rest of the server FIXME: MDEV-13640 / Properly fix MDEV-9469 'Incorrect key file' on ALTER TABLE FIXME: investigate result difference in innodb.innodb-alter-autoinc and ensure that MariaDB does the right thing with auto_increment_increment and auto_increment_offset, for both ALGORITHM=INPLACE and ALGORITHM=COPY (Oracle MySQL behaviour differs between those two). --- .../innodb/r/alter_rename_existing.result | 6 +-- .../innodb/r/innodb-alter-autoinc.result | 6 +-- mysql-test/suite/innodb/r/innodb-alter.result | 27 ++++++------- .../suite/innodb/r/innodb-index-debug.result | 17 ++++---- .../innodb/r/innodb-index-online-fk.result | 40 ++++++------------- .../suite/innodb/r/innodb-index-online.result | 22 +++++----- .../suite/innodb/r/innodb-table-online.result | 17 +++++--- .../suite/innodb/r/innodb-wl5980-alter.result | 16 ++++++-- .../suite/innodb/t/index_tree_operation.opt | 1 + mysql-test/suite/innodb/t/innodb-alter.opt | 3 ++ mysql-test/suite/innodb/t/innodb-alter.test | 25 +++++++++--- ...ebug-master.opt => innodb-index-debug.opt} | 0 .../suite/innodb/t/innodb-index-debug.test | 17 ++++---- .../suite/innodb/t/innodb-index-online-fk.opt | 4 ++ .../innodb/t/innodb-index-online-fk.test | 25 ++++++------ .../innodb/t/innodb-index-online-master.opt | 1 - .../suite/innodb/t/innodb-index-online.opt | 6 +++ .../suite/innodb/t/innodb-index-online.test | 26 +++++++----- .../suite/innodb/t/innodb-table-online.test | 12 +++--- .../suite/innodb/t/innodb-wl5980-alter.opt | 3 ++ .../suite/innodb/t/innodb-wl5980-alter.test | 31 ++++++++++++-- 21 files changed, 182 insertions(+), 123 deletions(-) create mode 100644 mysql-test/suite/innodb/t/index_tree_operation.opt create mode 100644 mysql-test/suite/innodb/t/innodb-alter.opt rename mysql-test/suite/innodb/t/{innodb-index-debug-master.opt => innodb-index-debug.opt} (100%) create mode 100644 mysql-test/suite/innodb/t/innodb-index-online-fk.opt delete mode 100644 mysql-test/suite/innodb/t/innodb-index-online-master.opt create mode 100644 mysql-test/suite/innodb/t/innodb-index-online.opt create mode 100644 mysql-test/suite/innodb/t/innodb-wl5980-alter.opt diff --git a/mysql-test/suite/innodb/r/alter_rename_existing.result b/mysql-test/suite/innodb/r/alter_rename_existing.result index 7eeeef7203d..b0b5083b635 100644 --- a/mysql-test/suite/innodb/r/alter_rename_existing.result +++ b/mysql-test/suite/innodb/r/alter_rename_existing.result @@ -13,7 +13,7 @@ INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); # t1.ibd ALTER TABLE t1 ENGINE = InnoDB; -ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 - Tablespace already exists) +ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists") # # Move the file to InnoDB as t2 # @@ -31,7 +31,7 @@ a b 2 two 3 three ALTER TABLE t2 RENAME TO t1; -ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 - Tablespace already exists) +ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists") # # Create another t1, but in the system tablespace. # @@ -61,7 +61,7 @@ SET GLOBAL innodb_file_per_table=ON; ALTER TABLE t1 ADD COLUMN e1 INT, ALGORITHM=INPLACE; ERROR HY000: Tablespace for table 'test/t1' exists. Please DISCARD the tablespace before IMPORT. ALTER TABLE t1 ADD COLUMN e2 INT, ALGORITHM=COPY; -ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 - Tablespace already exists) +ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists") # # Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd # Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd. diff --git a/mysql-test/suite/innodb/r/innodb-alter-autoinc.result b/mysql-test/suite/innodb/r/innodb-alter-autoinc.result index 8b4909917b3..452a3fbc46f 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-autoinc.result +++ b/mysql-test/suite/innodb/r/innodb-alter-autoinc.result @@ -148,7 +148,7 @@ t1 CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), KEY `id` (`id`,`a`) -) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1 INSERT INTO t1 SET a=123; INSERT INTO t1 VALUES(-123,-45); ALTER TABLE t1 AUTO_INCREMENT = 75; @@ -161,8 +161,8 @@ a id 123 55 347 60 33101 65 -123 70 123 75 +123 80 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -170,5 +170,5 @@ t1 CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), KEY `id` (`id`,`a`) -) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=latin1 DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result index 47fc97206c9..6ffa4c669d7 100644 --- a/mysql-test/suite/innodb/r/innodb-alter.result +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -540,6 +540,9 @@ ERROR 42000: Key column 'c2' doesn't exist in table ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; ERROR 42000: Key column 'c2' doesn't exist in table ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE; SHOW CREATE TABLE t1n; Table Create Table t1n CREATE TABLE `t1n` ( @@ -556,6 +559,9 @@ ALTER TABLE t1n DROP INDEX c4; ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; ERROR 42S21: Duplicate column name 'c1' ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE; SHOW CREATE TABLE t1n; Table Create Table t1n CREATE TABLE `t1n` ( @@ -634,11 +640,10 @@ CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL; ALTER TABLE t1o DROP INDEX ct, DROP INDEX FTS_DOC_ID_INDEX, CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); +call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o"); ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ADD FULLTEXT INDEX(ct); -ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, -ALGORITHM=INPLACE; -ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY. +ERROR HY000: Incorrect key file for table 't1o'; try to repair it DROP TABLE sys_indexes; CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; @@ -646,16 +651,9 @@ SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; NAME POS MTYPE PRTYPE LEN -FTS_DOC_ID 0 6 1800 8 -c2 1 6 1027 4 -ct 2 5 524540 10 -cu 3 5 524540 10 SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; NAME POS NAME -PRIMARY 0 FTS_DOC_ID -FTS_DOC_ID_INDEX 0 FTS_DOC_ID -ct 0 ct SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i INNER JOIN sys_foreign sf ON i.ID = sf.ID; ID FOR_COL_NAME REF_COL_NAME POS @@ -725,21 +723,20 @@ Table Create Table t2 CREATE TABLE `t2` ( `c2` int(11) NOT NULL, KEY `c2` (`c2`), - CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`C1`) + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -ALTER TABLE t1 CHANGE COLUMN C1 c5 INT; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c5` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`c5`) + `C1` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`C1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( `c2` int(11) NOT NULL, KEY `c2` (`c2`), - CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c5`) + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DROP TABLE t2, t1; # diff --git a/mysql-test/suite/innodb/r/innodb-index-debug.result b/mysql-test/suite/innodb/r/innodb-index-debug.result index 4db96a3b092..d78ba68078d 100644 --- a/mysql-test/suite/innodb/r/innodb-index-debug.result +++ b/mysql-test/suite/innodb/r/innodb-index-debug.result @@ -9,10 +9,11 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5); -SET SESSION DEBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs'; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs'; ALTER TABLE t1 ADD UNIQUE INDEX(c2); ERROR HY000: Too many active concurrent transactions -SET SESSION DEBUG=DEFAULT; +SET DEBUG_DBUG = @saved_debug_dbug; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -24,15 +25,15 @@ DROP TABLE t1; CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2)) ENGINE=InnoDB; INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0); -SET DEBUG='+d,ib_row_merge_buf_add_two'; +SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two'; CREATE UNIQUE INDEX ui ON bug13861218(c1); -SET DEBUG='-d,ib_row_merge_buf_add_two'; +SET DEBUG_DBUG = @saved_debug_dbug; DROP TABLE bug13861218; CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB; INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL); -SET DEBUG='+d,ib_row_merge_buf_add_two'; +SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two'; CREATE UNIQUE INDEX ui ON bug13861218(c1); -SET DEBUG='-d,ib_row_merge_buf_add_two'; +SET DEBUG_DBUG = @saved_debug_dbug; DROP TABLE bug13861218; set global innodb_file_per_table=1; set global innodb_file_format=Antelope; @@ -61,8 +62,8 @@ insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480; select count(*) from t1; count(*) 2880 -SET DEBUG = '+d,innobase_tmpfile_creation_failure'; +SET DEBUG_DBUG = '+d,innobase_tmpfile_creation_failure'; alter table t1 force, algorithm=inplace; ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space -SET DEBUG = '-d,innobase_tmpfile_creation_failure'; +SET DEBUG_DBUG = @saved_debug_dbug; drop table t1, t480; diff --git a/mysql-test/suite/innodb/r/innodb-index-online-fk.result b/mysql-test/suite/innodb/r/innodb-index-online-fk.result index c54cf6bebb4..acd0c7ae317 100644 --- a/mysql-test/suite/innodb/r/innodb-index-online-fk.result +++ b/mysql-test/suite/innodb/r/innodb-index-online-fk.result @@ -90,11 +90,12 @@ a1 a2 2 3 10 20 SET foreign_key_checks = 0; -SET DEBUG = '+d,innodb_test_open_ref_fail'; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_test_open_ref_fail'; ALTER TABLE child ADD CONSTRAINT fk_4 FOREIGN KEY (a1, a2) REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; -SET DEBUG = '-d,innodb_test_open_ref_fail'; +SET DEBUG_DBUG = @saved_debug_dbug; SELECT * FROM information_schema.INNODB_SYS_FOREIGN; ID FOR_NAME REF_NAME N_COLS TYPE test/fk_1 test/child test/parent 1 6 @@ -125,9 +126,6 @@ SYS_FOREIGN_COLS SYS_TABLESPACES mysql/innodb_index_stats mysql/innodb_table_stats -mysql/slave_master_info -mysql/slave_relay_log_info -mysql/slave_worker_info test/child test/parent INSERT INTO child VALUES(5,4); @@ -139,12 +137,12 @@ CREATE TABLE `#parent` (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; CREATE INDEX tb ON `#parent`(a, b); CREATE TABLE `#child` (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; CREATE INDEX tb ON `#child`(a1, a2); -SET DEBUG = '+d,innodb_test_no_foreign_idx'; +SET DEBUG_DBUG = '+d,innodb_test_no_foreign_idx'; ALTER TABLE `#child` ADD CONSTRAINT fk_40 FOREIGN KEY (a1, a2) REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_40' in the foreign table '#child' -SET DEBUG = '-d,innodb_test_no_foreign_idx'; +SET DEBUG_DBUG = @saved_debug_dbug; SHOW ERRORS; Level Code Message Error 1821 Failed to add the foreign key constaint. Missing index for constraint 'fk_40' in the foreign table '#child' @@ -166,21 +164,21 @@ test/fk_3 a1 a 0 test/fk_3 a2 b 1 test/fk_4 a1 a 0 test/fk_4 a2 b 1 -SET DEBUG = '+d,innodb_test_no_reference_idx'; +SET DEBUG_DBUG = '+d,innodb_test_no_reference_idx'; ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_42' in the referenced table 'parent' -SET DEBUG = '-d,innodb_test_no_reference_idx'; +SET DEBUG_DBUG = @saved_debug_dbug; SHOW ERRORS; Level Code Message Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_42' in the referenced table 'parent' -SET DEBUG = '+d,innodb_test_wrong_fk_option'; +SET DEBUG_DBUG = '+d,innodb_test_wrong_fk_option'; ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; ERROR HY000: Failed to add the foreign key constraint on table 'child'. Incorrect options in FOREIGN KEY constraint 'test/fk_42' -SET DEBUG = '-d,innodb_test_wrong_fk_option'; +SET DEBUG_DBUG = @saved_debug_dbug; SELECT * FROM information_schema.INNODB_SYS_FOREIGN; ID FOR_NAME REF_NAME N_COLS TYPE test/fk_1 test/child test/parent 1 6 @@ -199,12 +197,12 @@ test/fk_3 a1 a 0 test/fk_3 a2 b 1 test/fk_4 a1 a 0 test/fk_4 a2 b 1 -SET DEBUG = '+d,innodb_test_cannot_add_fk_system'; +SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system'; ALTER TABLE `#child` ADD CONSTRAINT fk_43 FOREIGN KEY (a1, a2) REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; ERROR HY000: Failed to add the foreign key constraint 'test/fk_43' to system tables -SET DEBUG = '-d,innodb_test_cannot_add_fk_system'; +SET DEBUG_DBUG = @saved_debug_dbug; SHOW ERRORS; Level Code Message Error 1823 Failed to add the foreign key constraint 'test/fk_43' to system tables @@ -295,13 +293,13 @@ INSERT INTO parent VALUES(10,20),(20,30); CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; CREATE INDEX tb ON child(a2); SET foreign_key_checks = 0; -SET DEBUG = '+d,innodb_test_cannot_add_fk_system'; +SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system'; ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, ALGORITHM = INPLACE; ERROR HY000: Failed to add the foreign key constraint 'test/fk_1' to system tables -SET DEBUG = '-d,innodb_test_cannot_add_fk_system'; +SET DEBUG_DBUG = @saved_debug_dbug; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; ID FOR_NAME REF_NAME N_COLS TYPE SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; @@ -318,9 +316,6 @@ SYS_FOREIGN_COLS SYS_TABLESPACES mysql/innodb_index_stats mysql/innodb_table_stats -mysql/slave_master_info -mysql/slave_relay_log_info -mysql/slave_worker_info test/child test/parent ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, @@ -345,9 +340,6 @@ SYS_FOREIGN_COLS SYS_TABLESPACES mysql/innodb_index_stats mysql/innodb_table_stats -mysql/slave_master_info -mysql/slave_relay_log_info -mysql/slave_worker_info test/child test/parent SHOW CREATE TABLE child; @@ -383,9 +375,6 @@ SYS_FOREIGN_COLS SYS_TABLESPACES mysql/innodb_index_stats mysql/innodb_table_stats -mysql/slave_master_info -mysql/slave_relay_log_info -mysql/slave_worker_info test/child test/parent SHOW CREATE TABLE child; @@ -421,9 +410,6 @@ SYS_FOREIGN_COLS SYS_TABLESPACES mysql/innodb_index_stats mysql/innodb_table_stats -mysql/slave_master_info -mysql/slave_relay_log_info -mysql/slave_worker_info test/child test/parent SHOW CREATE TABLE child; diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result index 8437959e0ad..77b7bc365aa 100644 --- a/mysql-test/suite/innodb/r/innodb-index-online.result +++ b/mysql-test/suite/innodb/r/innodb-index-online.result @@ -26,14 +26,15 @@ ddl_background_drop_indexes 0 ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 -SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter'; ALTER TABLE t1 ADD UNIQUE INDEX(c2); ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space -SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; -SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +SET DEBUG_DBUG = @saved_debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_inplace_alter'; CREATE UNIQUE INDEX c2 ON t1(c2); ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space -SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +SET DEBUG_DBUG = @saved_debug_dbug; CREATE UNIQUE INDEX c2 ON t1(c2); DROP INDEX c2 ON t1; SHOW CREATE TABLE t1; @@ -121,9 +122,6 @@ database_name table_name index_name last_update stat_name stat_value sample_size test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1 test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index -test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE n_diff_pfx01 3 1 DB_ROW_ID -test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index -test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE size 1 NULL Number of pages in the index KILL QUERY @id; ERROR 70100: Query execution was interrupted SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2d_created WAIT_FOR kill_done'; @@ -184,11 +182,10 @@ t1 CREATE TABLE `t1` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1 SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2e_created WAIT_FOR dml2_done'; SET lock_wait_timeout = 10; -ALTER TABLE t1 CHANGE c2 c22 INT, DROP INDEX c2d, ADD INDEX c2e(c22), +ALTER TABLE t1 DROP INDEX c2d, ADD INDEX c2e(c2), ALGORITHM = INPLACE; INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; -UPDATE t1 SET c2 = c2 + 1; SET DEBUG_SYNC = 'now WAIT_FOR c2e_created'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count @@ -249,7 +246,7 @@ ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done'; -ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; +ALTER TABLE t1 ADD INDEX c2f(c2); SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count @@ -273,7 +270,8 @@ ddl_online_create_index 1 ddl_pending_alter_table 1 SET DEBUG_SYNC = 'now SIGNAL dml3_done'; Warnings: -Note 1831 Duplicate index 'c2f' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Note 1831 Duplicate index `c2f`. This is deprecated and will be disallowed in a future release. +ALTER TABLE t1 CHANGE c2 c22f INT; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 @@ -339,10 +337,8 @@ ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = INPLACE; ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = COPY; ERROR 42000: Duplicate key name 'c2h' SET DEBUG_SYNC = 'RESET'; -SET DEBUG = ''; SET GLOBAL innodb_monitor_disable = module_ddl; DROP TABLE t1; -SET GLOBAL DEBUG = ''; SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; SET GLOBAL innodb_monitor_enable = default; SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb-table-online.result b/mysql-test/suite/innodb/r/innodb-table-online.result index ee51c3b8239..5440df0bb9c 100644 --- a/mysql-test/suite/innodb/r/innodb-table-online.result +++ b/mysql-test/suite/innodb/r/innodb-table-online.result @@ -31,14 +31,21 @@ ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 # session con1 -SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter'; ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space -SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; +SET SESSION DEBUG = @saved_debug_dbug; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space -SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +SET SESSION DEBUG = @saved_debug_dbug; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; # session default SHOW CREATE TABLE t1; @@ -68,7 +75,7 @@ LOCK = SHARED, ALGORITHM = INPLACE; ALTER TABLE t1 ADD UNIQUE INDEX(c2), LOCK = EXCLUSIVE, ALGORITHM = INPLACE; Warnings: -Note 1831 Duplicate index 'c2_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Note 1831 Duplicate index `c2_2`. This is deprecated and will be disallowed in a future release. SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -359,10 +366,8 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`,`c22f`,`c4`(5)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT SET DEBUG_SYNC = 'RESET'; -SET DEBUG = ''; SET GLOBAL innodb_monitor_disable = module_ddl; DROP TABLE t1; -SET GLOBAL DEBUG = ''; SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; SET GLOBAL innodb_monitor_enable = default; SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb-wl5980-alter.result b/mysql-test/suite/innodb/r/innodb-wl5980-alter.result index 59d0921e31f..11e4e926b43 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5980-alter.result +++ b/mysql-test/suite/innodb/r/innodb-wl5980-alter.result @@ -1010,6 +1010,9 @@ ERROR 42000: Key column 'c2' doesn't exist in table ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; ERROR 42000: Key column 'c2' doesn't exist in table ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE; ### files in MYSQL_DATA_DIR/test FTS_AUX_INDEX_1.ibd FTS_AUX_INDEX_2.ibd @@ -1110,6 +1113,9 @@ tt.ibd ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; ERROR 42S21: Duplicate column name 'c1' ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE; ### files in MYSQL_DATA_DIR/test FTS_AUX_INDEX_1.ibd FTS_AUX_INDEX_2.ibd @@ -1195,9 +1201,13 @@ tt.isl t1c.ibd t1p.ibd tt.ibd +call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o"); ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ERROR HY000: Incorrect key file for table 't1o'; try to repair it +ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; ### files in MYSQL_DATA_DIR/test FTS_AUX_INDEX_1.ibd FTS_AUX_INDEX_2.ibd @@ -1239,9 +1249,6 @@ tt.isl t1c.ibd t1p.ibd tt.ibd -ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, -LOCK=NONE; -ERROR 0A000: LOCK=NONE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try LOCK=SHARED. SELECT sc.pos FROM information_schema.innodb_sys_columns sc INNER JOIN information_schema.innodb_sys_tables st ON sc.TABLE_ID=st.TABLE_ID @@ -1345,6 +1352,9 @@ tt.isl tt.ibd ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ADD FULLTEXT INDEX(ct); +ERROR HY000: Incorrect key file for table 't1o'; try to repair it +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; ### files in MYSQL_DATA_DIR/test FTS_AUX_INDEX_1.ibd FTS_AUX_INDEX_2.ibd diff --git a/mysql-test/suite/innodb/t/index_tree_operation.opt b/mysql-test/suite/innodb/t/index_tree_operation.opt new file mode 100644 index 00000000000..66bceccc683 --- /dev/null +++ b/mysql-test/suite/innodb/t/index_tree_operation.opt @@ -0,0 +1 @@ +--innodb-sys-tablespaces diff --git a/mysql-test/suite/innodb/t/innodb-alter.opt b/mysql-test/suite/innodb/t/innodb-alter.opt new file mode 100644 index 00000000000..aa400236153 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter.opt @@ -0,0 +1,3 @@ +--loose-innodb-sys-indexes +--loose-innodb-sys-columns +--loose-innodb-sys-fields diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test index ca1252fb4e4..67f637a1814 100644 --- a/mysql-test/suite/innodb/t/innodb-alter.test +++ b/mysql-test/suite/innodb/t/innodb-alter.test @@ -298,12 +298,21 @@ SHOW CREATE TABLE t1n; ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; --error ER_KEY_COLUMN_DOES_NOT_EXITS ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; +# FIXME: MDEV-13668 InnoDB unnecessarily rebuilds table +# when renaming a column and adding index +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE; SHOW CREATE TABLE t1n; ALTER TABLE t1n DROP INDEX c4; --error ER_DUP_FIELDNAME ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +# FIXME: MDEV-13668 +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE; SHOW CREATE TABLE t1n; DROP TABLE t1n; @@ -361,12 +370,16 @@ CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); +# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE +call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o"); +--error ER_NOT_KEYFILE ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ADD FULLTEXT INDEX(ct); - ---error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON -ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, -ALGORITHM=INPLACE; +# FIXME: MDEV-9469 (enable this) +#--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +#ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +#ALGORITHM=INPLACE; +#end of MDEV-9469 FIXME DROP TABLE sys_indexes; CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i @@ -421,7 +434,9 @@ SHOW CREATE TABLE t2; ALTER TABLE t1 CHANGE COLUMN c1 C1 INT; SHOW CREATE TABLE t1; SHOW CREATE TABLE t2; -ALTER TABLE t1 CHANGE COLUMN C1 c5 INT; +# FIXME: MDEV-13671 InnoDB should use case-insensitive column name comparisons +# like the rest of the server +#ALTER TABLE t1 CHANGE COLUMN C1 c5 INT; SHOW CREATE TABLE t1; SHOW CREATE TABLE t2; DROP TABLE t2, t1; diff --git a/mysql-test/suite/innodb/t/innodb-index-debug-master.opt b/mysql-test/suite/innodb/t/innodb-index-debug.opt similarity index 100% rename from mysql-test/suite/innodb/t/innodb-index-debug-master.opt rename to mysql-test/suite/innodb/t/innodb-index-debug.opt diff --git a/mysql-test/suite/innodb/t/innodb-index-debug.test b/mysql-test/suite/innodb/t/innodb-index-debug.test index 8969dc69aa4..d4fcda4f160 100644 --- a/mysql-test/suite/innodb/t/innodb-index-debug.test +++ b/mysql-test/suite/innodb/t/innodb-index-debug.test @@ -15,10 +15,11 @@ CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB; SHOW CREATE TABLE t1; INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5); -SET SESSION DEBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs'; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs'; --error ER_TOO_MANY_CONCURRENT_TRXS ALTER TABLE t1 ADD UNIQUE INDEX(c2); -SET SESSION DEBUG=DEFAULT; +SET DEBUG_DBUG = @saved_debug_dbug; SHOW CREATE TABLE t1; DROP TABLE t1; @@ -29,20 +30,20 @@ DROP TABLE t1; CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2)) ENGINE=InnoDB; INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0); -SET DEBUG='+d,ib_row_merge_buf_add_two'; +SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two'; # Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2). # No crash here, because n_uniq for c2 includes the clustered index fields CREATE UNIQUE INDEX ui ON bug13861218(c1); -SET DEBUG='-d,ib_row_merge_buf_add_two'; +SET DEBUG_DBUG = @saved_debug_dbug; DROP TABLE bug13861218; CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB; INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL); -SET DEBUG='+d,ib_row_merge_buf_add_two'; +SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two'; # Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2). # assertion failure: ut_ad(cmp_dtuple_rec(dtuple, rec, rec_offsets) > 0) CREATE UNIQUE INDEX ui ON bug13861218(c1); -SET DEBUG='-d,ib_row_merge_buf_add_two'; +SET DEBUG_DBUG = @saved_debug_dbug; DROP TABLE bug13861218; eval set global innodb_file_per_table=$per_table; @@ -76,8 +77,8 @@ insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480; insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480; select count(*) from t1; -SET DEBUG = '+d,innobase_tmpfile_creation_failure'; +SET DEBUG_DBUG = '+d,innobase_tmpfile_creation_failure'; --error ER_OUT_OF_RESOURCES alter table t1 force, algorithm=inplace; -SET DEBUG = '-d,innobase_tmpfile_creation_failure'; +SET DEBUG_DBUG = @saved_debug_dbug; drop table t1, t480; diff --git a/mysql-test/suite/innodb/t/innodb-index-online-fk.opt b/mysql-test/suite/innodb/t/innodb-index-online-fk.opt new file mode 100644 index 00000000000..345d5529dce --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online-fk.opt @@ -0,0 +1,4 @@ +--loose-innodb-sys-tables +--loose-innodb-sys-columns +--loose-innodb-sys-foreign +--loose-innodb-sys-foreign-cols diff --git a/mysql-test/suite/innodb/t/innodb-index-online-fk.test b/mysql-test/suite/innodb/t/innodb-index-online-fk.test index bb8c4a323e7..4480b88f0bf 100644 --- a/mysql-test/suite/innodb/t/innodb-index-online-fk.test +++ b/mysql-test/suite/innodb/t/innodb-index-online-fk.test @@ -92,11 +92,12 @@ SET foreign_key_checks = 0; # This is to test the scenario we cannot open the referenced table. # Since foreign_key_checks is set to 0, the foreign key should still # be added. -SET DEBUG = '+d,innodb_test_open_ref_fail'; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_test_open_ref_fail'; ALTER TABLE child ADD CONSTRAINT fk_4 FOREIGN KEY (a1, a2) REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; -SET DEBUG = '-d,innodb_test_open_ref_fail'; +SET DEBUG_DBUG = @saved_debug_dbug; SELECT * FROM information_schema.INNODB_SYS_FOREIGN; @@ -127,12 +128,12 @@ CREATE TABLE `#child` (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; CREATE INDEX tb ON `#child`(a1, a2); # This is to test the scenario no foreign index, alter table should fail -SET DEBUG = '+d,innodb_test_no_foreign_idx'; +SET DEBUG_DBUG = '+d,innodb_test_no_foreign_idx'; --error ER_FK_NO_INDEX_CHILD, ALTER TABLE `#child` ADD CONSTRAINT fk_40 FOREIGN KEY (a1, a2) REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; -SET DEBUG = '-d,innodb_test_no_foreign_idx'; +SET DEBUG_DBUG = @saved_debug_dbug; SHOW ERRORS; @@ -142,23 +143,23 @@ SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; # This is to test the scenario no index on referenced table, # alter table should fail -SET DEBUG = '+d,innodb_test_no_reference_idx'; +SET DEBUG_DBUG = '+d,innodb_test_no_reference_idx'; --error ER_FK_NO_INDEX_PARENT, ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; -SET DEBUG = '-d,innodb_test_no_reference_idx'; +SET DEBUG_DBUG = @saved_debug_dbug; SHOW ERRORS; # This is to test the scenario no index on referenced table, # alter table should fail -SET DEBUG = '+d,innodb_test_wrong_fk_option'; +SET DEBUG_DBUG = '+d,innodb_test_wrong_fk_option'; --error ER_FK_INCORRECT_OPTION ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; -SET DEBUG = '-d,innodb_test_wrong_fk_option'; +SET DEBUG_DBUG = @saved_debug_dbug; SELECT * FROM information_schema.INNODB_SYS_FOREIGN; @@ -166,12 +167,12 @@ SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; # This is to test the scenario cannot add fk to the system table, # alter table should fail -SET DEBUG = '+d,innodb_test_cannot_add_fk_system'; +SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system'; --error ER_FK_FAIL_ADD_SYSTEM ALTER TABLE `#child` ADD CONSTRAINT fk_43 FOREIGN KEY (a1, a2) REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ALGORITHM = INPLACE; -SET DEBUG = '-d,innodb_test_cannot_add_fk_system'; +SET DEBUG_DBUG = @saved_debug_dbug; SHOW ERRORS; @@ -275,13 +276,13 @@ SET foreign_key_checks = 0; # Let's rebuild the table and add the FK, make the add FK failed. -SET DEBUG = '+d,innodb_test_cannot_add_fk_system'; +SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system'; --error ER_FK_FAIL_ADD_SYSTEM ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, ALGORITHM = INPLACE; -SET DEBUG = '-d,innodb_test_cannot_add_fk_system'; +SET DEBUG_DBUG = @saved_debug_dbug; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; diff --git a/mysql-test/suite/innodb/t/innodb-index-online-master.opt b/mysql-test/suite/innodb/t/innodb-index-online-master.opt deleted file mode 100644 index 9ac01ffb5ad..00000000000 --- a/mysql-test/suite/innodb/t/innodb-index-online-master.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=64k --innodb-buffer-pool-size=5M --innodb-log-buffer-size=256k diff --git a/mysql-test/suite/innodb/t/innodb-index-online.opt b/mysql-test/suite/innodb/t/innodb-index-online.opt new file mode 100644 index 00000000000..3f3c063b38f --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online.opt @@ -0,0 +1,6 @@ +--innodb-sort-buffer-size=64k +--innodb-online-alter-log-max-size=64k +--innodb-buffer-pool-size=5M +--innodb-log-buffer-size=256k +--innodb-sys-indexes +--innodb-sys-fields diff --git a/mysql-test/suite/innodb/t/innodb-index-online.test b/mysql-test/suite/innodb/t/innodb-index-online.test index c314607e617..24e3cd1ba22 100644 --- a/mysql-test/suite/innodb/t/innodb-index-online.test +++ b/mysql-test/suite/innodb/t/innodb-index-online.test @@ -1,4 +1,4 @@ ---source include/have_innodb.inc +--source include/innodb_page_size_small.inc --source include/have_debug_sync.inc let $innodb_metrics_select= @@ -42,14 +42,15 @@ reap; eval $innodb_metrics_select; connection con1; -SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter'; --error ER_OUT_OF_RESOURCES ALTER TABLE t1 ADD UNIQUE INDEX(c2); -SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; -SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +SET DEBUG_DBUG = @saved_debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_inplace_alter'; --error ER_OUT_OF_RESOURCES CREATE UNIQUE INDEX c2 ON t1(c2); -SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +SET DEBUG_DBUG = @saved_debug_dbug; CREATE UNIQUE INDEX c2 ON t1(c2); DROP INDEX c2 ON t1; @@ -206,7 +207,9 @@ SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2e_created WAIT_FOR dml2_done'; # Ensure that the ALTER TABLE will be executed even with some concurrent DML. SET lock_wait_timeout = 10; --send -ALTER TABLE t1 CHANGE c2 c22 INT, DROP INDEX c2d, ADD INDEX c2e(c22), +# FIXME: MDEV-13668 +#ALTER TABLE t1 CHANGE c2 c22 INT, DROP INDEX c2d, ADD INDEX c2e(c22), +ALTER TABLE t1 DROP INDEX c2d, ADD INDEX c2e(c2), ALGORITHM = INPLACE; # Generate some log (delete-mark, delete-unmark, insert etc.) @@ -215,7 +218,7 @@ ALGORITHM = INPLACE; connection default; INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; -UPDATE t1 SET c2 = c2 + 1; +#UPDATE t1 SET c2 = c2 + 1; SET DEBUG_SYNC = 'now WAIT_FOR c2e_created'; # At this point, the clustered index scan must have completed, # but the modification log keeps accumulating due to the DEBUG_SYNC. @@ -271,7 +274,9 @@ connection con1; # Accumulate and apply some modification log. SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done'; --send -ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; +# FIXME: MDEV-13668 +#ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; +ALTER TABLE t1 ADD INDEX c2f(c2); connection default; SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; @@ -291,6 +296,9 @@ SET DEBUG_SYNC = 'now SIGNAL dml3_done'; connection con1; reap; +# FIXME: MDEV-13668 +ALTER TABLE t1 CHANGE c2 c22f INT; + eval $innodb_metrics_select; SELECT COUNT(c22f) FROM t1; CHECK TABLE t1; @@ -386,7 +394,6 @@ ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = INPLACE; ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = COPY; SET DEBUG_SYNC = 'RESET'; -SET DEBUG = ''; SET GLOBAL innodb_monitor_disable = module_ddl; DROP TABLE t1; @@ -395,7 +402,6 @@ DROP TABLE t1; # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc -SET GLOBAL DEBUG = ''; SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; --disable_warnings SET GLOBAL innodb_monitor_enable = default; diff --git a/mysql-test/suite/innodb/t/innodb-table-online.test b/mysql-test/suite/innodb/t/innodb-table-online.test index f8bce701803..4dce8e4d65f 100644 --- a/mysql-test/suite/innodb/t/innodb-table-online.test +++ b/mysql-test/suite/innodb/t/innodb-table-online.test @@ -1,4 +1,5 @@ ---source include/have_innodb.inc +--source include/innodb_page_size.inc +--source include/have_debug.inc --source include/have_debug_sync.inc let $innodb_metrics_select= @@ -48,14 +49,15 @@ eval $innodb_metrics_select; --echo # session con1 connection con1; -SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter'; --error ER_OUT_OF_RESOURCES ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; -SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; +SET SESSION DEBUG = @saved_debug_dbug; SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; --error ER_OUT_OF_RESOURCES ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; -SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +SET SESSION DEBUG = @saved_debug_dbug; ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; --echo # session default @@ -363,7 +365,6 @@ disconnect con1; connection default; SHOW CREATE TABLE t1; SET DEBUG_SYNC = 'RESET'; -SET DEBUG = ''; SET GLOBAL innodb_monitor_disable = module_ddl; DROP TABLE t1; @@ -371,7 +372,6 @@ DROP TABLE t1; # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc -SET GLOBAL DEBUG = ''; SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; --disable_warnings SET GLOBAL innodb_monitor_enable = default; diff --git a/mysql-test/suite/innodb/t/innodb-wl5980-alter.opt b/mysql-test/suite/innodb/t/innodb-wl5980-alter.opt new file mode 100644 index 00000000000..aa400236153 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5980-alter.opt @@ -0,0 +1,3 @@ +--loose-innodb-sys-indexes +--loose-innodb-sys-columns +--loose-innodb-sys-fields diff --git a/mysql-test/suite/innodb/t/innodb-wl5980-alter.test b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test index 2815a6fc6d7..a3ae83753e0 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5980-alter.test +++ b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test @@ -447,7 +447,12 @@ ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; --error ER_KEY_COLUMN_DOES_NOT_EXITS ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; +# FIXME: MDEV-13668 InnoDB unnecessarily rebuilds table +# when renaming a column and adding index +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE; --echo ### files in MYSQL_DATA_DIR/test --replace_regex $regexp @@ -469,7 +474,11 @@ ALTER TABLE t1n DROP INDEX c4; --error ER_DUP_FIELDNAME ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +# FIXME: MDEV-13668 +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE; --echo ### files in MYSQL_DATA_DIR/test --replace_regex $regexp @@ -491,10 +500,17 @@ ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL; --replace_regex $regexp --list_files $MYSQL_TMP_DIR/alt_dir/test +# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE +call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o"); +--error ER_NOT_KEYFILE ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; +# end of MDEV-9469 FIXME + --echo ### files in MYSQL_DATA_DIR/test --replace_regex $regexp --list_files $MYSQL_DATA_DIR/test @@ -503,9 +519,11 @@ ALGORITHM=INPLACE; --list_files $MYSQL_TMP_DIR/alt_dir/test # This would create a hidden FTS_DOC_ID column, which cannot be done online. ---error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON -ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, -LOCK=NONE; +# FIXME: MDEV-9469 (enable this) +#--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +#ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +#LOCK=NONE; +#end of MDEV-9469 FIXME # This should not show duplicates. SELECT sc.pos FROM information_schema.innodb_sys_columns sc @@ -516,6 +534,7 @@ WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID'; --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR SHOW CREATE TABLE t1o; +# FIXME: MDEV-13668 ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, DROP INDEX ct, LOCK=NONE; @@ -553,9 +572,15 @@ ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); --replace_regex $regexp --list_files $MYSQL_TMP_DIR/alt_dir/test +# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE +--error ER_NOT_KEYFILE ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ADD FULLTEXT INDEX(ct); +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; +#end of MDEV-9469 FIXME + --echo ### files in MYSQL_DATA_DIR/test --replace_regex $regexp --list_files $MYSQL_DATA_DIR/test From 9e9a3b8ede2a398131b6fd35012af5153289d32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Aug 2017 13:15:35 +0300 Subject: [PATCH 079/101] Merge innodb.create-index test changes from MySQL 5.6 to MariaDB Import the MySQL 5.6 addition from innodb.create-index to a new debug-only test, innodb.create-index-debug. The existing test innodb.create-index also runs on a debug server. --- .../suite/innodb/r/create-index-debug.result | 26 ++++++++++++++ .../suite/innodb/t/create-index-debug.test | 34 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 mysql-test/suite/innodb/r/create-index-debug.result create mode 100644 mysql-test/suite/innodb/t/create-index-debug.test diff --git a/mysql-test/suite/innodb/r/create-index-debug.result b/mysql-test/suite/innodb/r/create-index-debug.result new file mode 100644 index 00000000000..99f6efe9bfe --- /dev/null +++ b/mysql-test/suite/innodb/r/create-index-debug.result @@ -0,0 +1,26 @@ +SET @saved_debug_dbug = @@SESSION.debug_dbug; +# +#BUG#21326304 INNODB ONLINE ALTER TABLE ENDS IN CRASH ON DISK FULL +# +CREATE TABLE t1(f1 CHAR(255) NOT NULL, f2 CHAR(255) NOT NULL, f3 +CHAR(255) NOT NULL, f4 CHAR(255) NOT NULL, f5 CHAR(255) NOT NULL,f6 +CHAR(255) NOT NULL, f7 CHAR(255) NOT NULL, f8 CHAR(255) NOT NULL,f9 +CHAR(255) NOT NULL, f10 CHAR(255) NOT NULL, f11 CHAR(255) NOT NULL,f12 +CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15 +CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18 +CHAR(255) NOT NULL) +ENGINE=INNODB ROW_FORMAT=DYNAMIC; +Warnings: +Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. +Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. +INSERT INTO t1 +VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET debug_dbug = '+d,disk_is_full'; +ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; +ERROR HY000: The table 't1' is full +SET debug_dbug= @saved_debug_dbug; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/create-index-debug.test b/mysql-test/suite/innodb/t/create-index-debug.test new file mode 100644 index 00000000000..9ea416fbe1e --- /dev/null +++ b/mysql-test/suite/innodb/t/create-index-debug.test @@ -0,0 +1,34 @@ +--source include/have_innodb.inc +--source include/have_innodb_16k.inc +--source include/have_debug.inc + +SET @saved_debug_dbug = @@SESSION.debug_dbug; + +--echo # +--echo #BUG#21326304 INNODB ONLINE ALTER TABLE ENDS IN CRASH ON DISK FULL +--echo # +CREATE TABLE t1(f1 CHAR(255) NOT NULL, f2 CHAR(255) NOT NULL, f3 +CHAR(255) NOT NULL, f4 CHAR(255) NOT NULL, f5 CHAR(255) NOT NULL,f6 +CHAR(255) NOT NULL, f7 CHAR(255) NOT NULL, f8 CHAR(255) NOT NULL,f9 +CHAR(255) NOT NULL, f10 CHAR(255) NOT NULL, f11 CHAR(255) NOT NULL,f12 +CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15 +CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18 +CHAR(255) NOT NULL) +ENGINE=INNODB ROW_FORMAT=DYNAMIC; + +INSERT INTO t1 +VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r'); + +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; + +SET debug_dbug = '+d,disk_is_full'; + +--error ER_RECORD_FILE_FULL +ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; + +SET debug_dbug= @saved_debug_dbug; + +DROP TABLE t1; From acaac7c233ef608bed28ab57e6631303fd6568ff Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 22 Aug 2017 15:56:53 +1000 Subject: [PATCH 080/101] submodules.cmake: git returns 128 if not in a repository It is possible that a .git directory isn't definitive on the existance of a working git tree. A git worktree over sshfs for instance will fail to build unless the main repository also exists in the same directory. Adding this extra test will make the detection that little more ruggardised for these odd build environments. Signed-off-by: Daniel Black --- cmake/submodules.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/submodules.cmake b/cmake/submodules.cmake index 61eacba7c73..86e3d41eb77 100644 --- a/cmake/submodules.cmake +++ b/cmake/submodules.cmake @@ -2,8 +2,9 @@ IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git") EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" config --get cmake.update-submodules WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - OUTPUT_VARIABLE cmake_update_submodules) - IF(cmake_update_submodules MATCHES no) + OUTPUT_VARIABLE cmake_update_submodules + RESULT_VARIABLE git_config_get_result) + IF(git_config_get_result EQUAL 128 OR cmake_update_submodules MATCHES no) SET(update_result 0) ELSEIF (cmake_update_submodules MATCHES force) MESSAGE("-- Updating submodules (forced)") From e634fdcd5b5ae8e8db38aa71307c59be295abc1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Aug 2017 21:58:02 +0300 Subject: [PATCH 081/101] WL#8845: Clarify the message about redo log format incompatibility recv_find_max_checkpoint(): Refer to MariaDB 10.2.2 instead of MySQL 5.7.9. Do not hint that a binary downgrade might be possible, because there are many changes in InnoDB 5.7 that could make downgrade impossible: a column appended to SYS_INDEXES, added SYS_* tables, undo log format changes, and so on. --- storage/innobase/log/log0recv.cc | 6 ++---- storage/xtradb/log/log0recv.cc | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index d128ccd26c5..5180f8b19c0 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -818,10 +818,8 @@ not_consistent: fprintf(stderr, "InnoDB: No valid checkpoint found.\n" - "InnoDB: If you are attempting downgrade" - " from MySQL 5.7.9 or later,\n" - "InnoDB: please refer to " REFMAN - "upgrading-downgrading.html\n" + "InnoDB: A downgrade from MariaDB 10.2.2" + " or later is not supported.\n" "InnoDB: If this error appears when you are" " creating an InnoDB database,\n" "InnoDB: the problem may be that during" diff --git a/storage/xtradb/log/log0recv.cc b/storage/xtradb/log/log0recv.cc index 6f76d151af3..0872d231612 100644 --- a/storage/xtradb/log/log0recv.cc +++ b/storage/xtradb/log/log0recv.cc @@ -845,10 +845,8 @@ not_consistent: fprintf(stderr, "InnoDB: No valid checkpoint found.\n" - "InnoDB: If you are attempting downgrade" - " from MySQL 5.7.9 or later,\n" - "InnoDB: please refer to " REFMAN - "upgrading-downgrading.html\n" + "InnoDB: A downgrade from MariaDB 10.2.2" + " or later is not supported.\n" "InnoDB: If this error appears when you are" " creating an InnoDB database,\n" "InnoDB: the problem may be that during" From eb389d5c390969b17d433d7a8710d87aa8b55a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 30 Aug 2017 09:32:03 +0300 Subject: [PATCH 082/101] Add missing {} to silence a compiler warning This is not affecting correctness; delete NULL is a valid operation. --- storage/spider/spd_db_conn.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 495420dad32..2406b66a84a 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -4130,8 +4130,10 @@ void spider_db_discard_multiple_result( if (!conn->db_conn->cmp_request_key_to_snd(&request_key)) break; if ((result = conn->db_conn->use_result(&request_key, &error_num))) + { result->free_result(); delete result; + } } while (!conn->db_conn->next_result()); DBUG_VOID_RETURN; } From d20fa485992067d0dd8d43ea5e3df02a1777eefb Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 30 Aug 2017 11:45:24 +0300 Subject: [PATCH 083/101] MDEV-13669: Some MyRocks test take a long time Make rocksdb.cardinality test faster (77 -> 42 sec with --mem) by loading records in batches. (loading everything as one bulk load batch will remove the purpose of the test) --- .../mysql-test/rocksdb/r/cardinality.result | 2 +- .../mysql-test/rocksdb/t/cardinality.test | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result b/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result index 840ad9a723c..3bd87e9ffd6 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result @@ -1,4 +1,4 @@ -DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t1,t10,t11; create table t1( id bigint not null primary key, i1 bigint, #unique diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test b/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test index 0bc0ae4e900..689753faf8d 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test @@ -3,7 +3,7 @@ --source include/restart_mysqld.inc --disable_warnings -DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t1,t10,t11; --enable_warnings create table t1( @@ -18,13 +18,26 @@ create table t1( index t1_4(c1, c2), index t1_5(c2, c1) ) engine=rocksdb; + --disable_query_log +create table t10(a int primary key); +insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t11(a int primary key); +insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C; + +set @a=0; let $i=0; -while ($i<100000) +set rocksdb_bulk_load=1; +while ($i<100) { inc $i; - eval insert t1(id, i1, i2, c1, c2) values($i, $i, $i div 10, $i, $i div 10); + eval insert into t1 select (@a:=@a+1), @a, @a div 10, @a, @a div 10 from t11; } +set rocksdb_bulk_load=0; + +drop table t10; +drop table t11; --enable_query_log # Flush memtable out to SST and display index cardinalities From 4c91fd4cd62e3cfa8949d4f6265c79943390b2d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 30 Aug 2017 12:29:17 +0300 Subject: [PATCH 084/101] Galera after-merge fixes wsrep_drop_table_query(): Remove the definition of this ununsed function. row_upd_sec_index_entry(), row_upd_clust_rec_by_insert(): Evaluate the simplest conditions first. The merge could have slightly hurt performance by causing extra calls to wsrep_on(). --- sql/wsrep_mysqld.cc | 58 --------------------------------- storage/innobase/row/row0upd.cc | 6 ++-- storage/xtradb/row/row0upd.cc | 6 ++-- 3 files changed, 6 insertions(+), 64 deletions(-) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 67b64301ff9..33689a91661 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1362,64 +1362,6 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len) static int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len); static int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len); -/* - Rewrite DROP TABLE for TOI. Temporary tables are eliminated from - the query as they are visible only to client connection. - - TODO: See comments for sql_base.cc:drop_temporary_table() and refine - the function to deal with transactional locked tables. - */ -static int wsrep_drop_table_query(THD* thd, uchar** buf, size_t* buf_len) -{ - - LEX* lex= thd->lex; - SELECT_LEX* select_lex= &lex->select_lex; - TABLE_LIST* first_table= select_lex->table_list.first; - String buff; - - bool found_temp_table= false; - for (TABLE_LIST* table= first_table; table; table= table->next_global) - { - if (find_temporary_table(thd, table->db, table->table_name)) - { - found_temp_table= true; - break; - } - } - - if (found_temp_table) - { - buff.append("DROP TABLE "); - if (lex->check_exists) - buff.append("IF EXISTS "); - - for (TABLE_LIST* table= first_table; table; table= table->next_global) - { - if (!find_temporary_table(thd, table->db, table->table_name)) - { - append_identifier(thd, &buff, table->db, strlen(table->db)); - buff.append("."); - append_identifier(thd, &buff, table->table_name, - strlen(table->table_name)); - buff.append(","); - } - } - - /* Chop the last comma */ - buff.chop(); - buff.append(" /* generated by wsrep */"); - - WSREP_DEBUG("Rewrote '%s' as '%s'", thd->query(), buff.ptr()); - - return wsrep_to_buf_helper(thd, buff.ptr(), buff.length(), buf, buf_len); - } - else - { - return wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), - buf, buf_len); - } -} - /* Decide if statement should run in TOI. diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index d8d7002aad7..85a4b0bdf19 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1982,9 +1982,9 @@ row_upd_sec_index_entry( index, offsets, thr, &mtr); } #ifdef WITH_WSREP - if (wsrep_on(trx->mysql_thd) && + if (err == DB_SUCCESS && !referenced && + wsrep_on(trx->mysql_thd) && !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && - err == DB_SUCCESS && !referenced && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && @@ -2270,7 +2270,7 @@ err_exit: } } #ifdef WITH_WSREP - if (wsrep_on(trx->mysql_thd) && !referenced && + if (!referenced && wsrep_on(trx->mysql_thd) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && foreign diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc index 2679e9a1c8a..91dbc5252bc 100644 --- a/storage/xtradb/row/row0upd.cc +++ b/storage/xtradb/row/row0upd.cc @@ -1988,9 +1988,9 @@ row_upd_sec_index_entry( index, offsets, thr, &mtr); } #ifdef WITH_WSREP - if (wsrep_on(trx->mysql_thd) && + if (err == DB_SUCCESS && !referenced && + wsrep_on(trx->mysql_thd) && !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && - err == DB_SUCCESS && !referenced && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && @@ -2279,7 +2279,7 @@ err_exit: } } #ifdef WITH_WSREP - if (wsrep_on(trx->mysql_thd) && !referenced && + if (!referenced && wsrep_on(trx->mysql_thd) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && foreign From 1831042279ca90f66ceac61db5cc4758cf353d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 30 Aug 2017 16:55:45 +0300 Subject: [PATCH 085/101] Temporarily disable encryption.innodb_encryption after the merge --- mysql-test/suite/encryption/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/encryption/disabled.def b/mysql-test/suite/encryption/disabled.def index d92d3495cb8..49f7f94729d 100644 --- a/mysql-test/suite/encryption/disabled.def +++ b/mysql-test/suite/encryption/disabled.def @@ -12,3 +12,4 @@ innodb_scrub : MDEV-8139 scrubbing does not work reliably innodb_scrub_background : MDEV-8139 scrubbing does not work reliably +innodb_encryption : an adjustment for MDEV-13583 is needed From 91826970c5e5335b9446c4aec8c1369ab97e45a9 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 30 Aug 2017 14:37:16 +0000 Subject: [PATCH 086/101] Fix threadpool to report connections aborted due to wait timeout. Update wait_timeout.test to add test case for this. --- mysql-test/r/wait_timeout.result | 6 ++++++ mysql-test/r/wait_timeout_not_windows.result | 6 ------ mysql-test/t/wait_timeout.test | 16 ++++++++++++-- mysql-test/t/wait_timeout_not_windows.test | 15 ------------- sql/signal_handler.cc | 4 ++++ sql/sql_class.cc | 3 +++ sql/sql_class.h | 5 +++++ sql/threadpool_common.cc | 22 +++++++++++++++++++- 8 files changed, 53 insertions(+), 24 deletions(-) delete mode 100644 mysql-test/r/wait_timeout_not_windows.result delete mode 100644 mysql-test/t/wait_timeout_not_windows.test diff --git a/mysql-test/r/wait_timeout.result b/mysql-test/r/wait_timeout.result index aa145ecf39b..8e5e5147f8b 100644 --- a/mysql-test/r/wait_timeout.result +++ b/mysql-test/r/wait_timeout.result @@ -35,3 +35,9 @@ SELECT 3; SET @@global.wait_timeout= ; disconnect con1; connect default,localhost,root,,test,,; +set global log_warnings=2; +connect foo,localhost,root; +set @@wait_timeout=1; +connection default; +FOUND 1 /Aborted.*Got timeout reading communication packets/ in mysqld.1.err +set global log_warnings=@@log_warnings; diff --git a/mysql-test/r/wait_timeout_not_windows.result b/mysql-test/r/wait_timeout_not_windows.result deleted file mode 100644 index f31dec1b4ba..00000000000 --- a/mysql-test/r/wait_timeout_not_windows.result +++ /dev/null @@ -1,6 +0,0 @@ -set global log_warnings=2; -connect foo,localhost,root; -set @@wait_timeout=1; -connection default; -FOUND 1 /Aborted.*Got timeout reading communication packets/ in mysqld.1.err -set global log_warnings=@@log_warnings; diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test index 4ece5fd1749..84841aabb8b 100644 --- a/mysql-test/t/wait_timeout.test +++ b/mysql-test/t/wait_timeout.test @@ -122,10 +122,22 @@ SELECT 3; eval SET @@global.wait_timeout= $start_value; disconnect con1; - -# The last connect is to keep tools checking the current test happy. connect (default,localhost,root,,test,,); +# +# MDEV-7775 Wrong error message (Unknown error) when idle sessions are killed after wait_timeout +# +set global log_warnings=2; +connect (foo,localhost,root); +set @@wait_timeout=1; +sleep 2; +connection default; +let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err; +let SEARCH_PATTERN= Aborted.*Got timeout reading communication packets; +source include/search_pattern_in_file.inc; +set global log_warnings=@@log_warnings; + + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/wait_timeout_not_windows.test b/mysql-test/t/wait_timeout_not_windows.test deleted file mode 100644 index 50731779845..00000000000 --- a/mysql-test/t/wait_timeout_not_windows.test +++ /dev/null @@ -1,15 +0,0 @@ -source include/not_embedded.inc; -source include/not_windows.inc; - -# -# MDEV-7775 Wrong error message (Unknown error) when idle sessions are killed after wait_timeout -# -set global log_warnings=2; -connect (foo,localhost,root); -set @@wait_timeout=1; -sleep 2; -connection default; -let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err; -let SEARCH_PATTERN= Aborted.*Got timeout reading communication packets; -source include/search_pattern_in_file.inc; -set global log_warnings=@@log_warnings; diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index efcc9a3f0b2..6e21d6249ab 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -204,6 +204,10 @@ extern "C" sig_handler handle_fatal_signal(int sig) case KILL_SLAVE_SAME_ID: kreason= "KILL_SLAVE_SAME_ID"; break; + case KILL_WAIT_TIMEOUT: + case KILL_WAIT_TIMEOUT_HARD: + kreason= "KILL_WAIT_TIMEOUT"; + break; } my_safe_printf_stderr("%s", "\n" "Trying to get some variables.\n" diff --git a/sql/sql_class.cc b/sql/sql_class.cc index decde918d9e..1b176d35512 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2008,6 +2008,9 @@ int THD::killed_errno() DBUG_RETURN(ER_SERVER_SHUTDOWN); case KILL_SLAVE_SAME_ID: DBUG_RETURN(ER_SLAVE_SAME_ID); + case KILL_WAIT_TIMEOUT: + case KILL_WAIT_TIMEOUT_HARD: + DBUG_RETURN(ER_NET_READ_INTERRUPTED); } DBUG_RETURN(0); // Keep compiler happy } diff --git a/sql/sql_class.h b/sql/sql_class.h index b46467af62e..ba72c46556d 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -492,6 +492,11 @@ enum killed_state KILL_SYSTEM_THREAD_HARD= 15, KILL_SERVER= 16, KILL_SERVER_HARD= 17, + /* + Used in threadpool to signal wait timeout. + */ + KILL_WAIT_TIMEOUT= 18, + KILL_WAIT_TIMEOUT_HARD= 19 }; diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index c6a3c7e44f8..598951da406 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -308,6 +308,24 @@ static void threadpool_remove_connection(THD *thd) my_thread_end(); } + +/* + Ensure that proper error message is sent to client, + and "aborted" message appears in the log in case of + wait timeout. + + See also timeout handling in net_serv.cc +*/ +static void handle_wait_timeout(THD *thd) +{ + thd->get_stmt_da()->reset_diagnostics_area(); + thd->reset_killed(); + my_error(ER_NET_READ_INTERRUPTED, MYF(0)); + thd->net.last_errno= ER_NET_READ_INTERRUPTED; + thd->net.error= 2; +} + + /** Process a single client request or a single batch. */ @@ -323,6 +341,8 @@ static int threadpool_process_request(THD *thd) or KILL command. Return error. */ retval= 1; + if(thd->killed == KILL_WAIT_TIMEOUT) + handle_wait_timeout(thd); goto end; } @@ -458,7 +478,7 @@ void tp_timeout_handler(TP_connection *c) return; THD *thd=c->thd; mysql_mutex_lock(&thd->LOCK_thd_data); - thd->killed= KILL_CONNECTION; + thd->set_killed(KILL_WAIT_TIMEOUT); c->priority= TP_PRIORITY_HIGH; post_kill_notification(thd); mysql_mutex_unlock(&thd->LOCK_thd_data); From 49f3fb8feb8552d1d914fecdbbdb006e3edb4a95 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 29 Aug 2017 14:54:04 +0000 Subject: [PATCH 087/101] small refactoring o innobase/CMakeLists.txt allow to build with -DPLUGIN_INNOBASE=NO --- storage/innobase/CMakeLists.txt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 91c5adc4f07..061ff1ce2ac 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -150,14 +150,7 @@ SET(INNOBASE_SOURCES ut/ut0wqueue.cc ut/ut0timer.cc) -IF(WITH_INNODB) - # Legacy option - SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) -ENDIF() - MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE -# MODULE_ONLY -# MODULE_OUTPUT_NAME ha_innodb DEFAULT RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES ${ZLIB_LIBRARY} @@ -166,8 +159,8 @@ MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE ${LIBSYSTEMD} ${LINKER_SCRIPT}) -IF(WITH_INNOBASE_STORAGE_ENGINE) - ADD_DEPENDENCIES(innobase GenError) +IF(NOT TARGET innobase) + RETURN() ENDIF() # A GCC bug causes crash when compiling these files on ARM64 with -O1+ From 43b262af55db507320b165bb0f9abf05b2f05a89 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 28 Aug 2017 16:10:25 +0000 Subject: [PATCH 088/101] One more attempt to fix dependencies with mysqld import/export libraries with Visual Studio simplify logic, VS generator seems to have problems if generated file (with ADD_CUSTOM_COMMAND) depends on another generated file. So, the fix is just to have mysqld_lib.{def,lib,exp} to be generated in a single ADD_CUSTOM_COMMAND rather than two steps. --- cmake/create_initial_db.cmake.in | 4 --- sql/CMakeLists.txt | 44 +++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/cmake/create_initial_db.cmake.in b/cmake/create_initial_db.cmake.in index c77e28d882c..baa48847815 100644 --- a/cmake/create_initial_db.cmake.in +++ b/cmake/create_initial_db.cmake.in @@ -82,7 +82,3 @@ EXECUTE_PROCESS ( IF(NOT RESULT EQUAL 0) MESSAGE(FATAL_ERROR "Could not create initial database \n ${OUT} \n ${ERR}") ENDIF() - -EXECUTE_PROCESS ( - COMMAND "@CMAKE_COMMAND@" -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep -) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index eddbccfbb66..3b9da7ef150 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -225,23 +225,35 @@ IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS) SET(_PLATFORM x64) ENDIF() + # Create a cmake script to generate import and export libs + # from a .def file + SET(CMAKE_CONFIGURABLE_FILE_CONTENT " + IF ((mysqld_lib.def IS_NEWER_THAN mysqld_lib.lib) OR + (mysqld_lib.def IS_NEWER_THAN mysqld_lib.exp)) + SET(ENV{VS_UNICODE_OUTPUT}) + EXECUTE_PROCESS ( + COMMAND \"${CMAKE_LINKER}\" /lib /NAME:mysqld.exe \"/DEF:${MYSQLD_DEF}\" /MACHINE:${_PLATFORM} + RESULT_VARIABLE ret) + IF(NOT ret EQUAL 0) + MESSAGE(FATAL_ERROR \"process failed ret=\${ret}\") + ENDIF() + ENDIF() + ") + + CONFIGURE_FILE( + ${PROJECT_SOURCE_DIR}/cmake/configurable_file_content.in + make_mysqld_lib.cmake) + ADD_CUSTOM_COMMAND( - OUTPUT ${MYSQLD_DEF} + OUTPUT ${MYSQLD_DEF} ${MYSQLD_LIB} ${MYSQLD_EXP} COMMAND cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js ${_PLATFORM} /forLib ${LIB_LOCATIONS} > mysqld_lib.def.tmp COMMAND ${CMAKE_COMMAND} -E copy_if_different mysqld_lib.def.tmp mysqld_lib.def - COMMAND ${CMAKE_COMMAND} -E remove mysqld_lib.def.tmp + COMMAND ${CMAKE_COMMAND} -P make_mysqld_lib.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${MYSQLD_CORELIBS} ) - ADD_CUSTOM_COMMAND( - OUTPUT ${MYSQLD_LIB} - COMMAND lib - ARGS /NAME:mysqld.exe "/DEF:${MYSQLD_DEF}" "/MACHINE:${_PLATFORM}" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${MYSQLD_DEF} - ) ADD_CUSTOM_TARGET(gen_mysqld_lib DEPENDS ${MYSQLD_LIB}) ADD_LIBRARY(mysqld_import_lib UNKNOWN IMPORTED GLOBAL) SET_TARGET_PROPERTIES(mysqld_import_lib PROPERTIES IMPORTED_LOCATION ${MYSQLD_LIB}) @@ -258,7 +270,10 @@ IF(APPLE) ENDIF() IF(NOT WITHOUT_DYNAMIC_PLUGINS) - SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) + IF(NOT MSVC) + SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) + ENDIF() + GET_TARGET_PROPERTY(mysqld_link_flags mysqld LINK_FLAGS) IF(NOT mysqld_link_flags) SET(mysqld_link_flags) @@ -272,7 +287,6 @@ IF(NOT WITHOUT_DYNAMIC_PLUGINS) ENDIF() ENDIF(NOT WITHOUT_DYNAMIC_PLUGINS) -SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) TARGET_LINK_LIBRARIES(mysqld sql) # Provide plugins with minimal set of libraries @@ -408,15 +422,15 @@ IF(WIN32 AND MYSQLD_EXECUTABLE) ENDIF() MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data) ADD_CUSTOM_COMMAND( - OUTPUT initdb.dep - COMMAND ${CMAKE_COMMAND} - ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep + COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data DEPENDS mysqld ) ADD_CUSTOM_TARGET(initial_database ALL - DEPENDS initdb.dep + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep ) INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data DESTINATION . COMPONENT DataFiles From eca238aea7925b3f165db7c8a0e03c5b3b179cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 29 Aug 2017 14:23:34 +0300 Subject: [PATCH 089/101] MDEV-13557: Startup failure, unable to decrypt ibdata1 Fixes also MDEV-13488: InnoDB writes CRYPT_INFO even though encryption is not enabled. Fixes also MDEV-13093: Leak of Datafile::m_crypt_info on shutdown after failed startup. Problem was that we created encryption metadata (crypt_data) for system tablespace even when no encryption was enabled and too early. System tablespace can be encrypted only using key rotation. Test innodb-key-rotation-disable, innodb_encryption, innodb_lotoftables require adjustment because INFORMATION_SCHEMA INNODB_TABLESPACES_ENCRYPTION contain row only if tablespace really has encryption metadata. xb_load_single_table_tablespace(): Do not call fil_space_destroy_crypt_data() any more, because Datafile::m_crypt_data has been removed. fil_crypt_realloc_iops(): Avoid divide by zero. fil_crypt_set_thread_cnt(): Set fil_crypt_threads_event if encryption threads exist. This is required to find tablespaces requiring key rotation if no other changes happen. fil_crypt_find_space_to_rotate(): Decrease the amount of time waiting when nothing happens to better enable key rotation on startup. fil_ibd_open(), fil_ibd_load(): Load possible crypt_data from first page. class Datafile, class SysTablespace : remove m_crypt_info field. Datafile::get_first_page(): Return a pointer to first page buffer. fsp_header_init(): Write encryption metadata to page 0 only if tablespace is encrypted or encryption is disabled by table option. i_s_dict_fill_tablespaces_encryption(): Skip tablespaces that do not contain encryption metadata. This is required to avoid too early wait condition trigger in encrypted -> unencrypted state transfer. --- extra/mariabackup/xtrabackup.cc | 4 - .../r/innodb-first-page-read.result | 61 +- .../r/innodb-key-rotation-disable.result | 3 - .../encryption/r/innodb_encryption.result | 58 +- .../encryption/r/innodb_lotoftables.result | 1182 ++++++++++++++++- .../encryption/t/innodb-first-page-read.test | 32 +- .../suite/encryption/t/innodb_encryption.test | 165 +-- .../encryption/t/innodb_lotoftables.test | 91 +- storage/innobase/fil/fil0crypt.cc | 23 +- storage/innobase/fil/fil0fil.cc | 24 +- storage/innobase/fsp/fsp0file.cc | 7 - storage/innobase/fsp/fsp0fsp.cc | 8 +- storage/innobase/fsp/fsp0space.cc | 2 +- storage/innobase/fsp/fsp0sysspace.cc | 13 +- storage/innobase/handler/i_s.cc | 7 + storage/innobase/include/fsp0file.h | 24 +- storage/innobase/include/fsp0sysspace.h | 6 +- 17 files changed, 1330 insertions(+), 380 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index cb42a359896..702ac088557 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2598,10 +2598,6 @@ xb_load_single_table_tablespace( ut_free(name); - if (fil_space_crypt_t* crypt_info = file->get_crypt_info()) { - fil_space_destroy_crypt_data(&crypt_info); - } - delete file; if (err != DB_SUCCESS && err != DB_CORRUPTION && xtrabackup_backup) { diff --git a/mysql-test/suite/encryption/r/innodb-first-page-read.result b/mysql-test/suite/encryption/r/innodb-first-page-read.result index 9b57b9de5f9..6df80e8223d 100644 --- a/mysql-test/suite/encryption/r/innodb-first-page-read.result +++ b/mysql-test/suite/encryption/r/innodb-first-page-read.result @@ -1,5 +1,6 @@ SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; +FLUSH STATUS; create database innodb_test; use innodb_test; create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb; @@ -50,40 +51,48 @@ insert into innodb_datadir1 select * from innodb_normal; insert into innodb_datadir2 select * from innodb_normal; insert into innodb_datadir3 select * from innodb_normal; commit; +FLUSH STATUS; # Restart server and see how many page 0's are read -# result should be less than actual number of tables -# i.e. < 23 + 3 = 26 -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +# result should actual number of tables except remote tables could be read twice +# i.e. < 23 + 3*2 = 29 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 set global innodb_encrypt_tables=OFF; # wait until tables are decrypted -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +# result should be actual number of tables except remote tables could be read twice +# i.e. < 23 + 3*2 = 29 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 +FLUSH STATUS; # restart and see number read page 0 -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 drop database innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +FLUSH STATUS; diff --git a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result index a642ad20183..680db692c17 100644 --- a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result +++ b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result @@ -2,9 +2,6 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ NAME SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; NAME -mysql/innodb_table_stats -mysql/innodb_index_stats -innodb_system create database enctests; use enctests; create table t1(a int not null primary key, b char(200)) engine=innodb; diff --git a/mysql-test/suite/encryption/r/innodb_encryption.result b/mysql-test/suite/encryption/r/innodb_encryption.result index ce494098d44..c49cf3813c9 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption.result +++ b/mysql-test/suite/encryption/r/innodb_encryption.result @@ -8,25 +8,22 @@ innodb_encrypt_tables ON innodb_encryption_rotate_key_age 15 innodb_encryption_rotation_iops 100 innodb_encryption_threads 4 -DESCRIBE INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; -Field Type Null Key Default Extra -SPACE int(11) unsigned NO 0 -NAME varchar(655) YES NULL -ENCRYPTION_SCHEME int(11) unsigned NO 0 -KEYSERVER_REQUESTS int(11) unsigned NO 0 -MIN_KEY_VERSION int(11) unsigned NO 0 -CURRENT_KEY_VERSION int(11) unsigned NO 0 -KEY_ROTATION_PAGE_NUMBER bigint(21) unsigned YES NULL -KEY_ROTATION_MAX_PAGE_NUMBER bigint(21) unsigned YES NULL -CURRENT_KEY_ID int(11) unsigned NO 0 -ROTATING_OR_FLUSHING int(1) unsigned NO 0 -# Wait max 5 min for key encryption threads to encrypt one space -# Success! -# Wait max 10 min for key encryption threads to encrypt all space +SET GLOBAL innodb_encrypt_tables = ON; +# Wait max 10 min for key encryption threads to encrypt all spaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +innodb_system # Success! # Now turn off encryption and wait for threads to decrypt everything SET GLOBAL innodb_encrypt_tables = off; -# Wait max 10 min for key encryption threads to decrypt all space +# Wait max 10 min for key encryption threads to encrypt all spaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +innodb_system +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME # Success! # Shutdown innodb_encryption_threads SET GLOBAL innodb_encryption_threads=0; @@ -34,16 +31,20 @@ SET GLOBAL innodb_encryption_threads=0; # since threads are off tables should remain unencrypted SET GLOBAL innodb_encrypt_tables = on; # Wait 15s to check that nothing gets encrypted +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +innodb_system +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME # Success! # Startup innodb_encryption_threads SET GLOBAL innodb_encryption_threads=@start_global_value; -# Wait 1 min to check that it start encrypting again -# Success! -# -# Check that restart with encryption turned off works -# even if spaces are encrypted -# -# First wait max 10 min for key encryption threads to encrypt all spaces +# Wait max 10 min for key encryption threads to encrypt all spaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +innodb_system # Success! # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 SHOW VARIABLES LIKE 'innodb_encrypt%'; @@ -53,9 +54,8 @@ innodb_encrypt_tables OFF innodb_encryption_rotate_key_age 15 innodb_encryption_rotation_iops 100 innodb_encryption_threads 0 -SELECT COUNT(*) > 0 as should_be_1 -FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION -WHERE MIN_KEY_VERSION <> 0; -should_be_1 -1 -# Restart mysqld again...with default options +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +innodb_system +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME diff --git a/mysql-test/suite/encryption/r/innodb_lotoftables.result b/mysql-test/suite/encryption/r/innodb_lotoftables.result index cf5724b527a..da07a52f8c3 100644 --- a/mysql-test/suite/encryption/r/innodb_lotoftables.result +++ b/mysql-test/suite/encryption/r/innodb_lotoftables.result @@ -17,10 +17,9 @@ commit work; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 +# should be empty +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; +NAME create database innodb_encrypted_2; use innodb_encrypted_2; show status like 'innodb_pages0_read%'; @@ -32,14 +31,112 @@ set autocommit=1; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 +# should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +# should contain 0 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME create database innodb_encrypted_3; use innodb_encrypted_3; show status like 'innodb_pages0_read%'; @@ -51,33 +148,626 @@ set autocommit=1; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -# should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 +# should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +# should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 use test; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 SET GLOBAL innodb_encrypt_tables = on; SET GLOBAL innodb_encryption_threads=4; -# Wait until all encrypted tables have been encrypted -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 @@ -127,26 +817,416 @@ Innodb_pages0_read 303 show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 303 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 SET GLOBAL innodb_encrypt_tables = off; SET GLOBAL innodb_encryption_threads=4; -# Wait until all default encrypted tables have been decrypted -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -# should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 303 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 use test; drop database innodb_encrypted_1; drop database innodb_encrypted_2; diff --git a/mysql-test/suite/encryption/t/innodb-first-page-read.test b/mysql-test/suite/encryption/t/innodb-first-page-read.test index 1fc07159e05..d661e4565d2 100644 --- a/mysql-test/suite/encryption/t/innodb-first-page-read.test +++ b/mysql-test/suite/encryption/t/innodb-first-page-read.test @@ -7,6 +7,8 @@ SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; --enable_warnings +FLUSH STATUS; + create database innodb_test; use innodb_test; create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb; @@ -63,16 +65,19 @@ insert into innodb_datadir2 select * from innodb_normal; insert into innodb_datadir3 select * from innodb_normal; commit; +FLUSH STATUS; + --echo # Restart server and see how many page 0's are read --source include/restart_mysqld.inc ---echo # result should be less than actual number of tables ---echo # i.e. < 23 + 3 = 26 -show status like 'innodb_pages0_read%'; +--echo # result should actual number of tables except remote tables could be read twice +--echo # i.e. < 23 + 3*2 = 29 + +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use innodb_test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; set global innodb_encrypt_tables=OFF; @@ -80,18 +85,25 @@ set global innodb_encrypt_tables=OFF; --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 --source include/wait_condition.inc -show status like 'innodb_pages0_read%'; +--echo # result should be actual number of tables except remote tables could be read twice +--echo # i.e. < 23 + 3*2 = 29 + +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use innodb_test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; + +FLUSH STATUS; --echo # restart and see number read page 0 -- source include/restart_mysqld.inc -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use innodb_test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; drop database innodb_test; -show status like 'innodb_pages0_read%'; +FLUSH STATUS; diff --git a/mysql-test/suite/encryption/t/innodb_encryption.test b/mysql-test/suite/encryption/t/innodb_encryption.test index 6e9f80aac0c..aab8c56f072 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption.test +++ b/mysql-test/suite/encryption/t/innodb_encryption.test @@ -15,78 +15,29 @@ SET @start_global_value = @@global.innodb_encryption_threads; SHOW VARIABLES LIKE 'innodb_encrypt%'; -DESCRIBE INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; +SET GLOBAL innodb_encrypt_tables = ON; ---echo # Wait max 5 min for key encryption threads to encrypt one space -let $cnt=300; -while ($cnt) -{ - let $success=`SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} ---echo # Success! +--echo # Wait max 10 min for key encryption threads to encrypt all spaces +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >= 1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; ---echo # Wait max 10 min for key encryption threads to encrypt all space -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} --echo # Success! --echo # Now turn off encryption and wait for threads to decrypt everything SET GLOBAL innodb_encrypt_tables = off; ---echo # Wait max 10 min for key encryption threads to decrypt all space -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} +--echo # Wait max 10 min for key encryption threads to encrypt all spaces +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; + --echo # Success! --echo # Shutdown innodb_encryption_threads @@ -97,84 +48,32 @@ SET GLOBAL innodb_encryption_threads=0; SET GLOBAL innodb_encrypt_tables = on; --echo # Wait 15s to check that nothing gets encrypted -let $cnt=15; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`; - if ($success) - { - real_sleep 1; - dec $cnt; - } - if (!$success) - { - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; - -- die Failure, tablespace getting encrypted even if innodb_encryption_threads=0 - } -} +--let $wait_timeout= 15 +--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; + --echo # Success! --echo # Startup innodb_encryption_threads SET GLOBAL innodb_encryption_threads=@start_global_value; ---echo # Wait 1 min to check that it start encrypting again -let $cnt=60; -while ($cnt) -{ - let $success=`SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 OR KEY_ROTATION_PAGE_NUMBER IS NOT NULL`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} ---echo # Success! +--echo # Wait max 10 min for key encryption threads to encrypt all spaces +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >=1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; ---echo # ---echo # Check that restart with encryption turned off works ---echo # even if spaces are encrypted ---echo # ---echo # First wait max 10 min for key encryption threads to encrypt all spaces -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} --echo # Success! --echo # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 -- let $restart_parameters=--innodb_encrypt_tables=0 --innodb_encryption_threads=0 -- source include/restart_mysqld.inc SHOW VARIABLES LIKE 'innodb_encrypt%'; -SELECT COUNT(*) > 0 as should_be_1 -FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION -WHERE MIN_KEY_VERSION <> 0; ---echo # Restart mysqld again...with default options --- let $restart_parameters= --- source include/restart_mysqld.inc +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; diff --git a/mysql-test/suite/encryption/t/innodb_lotoftables.test b/mysql-test/suite/encryption/t/innodb_lotoftables.test index 6e87c93df4b..cd3c6a30c07 100644 --- a/mysql-test/suite/encryption/t/innodb_lotoftables.test +++ b/mysql-test/suite/encryption/t/innodb_lotoftables.test @@ -48,9 +48,8 @@ show status like 'innodb_pages0_read%'; # # Verify # ---echo # should be 100 - -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; +--echo # should be empty +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; # # This will create 100 tables that are encrypted always @@ -84,10 +83,10 @@ show status like 'innodb_pages0_read%'; # # Verify # ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +--echo # should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +--echo # should contain 0 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; # # This will create 100 tables that are not encrypted @@ -121,45 +120,26 @@ show status like 'innodb_pages0_read%'; # # Verify # ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; ---echo # should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +--echo # should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +--echo # should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; use test; show status like 'innodb_pages0_read%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; SET GLOBAL innodb_encrypt_tables = on; SET GLOBAL innodb_encryption_threads=4; ---echo # Wait until all encrypted tables have been encrypted -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; show status like 'innodb_pages0_read%'; --echo # Success! @@ -226,40 +206,19 @@ while ($tables) show status like 'innodb_pages0_read%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; SET GLOBAL innodb_encrypt_tables = off; SET GLOBAL innodb_encryption_threads=4; ---echo # Wait until all default encrypted tables have been decrypted -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; ---echo # should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -show status like 'innodb_pages0_read%'; + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; # # Cleanup diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index faf57a33cab..f7fb1377fcf 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1340,12 +1340,12 @@ fil_crypt_realloc_iops( state->cnt_waited = 0; state->sum_waited_us = 0; } else { - DBUG_PRINT("ib_crypt", - ("thr_no: %u only waited " ULINTPF - "%% skip re-estimate.", - state->thread_no, - (100 * state->cnt_waited) / state->batch)); + ("thr_no: %u only waited " ULINTPF + "%% skip re-estimate.", + state->thread_no, + (100 * state->cnt_waited) + / (state->batch ? state->batch : 1))); } if (state->estimated_max_iops <= state->allocated_iops) { @@ -1448,7 +1448,7 @@ fil_crypt_find_space_to_rotate( /* we need iops to start rotating */ while (!state->should_shutdown() && !fil_crypt_alloc_iops(state)) { os_event_reset(fil_crypt_threads_event); - os_event_wait_time(fil_crypt_threads_event, 1000000); + os_event_wait_time(fil_crypt_threads_event, 100000); } if (state->should_shutdown()) { @@ -2271,7 +2271,13 @@ fil_crypt_set_thread_cnt( while(srv_n_fil_crypt_threads_started != srv_n_fil_crypt_threads) { os_event_reset(fil_crypt_event); - os_event_wait_time(fil_crypt_event, 1000000); + os_event_wait_time(fil_crypt_event, 100000); + } + + /* Send a message to encryption threads that there could be + something to do. */ + if (srv_n_fil_crypt_threads) { + os_event_set(fil_crypt_threads_event); } } @@ -2424,10 +2430,11 @@ fil_space_crypt_get_status( fil_crypt_read_crypt_data(const_cast(space)); } + status->space = ULINT_UNDEFINED; fil_space_crypt_t* crypt_data = space->crypt_data; - status->space = space->id; if (crypt_data != NULL) { + status->space = space->id; mutex_enter(&crypt_data->mutex); status->scheme = crypt_data->type; status->keyserver_requests = crypt_data->keyserver_requests; diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 1cafb253630..d34c8f91514 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -4341,11 +4341,18 @@ fil_ibd_open( skip_validate: if (err == DB_SUCCESS) { - fil_space_t* space = fil_space_create( - space_name, id, flags, purpose, - df_remote.is_open() ? df_remote.get_crypt_info() : - df_dict.is_open() ? df_dict.get_crypt_info() : - df_default.get_crypt_info()); + const byte* first_page = + df_default.is_open() ? df_default.get_first_page() : + df_dict.is_open() ? df_dict.get_first_page() : + df_remote.get_first_page(); + + fil_space_crypt_t* crypt_data = first_page + ? fil_space_read_crypt_data(page_size_t(flags), + first_page) + : NULL; + + fil_space_t* space = fil_space_create( + space_name, id, flags, purpose, crypt_data); /* We do not measure the size of the file, that is why we pass the 0 below */ @@ -4663,9 +4670,12 @@ fil_ibd_load( << FSP_FLAGS_MEM_COMPRESSION_LEVEL; } + const byte* first_page = file.get_first_page(); + fil_space_crypt_t* crypt_data = first_page + ? fil_space_read_crypt_data(page_size_t(flags), first_page) + : NULL; space = fil_space_create( - file.name(), space_id, flags, FIL_TYPE_TABLESPACE, - file.get_crypt_info()); + file.name(), space_id, flags, FIL_TYPE_TABLESPACE, crypt_data); if (space == NULL) { return(FIL_LOAD_INVALID); diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc index 4f03ace9d8e..c21c9497735 100644 --- a/storage/innobase/fsp/fsp0file.cc +++ b/storage/innobase/fsp/fsp0file.cc @@ -58,11 +58,6 @@ Datafile::shutdown() ut_free(m_name); m_name = NULL; - - /* The fil_space_t::crypt_data was freed in - fil_space_free_low(). Invalidate our redundant pointer. */ - m_crypt_info = NULL; - free_filepath(); free_first_page(); } @@ -374,8 +369,6 @@ Datafile::read_first_page(bool read_only_mode) return(DB_CORRUPTION); } - m_crypt_info = fil_space_read_crypt_data(ps, m_first_page); - return(err); } diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index ca0c712f608..5e89312a9de 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -799,8 +799,12 @@ fsp_header_init(ulint space_id, ulint size, mtr_t* mtr) fsp_fill_free_list(!is_system_tablespace(space_id), space, header, mtr); - if (space->crypt_data) { - space->crypt_data->write_page0(space, page, mtr); + /* Write encryption metadata to page 0 if tablespace is + encrypted or encryption is disabled by table option. */ + if (space->crypt_data && + (space->crypt_data->should_encrypt() || + space->crypt_data->not_encrypted())) { + space->crypt_data->write_page0(space, page, mtr); } } diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc index 94fae3d973b..9ca2786b935 100644 --- a/storage/innobase/fsp/fsp0space.cc +++ b/storage/innobase/fsp/fsp0space.cc @@ -125,7 +125,7 @@ Tablespace::open_or_create(bool is_temp) m_name, m_space_id, FSP_FLAGS_PAGE_SSIZE(), is_temp ? FIL_TYPE_TEMPORARY : FIL_TYPE_TABLESPACE, - it->m_crypt_info); + NULL); } ut_a(fil_validate()); diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc index e4bb11c9a22..cc156a5353a 100644 --- a/storage/innobase/fsp/fsp0sysspace.cc +++ b/storage/innobase/fsp/fsp0sysspace.cc @@ -562,8 +562,6 @@ SysTablespace::read_lsn_and_check_flags(lsn_t* flushed_lsn) err = it->read_first_page( m_ignore_read_only ? false : srv_read_only_mode); - m_crypt_info = it->m_crypt_info; - if (err != DB_SUCCESS) { return(err); } @@ -919,19 +917,10 @@ SysTablespace::open_or_create( /* Create the tablespace entry for the multi-file tablespace in the tablespace manager. */ - - if (!m_crypt_info) { - /* Create default crypt info for system - tablespace if it does not yet exists. */ - m_crypt_info = fil_space_create_crypt_data( - FIL_ENCRYPTION_DEFAULT, - FIL_DEFAULT_ENCRYPTION_KEY); - } - space = fil_space_create( name(), space_id(), flags(), is_temp ? FIL_TYPE_TEMPORARY : FIL_TYPE_TABLESPACE, - m_crypt_info); + NULL); } ut_a(fil_validate()); diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 8f04f9d15ee..8880d21aafb 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -8606,6 +8606,12 @@ i_s_dict_fill_tablespaces_encryption( fil_space_crypt_get_status(space, &status); + /* If tablespace id does not match, we did not find + encryption information for this tablespace. */ + if (!space->crypt_data || space->id != status.space) { + goto skip; + } + OK(fields[TABLESPACES_ENCRYPTION_SPACE]->store(space->id, true)); OK(field_store_string(fields[TABLESPACES_ENCRYPTION_NAME], @@ -8640,6 +8646,7 @@ i_s_dict_fill_tablespaces_encryption( OK(schema_table_store_record(thd, table_to_fill)); +skip: DBUG_RETURN(0); } /*******************************************************************//** diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h index 974de9c75ed..1f057be0877 100644 --- a/storage/innobase/include/fsp0file.h +++ b/storage/innobase/include/fsp0file.h @@ -66,8 +66,7 @@ public: m_first_page_buf(), m_first_page(), m_last_os_error(), - m_file_info(), - m_crypt_info() + m_file_info() { /* No op */ } @@ -89,8 +88,7 @@ public: m_first_page_buf(), m_first_page(), m_last_os_error(), - m_file_info(), - m_crypt_info() + m_file_info() { ut_ad(m_name != NULL); /* No op */ @@ -110,8 +108,7 @@ public: m_first_page_buf(), m_first_page(), m_last_os_error(), - m_file_info(), - m_crypt_info() + m_file_info() { m_name = mem_strdup(file.m_name); ut_ad(m_name != NULL); @@ -169,8 +166,6 @@ public: it should be reread if needed */ m_first_page_buf = NULL; m_first_page = NULL; - /* Do not copy crypt info it is read from first page */ - m_crypt_info = NULL; return(*this); } @@ -321,11 +316,6 @@ public: return(m_last_os_error); } - fil_space_crypt_t* get_crypt_info() const - { - return(m_crypt_info); - } - /** Test if the filepath provided looks the same as this filepath by string comparison. If they are two different paths to the same file, same_as() will be used to show that after the files are opened. @@ -339,6 +329,11 @@ public: @return true if it is the same file, else false */ bool same_as(const Datafile& other) const; + /** Get access to the first data page. + It is valid after open_read_only() succeeded. + @return the first data page */ + const byte* get_first_page() const { return(m_first_page); } + private: /** Free the filepath buffer. */ void free_filepath(); @@ -465,9 +460,6 @@ public: /* Use field st_ino. */ struct stat m_file_info; #endif /* WIN32 */ - - /** Encryption information */ - fil_space_crypt_t* m_crypt_info; }; diff --git a/storage/innobase/include/fsp0sysspace.h b/storage/innobase/include/fsp0sysspace.h index b8890adad74..efbd4fc3f24 100644 --- a/storage/innobase/include/fsp0sysspace.h +++ b/storage/innobase/include/fsp0sysspace.h @@ -53,8 +53,7 @@ public: m_last_file_size_max(), m_created_new_raw(), m_is_tablespace_full(false), - m_sanity_checks_done(false), - m_crypt_info() + m_sanity_checks_done(false) { /* No op */ } @@ -264,9 +263,6 @@ private: /** if false, then sanity checks are still pending */ bool m_sanity_checks_done; - - /** Encryption information */ - fil_space_crypt_t* m_crypt_info; }; /* GLOBAL OBJECTS */ From b29f26d774033d9dda6c1a519657f1092c964f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 31 Aug 2017 08:27:59 +0300 Subject: [PATCH 090/101] Fix test failures on embedded server. Problem was incorrect definition of wsrep_recovery, trx_sys_update_wsrep_checkpoint and trx_sys_read_wsrep_checkpoint functions causing innodb_plugin not to load as there was undefined symbols. --- storage/innobase/buf/buf0dump.cc | 10 +++++----- storage/innobase/include/trx0sys.h | 7 +++++-- storage/innobase/srv/srv0start.cc | 5 +++-- storage/innobase/trx/trx0sys.cc | 12 ++++++++---- storage/xtradb/buf/buf0dump.cc | 4 +--- storage/xtradb/include/trx0sys.h | 5 ++++- storage/xtradb/srv/srv0start.cc | 3 +-- storage/xtradb/trx/trx0sys.cc | 4 +++- 8 files changed, 30 insertions(+), 20 deletions(-) diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index 33a39aaed8a..703c425e127 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -41,9 +41,7 @@ Created April 08, 2011 Vasil Dimov #include "sync0rw.h" /* rw_lock_s_lock() */ #include "ut0byte.h" /* ut_ull_create() */ #include "ut0sort.h" /* UT_SORT_FUNCTION_BODY */ -#ifdef WITH_WSREP -extern my_bool wsrep_recovery; -#endif /* WITH_WSREP */ +#include "mysql/service_wsrep.h" /* wsrep_recovery */ enum status_severity { STATUS_INFO, @@ -695,12 +693,13 @@ DECLARE_THREAD(buf_dump_thread)(void*) buf_load_status(STATUS_INFO, "Loading buffer pool(s) not yet started"); if (srv_buffer_pool_load_at_startup) { + #ifdef WITH_WSREP if (!wsrep_recovery) { #endif /* WITH_WSREP */ - buf_load(); + buf_load(); #ifdef WITH_WSREP - } + } #endif /* WITH_WSREP */ } @@ -728,6 +727,7 @@ DECLARE_THREAD(buf_dump_thread)(void*) #ifdef WITH_WSREP if (!wsrep_recovery) { #endif /* WITH_WSREP */ + buf_dump(FALSE /* ignore shutdown down flag, keep going even if we are in a shutdown state */); #ifdef WITH_WSREP diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index 83814d088f3..f70c53b57e6 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -315,6 +315,7 @@ trx_sys_print_mysql_binlog_offset(void); @param[in] xid Transaction XID @param[in,out] sys_header sys_header @param[in] mtr minitransaction */ +UNIV_INTERN void trx_sys_update_wsrep_checkpoint( const XID* xid, @@ -322,8 +323,10 @@ trx_sys_update_wsrep_checkpoint( mtr_t* mtr); /** Read WSREP XID from sys_header of TRX_SYS_PAGE_NO = 5. -@param[out] xid Transaction XID */ -void +@param[out] xid Transaction XID +@return true on success, false on error. */ +UNIV_INTERN +bool trx_sys_read_wsrep_checkpoint(XID* xid); #endif /* WITH_WSREP */ diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 8b963fc3259..0010ec9c002 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -70,8 +70,7 @@ Created 2/16/1996 Heikki Tuuri #include "srv0start.h" #include "srv0srv.h" #include "btr0defragment.h" - -#include +#include "mysql/service_wsrep.h" /* wsrep_recovery */ #ifndef UNIV_HOTBACKUP # include "trx0rseg.h" @@ -3014,6 +3013,7 @@ files_checked: */ if (!wsrep_recovery) { #endif /* WITH_WSREP */ + /* Create the buffer pool dump/load thread */ srv_buf_dump_thread_active = true; buf_dump_thread_handle= @@ -3027,6 +3027,7 @@ files_checked: "wsrep recovery."); } #endif /* WITH_WSREP */ + /* Create thread(s) that handles key rotation */ fil_system_enter(); fil_crypt_threads_init(); diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 8cb4f9a4135..e9443e93140 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -344,6 +344,7 @@ static inline void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) @param[in] xid Transaction XID @param[in,out] sys_header sys_header @param[in] mtr minitransaction */ +UNIV_INTERN void trx_sys_update_wsrep_checkpoint( const XID* xid, @@ -402,8 +403,10 @@ trx_sys_update_wsrep_checkpoint( } /** Read WSREP XID from sys_header of TRX_SYS_PAGE_NO = 5. -@param[out] xid Transaction XID */ -void +@param[out] xid Transaction XID +@return true on success, false on error. */ +UNIV_INTERN +bool trx_sys_read_wsrep_checkpoint(XID* xid) { trx_sysf_t* sys_header; @@ -423,8 +426,8 @@ trx_sys_read_wsrep_checkpoint(XID* xid) xid->formatID = -1; trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); mtr_commit(&mtr); - return; - } + return false; + } xid->formatID = (int)mach_read_from_4( sys_header @@ -440,6 +443,7 @@ trx_sys_read_wsrep_checkpoint(XID* xid) XIDDATASIZE); mtr_commit(&mtr); + return true; } #endif /* WITH_WSREP */ diff --git a/storage/xtradb/buf/buf0dump.cc b/storage/xtradb/buf/buf0dump.cc index 023a267ee22..bf384390a98 100644 --- a/storage/xtradb/buf/buf0dump.cc +++ b/storage/xtradb/buf/buf0dump.cc @@ -41,9 +41,7 @@ Created April 08, 2011 Vasil Dimov #include "sync0rw.h" /* rw_lock_s_lock() */ #include "ut0byte.h" /* ut_ull_create() */ #include "ut0sort.h" /* UT_SORT_FUNCTION_BODY */ -#ifdef WITH_WSREP -extern my_bool wsrep_recovery; -#endif /* WITH_WSREP */ +#include "mysql/service_wsrep.h" /* wsrep_recovery */ enum status_severity { STATUS_INFO, diff --git a/storage/xtradb/include/trx0sys.h b/storage/xtradb/include/trx0sys.h index 1b418dfe380..85c454c4cf9 100644 --- a/storage/xtradb/include/trx0sys.h +++ b/storage/xtradb/include/trx0sys.h @@ -336,14 +336,17 @@ trx_sys_print_mysql_binlog_offset(void); @param[in] xid Transaction XID @param[in,out] sys_header sys_header @param[in] mtr minitransaction */ +UNIV_INTERN void trx_sys_update_wsrep_checkpoint( const XID* xid, trx_sysf_t* sys_header, mtr_t* mtr); -/** Read WSREP checkpoint XID from sys header. +/** Read WSREP checkpoint XID from sys header. +@param[out] xid Transaction XID @return true on success, false on error. */ +UNIV_INTERN bool trx_sys_read_wsrep_checkpoint( XID* xid); /*!< out: WSREP XID */ diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index bd31f229dc0..c87b7652c21 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -73,8 +73,7 @@ Created 2/16/1996 Heikki Tuuri #include "btr0defragment.h" #include "ut0timer.h" #include "btr0scrub.h" - -#include +#include "mysql/service_wsrep.h" /* wsrep_recovery */ #ifndef UNIV_HOTBACKUP # include "trx0rseg.h" diff --git a/storage/xtradb/trx/trx0sys.cc b/storage/xtradb/trx/trx0sys.cc index 063a43b177c..d2b1a8f9f0d 100644 --- a/storage/xtradb/trx/trx0sys.cc +++ b/storage/xtradb/trx/trx0sys.cc @@ -348,6 +348,7 @@ static inline void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) @param[in] xid Transaction XID @param[in,out] sys_header sys_header @param[in] mtr minitransaction */ +UNIV_INTERN void trx_sys_update_wsrep_checkpoint( const XID* xid, @@ -406,8 +407,9 @@ trx_sys_update_wsrep_checkpoint( } /** Read WSREP XID from sys_header of TRX_SYS_PAGE_NO = 5. -@param[out] xid Transaction XID +@param[out] xid Transaction XID @retval true if found, false if not */ +UNIV_INTERN bool trx_sys_read_wsrep_checkpoint(XID* xid) { From 28b2896a434670d7b03c4a5e3fba8b4f3872a297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 31 Aug 2017 09:15:23 +0300 Subject: [PATCH 091/101] Fixed test failure on innodb_encryption After MDEV-13583: Improvements for MTR rebootstrap introduced in MDEV-12042 bootsrap correctly creates mysql/innodb_table_stats and mysql/innodb_index_stats InnoDB tables before innodb_encryption test starts. These tables are also encrypted or decrypted, thus we need to wait also these tables (if not we could randomly get different results as system tablespace and these tables are encrypted or decrypted in parallel). --- mysql-test/suite/encryption/disabled.def | 2 +- .../suite/encryption/r/innodb_encryption.result | 12 ++++++++++-- mysql-test/suite/encryption/t/innodb_encryption.test | 7 ++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/encryption/disabled.def b/mysql-test/suite/encryption/disabled.def index 49f7f94729d..abbb82d51f6 100644 --- a/mysql-test/suite/encryption/disabled.def +++ b/mysql-test/suite/encryption/disabled.def @@ -12,4 +12,4 @@ innodb_scrub : MDEV-8139 scrubbing does not work reliably innodb_scrub_background : MDEV-8139 scrubbing does not work reliably -innodb_encryption : an adjustment for MDEV-13583 is needed + diff --git a/mysql-test/suite/encryption/r/innodb_encryption.result b/mysql-test/suite/encryption/r/innodb_encryption.result index 9194412133d..5909674c21c 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption.result +++ b/mysql-test/suite/encryption/r/innodb_encryption.result @@ -1,5 +1,3 @@ -call mtr.add_suppression("InnoDB: New log files created"); -call mtr.add_suppression("InnoDB: Creating foreign key constraint system tables."); SET @start_global_value = @@global.innodb_encryption_threads; SHOW VARIABLES LIKE 'innodb_encrypt%'; Variable_name Value @@ -14,6 +12,8 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ NAME SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; NAME +mysql/innodb_table_stats +mysql/innodb_index_stats ./ibdata1 # Success! # Now turn off encryption and wait for threads to decrypt everything @@ -21,6 +21,8 @@ SET GLOBAL innodb_encrypt_tables = off; # Wait max 10 min for key encryption threads to encrypt all spaces SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; NAME +mysql/innodb_table_stats +mysql/innodb_index_stats ./ibdata1 SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; NAME @@ -33,6 +35,8 @@ SET GLOBAL innodb_encrypt_tables = on; # Wait 15s to check that nothing gets encrypted SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; NAME +mysql/innodb_table_stats +mysql/innodb_index_stats ./ibdata1 SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; NAME @@ -44,6 +48,8 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ NAME SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; NAME +mysql/innodb_table_stats +mysql/innodb_index_stats ./ibdata1 # Success! # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 @@ -56,6 +62,8 @@ innodb_encryption_rotation_iops 100 innodb_encryption_threads 0 SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; NAME +mysql/innodb_table_stats +mysql/innodb_index_stats ./ibdata1 SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; NAME diff --git a/mysql-test/suite/encryption/t/innodb_encryption.test b/mysql-test/suite/encryption/t/innodb_encryption.test index aab8c56f072..35c2b3695a9 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption.test +++ b/mysql-test/suite/encryption/t/innodb_encryption.test @@ -8,9 +8,6 @@ # embedded does not support restart -- source include/not_embedded.inc -call mtr.add_suppression("InnoDB: New log files created"); -call mtr.add_suppression("InnoDB: Creating foreign key constraint system tables."); - SET @start_global_value = @@global.innodb_encryption_threads; SHOW VARIABLES LIKE 'innodb_encrypt%'; @@ -19,7 +16,7 @@ SET GLOBAL innodb_encrypt_tables = ON; --echo # Wait max 10 min for key encryption threads to encrypt all spaces --let $wait_timeout= 600 ---let $wait_condition=SELECT COUNT(*) >= 1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--let $wait_condition=SELECT COUNT(*) >= 3 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --source include/wait_condition.inc SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; @@ -62,7 +59,7 @@ SET GLOBAL innodb_encryption_threads=@start_global_value; --echo # Wait max 10 min for key encryption threads to encrypt all spaces --let $wait_timeout= 600 ---let $wait_condition=SELECT COUNT(*) >=1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--let $wait_condition=SELECT COUNT(*) >=3 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --source include/wait_condition.inc SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; From 03a8eaa072c2f3f6b7f7c3c9882614dc5c40bd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 31 Aug 2017 08:20:43 +0300 Subject: [PATCH 092/101] Fix some badly written Galera tests galera.galera_kill_applier: Make the test less likely to fail by adding sleep time. galera.query_cache: Remove data truncation. Part of the test file looks like it has been misinterpreted as latin1 and wrongly converted to UTF-8 encoding. In MariaDB 10.1, the server would only warn about data truncation and not issue an error. 10.2 is stricter. (The test should be carefully reviewed if it really makes sense.) --- mysql-test/suite/galera/r/query_cache.result | 76 +++++++++++++++++-- .../suite/galera/t/galera_kill_applier.test | 2 +- mysql-test/suite/galera/t/query_cache.test | 4 +- 3 files changed, 72 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/galera/r/query_cache.result b/mysql-test/suite/galera/r/query_cache.result index 4b1b950e5c3..4aaae2997f3 100644 --- a/mysql-test/suite/galera/r/query_cache.result +++ b/mysql-test/suite/galera/r/query_cache.result @@ -1,6 +1,7 @@ # Execute FLUSH/RESET commands. # On node-1 +connection node_1; SET @query_cache_size_saved=@@GLOBAL.query_cache_size; SET @query_cache_type_saved=@@GLOBAL.query_cache_type; set GLOBAL query_cache_size=1355776; @@ -8,6 +9,7 @@ flush query cache; reset query cache; flush status; # On node-2 +connection node_2; SET @query_cache_size_saved=@@GLOBAL.query_cache_size; SET @query_cache_type_saved=@@GLOBAL.query_cache_type; set GLOBAL query_cache_size=1355776; @@ -15,6 +17,7 @@ flush query cache; reset query cache; flush status; # On node-1 +connection node_1; create table t1 (a int not null) engine=innodb; insert into t1 values (1),(2),(3); select * from t1; @@ -47,6 +50,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; select * from t1; a 1 @@ -77,6 +81,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; delete from t1 where a=1; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -85,6 +90,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -92,6 +98,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; select * from t1; a 2 @@ -103,6 +110,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; select * from t1; a 2 @@ -114,6 +122,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; update t1 set a=1 where a=3; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -122,6 +131,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -129,6 +139,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; select * from t1; a 2 @@ -140,6 +151,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; select * from t1; a 2 @@ -151,6 +163,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; drop table t1; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -159,6 +172,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -167,6 +181,7 @@ Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; create table t1 (a int not null) ENGINE=MyISAM; insert into t1 values (1),(2),(3); create table t2 (a int not null) ENGINE=MyISAM; @@ -323,6 +338,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 3 # On node-2 +connection node_2; select * from t3; a select * from t3; @@ -338,6 +354,7 @@ Variable_name Value Qcache_hits 2 drop table t1, t2, t3; # On node-1 +connection node_1; set query_cache_type=demand; create table t1 (a int not null) engine=innodb; insert into t1 values (1),(2),(3); @@ -371,6 +388,7 @@ Variable_name Value Qcache_queries_in_cache 1 set query_cache_type=on; # On node-2 +connection node_2; set query_cache_type=demand; select * from t1; a @@ -402,6 +420,7 @@ Variable_name Value Qcache_queries_in_cache 1 set query_cache_type=on; # On node-1 +connection node_1; reset query cache; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -410,6 +429,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; reset query cache; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -418,6 +438,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 3 # On node-1 +connection node_1; select sql_no_cache * from t1; a 1 @@ -430,6 +451,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; select sql_no_cache * from t1; a 1 @@ -443,6 +465,7 @@ Variable_name Value Qcache_hits 3 drop table t1; # On node-1 +connection node_1; create table t1 (a text not null) engine=innodb; select CONNECTION_ID() from t1; CONNECTION_ID() @@ -483,6 +506,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; select CONNECTION_ID() from t1; CONNECTION_ID() select FOUND_ROWS(); @@ -523,6 +547,7 @@ Variable_name Value Qcache_hits 3 drop table t1; # On node-1 +connection node_1; create database mysqltest; create table mysqltest.t1 (i int not null auto_increment, a int, primary key (i)) engine=innodb; @@ -548,6 +573,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; select * from t1; a show status like "Qcache_queries_in_cache"; @@ -574,10 +600,9 @@ Variable_name Value Qcache_hits 3 drop table t1; # On node-1 +connection node_1; create table t1 (a char(1) not null collate koi8r_general_ci) engine=innodb; -insert into t1 values(_koi8r"á"); -Warnings: -Warning 1265 Data truncated for column 'a' at row 1 +insert into t1 values(_koi8r 0xc3); set CHARACTER SET koi8r; select * from t1; a @@ -594,6 +619,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; set CHARACTER SET koi8r; select * from t1; a @@ -611,6 +637,7 @@ Variable_name Value Qcache_hits 3 drop table t1; # On node-1 +connection node_1; create database if not exists mysqltest; create table mysqltest.t1 (i int not null) engine=innodb; create table t1 (i int not null) engine=innodb; @@ -637,6 +664,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 6 # On node-2 +connection node_2; select * from t1; i 2 @@ -660,6 +688,7 @@ Qcache_hits 5 drop database mysqltest; drop table t1; # On node-1 +connection node_1; create table t1 (i int not null) engine=innodb; insert into t1 (i) values (1),(2),(3),(4); select SQL_CALC_FOUND_ROWS * from t1 limit 2; @@ -713,6 +742,7 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 # On node-2 +connection node_2; select SQL_CALC_FOUND_ROWS * from t1 limit 2; i 1 @@ -765,9 +795,11 @@ Variable_name Value Qcache_queries_in_cache 2 drop table t1; # On node-2 +connection node_2; flush query cache; reset query cache; # On node-1 +connection node_1; flush query cache; reset query cache; create table t1 (a int not null) ENGINE=MYISAM; @@ -802,6 +834,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 9 # On node-2 +connection node_2; select * from t1; a select * from t1; @@ -830,6 +863,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 8 # On node-1 +connection node_1; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -837,6 +871,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 9 # On node-2 +connection node_2; show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 4096 @@ -847,6 +882,7 @@ show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 1000 # On node-1 +connection node_1; show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 4096 @@ -887,6 +923,7 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 # On node-2 +connection node_2; select * from t1; a 1 @@ -935,6 +972,7 @@ show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 4096 # On node-1 +connection node_1; select a from t2; a 1 @@ -957,6 +995,7 @@ show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 4096 # On node-1 +connection node_1; create table t1 (a int not null) engine=innodb; insert into t1 values (1); select "aaa" from t1; @@ -972,6 +1011,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 12 # On node-2 +connection node_2; select "aaa" from t1; aaa aaa @@ -986,6 +1026,7 @@ Variable_name Value Qcache_hits 11 drop table t1; # On node-1 +connection node_1; create table t1 (a int) engine=innodb; set GLOBAL query_cache_size=1000; Warnings: @@ -1052,6 +1093,7 @@ query_cache_size 102400 select * from t1; a # On node-2 +connection node_2; set GLOBAL query_cache_size=1000; Warnings: Warning 1292 Truncated incorrect query_cache_size value: '1000' @@ -1118,6 +1160,7 @@ select * from t1; a drop table t1; # On node-1 +connection node_1; set GLOBAL query_cache_size=1048576; create table t1 (i int not null) engine=innodb; create table t2 (i int not null) engine=innodb; @@ -1149,6 +1192,7 @@ Qcache_hits 12 update t1 set i=(select distinct 1 from (select * from t2) a); drop table t3; # On node-2 +connection node_2; set GLOBAL query_cache_size=1048576; select * from t1; i @@ -1168,6 +1212,7 @@ Variable_name Value Qcache_hits 11 drop table t1, t2; # On node-1 +connection node_1; use mysql; select * from db; show status like "Qcache_queries_in_cache"; @@ -1185,6 +1230,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 12 # On node-1 +connection node_1; create table t1(id int auto_increment primary key) engine=innodb; insert into t1 values (1), (2), (3); select * from t1; @@ -1199,6 +1245,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 12 # On node-2 +connection node_2; select * from t1; id 1 @@ -1211,6 +1258,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 11 # On node-1 +connection node_1; alter table t1 rename to t2; select * from t1; ERROR 42S02: Table 'test.t1' doesn't exist @@ -1221,6 +1269,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 12 # On node-2 +connection node_2; select * from t1; ERROR 42S02: Table 'test.t1' doesn't exist show status like "Qcache_queries_in_cache"; @@ -1231,6 +1280,7 @@ Variable_name Value Qcache_hits 11 drop table t2; # On node-1 +connection node_1; create table t1 (word char(20) not null) engine=innodb; select * from t1; word @@ -1251,6 +1301,7 @@ select count(*) from t1; count(*) 70 # On node-2 +connection node_2; select count(*) from t1; count(*) 70 @@ -1272,6 +1323,7 @@ count(*) 140 drop table t1; # On node-1 +connection node_1; create table t1 (a int) engine=innodb; insert into t1 values (1),(2),(3); show status like "Qcache_queries_in_cache"; @@ -1292,6 +1344,7 @@ Variable_name Value Qcache_hits 12 drop table t1; # On node-1 +connection node_1; create table t1 (a int) engine=innodb; insert into t1 values (1),(2); show status like "Qcache_queries_in_cache"; @@ -1316,6 +1369,7 @@ Variable_name Value Qcache_hits 12 SET SQL_SELECT_LIMIT=DEFAULT; # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -1339,6 +1393,7 @@ Qcache_hits 11 SET SQL_SELECT_LIMIT=DEFAULT; drop table t1; # On node-1 +connection node_1; create table t1 (a int not null) engine=innodb; create table t2 (a int not null) engine=innodb; set query_cache_wlock_invalidate=1; @@ -1380,6 +1435,7 @@ unlock table; drop view v1; set query_cache_wlock_invalidate=default; # On node-2 +connection node_2; set query_cache_wlock_invalidate=1; create view v1 as select * from t1; select * from t1; @@ -1420,6 +1476,7 @@ drop view v1; set query_cache_wlock_invalidate=default; drop table t1,t2; # On node-1 +connection node_1; create table t1 (id int primary key) engine=innodb; insert into t1 values (1),(2),(3); select * from t1; @@ -1433,12 +1490,10 @@ a drop table t1; drop table t1; # On node-1 +connection node_1; SET NAMES koi8r; CREATE TABLE t1 (a char(1) character set koi8r) engine=innodb; -INSERT INTO t1 VALUES (_koi8r'á'),(_koi8r'Á'); -Warnings: -Warning 1265 Data truncated for column 'a' at row 1 -Warning 1265 Data truncated for column 'a' at row 2 +INSERT INTO t1 VALUES (_koi8r 0xc3),(_koi8r 0xc3); SELECT a,'Â','â'='Â' FROM t1; a  'â'='Â'  0 @@ -1484,6 +1539,7 @@ Variable_name Value Qcache_queries_in_cache 4 SET NAMES default; # On node-2 +connection node_2; SELECT a,'Â','â'='Â' FROM t1; a  'â'='Â' ?  0 @@ -1529,6 +1585,7 @@ Variable_name Value Qcache_queries_in_cache 4 drop table t1; # On node-1 +connection node_1; create table t1 (a int) engine=innodb; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -1553,6 +1610,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 13 # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -1577,6 +1635,7 @@ Variable_name Value Qcache_hits 12 drop table t1; # On node-1 +connection node_1; set session query_cache_type = 2; create table t1(a int) engine=innodb; select table_name from information_schema.tables @@ -1614,6 +1673,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 14 # On node-2 +connection node_2; select a from t1; a select a from t1; @@ -1636,10 +1696,12 @@ Qcache_hits 13 drop table t1; # Restore original settings. # On node-1 +connection node_1; SET GLOBAL query_cache_size=@query_cache_size_saved; SET GLOBAL query_cache_type=@query_cache_type_saved; # On node-2 +connection node_2; SET GLOBAL query_cache_size=@query_cache_size_saved; SET GLOBAL query_cache_type=@query_cache_type_saved; # End of test diff --git a/mysql-test/suite/galera/t/galera_kill_applier.test b/mysql-test/suite/galera/t/galera_kill_applier.test index 6e3d7ea65d2..d04b72bce0a 100644 --- a/mysql-test/suite/galera/t/galera_kill_applier.test +++ b/mysql-test/suite/galera/t/galera_kill_applier.test @@ -6,7 +6,7 @@ --source include/have_innodb.inc --connection node_1 ---sleep 1 +--sleep 2 --let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE IS NULL LIMIT 1` --disable_query_log diff --git a/mysql-test/suite/galera/t/query_cache.test b/mysql-test/suite/galera/t/query_cache.test index 24ed8ecd077..e024b308fab 100644 --- a/mysql-test/suite/galera/t/query_cache.test +++ b/mysql-test/suite/galera/t/query_cache.test @@ -323,7 +323,7 @@ drop table t1; --echo # On node-1 --connection node_1 create table t1 (a char(1) not null collate koi8r_general_ci) engine=innodb; -insert into t1 values(_koi8r"á"); +insert into t1 values(_koi8r 0xc3); set CHARACTER SET koi8r; select * from t1; set CHARACTER SET cp1251_koi8; @@ -861,7 +861,7 @@ drop table t1; --connection node_1 SET NAMES koi8r; CREATE TABLE t1 (a char(1) character set koi8r) engine=innodb; -INSERT INTO t1 VALUES (_koi8r'á'),(_koi8r'Á'); +INSERT INTO t1 VALUES (_koi8r 0xc3),(_koi8r 0xc3); # # Run select # From 4386ee8ccc2efa7ba91061b5bd5a37bcf35f91d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 31 Aug 2017 08:20:29 +0300 Subject: [PATCH 093/101] Add ATTRIBUTE_NORETURN and ATTRIBUTE_COLD ATTRIBUTE_NORETURN is supported on all platforms (MSVS and GCC-like). It declares that a function will not return; instead, the thread or the whole process will terminate. ATTRIBUTE_COLD is supported starting with GCC 4.3. It declares that a function is supposed to be executed rarely. Rarely used error-handling functions and functions that emit messages to the error log should be tagged such. --- client/mysqltest.cc | 14 ++++++++------ include/my_compiler.h | 23 +++++++++++++++++++++++ sql/init.h | 2 +- sql/mysqld.cc | 2 +- sql/mysqld.h | 2 +- storage/innobase/fil/fil0fil.cc | 2 +- storage/innobase/fsp/fsp0fsp.cc | 6 +++--- storage/innobase/handler/handler0alter.cc | 2 +- storage/innobase/include/btr0btr.h | 2 +- storage/innobase/include/dict0dict.h | 2 +- storage/innobase/include/os0thread.h | 6 ++---- storage/innobase/include/row0log.h | 10 +++++----- storage/innobase/include/trx0undo.h | 2 +- storage/innobase/include/univ.i | 17 ----------------- storage/innobase/include/ut0dbg.h | 4 ++-- storage/innobase/include/ut0ut.h | 14 +++++++++++++- storage/innobase/os/os0thread.cc | 4 ++-- storage/innobase/rem/rem0cmp.cc | 2 +- storage/innobase/ut/ut0dbg.cc | 1 + storage/innobase/ut/ut0ut.cc | 1 + storage/maria/maria_chk.c | 2 +- 21 files changed, 70 insertions(+), 50 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index b4bd2b65276..05113f02a44 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -574,15 +574,17 @@ struct st_replace *glob_replace= 0; void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds, const char *from, int len); -static void cleanup_and_exit(int exit_code) __attribute__((noreturn)); +ATTRIBUTE_NORETURN +static void cleanup_and_exit(int exit_code); -void really_die(const char *msg) __attribute__((noreturn)); +ATTRIBUTE_NORETURN +void really_die(const char *msg); void report_or_die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); -void die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2) - __attribute__((noreturn)); +ATTRIBUTE_NORETURN ATTRIBUTE_FORMAT(printf, 1, 2) +void die(const char *fmt, ...); static void make_error_message(char *buf, size_t len, const char *fmt, va_list args); -void abort_not_supported_test(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2) - __attribute__((noreturn)); +ATTRIBUTE_NORETURN ATTRIBUTE_FORMAT(printf, 1, 2) +void abort_not_supported_test(const char *fmt, ...); void verbose_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); void log_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); diff --git a/include/my_compiler.h b/include/my_compiler.h index 000d4e42848..97e6f9ae106 100644 --- a/include/my_compiler.h +++ b/include/my_compiler.h @@ -148,6 +148,29 @@ struct my_aligned_storage #define MY_ALIGNED(size) #endif +#ifdef __GNUC__ +# define ATTRIBUTE_NORETURN __attribute__((noreturn)) +# if MY_GNUC_PREREQ(4,3) +/** Starting with GCC 4.3, the "cold" attribute is used to inform the +compiler that a function is unlikely executed. The function is +optimized for size rather than speed and on many targets it is placed +into special subsection of the text section so all cold functions +appears close together improving code locality of non-cold parts of +program. The paths leading to call of cold functions within code are +marked as unlikely by the branch prediction mechanism. optimize a +rarely invoked function for size instead for speed. */ +# define ATTRIBUTE_COLD __attribute__((cold)) +# endif +#elif defined _WIN32 +# define ATTRIBUTE_NORETURN __declspec(noreturn) +#else +# define ATTRIBUTE_NORETURN /* empty */ +#endif + +#ifndef ATTRIBUTE_COLD +# define ATTRIBUTE_COLD /* empty */ +#endif + #include #endif /* MY_COMPILER_INCLUDED */ diff --git a/sql/init.h b/sql/init.h index 88cd8e6e178..af2621e5e70 100644 --- a/sql/init.h +++ b/sql/init.h @@ -19,6 +19,6 @@ #include "my_global.h" /* ulong */ void unireg_init(ulong options); -void unireg_end(void) __attribute__((noreturn)); +ATTRIBUTE_NORETURN void unireg_end(void); #endif /* INIT_INCLUDED */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 01d65413f08..329d1492342 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1570,7 +1570,7 @@ static void close_server_sock(); static void clean_up_mutexes(void); static void wait_for_signal_thread_to_end(void); static void create_pid_file(); -static void mysqld_exit(int exit_code) __attribute__((noreturn)); +ATTRIBUTE_NORETURN static void mysqld_exit(int exit_code); #endif static void delete_pid_file(myf flags); static void end_ssl(); diff --git a/sql/mysqld.h b/sql/mysqld.h index bff2f010b93..912fe3696ae 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -708,7 +708,7 @@ enum enum_query_type /* query_id */ extern query_id_t global_query_id; -void unireg_end(void) __attribute__((noreturn)); +ATTRIBUTE_NORETURN void unireg_end(void); /* increment query_id and return it. */ inline __attribute__((warn_unused_result)) query_id_t next_query_id() diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index d34c8f91514..eaa678bba3b 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1005,7 +1005,7 @@ skip_flush: @param[in] size desired size in number of pages @param[out] success whether the operation succeeded @return whether the operation should be retried */ -static UNIV_COLD __attribute__((warn_unused_result, nonnull)) +static ATTRIBUTE_COLD __attribute__((warn_unused_result, nonnull)) bool fil_space_extend_must_retry( fil_space_t* space, diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 9f499d7ca1e..80303314d9f 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -102,7 +102,7 @@ then we will not allocate more extents @param[in,out] space tablespace @param[in,out] header tablespace header @param[in,out] mtr mini-transaction */ -static UNIV_COLD +static ATTRIBUTE_COLD void fsp_fill_free_list( bool init_space, @@ -899,7 +899,7 @@ data file. @param[in,out] header tablespace header @param[in,out] mtr mini-transaction @return true if success */ -static UNIV_COLD MY_ATTRIBUTE((warn_unused_result)) +static ATTRIBUTE_COLD __attribute__((warn_unused_result)) bool fsp_try_extend_data_file_with_pages( fil_space_t* space, @@ -932,7 +932,7 @@ fsp_try_extend_data_file_with_pages( @param[in,out] mtr mini-transaction @return number of pages added @retval 0 if the tablespace was not extended */ -UNIV_COLD MY_ATTRIBUTE((nonnull)) +ATTRIBUTE_COLD __attribute__((nonnull)) static ulint fsp_try_extend_data_file(fil_space_t* space, fsp_header_t* header, mtr_t* mtr) diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 3bcf4f710f6..1140cef8452 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -271,7 +271,7 @@ innobase_get_int_col_max_value( const Field* field); /*!< in: MySQL field */ /* Report an InnoDB error to the client by invoking my_error(). */ -static UNIV_COLD MY_ATTRIBUTE((nonnull)) +static ATTRIBUTE_COLD __attribute__((nonnull)) void my_error_innodb( /*============*/ diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index a5409c3ad4c..1d7710a1496 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -172,7 +172,7 @@ btr_corruption_report( /*==================*/ const buf_block_t* block, /*!< in: corrupted block */ const dict_index_t* index) /*!< in: index tree */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /** Assert that a B-tree page is not corrupted. @param block buffer block containing a B-tree page diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 8836e858018..04baf032ded 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -1867,7 +1867,7 @@ dict_set_corrupted( dict_index_t* index, /*!< in/out: index */ trx_t* trx, /*!< in/out: transaction */ const char* ctx) /*!< in: context */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /** Flags an index corrupted in the data dictionary cache only. This is used mostly to mark a corrupted index when index's own dictionary diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h index d4430f5ebce..c240f5dacdd 100644 --- a/storage/innobase/include/os0thread.h +++ b/storage/innobase/include/os0thread.h @@ -128,10 +128,8 @@ os_thread_join( /** Exits the current thread. @param[in] detach if true, the thread will be detached right before exiting. If false, another thread is responsible for joining this thread */ -void -os_thread_exit( - bool detach = true) - UNIV_COLD MY_ATTRIBUTE((noreturn)); +ATTRIBUTE_NORETURN ATTRIBUTE_COLD +void os_thread_exit(bool detach = true); /*****************************************************************//** Returns the thread identifier of current thread. diff --git a/storage/innobase/include/row0log.h b/storage/innobase/include/row0log.h index 980facee427..5657e09cc22 100644 --- a/storage/innobase/include/row0log.h +++ b/storage/innobase/include/row0log.h @@ -101,7 +101,7 @@ row_log_online_op( const dtuple_t* tuple, /*!< in: index tuple */ trx_id_t trx_id) /*!< in: transaction ID for insert, or 0 for delete */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /******************************************************//** Gets the error status of the online index rebuild log. @@ -137,7 +137,7 @@ row_log_table_delete( const ulint* offsets,/*!< in: rec_get_offsets(rec,index) */ const byte* sys) /*!< in: DB_TRX_ID,DB_ROLL_PTR that should be logged, or NULL to use those in rec */ - UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,3))); + ATTRIBUTE_COLD __attribute__((nonnull(1,2,3))); /******************************************************//** Logs an update operation to a table that is being rebuilt. @@ -174,7 +174,7 @@ row_log_table_get_pk( byte* sys, /*!< out: DB_TRX_ID,DB_ROLL_PTR for row_log_table_delete(), or NULL */ mem_heap_t** heap) /*!< in/out: memory heap where allocated */ - UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,5), warn_unused_result)); + ATTRIBUTE_COLD __attribute__((nonnull(1,2,5), warn_unused_result)); /******************************************************//** Logs an insert to a table that is being rebuilt. @@ -195,7 +195,7 @@ row_log_table_blob_free( /*====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /******************************************************//** Notes that a BLOB is being allocated during online ALTER TABLE. */ void @@ -203,7 +203,7 @@ row_log_table_blob_alloc( /*=====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /** Apply the row_log_table log to a table upon completing rebuild. @param[in] thr query graph diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index cdf97b6a9cf..b1d442a9acf 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -319,7 +319,7 @@ void trx_undo_free_prepared( /*===================*/ trx_t* trx) /*!< in/out: PREPARED transaction */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /* Forward declaration. */ namespace undo { diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 21ca95bacb7..e797fd7bef7 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -258,23 +258,6 @@ easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */ #endif #endif -#if defined(COMPILER_HINTS) \ - && defined __GNUC__ \ - && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3) - -/** Starting with GCC 4.3, the "cold" attribute is used to inform the -compiler that a function is unlikely executed. The function is -optimized for size rather than speed and on many targets it is placed -into special subsection of the text section so all cold functions -appears close together improving code locality of non-cold parts of -program. The paths leading to call of cold functions within code are -marked as unlikely by the branch prediction mechanism. optimize a -rarely invoked function for size instead for speed. */ -# define UNIV_COLD MY_ATTRIBUTE((cold)) -#else -# define UNIV_COLD /* empty */ -#endif - #define UNIV_INLINE static inline #define UNIV_WORD_SIZE SIZEOF_SIZE_T diff --git a/storage/innobase/include/ut0dbg.h b/storage/innobase/include/ut0dbg.h index 706579a3b9f..fd9a064ba35 100644 --- a/storage/innobase/include/ut0dbg.h +++ b/storage/innobase/include/ut0dbg.h @@ -39,13 +39,13 @@ Created 1/30/1994 Heikki Tuuri /*************************************************************//** Report a failed assertion. */ +ATTRIBUTE_NORETURN ATTRIBUTE_COLD __attribute__((nonnull(2))) void ut_dbg_assertion_failed( /*====================*/ const char* expr, /*!< in: the failed assertion */ const char* file, /*!< in: source file containing the assertion */ - unsigned line) /*!< in: line number of the assertion */ - UNIV_COLD MY_ATTRIBUTE((nonnull(2), noreturn)); + unsigned line); /*!< in: line number of the assertion */ /** Abort execution if EXPR does not evaluate to nonzero. @param EXPR assertion expression that should hold */ diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 7082d18da53..b8282b7d0de 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -299,7 +299,7 @@ void ut_print_timestamp( /*===============*/ FILE* file) /*!< in: file where to print */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); #ifndef UNIV_INNOCHECKSUM @@ -505,6 +505,7 @@ use this class directly, instead use one of the derived classes. */ class logger { public: template + ATTRIBUTE_COLD logger& operator<<(const T& rhs) { m_oss << rhs; @@ -515,6 +516,7 @@ public: @param[in] buf the buffer whose contents will be logged. @param[in] count the length of the buffer buf. @return the output stream into which buffer was written. */ + ATTRIBUTE_COLD std::ostream& write( const char* buf, @@ -527,6 +529,7 @@ public: @param[in] buf the buffer whose contents will be logged. @param[in] count the length of the buffer buf. @return the output stream into which buffer was written. */ + ATTRIBUTE_COLD std::ostream& write( const byte* buf, @@ -539,6 +542,7 @@ public: protected: /* This class must not be used directly, hence making the default constructor protected. */ + ATTRIBUTE_COLD logger() {} }; @@ -555,6 +559,7 @@ statement. If a named object is created, then the log message will be emitted only when it goes out of scope or destroyed. */ class info : public logger { public: + ATTRIBUTE_COLD ~info(); }; @@ -562,6 +567,7 @@ public: class info for further details. */ class warn : public logger { public: + ATTRIBUTE_COLD ~warn(); }; @@ -569,6 +575,7 @@ public: documentation of class info for further details. */ class error : public logger { public: + ATTRIBUTE_COLD ~error(); }; @@ -577,6 +584,7 @@ by crashing it. Use this class when MySQL server needs to be stopped immediately. Refer to the documentation of class info for usage details. */ class fatal : public logger { public: + ATTRIBUTE_NORETURN ~fatal(); }; @@ -584,10 +592,12 @@ public: warning message */ class error_or_warn : public logger { public: + ATTRIBUTE_COLD error_or_warn(bool pred) : m_error(pred) {} + ATTRIBUTE_COLD ~error_or_warn(); private: const bool m_error; @@ -597,10 +607,12 @@ private: error message. */ class fatal_or_error : public logger { public: + ATTRIBUTE_COLD fatal_or_error(bool pred) : m_fatal(pred) {} + ATTRIBUTE_COLD ~fatal_or_error(); private: const bool m_fatal; diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index fde743a9074..3986c4f4c44 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -174,9 +174,9 @@ os_thread_join( /** Exits the current thread. @param[in] detach if true, the thread will be detached right before exiting. If false, another thread is responsible for joining this thread */ +ATTRIBUTE_NORETURN void -os_thread_exit( - bool detach) +os_thread_exit(bool detach) { #ifdef UNIV_DEBUG_THREAD_CREATION ib::info() << "Thread exits, id " diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc index ffe93ac8612..7c965f791be 100644 --- a/storage/innobase/rem/rem0cmp.cc +++ b/storage/innobase/rem/rem0cmp.cc @@ -158,7 +158,7 @@ TODO: Remove this function. Everything should use MYSQL_TYPE_NEWDECIMAL. @param[in] b_length length of b, in bytes (not UNIV_SQL_NULL) @return positive, 0, negative, if a is greater, equal, less than b, respectively */ -static UNIV_COLD +static ATTRIBUTE_COLD int cmp_decimal( const byte* a, diff --git a/storage/innobase/ut/ut0dbg.cc b/storage/innobase/ut/ut0dbg.cc index fff1f0e6687..28643645de9 100644 --- a/storage/innobase/ut/ut0dbg.cc +++ b/storage/innobase/ut/ut0dbg.cc @@ -30,6 +30,7 @@ Created 1/30/1994 Heikki Tuuri /*************************************************************//** Report a failed assertion. */ +ATTRIBUTE_NORETURN void ut_dbg_assertion_failed( /*====================*/ diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index 4eb9d45b0dc..7393a24b72c 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -834,6 +834,7 @@ error::~error() sql_print_error("InnoDB: %s", m_oss.str().c_str()); } +ATTRIBUTE_NORETURN fatal::~fatal() { sql_print_error("[FATAL] InnoDB: %s", m_oss.str().c_str()); diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index 2b6f8164135..fc3d3492252 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -89,7 +89,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param, MARIA_PAGE *page, uint sortkey, File new_file, my_bool update_index); static my_bool write_log_record(HA_CHECK *param); -static void my_exit(int exit_code) __attribute__ ((noreturn)); +ATTRIBUTE_NORETURN static void my_exit(int exit_code); HA_CHECK check_param; From 38ca9be4de38a4a6688985f3f73d75a2a75665f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 31 Aug 2017 11:08:43 +0300 Subject: [PATCH 094/101] MDEV-13684 InnoDB race condition between fil_crypt_thread and btr_scrub_init There is a race condition in InnoDB startup. A number of fil_crypt_thread are created by fil_crypt_threads_init(). These threads may call btr_scrub_complete_space() before btr_scrub_init() was called. Those too early calls would be accessing an uninitialized scrub_stat_mutex. innobase_start_or_create_for_mysql(): Invoke btr_scrub_init() before fil_crypt_threads_init(). fil_crypt_complete_rotate_space(): Only invoke btr_scrub_complete_space() if scrubbing is enabled. There is no need to update the statistics if it is not enabled. --- storage/innobase/btr/btr0scrub.cc | 12 +++++------- storage/innobase/fil/fil0crypt.cc | 3 ++- storage/innobase/include/btr0scrub.h | 11 ++++------- storage/innobase/srv/srv0start.cc | 4 +--- storage/xtradb/btr/btr0scrub.cc | 12 +++++------- storage/xtradb/fil/fil0crypt.cc | 3 ++- storage/xtradb/include/btr0scrub.h | 11 ++++------- storage/xtradb/srv/srv0start.cc | 4 +--- 8 files changed, 24 insertions(+), 36 deletions(-) diff --git a/storage/innobase/btr/btr0scrub.cc b/storage/innobase/btr/btr0scrub.cc index 24c84ed301b..1b10b79838d 100644 --- a/storage/innobase/btr/btr0scrub.cc +++ b/storage/innobase/btr/btr0scrub.cc @@ -886,17 +886,15 @@ btr_scrub_update_total_stat(btr_scrub_t *scrub_data) memset(&scrub_data->scrub_stat, 0, sizeof(scrub_data->scrub_stat)); } -/**************************************************************//** -Complete iterating a space */ +/** Complete iterating a space. +@param[in,out] scrub_data scrub data */ UNIV_INTERN -bool -btr_scrub_complete_space( -/*=====================*/ - btr_scrub_t* scrub_data) /*!< in/out: scrub data */ +void +btr_scrub_complete_space(btr_scrub_t* scrub_data) { + ut_ad(scrub_data->scrubbing); btr_scrub_table_close_for_thread(scrub_data); btr_scrub_update_total_stat(scrub_data); - return scrub_data->scrubbing; } /********************************************************************* diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index a388ce4b604..25966e17e75 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -2127,7 +2127,8 @@ fil_crypt_complete_rotate_space( mutex_exit(&crypt_data->mutex); /* all threads must call btr_scrub_complete_space wo/ mutex held */ - if (btr_scrub_complete_space(&state->scrub_data) == true) { + if (state->scrub_data.scrubbing) { + btr_scrub_complete_space(&state->scrub_data); if (should_flush) { /* only last thread updates last_scrub_completed */ ut_ad(crypt_data); diff --git a/storage/innobase/include/btr0scrub.h b/storage/innobase/include/btr0scrub.h index 608266c206d..8029cc91005 100644 --- a/storage/innobase/include/btr0scrub.h +++ b/storage/innobase/include/btr0scrub.h @@ -154,13 +154,10 @@ btr_scrub_start_space( ulint space, /*!< in: space */ btr_scrub_t* scrub_data); /*!< in/out: scrub data */ -/**************************************************************** -Complete iterating a space -* @return true if space was scrubbed */ +/** Complete iterating a space. +@param[in,out] scrub_data scrub data */ UNIV_INTERN -bool -btr_scrub_complete_space( -/*=====================*/ - btr_scrub_t* scrub_data); /*!< in/out: scrub data */ +void +btr_scrub_complete_space(btr_scrub_t* scrub_data); #endif diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 0010ec9c002..db52e31881c 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -3030,12 +3030,10 @@ files_checked: /* Create thread(s) that handles key rotation */ fil_system_enter(); + btr_scrub_init(); fil_crypt_threads_init(); fil_system_exit(); - /* Init data for datafile scrub threads */ - btr_scrub_init(); - /* Initialize online defragmentation. */ btr_defragment_init(); btr_defragment_thread_active = true; diff --git a/storage/xtradb/btr/btr0scrub.cc b/storage/xtradb/btr/btr0scrub.cc index 24c84ed301b..1b10b79838d 100644 --- a/storage/xtradb/btr/btr0scrub.cc +++ b/storage/xtradb/btr/btr0scrub.cc @@ -886,17 +886,15 @@ btr_scrub_update_total_stat(btr_scrub_t *scrub_data) memset(&scrub_data->scrub_stat, 0, sizeof(scrub_data->scrub_stat)); } -/**************************************************************//** -Complete iterating a space */ +/** Complete iterating a space. +@param[in,out] scrub_data scrub data */ UNIV_INTERN -bool -btr_scrub_complete_space( -/*=====================*/ - btr_scrub_t* scrub_data) /*!< in/out: scrub data */ +void +btr_scrub_complete_space(btr_scrub_t* scrub_data) { + ut_ad(scrub_data->scrubbing); btr_scrub_table_close_for_thread(scrub_data); btr_scrub_update_total_stat(scrub_data); - return scrub_data->scrubbing; } /********************************************************************* diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index a388ce4b604..25966e17e75 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -2127,7 +2127,8 @@ fil_crypt_complete_rotate_space( mutex_exit(&crypt_data->mutex); /* all threads must call btr_scrub_complete_space wo/ mutex held */ - if (btr_scrub_complete_space(&state->scrub_data) == true) { + if (state->scrub_data.scrubbing) { + btr_scrub_complete_space(&state->scrub_data); if (should_flush) { /* only last thread updates last_scrub_completed */ ut_ad(crypt_data); diff --git a/storage/xtradb/include/btr0scrub.h b/storage/xtradb/include/btr0scrub.h index 608266c206d..8029cc91005 100644 --- a/storage/xtradb/include/btr0scrub.h +++ b/storage/xtradb/include/btr0scrub.h @@ -154,13 +154,10 @@ btr_scrub_start_space( ulint space, /*!< in: space */ btr_scrub_t* scrub_data); /*!< in/out: scrub data */ -/**************************************************************** -Complete iterating a space -* @return true if space was scrubbed */ +/** Complete iterating a space. +@param[in,out] scrub_data scrub data */ UNIV_INTERN -bool -btr_scrub_complete_space( -/*=====================*/ - btr_scrub_t* scrub_data); /*!< in/out: scrub data */ +void +btr_scrub_complete_space(btr_scrub_t* scrub_data); #endif diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index c87b7652c21..94e680d0e80 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -3146,12 +3146,10 @@ files_checked: #endif /* WITH_WSREP */ /* Create thread(s) that handles key rotation */ fil_system_enter(); + btr_scrub_init(); fil_crypt_threads_init(); fil_system_exit(); - /* Init data for datafile scrub threads */ - btr_scrub_init(); - /* Initialize online defragmentation. */ btr_defragment_init(); btr_defragment_thread_active = true; From 0e45edf35014506b891ccb030df9b21a9490a1f4 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 31 Aug 2017 11:42:41 +0300 Subject: [PATCH 095/101] MDEV-13669: Some MyRocks test take a long time Make rocksdb.bloomfilter* tests 1.8x faster by doing loading in bulk --- .../mysql-test/rocksdb/t/bloomfilter.inc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc index 6644d93cbc5..1fb9ef8a0e7 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc +++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc @@ -12,7 +12,6 @@ select case when variable_value-@c > 0 then 'true' else 'false' end as checked f END// DELIMITER ;// - #BF is sometimes invoked and useful --let $CF= --source bloomfilter_table_def.inc @@ -40,13 +39,25 @@ DELIMITER ;// # BUG: Prev() with prefix lookup should not use prefix bloom filter create table r1 (id1 bigint, id2 bigint, id3 bigint, v1 int, v2 text, primary key (id1, id2, id3)) engine=rocksdb DEFAULT CHARSET=latin1 collate latin1_bin; --disable_query_log -let $max = 100000; +let $max = 100; let $i = 1; + +create table t10(a int primary key); +insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t11(a int primary key); +insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C; + +set @a=0; +set rocksdb_bulk_load=1; while ($i <= $max) { - let $insert = INSERT INTO r1 VALUES ($i,$i,$i,$i,$i); inc $i; - eval $insert; + eval insert into r1 select @a:=@a+1, @a, @a, @a, @a from t11; } +set rocksdb_bulk_load=0; + +drop table t10, t11; + --enable_query_log call bloom_start(); select * from r1 where id1=1 and id2 in (1) order by id3 asc; From aa22981dd2bfb710240ca377d07575e5359344a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 11 May 2017 11:15:37 +0300 Subject: [PATCH 096/101] MDEV-12741: innodb.ibuf_not_empty failed in buildbot with "InnoDB: Trying to do I/O to a tablespace which does not exist" Background thread is doing ibuf merge, in buf0rea.cc buf_read_ibuf_merge_pages(). It first tries to get page_size and if space is not found it deletes them, but as we do not hold any mutexes, space can be marked as stopped between that and buf_read_page_low() for same space. This naturally leads seen error message on log. buf_read_page_low(): Add parameter ignore_missing_space = false that is passed to fil_io() buf_read_ibuf_merge_pages(): call buf_read_page_low with ignore_missing_space = true, this function will handle missing space error code after buf_read_page_low returns. fil_io(): if ignore_missing_space = true do not print error message about trying to do I/0 for missing space, just return correct error code that is handled later. --- storage/innobase/buf/buf0rea.cc | 8 +++++--- storage/innobase/fil/fil0fil.cc | 6 ++++-- storage/innobase/include/fil0fil.h | 6 ++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index f3b701816e6..3c2b697b0f4 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -105,6 +105,7 @@ flag is cleared and the x-lock released by an i/o-handler thread. @param[in] mode BUF_READ_IBUF_PAGES_ONLY, ..., @param[in] page_id page id @param[in] unzip true=request uncompressed page +@param[in] ignore_missing_space true=ignore missing space when reading @return 1 if a read request was queued, 0 if the page already resided in buf_pool, or if the page is in the doublewrite buffer blocks in which case it is never read into the pool, or if the tablespace does @@ -118,7 +119,8 @@ buf_read_page_low( ulint mode, const page_id_t& page_id, const page_size_t& page_size, - bool unzip) + bool unzip, + bool ignore_missing_space = false) { buf_page_t* bpage; @@ -178,7 +180,7 @@ buf_read_page_low( *err = fil_io( request, sync, page_id, page_size, 0, page_size.physical(), - dst, bpage); + dst, bpage, ignore_missing_space); if (sync) { thd_wait_end(NULL); @@ -847,7 +849,7 @@ tablespace_deleted: sync && (i + 1 == n_stored), 0, BUF_READ_ANY_PAGE, page_id, page_size, - true); + true, true /* ignore_missing_space */); switch(err) { case DB_SUCCESS: diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index eaa678bba3b..f34619663ad 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -5158,6 +5158,7 @@ fil_report_invalid_page_access( aligned @param[in] message message for aio handler if non-sync aio used, else ignored +@param[in] ignore_missing_space true=ignore missing space duging read @return DB_SUCCESS, DB_TABLESPACE_DELETED or DB_TABLESPACE_TRUNCATED if we are trying to do i/o on a tablespace which does not exist */ dberr_t @@ -5169,7 +5170,8 @@ fil_io( ulint byte_offset, ulint len, void* buf, - void* message) + void* message, + bool ignore_missing_space) { os_offset_t offset; IORequest req_type(type); @@ -5248,7 +5250,7 @@ fil_io( mutex_exit(&fil_system->mutex); - if (!req_type.ignore_missing()) { + if (!req_type.ignore_missing() && !ignore_missing_space) { ib::error() << "Trying to do I/O to a tablespace which" " does not exist. I/O type: " diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 204f031bce2..3b53fa28be3 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1224,7 +1224,7 @@ fil_space_get_n_reserved_extents( aligned @param[in] message message for aio handler if non-sync aio used, else ignored - +@param[in] ignore_missing_space true=ignore missing space during read @return DB_SUCCESS, DB_TABLESPACE_DELETED or DB_TABLESPACE_TRUNCATED if we are trying to do i/o on a tablespace which does not exist */ dberr_t @@ -1236,7 +1236,9 @@ fil_io( ulint byte_offset, ulint len, void* buf, - void* message); + void* message, + bool ignore_missing_space = false); + /**********************************************************************//** Waits for an aio operation to complete. This function is used to write the handler for completed requests. The aio array of pending requests is divided From e23de9f2e004bd135ccdd16afc7f2e81dbad7cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 31 Aug 2017 13:36:36 +0300 Subject: [PATCH 097/101] MDEV-13674: Deprecate innodb_use_mtflush and innodb_mtflush_threads These parameters and associated code is to be removed in 10.3. Users can use innodb-page-cleaners > 1 instead. --- .../suite/sys_vars/r/sysvars_innodb.result | 4 ++-- storage/innobase/handler/ha_innodb.cc | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 62a72525aab..b2c8ada4b27 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -2029,7 +2029,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 8 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT -VARIABLE_COMMENT Number of multi-threaded flush threads +VARIABLE_COMMENT DEPRECATED. Number of multi-threaded flush threads NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 64 NUMERIC_BLOCK_SIZE 0 @@ -3037,7 +3037,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE OFF VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Use multi-threaded flush. Default FALSE. +VARIABLE_COMMENT DEPRECATED. Use multi-threaded flush. Default FALSE. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index dba7c0b0674..6be10d77edf 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3751,6 +3751,16 @@ static const char* deprecated_instrument_semaphores = "Using innodb_instrument_semaphores is deprecated" " and the parameter will be removed in MariaDB 10.3."; +static const char* deprecated_use_mtflush + = "Using innodb_use_mtflush is deprecated" + " and the parameter will be removed in MariaDB 10.3." + " Use innodb-page-cleaners instead. "; + +static const char* deprecated_mtflush_threads + = "Using innodb_mtflush_threads is deprecated" + " and the parameter will be removed in MariaDB 10.3." + " Use innodb-page-cleaners instead. "; + static my_bool innodb_instrument_semaphores; /** Update log_checksum_algorithm_ptr with a pointer to the function @@ -4111,6 +4121,14 @@ innobase_init( ib::warn() << deprecated_instrument_semaphores; } + if (srv_use_mtflush) { + ib::warn() << deprecated_use_mtflush; + } + + if (srv_use_mtflush && srv_mtflush_threads != MTFLUSH_DEFAULT_WORKER) { + ib::warn() << deprecated_mtflush_threads; + } + /* Validate the file format by animal name */ if (innobase_file_format_name != NULL) { @@ -21615,7 +21633,7 @@ static MYSQL_SYSVAR_ENUM(compression_algorithm, innodb_compression_algorithm, static MYSQL_SYSVAR_LONG(mtflush_threads, srv_mtflush_threads, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, - "Number of multi-threaded flush threads", + "DEPRECATED. Number of multi-threaded flush threads", NULL, NULL, MTFLUSH_DEFAULT_WORKER, /* Default setting */ 1, /* Minimum setting */ @@ -21624,7 +21642,7 @@ static MYSQL_SYSVAR_LONG(mtflush_threads, srv_mtflush_threads, static MYSQL_SYSVAR_BOOL(use_mtflush, srv_use_mtflush, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, - "Use multi-threaded flush. Default FALSE.", + "DEPRECATED. Use multi-threaded flush. Default FALSE.", NULL, NULL, FALSE); static MYSQL_SYSVAR_ULONG(fatal_semaphore_wait_threshold, srv_fatal_semaphore_wait_threshold, From a9e71c77e429e5cf35bb5373a4bda41983d21002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 31 Aug 2017 14:35:35 +0300 Subject: [PATCH 098/101] Disable a badly written, randomly failing Galera test CURRENT_TEST: galera.galera_kill_applier mysqltest: At line 14: query 'KILL $applier_thread' failed with wrong errno 1064: 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1', instead of 1095... --- mysql-test/suite/galera/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 8c3c9550890..423c83208f8 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -55,3 +55,4 @@ galera_lock_table : MDEV-13549 Galera test failures 10.1 MW-284 : MDEV-13549 Galera test failures 10.1 galera_as_slave : MDEV-13549 Galera test failures 10.1 galera_var_innodb_disallow_writes : MDEV-10949 +galera_kill_applier : race condition at the start of the test From 66eb9774e43dc96e7d45d800b4860354f81d258d Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 31 Aug 2017 12:33:46 +0000 Subject: [PATCH 099/101] MDEV-13691 : my_write() sets inappropriate errno for ERROR_FILE_SYSTEM_LIMITATON ERROR_FILE_SYSTEM_LIMITATION was seen by support when backing up large file. However mariabackup error message was not very helpful, since it mapped the error to generic catch-all EINVAL. With the patch, ERROR_FILE_SYSTEM_LIMITATION will be mapped to more appropriate EFBIG. Also add mapping from ERROR_NO_SYSTEM_RESOURCES to ENOMEM. --- mysys/my_winerr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysys/my_winerr.c b/mysys/my_winerr.c index 15f52dd7f37..9577db09eaf 100644 --- a/mysys/my_winerr.c +++ b/mysys/my_winerr.c @@ -75,7 +75,9 @@ static struct errentry errtable[]= { { ERROR_ALREADY_EXISTS, EEXIST }, /* 183 */ { ERROR_FILENAME_EXCED_RANGE, ENOENT }, /* 206 */ { ERROR_NESTING_NOT_ALLOWED, EAGAIN }, /* 215 */ - { ERROR_NOT_ENOUGH_QUOTA, ENOMEM } /* 1816 */ + { ERROR_FILE_SYSTEM_LIMITATION, EFBIG }, /* 665 */ + { ERROR_NO_SYSTEM_RESOURCES, ENOMEM }, /* 1450 */ + { ERROR_NOT_ENOUGH_QUOTA, ENOMEM } /* 1816 */ }; /* size of the table */ From 6be93c3b8a1d8c080d73750e3804752ad80f56d1 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 31 Aug 2017 14:50:45 +0000 Subject: [PATCH 100/101] MDEV-13693 : Fix parameter passing to my_error. char* parameter is expected by the message ER_KEY_COLUMN_DOES_NOT_EXITS, thus pass char*, rather than LEX_STRING. --- sql/sql_class.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index da1a0e43ac1..eedda8579e7 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -230,7 +230,7 @@ bool Foreign_key::validate(List &table_fields) sql_field->field_name)) {} if (!sql_field) { - my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name); + my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str); DBUG_RETURN(TRUE); } if (type == Key::FOREIGN_KEY && sql_field->vcol_info) From 1b41a54fc98dab0e05523c36b53bd62d7e7f28b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 1 Sep 2017 08:38:19 +0300 Subject: [PATCH 101/101] Fix test for MDEV-13674: Deprecate innodb_use_mtflush and innodb_mtflush_threads --- mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff index 44bb824432b..3122f0a5711 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff @@ -480,7 +480,7 @@ VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT +VARIABLE_TYPE INT - VARIABLE_COMMENT Number of multi-threaded flush threads + VARIABLE_COMMENT DEPRECATED. Number of multi-threaded flush threads NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 64 @@ -2084,10 +2084,10 @@