diff options
Diffstat (limited to 'storage/innobase/include/trx0purge.h')
-rw-r--r-- | storage/innobase/include/trx0purge.h | 147 |
1 files changed, 82 insertions, 65 deletions
diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index 2bd9e64476b..0199083467c 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2011, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, 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 @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -52,17 +52,6 @@ trx_purge_get_log_from_hist( /*========================*/ fil_addr_t node_addr); /*!< in: file address of the history list node of the log */ -/*****************************************************************//** -Checks if trx_id is >= purge_view: then it is guaranteed that its update -undo log still exists in the system. -@return TRUE if is sure that it is preserved, also if the function -returns FALSE, it is possible that the undo log still exists in the -system */ -UNIV_INTERN -ibool -trx_purge_update_undo_must_exist( -/*=============================*/ - trx_id_t trx_id);/*!< in: transaction id */ /********************************************************************//** Creates the global purge system control structure and inits the history mutex. */ @@ -70,7 +59,8 @@ UNIV_INTERN void trx_purge_sys_create( /*=================*/ - ib_bh_t* ib_bh); /*!< in/own: UNDO log min binary heap*/ + ulint n_purge_threads,/*!< in: number of purge threads */ + ib_bh_t* ib_bh); /*!< in/own: UNDO log min binary heap*/ /********************************************************************//** Frees the global purge system control structure. */ UNIV_INTERN @@ -88,26 +78,6 @@ trx_purge_add_update_undo_to_history( page_t* undo_page, /*!< in: update undo log header page, x-latched */ mtr_t* mtr); /*!< in: mtr */ -/********************************************************************//** -Fetches the next undo log record from the history list to purge. It must be -released with the corresponding release function. -@return copy of an undo log record or pointer to trx_purge_dummy_rec, -if the whole undo log can skipped in purge; NULL if none left */ -UNIV_INTERN -trx_undo_rec_t* -trx_purge_fetch_next_rec( -/*=====================*/ - roll_ptr_t* roll_ptr,/*!< out: roll pointer to undo record */ - trx_undo_inf_t** cell, /*!< out: storage cell for the record in the - purge array */ - mem_heap_t* heap); /*!< in: memory heap where copied */ -/*******************************************************************//** -Releases a reserved purge undo record. */ -UNIV_INTERN -void -trx_purge_rec_release( -/*==================*/ - trx_undo_inf_t* cell); /*!< in: storage cell */ /*******************************************************************//** This function runs a purge batch. @return number of undo log pages handled in the batch */ @@ -115,47 +85,92 @@ UNIV_INTERN ulint trx_purge( /*======*/ - ulint limit); /*!< in: the maximum number of records to - purge in one batch */ -/******************************************************************//** -Prints information of the purge system to stderr. */ + ulint n_purge_threads, /*!< in: number of purge tasks to + submit to task queue. */ + ulint limit, /*!< in: the maximum number of + records to purge in one batch */ + bool truncate); /*!< in: truncate history if true */ +/*******************************************************************//** +Stop purge and wait for it to stop, move to PURGE_STATE_STOP. */ UNIV_INTERN void -trx_purge_sys_print(void); -/*======================*/ +trx_purge_stop(void); +/*================*/ +/*******************************************************************//** +Resume purge, move to PURGE_STATE_RUN. */ +UNIV_INTERN +void +trx_purge_run(void); +/*================*/ + +/** Purge states */ +enum purge_state_t { + PURGE_STATE_INIT, /*!< Purge instance created */ + PURGE_STATE_RUN, /*!< Purge should be running */ + PURGE_STATE_STOP, /*!< Purge should be stopped */ + PURGE_STATE_EXIT /*!< Purge has been shutdown */ +}; + +/*******************************************************************//** +Get the purge state. +@return purge state. */ +UNIV_INTERN +purge_state_t +trx_purge_state(void); +/*=================*/ + +/** This is the purge pointer/iterator. We need both the undo no and the +transaction no up to which purge has parsed and applied the records. */ +typedef struct purge_iter_struct { + trx_id_t trx_no; /*!< Purge has advanced past all + transactions whose number is less + than this */ + undo_no_t undo_no; /*!< Purge has advanced past all records + whose undo number is less than this */ +} purge_iter_t; /** The control structure used in the purge operation */ struct trx_purge_struct{ - ulint state; /*!< Purge system state */ sess_t* sess; /*!< System session running the purge query */ trx_t* trx; /*!< System transaction running the - purge - query: this trx is not in the trx list - of the trx system and it never ends */ - que_t* query; /*!< The query graph which will do the - parallelized purge operation */ + purge query: this trx is not in the + trx list of the trx system and it + never ends */ rw_lock_t latch; /*!< The latch protecting the purge - view. A purge operation must acquire - an x-latch here for the instant at which + view. A purge operation must acquire an + x-latch here for the instant at which it changes the purge view: an undo log operation can prevent this by - obtaining an s-latch here. */ + obtaining an s-latch here. It also + protects state and running */ + os_event_t event; /*!< State signal event */ + ulint n_stop; /*!< Counter to track number stops */ + bool running; /*!< true, if purge is active */ + volatile purge_state_t state; /*!< Purge coordinator thread states, + we check this in several places + without holding the latch. */ + que_t* query; /*!< The query graph which will do the + parallelized purge operation */ read_view_t* view; /*!< The purge will not remove undo logs which are >= this view (purge view) */ - ulonglong n_pages_handled;/*!< Approximate number of undo log - pages processed in purge */ - ulonglong handle_limit; /*!< Target of how many pages to get - processed in the current purge */ + volatile ulint n_submitted; /*!< Count of total tasks submitted + to the task queue */ + volatile ulint n_completed; /*!< Count of total tasks completed */ + /*------------------------------*/ /* The following two fields form the 'purge pointer' which advances during a purge, and which is used in history list truncation */ - trx_id_t purge_trx_no; /*!< Purge has advanced past all - transactions whose number is less - than this */ - undo_no_t purge_undo_no; /*!< Purge has advanced past all records - whose undo number is less than this */ + purge_iter_t iter; /* Limit up to which we have read and + parsed the UNDO log records. Not + necessarily purged from the indexes. + Note that this can never be less than + the limit below, we check for this + invariant in trx0purge.cc */ + purge_iter_t limit; /* The 'purge pointer' which advances + during a purge, and which is used in + history list truncation */ /*-----------------------------*/ ibool next_stored; /*!< TRUE if the info of the next record to purge is stored below: if yes, then @@ -174,9 +189,6 @@ struct trx_purge_struct{ the next record to purge belongs */ ulint hdr_offset; /*!< Header byte offset on the page */ /*-----------------------------*/ - trx_undo_arr_t* arr; /*!< Array of transaction numbers and - undo numbers of the undo records - currently under processing in purge */ mem_heap_t* heap; /*!< Temporary storage used during a purge: can be emptied after purge completes */ @@ -187,9 +199,14 @@ struct trx_purge_struct{ mutex_t bh_mutex; /*!< Mutex protecting ib_bh */ }; -#define TRX_PURGE_ON 1 /* purge operation is running */ -#define TRX_STOP_PURGE 2 /* purge operation is stopped, or - it should be stopped */ +/** Info required to purge a record */ +struct trx_purge_rec_struct { + trx_undo_rec_t* undo_rec; /*!< Record to purge */ + roll_ptr_t roll_ptr; /*!< File pointr to UNDO record */ +}; + +typedef struct trx_purge_rec_struct trx_purge_rec_t; + #ifndef UNIV_NONINL #include "trx0purge.ic" #endif |