00001 /****************************************************** 00002 Purge old versions 00003 00004 (c) 1996 Innobase Oy 00005 00006 Created 3/26/1996 Heikki Tuuri 00007 *******************************************************/ 00008 00009 #ifndef trx0purge_h 00010 #define trx0purge_h 00011 00012 #include "univ.i" 00013 #include "trx0types.h" 00014 #include "mtr0mtr.h" 00015 #include "trx0sys.h" 00016 #include "que0types.h" 00017 #include "page0page.h" 00018 #include "usr0sess.h" 00019 #include "fil0fil.h" 00020 00021 /* The global data structure coordinating a purge */ 00022 extern trx_purge_t* purge_sys; 00023 00024 /* A dummy undo record used as a return value when we have a whole undo log 00025 which needs no purge */ 00026 extern trx_undo_rec_t trx_purge_dummy_rec; 00027 00028 /************************************************************************ 00029 Calculates the file address of an undo log header when we have the file 00030 address of its history list node. */ 00031 UNIV_INLINE 00032 fil_addr_t 00033 trx_purge_get_log_from_hist( 00034 /*========================*/ 00035 /* out: file address of the log */ 00036 fil_addr_t node_addr); /* in: file address of the history 00037 list node of the log */ 00038 /********************************************************************* 00039 Checks if trx_id is >= purge_view: then it is guaranteed that its update 00040 undo log still exists in the system. */ 00041 00042 ibool 00043 trx_purge_update_undo_must_exist( 00044 /*=============================*/ 00045 /* out: TRUE if is sure that it is preserved, also 00046 if the function returns FALSE, it is possible that 00047 the undo log still exists in the system */ 00048 dulint trx_id);/* in: transaction id */ 00049 /************************************************************************ 00050 Creates the global purge system control structure and inits the history 00051 mutex. */ 00052 00053 void 00054 trx_purge_sys_create(void); 00055 /*======================*/ 00056 /************************************************************************ 00057 Adds the update undo log as the first log in the history list. Removes the 00058 update undo log segment from the rseg slot if it is too big for reuse. */ 00059 00060 void 00061 trx_purge_add_update_undo_to_history( 00062 /*=================================*/ 00063 trx_t* trx, /* in: transaction */ 00064 page_t* undo_page, /* in: update undo log header page, 00065 x-latched */ 00066 mtr_t* mtr); /* in: mtr */ 00067 /************************************************************************ 00068 Fetches the next undo log record from the history list to purge. It must be 00069 released with the corresponding release function. */ 00070 00071 trx_undo_rec_t* 00072 trx_purge_fetch_next_rec( 00073 /*=====================*/ 00074 /* out: copy of an undo log record, or 00075 pointer to the dummy undo log record 00076 &trx_purge_dummy_rec if the whole undo log 00077 can skipped in purge; NULL if none left */ 00078 dulint* roll_ptr,/* out: roll pointer to undo record */ 00079 trx_undo_inf_t** cell, /* out: storage cell for the record in the 00080 purge array */ 00081 mem_heap_t* heap); /* in: memory heap where copied */ 00082 /*********************************************************************** 00083 Releases a reserved purge undo record. */ 00084 00085 void 00086 trx_purge_rec_release( 00087 /*==================*/ 00088 trx_undo_inf_t* cell); /* in: storage cell */ 00089 /*********************************************************************** 00090 This function runs a purge batch. */ 00091 00092 ulint 00093 trx_purge(void); 00094 /*===========*/ 00095 /* out: number of undo log pages handled in 00096 the batch */ 00097 /********************************************************************** 00098 Prints information of the purge system to stderr. */ 00099 00100 void 00101 trx_purge_sys_print(void); 00102 /*======================*/ 00103 00104 /* The control structure used in the purge operation */ 00105 struct trx_purge_struct{ 00106 ulint state; /* Purge system state */ 00107 sess_t* sess; /* System session running the purge 00108 query */ 00109 trx_t* trx; /* System transaction running the purge 00110 query: this trx is not in the trx list 00111 of the trx system and it never ends */ 00112 que_t* query; /* The query graph which will do the 00113 parallelized purge operation */ 00114 rw_lock_t latch; /* The latch protecting the purge view. 00115 A purge operation must acquire an 00116 x-latch here for the instant at which 00117 it changes the purge view: an undo 00118 log operation can prevent this by 00119 obtaining an s-latch here. */ 00120 read_view_t* view; /* The purge will not remove undo logs 00121 which are >= this view (purge view) */ 00122 mutex_t mutex; /* Mutex protecting the fields below */ 00123 ulint n_pages_handled;/* Approximate number of undo log 00124 pages processed in purge */ 00125 ulint handle_limit; /* Target of how many pages to get 00126 processed in the current purge */ 00127 /*------------------------------*/ 00128 /* The following two fields form the 'purge pointer' which advances 00129 during a purge, and which is used in history list truncation */ 00130 00131 dulint purge_trx_no; /* Purge has advanced past all 00132 transactions whose number is less 00133 than this */ 00134 dulint purge_undo_no; /* Purge has advanced past all records 00135 whose undo number is less than this */ 00136 /*-----------------------------*/ 00137 ibool next_stored; /* TRUE if the info of the next record 00138 to purge is stored below: if yes, then 00139 the transaction number and the undo 00140 number of the record are stored in 00141 purge_trx_no and purge_undo_no above */ 00142 trx_rseg_t* rseg; /* Rollback segment for the next undo 00143 record to purge */ 00144 ulint page_no; /* Page number for the next undo 00145 record to purge, page number of the 00146 log header, if dummy record */ 00147 ulint offset; /* Page offset for the next undo 00148 record to purge, 0 if the dummy 00149 record */ 00150 ulint hdr_page_no; /* Header page of the undo log where 00151 the next record to purge belongs */ 00152 ulint hdr_offset; /* Header byte offset on the page */ 00153 /*-----------------------------*/ 00154 trx_undo_arr_t* arr; /* Array of transaction numbers and 00155 undo numbers of the undo records 00156 currently under processing in purge */ 00157 mem_heap_t* heap; /* Temporary storage used during a 00158 purge: can be emptied after purge 00159 completes */ 00160 }; 00161 00162 #define TRX_PURGE_ON 1 /* purge operation is running */ 00163 #define TRX_STOP_PURGE 2 /* purge operation is stopped, or 00164 it should be stopped */ 00165 #ifndef UNIV_NONINL 00166 #include "trx0purge.ic" 00167 #endif 00168 00169 #endif
1.4.7

