~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/trx0purge.h

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/trx0purge.h
 
1
/******************************************************
21
2
Purge old versions
22
3
 
 
4
(c) 1996 Innobase Oy
 
5
 
23
6
Created 3/26/1996 Heikki Tuuri
24
7
*******************************************************/
25
8
 
35
18
#include "usr0sess.h"
36
19
#include "fil0fil.h"
37
20
 
38
 
/** The global data structure coordinating a purge */
 
21
/* The global data structure coordinating a purge */
39
22
extern trx_purge_t*     purge_sys;
40
23
 
41
 
/** A dummy undo record used as a return value when we have a whole undo log
 
24
/* A dummy undo record used as a return value when we have a whole undo log
42
25
which needs no purge */
43
26
extern trx_undo_rec_t   trx_purge_dummy_rec;
44
27
 
45
 
/********************************************************************//**
 
28
/************************************************************************
46
29
Calculates the file address of an undo log header when we have the file
47
 
address of its history list node.
48
 
@return file address of the log */
 
30
address of its history list node. */
49
31
UNIV_INLINE
50
32
fil_addr_t
51
33
trx_purge_get_log_from_hist(
52
34
/*========================*/
53
 
        fil_addr_t      node_addr);     /*!< in: file address of the history
 
35
                                        /* out: file address of the log */
 
36
        fil_addr_t      node_addr);     /* in: file address of the history
54
37
                                        list node of the log */
55
 
/*****************************************************************//**
 
38
/*********************************************************************
56
39
Checks if trx_id is >= purge_view: then it is guaranteed that its update
57
 
undo log still exists in the system.
58
 
@return TRUE if is sure that it is preserved, also if the function
59
 
returns FALSE, it is possible that the undo log still exists in the
60
 
system */
 
40
undo log still exists in the system. */
61
41
UNIV_INTERN
62
42
ibool
63
43
trx_purge_update_undo_must_exist(
64
44
/*=============================*/
65
 
        trx_id_t        trx_id);/*!< in: transaction id */
66
 
/********************************************************************//**
 
45
                        /* out: TRUE if is sure that it is preserved, also
 
46
                        if the function returns FALSE, it is possible that
 
47
                        the undo log still exists in the system */
 
48
        dulint  trx_id);/* in: transaction id */
 
49
/************************************************************************
67
50
Creates the global purge system control structure and inits the history
68
51
mutex. */
69
52
UNIV_INTERN
70
53
void
71
54
trx_purge_sys_create(void);
72
55
/*======================*/
73
 
/********************************************************************//**
74
 
Frees the global purge system control structure. */
75
 
UNIV_INTERN
76
 
void
77
 
trx_purge_sys_close(void);
78
 
/*======================*/
79
56
/************************************************************************
80
57
Adds the update undo log as the first log in the history list. Removes the
81
58
update undo log segment from the rseg slot if it is too big for reuse. */
83
60
void
84
61
trx_purge_add_update_undo_to_history(
85
62
/*=================================*/
86
 
        trx_t*  trx,            /*!< in: transaction */
87
 
        page_t* undo_page,      /*!< in: update undo log header page,
 
63
        trx_t*  trx,            /* in: transaction */
 
64
        page_t* undo_page,      /* in: update undo log header page,
88
65
                                x-latched */
89
 
        mtr_t*  mtr);           /*!< in: mtr */
90
 
/********************************************************************//**
 
66
        mtr_t*  mtr);           /* in: mtr */
 
67
/************************************************************************
91
68
Fetches the next undo log record from the history list to purge. It must be
92
 
released with the corresponding release function.
93
 
@return copy of an undo log record or pointer to trx_purge_dummy_rec,
94
 
if the whole undo log can skipped in purge; NULL if none left */
 
69
released with the corresponding release function. */
95
70
UNIV_INTERN
96
71
trx_undo_rec_t*
97
72
trx_purge_fetch_next_rec(
98
73
/*=====================*/
99
 
        roll_ptr_t*     roll_ptr,/*!< out: roll pointer to undo record */
100
 
        trx_undo_inf_t** cell,  /*!< out: storage cell for the record in the
 
74
                                /* out: copy of an undo log record, or
 
75
                                pointer to the dummy undo log record
 
76
                                &trx_purge_dummy_rec if the whole undo log
 
77
                                can skipped in purge; NULL if none left */
 
78
        dulint*         roll_ptr,/* out: roll pointer to undo record */
 
79
        trx_undo_inf_t** cell,  /* out: storage cell for the record in the
101
80
                                purge array */
102
 
        mem_heap_t*     heap);  /*!< in: memory heap where copied */
103
 
/*******************************************************************//**
 
81
        mem_heap_t*     heap);  /* in: memory heap where copied */
 
82
/***********************************************************************
104
83
Releases a reserved purge undo record. */
105
84
UNIV_INTERN
106
85
void
107
86
trx_purge_rec_release(
108
87
/*==================*/
109
 
        trx_undo_inf_t* cell);  /*!< in: storage cell */
110
 
/*******************************************************************//**
111
 
This function runs a purge batch.
112
 
@return number of undo log pages handled in the batch */
 
88
        trx_undo_inf_t* cell);  /* in: storage cell */
 
89
/***********************************************************************
 
90
This function runs a purge batch. */
113
91
UNIV_INTERN
114
92
ulint
115
 
trx_purge(
116
 
/*======*/
117
 
        ulint   limit);         /*!< in: the maximum number of records to
118
 
                                purge in one batch */
119
 
/******************************************************************//**
 
93
trx_purge(void);
 
94
/*===========*/
 
95
                                /* out: number of undo log pages handled in
 
96
                                the batch */
 
97
/**********************************************************************
120
98
Prints information of the purge system to stderr. */
121
99
UNIV_INTERN
122
100
void
123
101
trx_purge_sys_print(void);
124
102
/*======================*/
125
103
 
126
 
/** The control structure used in the purge operation */
 
104
/* The control structure used in the purge operation */
127
105
struct trx_purge_struct{
128
 
        ulint           state;          /*!< Purge system state */
129
 
        sess_t*         sess;           /*!< System session running the purge
 
106
        ulint           state;          /* Purge system state */
 
107
        sess_t*         sess;           /* System session running the purge
130
108
                                        query */
131
 
        trx_t*          trx;            /*!< System transaction running the purge
 
109
        trx_t*          trx;            /* System transaction running the purge
132
110
                                        query: this trx is not in the trx list
133
111
                                        of the trx system and it never ends */
134
 
        que_t*          query;          /*!< The query graph which will do the
 
112
        que_t*          query;          /* The query graph which will do the
135
113
                                        parallelized purge operation */
136
 
        rw_lock_t       latch;          /*!< The latch protecting the purge view.
 
114
        rw_lock_t       latch;          /* The latch protecting the purge view.
137
115
                                        A purge operation must acquire an
138
116
                                        x-latch here for the instant at which
139
117
                                        it changes the purge view: an undo
140
118
                                        log operation can prevent this by
141
119
                                        obtaining an s-latch here. */
142
 
        read_view_t*    view;           /*!< The purge will not remove undo logs
 
120
        read_view_t*    view;           /* The purge will not remove undo logs
143
121
                                        which are >= this view (purge view) */
144
 
        mutex_t         mutex;          /*!< Mutex protecting the fields below */
145
 
        ulint           n_pages_handled;/*!< Approximate number of undo log
 
122
        mutex_t         mutex;          /* Mutex protecting the fields below */
 
123
        ulint           n_pages_handled;/* Approximate number of undo log
146
124
                                        pages processed in purge */
147
 
        ulint           handle_limit;   /*!< Target of how many pages to get
 
125
        ulint           handle_limit;   /* Target of how many pages to get
148
126
                                        processed in the current purge */
149
127
        /*------------------------------*/
150
128
        /* The following two fields form the 'purge pointer' which advances
151
129
        during a purge, and which is used in history list truncation */
152
130
 
153
 
        trx_id_t        purge_trx_no;   /*!< Purge has advanced past all
 
131
        dulint          purge_trx_no;   /* Purge has advanced past all
154
132
                                        transactions whose number is less
155
133
                                        than this */
156
 
        undo_no_t       purge_undo_no;  /*!< Purge has advanced past all records
 
134
        dulint          purge_undo_no;  /* Purge has advanced past all records
157
135
                                        whose undo number is less than this */
158
136
        /*-----------------------------*/
159
 
        ibool           next_stored;    /*!< TRUE if the info of the next record
 
137
        ibool           next_stored;    /* TRUE if the info of the next record
160
138
                                        to purge is stored below: if yes, then
161
139
                                        the transaction number and the undo
162
140
                                        number of the record are stored in
163
141
                                        purge_trx_no and purge_undo_no above */
164
 
        trx_rseg_t*     rseg;           /*!< Rollback segment for the next undo
 
142
        trx_rseg_t*     rseg;           /* Rollback segment for the next undo
165
143
                                        record to purge */
166
 
        ulint           page_no;        /*!< Page number for the next undo
 
144
        ulint           page_no;        /* Page number for the next undo
167
145
                                        record to purge, page number of the
168
146
                                        log header, if dummy record */
169
 
        ulint           offset;         /*!< Page offset for the next undo
 
147
        ulint           offset;         /* Page offset for the next undo
170
148
                                        record to purge, 0 if the dummy
171
149
                                        record */
172
 
        ulint           hdr_page_no;    /*!< Header page of the undo log where
 
150
        ulint           hdr_page_no;    /* Header page of the undo log where
173
151
                                        the next record to purge belongs */
174
 
        ulint           hdr_offset;     /*!< Header byte offset on the page */
 
152
        ulint           hdr_offset;     /* Header byte offset on the page */
175
153
        /*-----------------------------*/
176
 
        trx_undo_arr_t* arr;            /*!< Array of transaction numbers and
 
154
        trx_undo_arr_t* arr;            /* Array of transaction numbers and
177
155
                                        undo numbers of the undo records
178
156
                                        currently under processing in purge */
179
 
        mem_heap_t*     heap;           /*!< Temporary storage used during a
 
157
        mem_heap_t*     heap;           /* Temporary storage used during a
180
158
                                        purge: can be emptied after purge
181
159
                                        completes */
182
160
};