MySQL  8.0.21
Source Code Documentation
row0purge.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1997, 2019, Oracle and/or its affiliates. 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, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 
27 /** @file include/row0purge.h
28  Purge obsolete records
29 
30  Created 3/14/1997 Heikki Tuuri
31  *******************************************************/
32 
33 #ifndef row0purge_h
34 #define row0purge_h
35 
36 #include "univ.i"
37 
38 #include "btr0pcur.h"
39 #include "btr0types.h"
40 #include "data0data.h"
41 #include "dict0types.h"
42 #include "que0types.h"
43 #include "row0types.h"
44 #include "trx0types.h"
45 #include "ut0vec.h"
46 
47 /** Create a purge node to a query graph.
48 @param[in] parent parent node, i.e., a thr node
49 @param[in] heap memory heap where created
50 @return own: purge node */
52  MY_ATTRIBUTE((warn_unused_result));
53 
54 /** Determines if it is possible to remove a secondary index entry.
55  Removal is possible if the secondary index entry does not refer to any
56  not delete marked version of a clustered index record where DB_TRX_ID
57  is newer than the purge view.
58 
59  NOTE: This function should only be called by the purge thread, only
60  while holding a latch on the leaf page of the secondary index entry
61  (or keeping the buffer pool watch on the page). It is possible that
62  this function first returns true and then false, if a user transaction
63  inserts a record that the secondary index entry would refer to.
64  However, in that case, the user transaction would also re-insert the
65  secondary index entry after purge has removed it and released the leaf
66  page latch.
67  @return true if the secondary index record can be purged */
68 bool row_purge_poss_sec(purge_node_t *node, /*!< in/out: row purge node */
69  dict_index_t *index, /*!< in: secondary index */
70  const dtuple_t *entry) /*!< in: secondary index entry */
71  MY_ATTRIBUTE((warn_unused_result));
72 /***************************************************************
73 Does the purge operation for a single undo log record. This is a high-level
74 function used in an SQL execution graph.
75 @return query thread to run next or NULL */
76 que_thr_t *row_purge_step(que_thr_t *thr) /*!< in: query thread */
77  MY_ATTRIBUTE((warn_unused_result));
78 
79 /* Purge node structure */
80 
81 struct purge_node_t {
82  /** Info required to purge a record */
83  struct rec_t {
84  /** Record to purge */
86 
87  /** File pointer to UNDO record */
89 
90  /** Trx that created this undo record */
92  };
93 
94  using Recs = std::list<rec_t, mem_heap_allocator<rec_t>>;
95 
96  /** node type: QUE_NODE_PURGE */
98 
99  /* Local storage for this graph node */
100 
101  /** roll pointer to undo log record */
103 
104  /** undo number of the record */
106 
107  /** undo log record type: TRX_UNDO_INSERT_REC, ... */
108  ulint rec_type;
109 
110  /** table where purge is done */
112 
113  /** MDL ticket for the table name */
115 
116  /** parent table for an FTS AUX TABLE */
118 
119  /** MDL ticket for the parent table of an FTS AUX TABLE */
121 
122  /** MySQL table instance */
124 
125  /** compiler analysis info of an update */
126  ulint cmpl_info;
127 
128  /** update vector for a clustered index record */
130 
131  /** NULL, or row reference to the next row to handle */
133 
134  /** NULL, or a copy (also fields copied to heap) of the indexed
135  fields of the row to handle */
137 
138  /** NULL, or the next index whose record should be handled */
140 
141  /** The heap is owned by purge_sys and is reset after a purge
142  batch has completed. */
144 
145  /** true if the clustered index record determined by ref was
146  found in the clustered index, and we were able to position pcur on it */
148 
149  /** persistent cursor used in searching the clustered index record */
151 
152  /** Debug flag */
153  bool done;
154 
155  /** trx id for this purging record */
157 
158  /** trx id for this purging record */
160 
161  /** Undo recs to purge */
163 
164  /** Check if undo records of given table_id is there in this purge node.
165  @param[in] table_id look for undo records of this table id.
166  @return true if undo records of table id exists, false otherwise. */
167  bool is_table_id_exists(table_id_t table_id) const;
168 
169 #ifdef UNIV_DEBUG
170  /** Check if there are more than one undo record with same (trx_id, undo_no)
171  combination.
172  @return true when no duplicates are found, false otherwise. */
173  bool check_duplicate_undo_no() const;
174 #endif /* UNIV_DEBUG */
175 
177 #ifdef UNIV_DEBUG
178  /** Validate the persisent cursor. The purge node has two references
179  to the clustered index record - one via the ref member, and the
180  other via the persistent cursor. These two references must match
181  each other if the found_clust flag is set.
182  @return true if the persistent cursor is consistent with
183  the ref member.*/
184  bool validate_pcur();
185 #endif
186 };
187 
188 #endif
Info required to purge a record.
Definition: row0purge.h:83
dtuple_t * row
NULL, or a copy (also fields copied to heap) of the indexed fields of the row to handle.
Definition: row0purge.h:136
A granted metadata lock.
Definition: mdl.h:965
A vector of pointers to data items.
byte trx_undo_rec_t
Undo log record.
Definition: trx0types.h:173
ib_id_t roll_ptr_t
Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR)
Definition: trx0types.h:146
Definition: row0purge.h:81
bool check_duplicate_undo_no() const
Check if there are more than one undo record with same (trx_id, undo_no) combination.
Definition: row0purge.cc:1319
TABLE * mysql_table
MySQL table instance.
Definition: row0purge.h:123
Data structure for a database table.
Definition: dict0mem.h:1524
dtuple_t * ref
NULL, or row reference to the next row to handle.
Definition: row0purge.h:132
bool row_purge_poss_sec(purge_node_t *node, dict_index_t *index, const dtuple_t *entry)
Determines if it is possible to remove a secondary index entry.
Definition: row0purge.cc:270
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:347
Definition: btr0pcur.h:177
The rollback segment memory object.
Definition: trx0types.h:183
SQL data field and tuple.
Definition: table.h:1313
Query graph global types.
The index tree general types.
Data dictionary global types.
ulint rec_type
undo log record type: TRX_UNDO_INSERT_REC, ...
Definition: row0purge.h:108
trx_id_t modifier_trx_id
Trx that created this undo record.
Definition: row0purge.h:91
undo_no_t undo_no
undo number of the record
Definition: row0purge.h:105
bool is_table_id_exists(table_id_t table_id) const
Check if undo records of given table_id is there in this purge node.
Definition: row0purge.cc:1301
dict_table_t * table
table where purge is done
Definition: row0purge.h:111
roll_ptr_t roll_ptr
File pointer to UNDO record.
Definition: row0purge.h:88
btr_pcur_t pcur
persistent cursor used in searching the clustered index record
Definition: row0purge.h:150
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:711
Recs * recs
Undo recs to purge.
Definition: row0purge.h:162
roll_ptr_t roll_ptr
roll pointer to undo log record
Definition: row0purge.h:102
std::list< rec_t, mem_heap_allocator< rec_t > > Recs
Definition: row0purge.h:94
Row operation global types.
Definition: que0que.h:248
purge_node_t * row_purge_node_create(que_thr_t *parent, mem_heap_t *heap)
Create a purge node to a query graph.
Definition: row0purge.cc:79
trx_undo_rec_t * undo_rec
Record to purge.
Definition: row0purge.h:85
bool done
Debug flag.
Definition: row0purge.h:153
mem_heap_t * heap
The heap is owned by purge_sys and is reset after a purge batch has completed.
Definition: row0purge.h:143
trx_id_t trx_id
trx id for this purging record
Definition: row0purge.h:156
ulint cmpl_info
compiler analysis info of an update
Definition: row0purge.h:126
The index tree persistent cursor.
que_common_t common
node type: QUE_NODE_PURGE
Definition: row0purge.h:97
Transaction system global type definitions.
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:215
bool validate_pcur()
Validate the persisent cursor.
Definition: row0purge.cc:1262
Definition: que0types.h:50
que_thr_t * row_purge_step(que_thr_t *thr)
Does the purge operation for a single undo log record.
Definition: row0purge.cc:1213
dict_index_t * index
NULL, or the next index whose record should be handled.
Definition: row0purge.h:139
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:144
trx_id_t modifier_trx_id
trx id for this purging record
Definition: row0purge.h:159
bool found_clust
true if the clustered index record determined by ref was found in the clustered index, and we were able to position pcur on it
Definition: row0purge.h:147
MDL_ticket * parent_mdl
MDL ticket for the parent table of an FTS AUX TABLE.
Definition: row0purge.h:120
dict_table_t * parent
parent table for an FTS AUX TABLE
Definition: row0purge.h:117
MDL_ticket * mdl
MDL ticket for the table name.
Definition: row0purge.h:114
Definition: completion_hash.h:34
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:148
trx_rseg_t * rseg
Definition: row0purge.h:176
upd_t * update
update vector for a clustered index record
Definition: row0purge.h:129
Definition: row0upd.h:574
Data structure for an index.
Definition: dict0mem.h:883