diff options
Diffstat (limited to 'storage/xtradb/include')
26 files changed, 256 insertions, 230 deletions
diff --git a/storage/xtradb/include/buf0buf.ic b/storage/xtradb/include/buf0buf.ic index f7e51231471..7b1c66f2a05 100644 --- a/storage/xtradb/include/buf0buf.ic +++ b/storage/xtradb/include/buf0buf.ic @@ -305,6 +305,20 @@ buf_page_set_state( ut_a(state == BUF_BLOCK_NOT_USED); break; case BUF_BLOCK_FILE_PAGE: + if (!(state == BUF_BLOCK_NOT_USED + || state == BUF_BLOCK_REMOVE_HASH)) { + const char *old_state_name = buf_get_state_name((buf_block_t*)bpage); + bpage->state = state; + + fprintf(stderr, + "InnoDB: Error: block old state %d (%s) " + " new state %d (%s) not correct\n", + old_state, + old_state_name, + state, + buf_get_state_name((buf_block_t*)bpage)); + } + ut_a(state == BUF_BLOCK_NOT_USED || state == BUF_BLOCK_REMOVE_HASH); break; diff --git a/storage/xtradb/include/buf0flu.h b/storage/xtradb/include/buf0flu.h index 87ce7d88bdf..c8a329251fa 100644 --- a/storage/xtradb/include/buf0flu.h +++ b/storage/xtradb/include/buf0flu.h @@ -312,6 +312,12 @@ buf_flush_flush_list_in_progress(void) /*==================================*/ __attribute__((warn_unused_result)); +/** If LRU list of a buf_pool is less than this size then LRU eviction +should not happen. This is because when we do LRU flushing we also put +the blocks on free list. If LRU list is very small then we can end up +in thrashing. */ +#define BUF_LRU_MIN_LEN 256 + /******************************************************************//** Start a buffer flush batch for LRU or flush list */ ibool diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h index 9c43829cecf..a55d5316969 100644 --- a/storage/xtradb/include/dict0mem.h +++ b/storage/xtradb/include/dict0mem.h @@ -2,7 +2,7 @@ Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2015, MariaDB Corporation. +Copyright (c) 2013, 2016, 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 @@ -1025,6 +1025,18 @@ if table->memcached_sync_count == DICT_TABLE_IN_DDL means there's DDL running on the table, DML from memcached will be blocked. */ #define DICT_TABLE_IN_DDL -1 +/** These are used when MySQL FRM and InnoDB data dictionary are +in inconsistent state. */ +typedef enum { + DICT_FRM_CONSISTENT = 0, /*!< Consistent state */ + DICT_FRM_NO_PK = 1, /*!< MySQL has no primary key + but InnoDB dictionary has + non-generated one. */ + DICT_NO_PK_FRM_HAS = 2, /*!< MySQL has primary key but + InnoDB dictionary has not. */ + DICT_FRM_INCONSISTENT_KEYS = 3 /*!< Key count mismatch */ +} dict_frm_t; + /** Data structure for a database table. Most fields will be initialized to 0, NULL or FALSE in dict_mem_table_create(). */ struct dict_table_t{ @@ -1085,6 +1097,10 @@ struct dict_table_t{ /*!< True if the table belongs to a system database (mysql, information_schema or performance_schema) */ + dict_frm_t dict_frm_mismatch; + /*!< !DICT_FRM_CONSISTENT==0 if data + dictionary information and + MySQL FRM information mismatch. */ #ifndef UNIV_HOTBACKUP hash_node_t name_hash; /*!< hash chain node */ hash_node_t id_hash; /*!< hash chain node */ diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index 973882a50b4..fb9c79a3e5a 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -1281,11 +1281,6 @@ fil_system_hash_nodes(void); /************************************************************************* functions to access is_corrupt flag of fil_space_t*/ -ibool -fil_space_is_corrupt( -/*=================*/ - ulint space_id); - void fil_space_set_corrupt( /*==================*/ diff --git a/storage/xtradb/include/fil0pagecompress.h b/storage/xtradb/include/fil0pagecompress.h index 8316083d52d..99a05f14ffe 100644 --- a/storage/xtradb/include/fil0pagecompress.h +++ b/storage/xtradb/include/fil0pagecompress.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2015 MariaDB Corporation. All Rights Reserved. +Copyright (C) 2013, 2016 MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -117,8 +117,12 @@ fil_decompress_page( byte* buf, /*!< out: buffer from which to read; in aio this must be appropriately aligned */ ulong len, /*!< in: length of output buffer.*/ - ulint* write_size); /*!< in/out: Actual payload size of + ulint* write_size, /*!< in/out: Actual payload size of the compressed data. */ + bool return_error=false); + /*!< in: true if only an error should + be produced when decompression fails. + By default this parameter is false. */ /****************************************************************//** Get space id from fil node diff --git a/storage/xtradb/include/fsp0fsp.h b/storage/xtradb/include/fsp0fsp.h index 8fdacc51277..839aed80418 100644 --- a/storage/xtradb/include/fsp0fsp.h +++ b/storage/xtradb/include/fsp0fsp.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, SkySQL Ab. All Rights Reserved. +Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -99,6 +99,9 @@ dictionary */ /** Zero relative shift position of the start of the DATA DIR bits */ #define FSP_FLAGS_POS_DATA_DIR (FSP_FLAGS_POS_PAGE_SSIZE \ + FSP_FLAGS_WIDTH_PAGE_SSIZE) +#define FSP_FLAGS_POS_DATA_DIR_ORACLE (FSP_FLAGS_POS_ATOMIC_BLOBS \ + + FSP_FLAGS_WIDTH_ATOMIC_BLOBS \ + + FSP_FLAGS_WIDTH_PAGE_SSIZE) /** Zero relative shift position of the start of the UNUSED bits */ #define FSP_FLAGS_POS_UNUSED (FSP_FLAGS_POS_DATA_DIR\ + FSP_FLAGS_WIDTH_DATA_DIR) @@ -123,6 +126,10 @@ dictionary */ #define FSP_FLAGS_MASK_DATA_DIR \ ((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \ << FSP_FLAGS_POS_DATA_DIR) +/** Bit mask of the DATA_DIR field */ +#define FSP_FLAGS_MASK_DATA_DIR_ORACLE \ + ((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \ + << FSP_FLAGS_POS_DATA_DIR_ORACLE) /** Bit mask of the PAGE_COMPRESSION field */ #define FSP_FLAGS_MASK_PAGE_COMPRESSION \ ((~(~0 << FSP_FLAGS_WIDTH_PAGE_COMPRESSION)) \ @@ -156,6 +163,9 @@ dictionary */ #define FSP_FLAGS_HAS_DATA_DIR(flags) \ ((flags & FSP_FLAGS_MASK_DATA_DIR) \ >> FSP_FLAGS_POS_DATA_DIR) +#define FSP_FLAGS_HAS_DATA_DIR_ORACLE(flags) \ + ((flags & FSP_FLAGS_MASK_DATA_DIR_ORACLE) \ + >> FSP_FLAGS_POS_DATA_DIR_ORACLE) /** Return the contents of the UNUSED bits */ #define FSP_FLAGS_GET_UNUSED(flags) \ (flags >> FSP_FLAGS_POS_UNUSED) diff --git a/storage/xtradb/include/fts0fts.h b/storage/xtradb/include/fts0fts.h index d54ed281d9a..9f7b0216d9b 100644 --- a/storage/xtradb/include/fts0fts.h +++ b/storage/xtradb/include/fts0fts.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -724,6 +724,13 @@ fts_optimize_remove_table( /*======================*/ dict_table_t* table); /*!< in: table to remove */ +/** Send sync fts cache for the table. +@param[in] table table to sync */ +UNIV_INTERN +void +fts_optimize_request_sync_table( + dict_table_t* table); + /**********************************************************************//** Signal the optimize thread to prepare for shutdown. */ UNIV_INTERN @@ -826,15 +833,18 @@ fts_drop_index_split_tables( dict_index_t* index) /*!< in: fts instance */ __attribute__((nonnull, warn_unused_result)); -/****************************************************************//** -Run SYNC on the table, i.e., write out data from the cache to the -FTS auxiliary INDEX table and clear the cache at the end. */ +/** Run SYNC on the table, i.e., write out data from the cache to the +FTS auxiliary INDEX table and clear the cache at the end. +@param[in,out] table fts table +@param[in] unlock_cache whether unlock cache when write node +@param[in] wait whether wait for existing sync to finish +@return DB_SUCCESS on success, error code on failure. */ UNIV_INTERN dberr_t fts_sync_table( -/*===========*/ - dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + dict_table_t* table, + bool unlock_cache, + bool wait); /****************************************************************//** Free the query graph but check whether dict_sys->mutex is already diff --git a/storage/xtradb/include/fts0types.h b/storage/xtradb/include/fts0types.h index 64677428331..e495fe72a60 100644 --- a/storage/xtradb/include/fts0types.h +++ b/storage/xtradb/include/fts0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -122,7 +122,11 @@ struct fts_sync_t { doc_id_t max_doc_id; /*!< The doc id at which the cache was noted as being full, we use this to set the upper_limit field */ - ib_time_t start_time; /*!< SYNC start time */ + ib_time_t start_time; /*!< SYNC start time */ + bool in_progress; /*!< flag whether sync is in progress.*/ + bool unlock_cache; /*!< flag whether unlock cache when + write fts node */ + os_event_t event; /*!< sync finish event */ }; /** The cache for the FTS system. It is a memory-based inverted index @@ -165,7 +169,6 @@ struct fts_cache_t { objects, they are recreated after a SYNC is completed */ - ib_alloc_t* self_heap; /*!< This heap is the heap out of which an instance of the cache itself was created. Objects created using @@ -212,6 +215,7 @@ struct fts_node_t { ulint ilist_size_alloc; /*!< Allocated size of ilist in bytes */ + bool synced; /*!< flag whether the node is synced */ }; /** A tokenizer word. Contains information about one word. */ diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h index a9c003d5bb1..077c00d8eb0 100644 --- a/storage/xtradb/include/ha_prototypes.h +++ b/storage/xtradb/include/ha_prototypes.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -295,8 +295,10 @@ innobase_casedn_str( #ifdef WITH_WSREP UNIV_INTERN int -wsrep_innobase_kill_one_trx(void *thd_ptr, - const trx_t *bf_trx, trx_t *victim_trx, ibool signal); +wsrep_innobase_kill_one_trx(void * const thd_ptr, + const trx_t * const bf_trx, + trx_t *victim_trx, + ibool signal); int wsrep_innobase_mysql_sort(int mysql_type, uint charset_number, unsigned char* str, unsigned int str_length, unsigned int buf_length); @@ -356,6 +358,15 @@ thd_supports_xa( THD* thd); /*!< in: thread handle, or NULL to query the global innodb_supports_xa */ +/** Get status of innodb_tmpdir. +@param[in] thd thread handle, or NULL to query + the global innodb_tmpdir. +@retval NULL if innodb_tmpdir="" */ +UNIV_INTERN +const char* +thd_innodb_tmpdir( + THD* thd); + /******************************************************************//** Check the status of fake changes mode (innodb_fake_changes) @return true if fake change mode is enabled. */ diff --git a/storage/xtradb/include/log0log.h b/storage/xtradb/include/log0log.h index 4ebda650ca0..f5655e98a13 100644 --- a/storage/xtradb/include/log0log.h +++ b/storage/xtradb/include/log0log.h @@ -352,17 +352,6 @@ log_archive_do( ulint* n_bytes);/*!< out: archive log buffer size, 0 if nothing to archive */ /****************************************************************//** -Writes the log contents to the archive up to the lsn when this function was -called, and stops the archiving. When archiving is started again, the archived -log file numbers start from a number one higher, so that the archiving will -not write again to the archived log files which exist when this function -returns. -@return DB_SUCCESS or DB_ERROR */ -UNIV_INTERN -ulint -log_archive_stop(void); -/*==================*/ -/****************************************************************//** Starts again archiving which has been stopped. @return DB_SUCCESS or DB_ERROR */ UNIV_INTERN @@ -624,25 +613,14 @@ log_mem_free(void); /*==============*/ /****************************************************************//** -Safely reads the log_sys->tracked_lsn value. Uses atomic operations -if available, otherwise this field is protected with the log system -mutex. The writer counterpart function is log_set_tracked_lsn() in -log0online.c. +Safely reads the log_sys->tracked_lsn value. The writer counterpart function +is log_set_tracked_lsn() in log0online.c. @return log_sys->tracked_lsn value. */ UNIV_INLINE lsn_t log_get_tracked_lsn(void); /*=====================*/ -/****************************************************************//** -Unsafely reads the log_sys->tracked_lsn value. Uses atomic operations -if available, or use dirty read. Use for printing only. - -@return log_sys->tracked_lsn value. */ -UNIV_INLINE -lsn_t -log_get_tracked_lsn_peek(void); -/*==========================*/ extern log_t* log_sys; @@ -951,7 +929,7 @@ struct log_t{ pending flushes or writes */ /* NOTE on the 'flush' in names of the fields below: starting from 4.0.14, we separate the write of the log file and the actual fsync() - or other method to flush it to disk. The names below shhould really + or other method to flush it to disk. The names below should really be 'flush_or_write'! */ os_event_t no_flush_event; /*!< this event is in the reset state when a flush or a write is running; diff --git a/storage/xtradb/include/log0log.ic b/storage/xtradb/include/log0log.ic index ff5a83be249..70458fa546b 100644 --- a/storage/xtradb/include/log0log.ic +++ b/storage/xtradb/include/log0log.ic @@ -553,37 +553,15 @@ log_free_check(void) #endif /* !UNIV_HOTBACKUP */ /****************************************************************//** -Unsafely reads the log_sys->tracked_lsn value. Uses atomic operations -if available, or use dirty read. Use for printing only. +Safely reads the log_sys->tracked_lsn value. The writer counterpart function +is log_set_tracked_lsn() in log0online.c. @return log_sys->tracked_lsn value. */ UNIV_INLINE lsn_t -log_get_tracked_lsn_peek(void) -/*==========================*/ -{ -#ifdef HAVE_ATOMIC_BUILTINS_64 - return os_atomic_increment_uint64(&log_sys->tracked_lsn, 0); -#else - return log_sys->tracked_lsn; -#endif -} - -/****************************************************************//** -Safely reads the log_sys->tracked_lsn value. Uses atomic operations -if available, otherwise this field is protected with the log system -mutex. The writer counterpart function is log_set_tracked_lsn() in -log0online.c. -@return log_sys->tracked_lsn value. */ -UNIV_INLINE -lsn_t log_get_tracked_lsn(void) /*=====================*/ { -#ifdef HAVE_ATOMIC_BUILTINS_64 - return os_atomic_increment_uint64(&log_sys->tracked_lsn, 0); -#else - ut_ad(mutex_own(&(log_sys->mutex))); + os_rmb; return log_sys->tracked_lsn; -#endif } diff --git a/storage/xtradb/include/log0online.h b/storage/xtradb/include/log0online.h index 1ef4df7d6da..67dc0d72b4b 100644 --- a/storage/xtradb/include/log0online.h +++ b/storage/xtradb/include/log0online.h @@ -73,20 +73,7 @@ UNIV_INTERN ibool log_online_purge_changed_page_bitmaps( /*==================================*/ - ib_uint64_t lsn); /*!<in: LSN to purge files up to */ - -/************************************************************//** -Delete all the bitmap files for data less than the specified LSN. -If called with lsn == 0 (i.e. set by RESET request) or -IB_ULONGLONG_MAX, restart the bitmap file sequence, otherwise -continue it. - -@return FALSE to indicate success, TRUE for failure. */ -UNIV_INTERN -ibool -log_online_purge_changed_page_bitmaps( -/*==================================*/ - ib_uint64_t lsn); /*!<in: LSN to purge files up to */ + lsn_t lsn); /*!<in: LSN to purge files up to */ #define LOG_BITMAP_ITERATOR_START_LSN(i) \ ((i).start_lsn) diff --git a/storage/xtradb/include/log0recv.h b/storage/xtradb/include/log0recv.h index 8fc5daaef1d..1019f43f70c 100644 --- a/storage/xtradb/include/log0recv.h +++ b/storage/xtradb/include/log0recv.h @@ -101,15 +101,6 @@ UNIV_INLINE ibool recv_recovery_is_on(void); /*=====================*/ -#ifdef UNIV_LOG_ARCHIVE -/*******************************************************************//** -Returns TRUE if recovery from backup is currently running. -@return recv_recovery_from_backup_on */ -UNIV_INLINE -ibool -recv_recovery_from_backup_is_on(void); -/*=================================*/ -#endif /* UNIV_LOG_ARCHIVE */ /************************************************************************//** Applies the hashed log records to the page, if the page lsn is less than the lsn of a log record. This can be called when a buffer page has just been @@ -331,30 +322,6 @@ void recv_apply_log_recs_for_backup(void); /*================================*/ #endif -#ifdef UNIV_LOG_ARCHIVE -/********************************************************//** -Recovers from archived log files, and also from log files, if they exist. -@return error code or DB_SUCCESS */ -UNIV_INTERN -dberr_t -recv_recovery_from_archive_start( -/*=============================*/ - lsn_t min_flushed_lsn,/*!< in: min flushed lsn field from the - data files */ - lsn_t limit_lsn, /*!< in: recover up to this lsn if - possible */ - lsn_t first_log_no); /*!< in: number of the first archived - log file to use in the recovery; the - file will be searched from - INNOBASE_LOG_ARCH_DIR specified in - server config file */ -/********************************************************//** -Completes recovery from archive. */ -UNIV_INTERN -void -recv_recovery_from_archive_finish(void); -/*===================================*/ -#endif /* UNIV_LOG_ARCHIVE */ /** Block of log record data */ struct recv_data_t{ diff --git a/storage/xtradb/include/log0recv.ic b/storage/xtradb/include/log0recv.ic index 32c28dd03e6..b29272f4672 100644 --- a/storage/xtradb/include/log0recv.ic +++ b/storage/xtradb/include/log0recv.ic @@ -35,19 +35,3 @@ recv_recovery_is_on(void) { return(recv_recovery_on); } - -#ifdef UNIV_LOG_ARCHIVE -/** TRUE when applying redo log records from an archived log file */ -extern ibool recv_recovery_from_backup_on; - -/*******************************************************************//** -Returns TRUE if recovery from backup is currently running. -@return recv_recovery_from_backup_on */ -UNIV_INLINE -ibool -recv_recovery_from_backup_is_on(void) -/*=================================*/ -{ - return(recv_recovery_from_backup_on); -} -#endif /* UNIV_LOG_ARCHIVE */ diff --git a/storage/xtradb/include/os0file.h b/storage/xtradb/include/os0file.h index c15d896caa6..453536beba4 100644 --- a/storage/xtradb/include/os0file.h +++ b/storage/xtradb/include/os0file.h @@ -451,20 +451,19 @@ os_get_os_version(void); /*===================*/ #endif /* __WIN__ */ #ifndef UNIV_HOTBACKUP -/****************************************************************//** -Creates the seek mutexes used in positioned reads and writes. */ -UNIV_INTERN -void -os_io_init_simple(void); -/*===================*/ -/***********************************************************************//** -Creates a temporary file. This function is like tmpfile(3), but -the temporary file is created in the MySQL temporary directory. -@return temporary file handle, or NULL on error */ + +/** Create a temporary file. This function is like tmpfile(3), but +the temporary file is created in the given parameter path. If the path +is null then it will create the file in the mysql server configuration +parameter (--tmpdir). +@param[in] path location for creating temporary file +@return temporary file handle, or NULL on error */ +UNIV_INTERN FILE* -os_file_create_tmpfile(void); -/*========================*/ +os_file_create_tmpfile( + const char* path); + #endif /* !UNIV_HOTBACKUP */ /***********************************************************************//** The os_file_opendir() function opens a directory stream corresponding to the @@ -1314,14 +1313,14 @@ os_file_get_status( file can be opened in RW mode */ #if !defined(UNIV_HOTBACKUP) -/*********************************************************************//** -Creates a temporary file that will be deleted on close. -This function is defined in ha_innodb.cc. -@return temporary file descriptor, or < 0 on error */ +/** Create a temporary file in the location specified by the parameter +path. If the path is null, then it will be created in tmpdir. +@param[in] path location for creating temporary file +@return temporary file descriptor, or < 0 on error */ UNIV_INTERN int -innobase_mysql_tmpfile(void); -/*========================*/ +innobase_mysql_tmpfile( + const char* path); #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/xtradb/include/os0sync.h b/storage/xtradb/include/os0sync.h index db996b096bb..0f93f3ff074 100644 --- a/storage/xtradb/include/os0sync.h +++ b/storage/xtradb/include/os0sync.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -42,7 +42,6 @@ Created 9/6/1995 Heikki Tuuri || defined _M_X64 || defined __WIN__ #define IB_STRONG_MEMORY_MODEL -#undef HAVE_IB_GCC_ATOMIC_TEST_AND_SET // Quick-and-dirty fix for bug 1519094 #endif /* __i386__ || __x86_64__ || _M_IX86 || _M_X64 || __WIN__ */ @@ -94,16 +93,62 @@ struct os_event { #endif os_fast_mutex_t os_mutex; /*!< this mutex protects the next fields */ - ibool is_set; /*!< this is TRUE when the event is - in the signaled state, i.e., a thread - does not stop if it tries to wait for - this event */ - ib_int64_t signal_count; /*!< this is incremented each time - the event becomes signaled */ +private: + /** Masks for the event signal count and set flag in the count_and_set + field */ + static const ib_uint64_t count_mask = 0x7fffffffffffffffULL; + static const ib_uint64_t set_mask = 0x8000000000000000ULL; + + /** The MSB is set whenever when the event is in the signaled state, + i.e. a thread does not stop if it tries to wait for this event. Lower + bits are incremented each time the event becomes signaled. */ + ib_uint64_t count_and_set; +public: os_cond_t cond_var; /*!< condition variable is used in waiting for the event */ - UT_LIST_NODE_T(os_event_t) os_event_list; - /*!< list of all created events */ + + /** Initialise count_and_set field */ + void init_count_and_set(void) + { + /* We return this value in os_event_reset(), which can then be + be used to pass to the os_event_wait_low(). The value of zero + is reserved in os_event_wait_low() for the case when the + caller does not want to pass any signal_count value. To + distinguish between the two cases we initialize signal_count + to 1 here. */ + count_and_set = 1; + } + + /** Mark this event as set */ + void set(void) + { + count_and_set |= set_mask; + } + + /** Unmark this event as set */ + void reset(void) + { + count_and_set &= count_mask; + } + + /** Return true if this event is set */ + bool is_set(void) const + { + return count_and_set & set_mask; + } + + /** Bump signal count for this event */ + void inc_signal_count(void) + { + ut_ad(static_cast<ib_uint64_t>(signal_count()) < count_mask); + count_and_set++; + } + + /** Return how many times this event has been signalled */ + ib_int64_t signal_count(void) const + { + return (count_and_set & count_mask); + } }; /** Denotes an infinite delay for os_event_wait_time() */ @@ -115,8 +160,7 @@ struct os_event { /** Operating system mutex handle */ typedef struct os_mutex_t* os_ib_mutex_t; -/** Mutex protecting counts and the event and OS 'slow' mutex lists */ -extern os_ib_mutex_t os_sync_mutex; +// All the os_*_count variables are accessed atomically /** This is incremented by 1 in os_thread_create and decremented by 1 in os_thread_exit */ @@ -132,12 +176,15 @@ UNIV_INTERN void os_sync_init(void); /*==============*/ -/*********************************************************//** -Frees created events and OS 'slow' mutexes. */ + +/** Create an event semaphore, i.e., a semaphore which may just have two +states: signaled and nonsignaled. The created event is manual reset: it must be +reset explicitly by calling sync_os_reset_event. +@param[in,out] event memory block where to create the event */ UNIV_INTERN void -os_sync_free(void); -/*==============*/ +os_event_create(os_event_t event); + /*********************************************************//** Creates an event semaphore, i.e., a semaphore which may just have two states: signaled and nonsignaled. The created event is manual reset: it must be reset @@ -173,7 +220,10 @@ UNIV_INTERN void os_event_free( /*==========*/ - os_event_t event); /*!< in: event to free */ + os_event_t event, /*!< in: event to free */ + bool free_memory = true); + /*!< in: if true, deallocate the event memory + block too */ /**********************************************************//** Waits for an event object until it is in the signaled state. @@ -467,28 +517,7 @@ amount to decrement. */ # define os_atomic_decrement_uint64(ptr, amount) \ os_atomic_decrement(ptr, amount) -# if defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET) - -/** Do an atomic test-and-set. -@param[in,out] ptr Memory location to set to non-zero -@return the previous value */ -inline -lock_word_t -os_atomic_test_and_set(volatile lock_word_t* ptr) -{ - return(__atomic_test_and_set(ptr, __ATOMIC_ACQUIRE)); -} - -/** Do an atomic clear. -@param[in,out] ptr Memory location to set to zero */ -inline -void -os_atomic_clear(volatile lock_word_t* ptr) -{ - __atomic_clear(ptr, __ATOMIC_RELEASE); -} - -# elif defined(HAVE_ATOMIC_BUILTINS) +# if defined(HAVE_ATOMIC_BUILTINS) /** Do an atomic test and set. @param[in,out] ptr Memory location to set to non-zero @@ -517,6 +546,27 @@ os_atomic_clear(volatile lock_word_t* ptr) return(__sync_lock_test_and_set(ptr, 0)); } +# elif defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET) + +/** Do an atomic test-and-set. +@param[in,out] ptr Memory location to set to non-zero +@return the previous value */ +inline +lock_word_t +os_atomic_test_and_set(volatile lock_word_t* ptr) +{ + return(__atomic_test_and_set(ptr, __ATOMIC_ACQUIRE)); +} + +/** Do an atomic clear. +@param[in,out] ptr Memory location to set to zero */ +inline +void +os_atomic_clear(volatile lock_word_t* ptr) +{ + __atomic_clear(ptr, __ATOMIC_RELEASE); +} + # else # error "Unsupported platform" diff --git a/storage/xtradb/include/row0log.h b/storage/xtradb/include/row0log.h index f105838eece..e127504c484 100644 --- a/storage/xtradb/include/row0log.h +++ b/storage/xtradb/include/row0log.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -55,8 +55,9 @@ row_log_allocate( const dtuple_t* add_cols, /*!< in: default values of added columns, or NULL */ - const ulint* col_map)/*!< in: mapping of old column + const ulint* col_map,/*!< in: mapping of old column numbers to new ones, or NULL if !table */ + const char* path) /*!< in: where to create temporary file */ __attribute__((nonnull(1), warn_unused_result)); /******************************************************//** diff --git a/storage/xtradb/include/row0merge.h b/storage/xtradb/include/row0merge.h index 3e3459b8703..53164b5197f 100644 --- a/storage/xtradb/include/row0merge.h +++ b/storage/xtradb/include/row0merge.h @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 2005, 2014, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, MariaDB Corporation. +Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2016, 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 @@ -187,14 +187,14 @@ void row_merge_drop_temp_indexes(void); /*=============================*/ -/*********************************************************************//** -Creates temporary merge files, and if UNIV_PFS_IO defined, register -the file descriptor with Performance Schema. +/** Create temporary merge files in the given paramater path, and if +UNIV_PFS_IO defined, register the file descriptor with Performance Schema. +@param[in] path location for creating temporary merge files. @return File descriptor */ UNIV_INTERN int -row_merge_file_create_low(void) -/*===========================*/ +row_merge_file_create_low( + const char* path) __attribute__((warn_unused_result)); /*********************************************************************//** Destroy a merge file. And de-register the file from Performance Schema @@ -372,15 +372,17 @@ row_merge_buf_empty( /*================*/ row_merge_buf_t* buf) /*!< in,own: sort buffer */ __attribute__((warn_unused_result, nonnull)); -/*********************************************************************//** -Create a merge file. + +/** Create a merge file in the given location. +@param[out] merge_file merge file structure +@param[in] path location for creating temporary file @return file descriptor, or -1 on failure */ UNIV_INTERN int row_merge_file_create( -/*==================*/ - merge_file_t* merge_file) /*!< out: merge file structure */ - __attribute__((nonnull)); + merge_file_t* merge_file, + const char* path); + /*********************************************************************//** Merge disk files. @return DB_SUCCESS or error code */ diff --git a/storage/xtradb/include/row0mysql.h b/storage/xtradb/include/row0mysql.h index a0ff6cdad15..e6a201be7a5 100644 --- a/storage/xtradb/include/row0mysql.h +++ b/storage/xtradb/include/row0mysql.h @@ -491,6 +491,9 @@ row_drop_table_for_mysql( const char* name, /*!< in: table name */ trx_t* trx, /*!< in: dictionary transaction handle */ bool drop_db,/*!< in: true=dropping whole database */ + ibool create_failed,/*!<in: TRUE=create table failed + because e.g. foreign key column + type mismatch. */ bool nonatomic = true) /*!< in: whether it is permitted to release and reacquire dict_operation_lock */ diff --git a/storage/xtradb/include/srv0srv.h b/storage/xtradb/include/srv0srv.h index 4a3a2da733f..018852a7f92 100644 --- a/storage/xtradb/include/srv0srv.h +++ b/storage/xtradb/include/srv0srv.h @@ -477,8 +477,6 @@ extern ulong srv_innodb_stats_method; #ifdef UNIV_LOG_ARCHIVE extern ibool srv_log_archive_on; -extern ibool srv_archive_recovery; -extern ib_uint64_t srv_archive_recovery_limit_lsn; #endif /* UNIV_LOG_ARCHIVE */ extern char* srv_file_flush_method_str; @@ -951,19 +949,29 @@ ulint srv_get_activity_count(void); /*========================*/ /*******************************************************************//** -Check if there has been any activity. +Check if there has been any activity. Considers background change buffer +merge as regular server activity unless a non-default +old_ibuf_merge_activity_count value is passed, in which case the merge will be +treated as keeping server idle. @return FALSE if no change in activity counter. */ UNIV_INTERN ibool srv_check_activity( /*===============*/ - ulint old_activity_count); /*!< old activity count */ + ulint old_activity_count, /*!< old activity count */ + /*!< old change buffer merge + activity count, or + ULINT_UNDEFINED */ + ulint old_ibuf_merge_activity_count = ULINT_UNDEFINED); /******************************************************************//** Increment the server activity counter. */ UNIV_INTERN void -srv_inc_activity_count(void); -/*=========================*/ +srv_inc_activity_count( +/*===================*/ + bool ibuf_merge_activity = false); /*!< whether this activity bump + is caused by the background + change buffer merge */ /**********************************************************************//** Enqueues a task to server task queue and releases a worker thread, if there diff --git a/storage/xtradb/include/sync0rw.h b/storage/xtradb/include/sync0rw.h index d59613e0abb..cef2008c4ea 100644 --- a/storage/xtradb/include/sync0rw.h +++ b/storage/xtradb/include/sync0rw.h @@ -734,8 +734,8 @@ struct rw_lock_t { /*!< Thread id of writer thread. Is only guaranteed to have sane and non-stale value iff recursive flag is set. */ - os_event_t event; /*!< Used by sync0arr.cc for thread queueing */ - os_event_t wait_ex_event; + struct os_event event; /*!< Used by sync0arr.cc for thread queueing */ + struct os_event wait_ex_event; /*!< Event for next-writer to wait on. A thread must decrement lock_word before waiting. */ #ifndef INNODB_RW_LOCKS_USE_ATOMICS @@ -788,12 +788,12 @@ struct prio_rw_lock_t { volatile ulint high_priority_s_waiters; /* Number of high priority S waiters */ - os_event_t high_priority_s_event; /* High priority wait + struct os_event high_priority_s_event; /* High priority wait array event for S waiters */ volatile ulint high_priority_x_waiters; /* Number of high priority X waiters */ - os_event_t high_priority_x_event; + struct os_event high_priority_x_event; /* High priority wait arraay event for X waiters */ volatile ulint high_priority_wait_ex_waiter; diff --git a/storage/xtradb/include/sync0rw.ic b/storage/xtradb/include/sync0rw.ic index f66d435b8fc..b65e48e0881 100644 --- a/storage/xtradb/include/sync0rw.ic +++ b/storage/xtradb/include/sync0rw.ic @@ -602,7 +602,7 @@ rw_lock_s_unlock_func( /* wait_ex waiter exists. It may not be asleep, but we signal anyway. We do not wake other waiters, because they can't exist without wait_ex waiter and wait_ex waiter goes first.*/ - os_event_set(lock->wait_ex_event); + os_event_set(&lock->wait_ex_event); sync_array_object_signalled(); } @@ -642,7 +642,7 @@ rw_lock_s_unlock_func( /* A waiting next-writer exists, either high priority or regular, sharing the same wait event. */ - os_event_set(lock->base_lock.wait_ex_event); + os_event_set(&lock->base_lock.wait_ex_event); sync_array_object_signalled(); } else if (lock_word == X_LOCK_DECR) { @@ -653,7 +653,7 @@ rw_lock_s_unlock_func( if (lock->base_lock.waiters) { rw_lock_reset_waiter_flag(&lock->base_lock); - os_event_set(lock->base_lock.event); + os_event_set(&lock->base_lock.event); sync_array_object_signalled(); } } @@ -735,7 +735,7 @@ rw_lock_x_unlock_func( if (lock->waiters) { rw_lock_reset_waiter_flag(lock); - os_event_set(lock->event); + os_event_set(&lock->event); sync_array_object_signalled(); } } @@ -778,16 +778,16 @@ rw_lock_x_unlock_func( if (lock->high_priority_x_waiters) { - os_event_set(lock->high_priority_x_event); + os_event_set(&lock->high_priority_x_event); sync_array_object_signalled(); } else if (lock->high_priority_s_waiters) { - os_event_set(lock->high_priority_s_event); + os_event_set(&lock->high_priority_s_event); sync_array_object_signalled(); } else if (lock->base_lock.waiters) { rw_lock_reset_waiter_flag(&lock->base_lock); - os_event_set(lock->base_lock.event); + os_event_set(&lock->base_lock.event); sync_array_object_signalled(); } } diff --git a/storage/xtradb/include/sync0sync.h b/storage/xtradb/include/sync0sync.h index 88fe4644a07..2b794059399 100644 --- a/storage/xtradb/include/sync0sync.h +++ b/storage/xtradb/include/sync0sync.h @@ -926,7 +926,7 @@ implementation of a mutual exclusion semaphore. */ /** InnoDB mutex */ struct ib_mutex_t { - os_event_t event; /*!< Used by sync0arr.cc for the wait queue */ + struct os_event event; /*!< Used by sync0arr.cc for the wait queue */ volatile lock_word_t lock_word; /*!< lock_word is the target of the atomic test-and-set instruction when atomic operations are enabled. */ @@ -974,14 +974,13 @@ struct ib_mutex_t { struct ib_prio_mutex_t { ib_mutex_t base_mutex; /* The regular mutex provides the lock word etc. for the priority mutex */ - os_event_t high_priority_event; /* High priority wait array + struct os_event high_priority_event; /* High priority wait array event */ volatile ulint high_priority_waiters; /* Number of threads that asked for this mutex to be acquired with high priority in the global wait array waiting for this mutex to be released. */ - UT_LIST_NODE_T(ib_prio_mutex_t) list; }; /** Constant determining how long spin wait is continued before suspending diff --git a/storage/xtradb/include/sync0sync.ic b/storage/xtradb/include/sync0sync.ic index fa0724d7996..83f28bfeded 100644 --- a/storage/xtradb/include/sync0sync.ic +++ b/storage/xtradb/include/sync0sync.ic @@ -224,7 +224,7 @@ mutex_exit_func( /* Wake up any high priority waiters first. */ if (mutex->high_priority_waiters != 0) { - os_event_set(mutex->high_priority_event); + os_event_set(&mutex->high_priority_event); sync_array_object_signalled(); } else if (mutex_get_waiters(&mutex->base_mutex) != 0) { diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index f4a0da12476..528abe183c7 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -45,10 +45,10 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 28 +#define INNODB_VERSION_BUGFIX 30 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 76.1 +#define PERCONA_INNODB_VERSION 76.3 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ diff --git a/storage/xtradb/include/ut0byte.ic b/storage/xtradb/include/ut0byte.ic index 873d98c727e..1a7af5ae33d 100644 --- a/storage/xtradb/include/ut0byte.ic +++ b/storage/xtradb/include/ut0byte.ic @@ -110,7 +110,7 @@ ut_align_down( ut_ad(sizeof(void*) == sizeof(ulint)); - return((void*)((((ulint) ptr)) & ~(align_no - 1))); + return((void*)(((ulint) ptr) & ~(align_no - 1))); } /*********************************************************//** |