Debian Codegraph @

storage/innobase/include/trx0purge.h

raw symbols SCIP
1
2 /*****************************************************************************
3
4 Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
5 Copyright (c) 2017, 2022, MariaDB Corporation.
6
7 This program is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free Software
9 Foundation; version 2 of the License.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
18
19 *****************************************************************************/
20
21 /**************************************************//**
22 @file include/trx0purge.h
23 Purge old versions
24
25 Created 3/26/1996 Heikki Tuuri
26 *******************************************************/
27
28 #pragma once
29
30 #include "trx0sys.h"cxx . . $ `<file>/storage/innobase/include/trx0sys.h`/
31 #include "que0types.h"cxx . . $ `<file>/storage/innobase/include/que0types.h`/
32 #include "srw_lock.h"cxx . . $ `<file>/storage/innobase/include/srw_lock.h`/
33 #include "row0purge.h"cxx . . $ `<file>/storage/innobase/include/row0purge.h`/
34
35 #include <queue>
36 #include <unordered_map>
37
38 struct TABLEcxx . . $ TABLE#;
39 /** Prepend the history list with an undo log.
40 Remove the undo log segment from the rseg slot if it is too big for reuse.
41 @param[in] trx transaction
42 @param[in,out] undo undo log
43 @param[in,out] mtr mini-transaction */
44 void
45 trx_purge_add_undo_to_historycxx . . $ trx_purge_add_undo_to_history(12476e5b870e3162).(const trx_tcxx . . $ trx_t#* trx, trx_undo_tcxx . . $ trx_undo_t#*& undo, mtr_tcxx . . $ mtr_t#* mtr);
46
47 /**
48 Remove unnecessary history data from rollback segments. NOTE that when this
49 function is called, the caller (purge_coordinator_callback)
50 must not have any latches on undo log pages!
51 */
52 void trx_purge_truncate_historycxx . . $ trx_purge_truncate_history(49f6e7a06ebc5aa8).();
53
54 /**
55 Run a purge batch.
56 @param trx dummy transaction associated with the purge coordinator
57 @param n_tasks number of purge tasks to submit to the queue
58 @param history_size trx_sys.history_size()
59 @return number of undo log pages handled in the batch */
60 ulintcxx . . $ ulint# trx_purgecxx . . $ trx_purge(6c100f46636e7b39).(trx_tcxx . . $ trx_t# *trx, ulintcxx . . $ ulint# n_tasks, ulintcxx . . $ ulint# history_size) noexcept;
61
62 /** The control structure used in the purge operation */
63 class purge_sys_tcxx . . $ purge_sys_t#
64 {
65 /** Min-heap based priority queue of (trx_no, trx_sys.rseg_array index)
66 pairs, ordered on trx_no. The highest 64-TRX_NO_SHIFT bits of each element is
67 trx_no, the lowest 8 bits is rseg's index in trx_sys.rseg_array. */
68 class purge_queuecxx . . $ purge_sys_t#purge_queue#
69 {
70 public:
71 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<uint64_tcxx . . $ uint64_t#, ut_allocatorcxx . . $ ut_allocator#<uint64_tcxx . . $ uint64_t#>> container_typecxx . . $ purge_sys_t#purge_queue#container_type#;
72 /** Number of bits reseved to shift trx_no in purge queue element */
73 static constexpr unsigned TRX_NO_SHIFTcxx . . $ purge_sys_t#purge_queue#TRX_NO_SHIFT.= 8;
74
75 bool emptycxx . . $ purge_sys_t#purge_queue#empty(50ce9a9e25b4a850).() const { return m_arraycxx . . $ purge_sys_t#purge_queue#m_array..emptycxx . . $ std/vector#empty(3482b152b9333168).(); }
76 void clearcxx . . $ purge_sys_t#purge_queue#clear(49f6e7a06ebc5aa8).() { m_arraycxx . . $ purge_sys_t#purge_queue#m_array..clearcxx . . $ std/vector#clear(ced63f7c635d850d).(); }
77
78 /** Push (trx_no, trx_sys.rseg_array index) into min-heap.
79 @param trx_no_rseg (trx_no << TRX_NO_SHIFT | (trx_sys.rseg_array index)) */
80 void push_trx_no_rsegcxx . . $ purge_sys_t#purge_queue#push_trx_no_rseg(2c44cd906ae4e829).(container_typecxx . . $ purge_sys_t#purge_queue#container_type#::value_typecxx . . $ std/vector#value_type# trx_no_rseg)
81 {
82 m_arraycxx . . $ purge_sys_t#purge_queue#m_array..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(trx_no_rseg);
83 stdcxx . . $ std/::push_heapcxx . . $ std/push_heap(4d3091562df4e52e).(m_arraycxx . . $ purge_sys_t#purge_queue#m_array..begincxx . . $ std/vector#begin(55a6de06420d4903).(), m_arraycxx . . $ purge_sys_t#purge_queue#m_array..endcxx . . $ std/vector#end(55a6de06420d4903).(),
84 stdcxx . . $ std/::greatercxx . . $ std/greater#<container_typecxx . . $ purge_sys_t#purge_queue#container_type#::value_typecxx . . $ std/vector#value_type#>());
85 }
86
87 /** Push rseg to priority queue.
88 @param trx_no trx_no of committed transaction
89 @param rseg rseg of committed transaction*/
90 void pushcxx . . $ purge_sys_t#purge_queue#push(eb209464bbdc6da6).(trx_id_tcxx . . $ trx_id_t# trx_no, const trx_rseg_tcxx . . $ trx_rseg_t# &rseg)
91 {
92 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(trx_no < 1ULL << (DATA_TRX_ID_LEN * CHAR_BIT));
93 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(&rseg >= trx_sys.rseg_array);
94 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(&rseg < trx_sys.rseg_array + TRX_SYS_N_RSEGS);
95 push_trx_no_rsegcxx . . $ purge_sys_t#purge_queue#push_trx_no_rseg(2c44cd906ae4e829).(trx_no << TRX_NO_SHIFTcxx . . $ purge_sys_t#purge_queue#TRX_NO_SHIFT. |
96 bytecxx . . $ byte#(&rseg - trx_syscxx . . $ trx_sys..rseg_arraycxx . . $ trx_sys_t#rseg_array.));
97 }
98
99 /** Extracts rseg from (trx_no, trx_sys.rseg_array index) pair.
100 @param trx_no_rseg (trx_no << TRX_NO_SHIFT | (trx_sys.rseg_array index)
101 @return pointer to rseg in trx_sys.rseg_array */
102 static trx_rseg_tcxx . . $ trx_rseg_t# *rsegcxx . . $ purge_sys_t#purge_queue#rseg(16585c104f04fa21).(container_typecxx . . $ purge_sys_t#purge_queue#container_type#::value_typecxx . . $ std/vector#value_type# trx_no_rseg) {
103 bytecxx . . $ byte# i= static_cast<bytecxx . . $ byte#>(trx_no_rseg);
104 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(i < TRX_SYS_N_RSEGS);
105 return &trx_syscxx . . $ trx_sys..rseg_arraycxx . . $ trx_sys_t#rseg_array.[i];
106 }
107
108 /** Pop rseg from priority queue.
109 @return pointer to popped trx_rseg_t object */
110 trx_rseg_tcxx . . $ trx_rseg_t# *popcxx . . $ purge_sys_t#purge_queue#pop(eac49893822de0e3).()
111 {
112 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!empty());
113 stdcxx . . $ std/::pop_heapcxx . . $ std/pop_heap(4d3091562df4e52e).(m_arraycxx . . $ purge_sys_t#purge_queue#m_array..begincxx . . $ std/vector#begin(55a6de06420d4903).(), m_arraycxx . . $ purge_sys_t#purge_queue#m_array..endcxx . . $ std/vector#end(55a6de06420d4903).(),
114 stdcxx . . $ std/::greatercxx . . $ std/greater#<container_typecxx . . $ purge_sys_t#purge_queue#container_type#::value_typecxx . . $ std/vector#value_type#>());
115 trx_rseg_tcxx . . $ trx_rseg_t# *r = rsegcxx . . $ purge_sys_t#purge_queue#rseg(16585c104f04fa21).(m_arraycxx . . $ purge_sys_t#purge_queue#m_array..backcxx . . $ std/vector#back(6baabfa6fc7b3a8e).());
116 m_arraycxx . . $ purge_sys_t#purge_queue#m_array..pop_backcxx . . $ std/vector#pop_back(ced63f7c635d850d).();
117 return r;
118 }
119
120 /** Clone m_array.
121 @return m_array clone */
122 container_typecxx . . $ purge_sys_t#purge_queue#container_type# clone_containercxx . . $ purge_sys_t#purge_queue#clone_container(58482be275174f31).() const{ return m_arraycxx . . $ std/vector#vector(a1201200cf0efa42).; }
123
124 private:
125 /** Array of (trx_no, trx_sys.rseg_array index) pairs. */
126 container_typecxx . . $ purge_sys_t#purge_queue#container_type# m_arraycxx . . $ purge_sys_t#purge_queue#m_array.;
127 };
128
129
130 public:
131 /** latch protecting view, m_enabled */
132 alignas(CPU_LEVEL1_DCACHE_LINESIZEcxx . . $ `include/my_global.h:1180:13`!)
133 mutable IF_DBUGcxx . . $ `include/my_dbug.h:192:9`!(srw_lock_debug,srw_spin_lock) latchcxx . . $ purge_sys_t#latch.;
134 private:
135 /** Read view at the start of a purge batch. Any encountered index records
136 that are older than view will be removed. */
137 ReadViewBasecxx . . $ ReadViewBase# viewcxx . . $ purge_sys_t#view.;
138 /** whether the subsystem has been initialized */
139 bool m_initializedcxx . . $ purge_sys_t#m_initialized.{false};
140 /** whether purge is enabled; protected by latch and std::atomic */
141 stdcxx . . $ std/::atomiccxx . . $ std/atomic#<bool> m_enabledcxx . . $ purge_sys_t#m_enabled.{cxx . . $ std/atomic#atomic(9f0ba574c1c44ffc).false};
142 /** The primary candidate for iterator::free_history() is
143 rseg=trx_sys.rseg_array[skipped_rseg]. This field may be changed
144 after invoking rseg.set_skip_allocation() and rseg.clear_skip_allocation()
145 and while holding the exclusive rseg.latch.
146
147 This may only be 0 if innodb_undo_tablespaces=0, because rollback segment
148 0 always resides in the system tablespace and would never be used when
149 dedicated undo tablespaces are in use. */
150 Atomic_relaxedcxx . . $ Atomic_relaxed#<uint8_tcxx . . $ uint8_t#> skipped_rsegcxx . . $ purge_sys_t#skipped_rseg.;
151 public:
152 /** whether purge is active (may hold table handles) */
153 stdcxx . . $ std/::atomiccxx . . $ std/atomic#<bool> m_activecxx . . $ purge_sys_t#m_active.{cxx . . $ std/atomic#atomic(9f0ba574c1c44ffc).false};
154 private:
155 /** number of pending stop() calls without resume() */
156 Atomic_countercxx . . $ Atomic_counter#<uint32_tcxx . . $ uint32_t#> m_pausedcxx . . $ purge_sys_t#m_paused.;
157 /** PAUSED_SYS * number of stop_SYS() calls without resume_SYS() +
158 number of stop_FTS() calls without resume_FTS() */
159 Atomic_relaxedcxx . . $ Atomic_relaxed#<uint32_tcxx . . $ uint32_t#> m_FTS_pausedcxx . . $ purge_sys_t#m_FTS_paused.;
160 /** The stop_SYS() multiplier in m_FTS_paused */
161 static constexpr const uint32_tcxx . . $ uint32_t# PAUSED_SYScxx . . $ purge_sys_t#PAUSED_SYS.= 1U << 16;
162
163 /** latch protecting end_view */
164 alignas(CPU_LEVEL1_DCACHE_LINESIZEcxx . . $ `include/my_global.h:1180:13`!) srw_spin_lock_lowcxx . . $ srw_spin_lock_low# end_latchcxx . . $ purge_sys_t#end_latch.;
165 /** Read view at the end of a purge batch (copied from view). Any undo pages
166 containing records older than end_view may be freed. */
167 ReadViewBasecxx . . $ ReadViewBase# end_viewcxx . . $ purge_sys_t#end_view.;
168
169 struct hashercxx . . $ purge_sys_t#hasher#
170 {
171 size_t operatorcxx . . $ purge_sys_t#hasher#`operator()`(6c7d461c7ebdaf5b).()(const page_id_tcxx . . $ page_id_t# &id) const { return size_t(id.rawcxx . . $ page_id_t#raw(48d4d1a65303b006).()); }
172 };
173
174 using unordered_mapcxx . . $ purge_sys_t#unordered_map# =
175 stdcxx . . $ std/::unordered_mapcxx . . $ std/unordered_map#<const page_id_tcxx . . $ page_id_t#, buf_block_tcxx . . $ buf_block_t#*, hashercxx . . $ purge_sys_t#hasher#,
176 #if defined __GNUC__cxx . . $ `<built-in>:8:9`! && __GNUC__cxx . . $ `<built-in>:8:9`! == 4 && __GNUC_MINOR__cxx . . $ `<built-in>:9:9`! >= 8
177 std::equal_to<page_id_t>
178 /* GCC 4.8.5 would fail to find a matching allocator */
179 #else
180 stdcxx . . $ std/::equal_tocxx . . $ std/equal_to#<page_id_tcxx . . $ page_id_t#>,
181 ut_allocatorcxx . . $ ut_allocator#<stdcxx . . $ std/::paircxx . . $ std/pair#<const page_id_tcxx . . $ page_id_t#, buf_block_tcxx . . $ buf_block_t#*>>
182 #endif
183 >;
184 /** map of buffer-fixed undo log pages processed during a purge batch */
185 unordered_mapcxx . . $ purge_sys_t#unordered_map# pagescxx . . $ purge_sys_t#pages.;
186 public:
187 /** @return the number of processed undo pages */
188 size_t n_pages_handledcxx . . $ purge_sys_t#n_pages_handled(fe4d2d262d4164a8).() const { return pagescxx . . $ purge_sys_t#pages..sizecxx . . $ std/unordered_map#size(fe713de6d184c8a).(); }
189
190 /** Look up an undo log page.
191 @param id undo page identifier
192 @param trx transaction attached to current_thd
193 @return undo page
194 @retval nullptr in case the page is corrupted */
195 buf_block_tcxx . . $ buf_block_t# *get_pagecxx . . $ purge_sys_t#get_page(61dc2f865ba30229).(page_id_tcxx . . $ page_id_t# id, trx_tcxx . . $ trx_t# *trx);
196
197 que_tcxx . . $ que_t#* querycxx . . $ purge_sys_t#query.; /*!< The query graph which will do the
198 parallelized purge operation */
199
200 /** Iterator to the undo log records of committed transactions */
201 struct iteratorcxx . . $ purge_sys_t#iterator#
202 {
203 bool operatorcxx . . $ purge_sys_t#iterator#`operator<=`(2e2c6d21236448ac).<=(const iteratorcxx . . $ purge_sys_t#iterator#& other) const
204 {
205 if (trx_nocxx . . $ purge_sys_t#iterator#trx_no. < other.trx_nocxx . . $ purge_sys_t#iterator#trx_no.) return true;
206 if (trx_nocxx . . $ purge_sys_t#iterator#trx_no. > other.trx_nocxx . . $ purge_sys_t#iterator#trx_no.) return false;
207 return undo_nocxx . . $ purge_sys_t#iterator#undo_no. <= other.undo_nocxx . . $ purge_sys_t#iterator#undo_no.;
208 }
209
210 /** Remove unnecessary history data from a rollback segment.
211 @param rseg rollback segment
212 @return error code */
213 inline dberr_tcxx . . $ dberr_t# free_history_rsegcxx . . $ purge_sys_t#iterator#free_history_rseg(ada28ec56c108510).(trx_rseg_tcxx . . $ trx_rseg_t# &rseg) const;
214
215 /** Free the undo pages up to this. */
216 dberr_tcxx . . $ dberr_t# free_historycxx . . $ purge_sys_t#iterator#free_history(ac874e7d7cb7faf0).() const;
217
218 /** trx_t::no of the committed transaction */
219 trx_id_tcxx . . $ trx_id_t# trx_nocxx . . $ purge_sys_t#iterator#trx_no.;
220 /** The record number within the committed transaction's undo
221 log, increasing, purged from from 0 onwards */
222 undo_no_tcxx . . $ undo_no_t# undo_nocxx . . $ purge_sys_t#iterator#undo_no.;
223 };
224
225 /** The tail of the purge queue; the last parsed undo log of a
226 committed transaction. */
227 iteratorcxx . . $ purge_sys_t#iterator# tailcxx . . $ purge_sys_t#tail.;
228 /** The head of the purge queue; any older undo logs of committed
229 transactions may be discarded (history list truncation).
230 Protected by latch. */
231 iteratorcxx . . $ purge_sys_t#iterator# headcxx . . $ purge_sys_t#head.;
232 /*-----------------------------*/
233 bool next_storedcxx . . $ purge_sys_t#next_stored.; /*!< whether rseg holds the next record
234 to purge */
235 trx_rseg_tcxx . . $ trx_rseg_t#* rsegcxx . . $ purge_sys_t#rseg.; /*!< Rollback segment for the next undo
236 record to purge */
237 private:
238 /** Coordinator thread's THD during batch processing.
239 Set by the coordinator at the start of trx_purge() and cleared
240 at the end. This serves two purposes:
241 1. Identifies the coordinator thread in reset_worker_thd()
242 which skips THD reset for the coordinator since it manages
243 cleanup centrally in trx_purge() after all workers complete.
244
245 2. Used to set TABLE::in_use when opening tables for purge
246 operations with virtual columns, ensuring proper table
247 ownership tracking during the purge batch. */
248 THDcxx . . $ THD# *coordinator_thdcxx . . $ purge_sys_t#coordinator_thd.= nullptr;
249
250 uint32_tcxx . . $ uint32_t# page_nocxx . . $ purge_sys_t#page_no.; /*!< Page number for the next undo
251 record to purge, page number of the
252 log header, if dummy record */
253 uint32_tcxx . . $ uint32_t# hdr_page_nocxx . . $ purge_sys_t#hdr_page_no.; /*!< Header page of the undo log where
254 the next record to purge belongs */
255 uint16_tcxx . . $ uint16_t# offsetcxx . . $ purge_sys_t#offset.; /*!< Page offset for the next undo
256 record to purge, 0 if the dummy
257 record */
258 uint16_tcxx . . $ uint16_t# hdr_offsetcxx . . $ purge_sys_t#hdr_offset.; /*!< Header byte offset on the page */
259
260 /** Binary min-heap of (trx_no, trx_sys.rseg_array index) pairs, ordered on
261 trx_no. It is protected by the pq_mutex */
262 purge_queuecxx . . $ purge_sys_t#purge_queue# purge_queuecxx . . $ purge_sys_t#purge_queue.;
263
264 /** Mutex protecting purge_queue */
265 mysql_mutex_t pq_mutexcxx . . $ purge_sys_t#pq_mutex.;
266
267 public:
268
269 void enqueuecxx . . $ purge_sys_t#enqueue(eb209464bbdc6da6).(trx_id_tcxx . . $ trx_id_t# trx_no, const trx_rseg_tcxx . . $ trx_rseg_t# &rseg) {
270 mysql_mutex_assert_ownercxx . . $ `include/mysql/psi/mysql_thread.h:273:9`!(&pq_mutex);
271 purge_queuecxx . . $ purge_sys_t#purge_queue..pushcxx . . $ purge_sys_t#purge_queue#push(eb209464bbdc6da6).(trx_no, rseg);
272 }
273
274 /** Push to purge queue without acquiring pq_mutex.
275 @param rseg rseg to push */
276 void enqueuecxx . . $ purge_sys_t#enqueue(b1c08a7cb91aa104).(const trx_rseg_tcxx . . $ trx_rseg_t# &rseg) { enqueuecxx . . $ purge_sys_t#enqueue(eb209464bbdc6da6).(rseg.last_trx_nocxx . . $ trx_rseg_t#last_trx_no(fe4d2d262d4164a8).(), rseg); }
277
278 /** Clone purge queue container.
279 @return purge queue container clone */
280 purge_queuecxx . . $ purge_sys_t#purge_queue#::container_typecxx . . $ purge_sys_t#purge_queue#container_type# clone_queue_containercxx . . $ purge_sys_t#clone_queue_container(58482be275174f31).() const {
281 mysql_mutex_assert_ownercxx . . $ `include/mysql/psi/mysql_thread.h:273:9`!(&pq_mutex);
282 return purge_queuecxx . . $ purge_sys_t#purge_queue..clone_containercxx . . $ purge_sys_t#purge_queue#clone_container(58482be275174f31).();
283 }
284
285 /** Acquare purge_queue_mutex */
286 void queue_lockcxx . . $ purge_sys_t#queue_lock(49f6e7a06ebc5aa8).() { mysql_mutex_lockcxx . . $ `include/mysql/psi/mysql_thread.h:360:11`!(&pq_mutex); }
287
288 /** Release purge queue mutex */
289 void queue_unlockcxx . . $ purge_sys_t#queue_unlock(49f6e7a06ebc5aa8).() { mysql_mutex_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:391:11`!(&pq_mutex); }
290
291 /** innodb_undo_log_truncate=ON state;
292 only modified by purge_coordinator_callback() */
293 structcxx . . $ purge_sys_t#$anonymous_type_0# {
294 /** The undo tablespace that is currently being truncated */
295 Atomic_relaxedcxx . . $ Atomic_relaxed#<fil_space_tcxx . . $ fil_space_t#*> currentcxx . . $ purge_sys_t#$anonymous_type_0#current.;
296 /** The number of the undo tablespace that was last truncated,
297 relative from srv_undo_space_id_start */
298 uint32_tcxx . . $ uint32_t# lastcxx . . $ purge_sys_t#$anonymous_type_0#last.;
299 } truncate_undo_spacecxx . . $ purge_sys_t#truncate_undo_space.;
300
301 /** Create the instance */
302 void createcxx . . $ purge_sys_t#create(49f6e7a06ebc5aa8).();
303
304 /** Close the purge system on shutdown */
305 void closecxx . . $ purge_sys_t#close(49f6e7a06ebc5aa8).();
306
307 /** @return whether purge is enabled */
308 bool enabledcxx . . $ purge_sys_t#enabled(c9857a73d68e59ba).() { return m_enabledcxx . . $ purge_sys_t#m_enabled..loadcxx . . $ std/atomic#load(84dca352c0e0dfc2).(stdcxx . . $ std/::memory_order_relaxedcxx . . $ std/memory_order_relaxed.); }
309 /** @return whether the purge coordinator is paused */
310 bool pausedcxx . . $ purge_sys_t#paused(c9857a73d68e59ba).()
311 { return m_pausedcxx . . $ purge_sys_t#m_paused. != 0; }
312
313 /** Enable purge at startup. */
314 void coordinator_startupcxx . . $ purge_sys_t#coordinator_startup(49f6e7a06ebc5aa8).()
315 {
316 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!enabled());
317 m_enabledcxx . . $ purge_sys_t#m_enabled..storecxx . . $ std/atomic#store(8f3cbf3da563ad44).(true, stdcxx . . $ std/::memory_order_relaxedcxx . . $ std/memory_order_relaxed.);
318 wake_if_not_activecxx . . $ purge_sys_t#wake_if_not_active(49f6e7a06ebc5aa8).();
319 }
320
321 /** Disable purge at shutdown */
322 void coordinator_shutdowncxx . . $ purge_sys_t#coordinator_shutdown(49f6e7a06ebc5aa8).()
323 {
324 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(enabled());
325 m_enabledcxx . . $ purge_sys_t#m_enabled..storecxx . . $ std/atomic#store(8f3cbf3da563ad44).(false, stdcxx . . $ std/::memory_order_relaxedcxx . . $ std/memory_order_relaxed.);
326 }
327
328 /** @return whether the purge tasks are active */
329 static bool runningcxx . . $ purge_sys_t#running(c9857a73d68e59ba).();
330
331 /** Stop purge during FLUSH TABLES FOR EXPORT. */
332 void stopcxx . . $ purge_sys_t#stop(49f6e7a06ebc5aa8).();
333 /** Resume purge at UNLOCK TABLES after FLUSH TABLES FOR EXPORT */
334 void resumecxx . . $ purge_sys_t#resume(49f6e7a06ebc5aa8).();
335
336 /** Close and reopen all tables in case of a MDL conflict with DDL
337 @param id table identifier that triggered reopen
338 @param pt last purge_table entry processed
339 @param thd coordinator thread
340 @return purge_table for the reopened table, or empty on error */
341 purge_tablecxx . . $ purge_table# close_and_reopencxx . . $ purge_sys_t#close_and_reopen(342b122877d4ec6e).(table_id_tcxx . . $ table_id_t# id, purge_tablecxx . . $ purge_table# pt,
342 THDcxx . . $ THD# *thd) noexcept;
343
344 private:
345 /** Suspend purge during a DDL operation on FULLTEXT INDEX tables */
346 void wait_FTScxx . . $ purge_sys_t#wait_FTS(b45ddcbc8423892c).(bool also_sys);
347 public:
348 /** Suspend purge in data dictionary tables */
349 void stop_SYScxx . . $ purge_sys_t#stop_SYS(49f6e7a06ebc5aa8).()
350 {
351 ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(const auto p=) m_FTS_pausedcxx . . $ purge_sys_t#m_FTS_paused..fetch_addcxx . . $ Atomic_relaxed#fetch_add(215bad66c94842d9).(PAUSED_SYScxx . . $ purge_sys_t#PAUSED_SYS.);
352 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(p < p + PAUSED_SYS);
353 }
354 /** Resume purge in data dictionary tables */
355 static void resume_SYScxx . . $ purge_sys_t#resume_SYS(5d22bdacc48458e8).(void *);
356
357 /** Pause purge during a DDL operation that could drop FTS_ tables. */
358 void stop_FTScxx . . $ purge_sys_t#stop_FTS(49f6e7a06ebc5aa8).();
359 /** Resume purge after stop_FTS(). */
360 void resume_FTScxx . . $ purge_sys_t#resume_FTS(49f6e7a06ebc5aa8).()
361 { ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(const auto p=) m_FTS_pausedcxx . . $ purge_sys_t#m_FTS_paused..fetch_subcxx . . $ Atomic_relaxed#fetch_sub(215bad66c94842d9).(1); ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(p & ~PAUSED_SYS); }
362 /** @return whether stop_SYS() is in effect */
363 bool must_wait_FTScxx . . $ purge_sys_t#must_wait_FTS(50ce9a9e25b4a850).() const { return m_FTS_pausedcxx . . $ purge_sys_t#m_FTS_paused. & ~PAUSED_SYScxx . . $ purge_sys_t#PAUSED_SYS.; }
364 /** Reset coordinator thread back to table->in_use */
365 inline void reset_in_usecxx . . $ purge_sys_t#reset_in_use(4a456cfb36f25b53).(TABLEcxx . . $ TABLE# *table) const noexcept;
366
367 private:
368 /**
369 Get the next record to purge and update the info in the purge system.
370 @param trx transaction attached to current_thd
371 @param roll_ptr undo log pointer to the record
372 @return buffer-fixed reference to undo log record
373 @retval {nullptr,1} if the whole undo log can skipped in purge
374 @retval {nullptr,0} if nothing is left, or on corruption */
375 inline trx_purge_rec_tcxx . . $ trx_purge_rec_t# get_next_reccxx . . $ purge_sys_t#get_next_rec(5a4150388f549195).(trx_tcxx . . $ trx_t# *trx, roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr)
376 noexcept;
377
378 /** Choose the next undo log to purge.
379 @param trx transaction attached to current_thd
380 @return whether anything is to be purged */
381 bool choose_next_logcxx . . $ purge_sys_t#choose_next_log(e25b100dcc9a6887).(trx_tcxx . . $ trx_t# *trx) noexcept;
382
383 /** Update the last not yet purged history log info in rseg when
384 we have purged a whole undo log. Advances also purge_trx_no
385 past the purged log.
386 @param trx transaction attached to current_thd
387 @return whether anything is to be purged */
388 bool rseg_get_next_history_logcxx . . $ purge_sys_t#rseg_get_next_history_log(e25b100dcc9a6887).(trx_tcxx . . $ trx_t# *trx) noexcept;
389
390 public:
391 /**
392 Fetch the next undo log record from the history list to purge.
393 @param trx transaction attached to current_thd
394 @return buffer-fixed reference to undo log record
395 @retval {nullptr,1} if the whole undo log can skipped in purge
396 @retval {nullptr,0} if nothing is left, or on corruption */
397 inline trx_purge_rec_tcxx . . $ trx_purge_rec_t# fetch_next_reccxx . . $ purge_sys_t#fetch_next_rec(877a5152e998ee40).(trx_tcxx . . $ trx_t# *trx) noexcept;
398
399 /** Determine if the history of a transaction is purgeable.
400 @param trx_id transaction identifier
401 @return whether the history is purgeable */
402 bool is_purgeablecxx . . $ purge_sys_t#is_purgeable(9d5f7ce526bbb82a).(trx_id_tcxx . . $ trx_id_t# trx_id) const noexcept;
403
404 /** A wrapper around ReadView::low_limit_no(). */
405 trx_id_tcxx . . $ trx_id_t# low_limit_nocxx . . $ purge_sys_t#low_limit_no(fe4d2d262d4164a8).() const
406 {
407 /* This function may only be called by purge_coordinator_callback().
408
409 The purge coordinator task may call this without holding any latch,
410 because it is the only thread that may modify purge_sys.view.
411
412 Any other threads that access purge_sys.view must hold purge_sys.latch,
413 typically via purge_sys_t::view_guard. */
414 return viewcxx . . $ purge_sys_t#view..low_limit_nocxx . . $ ReadViewBase#low_limit_no(fe4d2d262d4164a8).();
415 }
416 /** A wrapper around ReadView::sees(). */
417 trx_id_tcxx . . $ trx_id_t# seescxx . . $ purge_sys_t#sees(611be0c07d97f8b8).(trx_id_tcxx . . $ trx_id_t# id) const
418 {
419 /* This function may only be called by purge_coordinator_callback().
420
421 The purge coordinator task may call this without holding any latch,
422 because it is the only thread that may modify purge_sys.view.
423
424 Any other threads that access purge_sys.view must hold purge_sys.latch,
425 typically via purge_sys_t::view_guard. */
426 return viewcxx . . $ purge_sys_t#view..seescxx . . $ ReadViewBase#sees(2ff7c7de1baa6d0a).(id);
427 }
428
429 private:
430 /** Enable the use of a rollback segment and advance skipped_rseg,
431 after iterator::free_history_rseg() had invoked
432 rseg.set_skip_allocation(). */
433 inline void rseg_enablecxx . . $ purge_sys_t#rseg_enable(310dffeae004fd72).(trx_rseg_tcxx . . $ trx_rseg_t# &rseg);
434
435 /** Try to start truncating a tablespace.
436 @param id undo tablespace identifier
437 @param size the maximum desired undo tablespace size, in pages
438 @return undo tablespace whose truncation was started
439 @retval nullptr if truncation is not currently possible */
440 inline fil_space_tcxx . . $ fil_space_t# *undo_truncate_trycxx . . $ purge_sys_t#undo_truncate_try(ac6b828a4d6c8c02).(uint32_tcxx . . $ uint32_t# id, uint32_tcxx . . $ uint32_t# size);
441 public:
442 /** Check if innodb_undo_log_truncate=ON needs to be handled.
443 This is only to be called by purge_coordinator_callback().
444 @return undo tablespace chosen by innodb_undo_log_truncate=ON
445 @retval nullptr if truncation is not currently possible */
446 fil_space_tcxx . . $ fil_space_t# *truncating_tablespacecxx . . $ purge_sys_t#truncating_tablespace(edeef8bc7ec34c55).();
447
448 /** A wrapper around trx_sys_t::clone_oldest_view(). */
449 template<bool also_end_view= false>
450 void clone_oldest_viewcxx . . $ purge_sys_t#clone_oldest_view(4b9aaf75000f3009).(THDcxx . . $ THD# *thd)
451 {
452 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(also_end_view == !thd);
453 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!thd || !coordinator_thd);
454 coordinator_thdcxx . . $ purge_sys_t#coordinator_thd.= thd;
455
456 if (!also_end_view)
457 wait_FTScxx . . $ purge_sys_t#wait_FTS(b45ddcbc8423892c).(true);
458 latchcxx . . $ purge_sys_t#latch..wr_lockcxx . . $ srw_lock_impl#wr_lock(9bb8261ff8654062).(SRW_LOCK_CALLcxx . . $ `storage/innobase/include/srw_lock.h:44:10`!);
459 trx_syscxx . . $ trx_sys..clone_oldest_viewcxx . . $ trx_sys_t#clone_oldest_view(7cd7dd84e6152e76).(&viewcxx . . $ purge_sys_t#view.);
460 if (also_end_view)
461 (end_viewcxx . . $ purge_sys_t#end_view.=cxx . . $ ReadViewBase#`operator=`(d656b4f852d7c8c8). viewcxx . . $ purge_sys_t#view.).
462 clamp_low_limit_idcxx . . $ ReadViewBase#clamp_low_limit_id(2c44cd906ae4e829).(headcxx . . $ purge_sys_t#head..trx_nocxx . . $ purge_sys_t#iterator#trx_no. ? headcxx . . $ purge_sys_t#head..trx_nocxx . . $ purge_sys_t#iterator#trx_no. : tailcxx . . $ purge_sys_t#tail..trx_nocxx . . $ purge_sys_t#iterator#trx_no.);
463 latchcxx . . $ purge_sys_t#latch..wr_unlockcxx . . $ srw_lock_impl#wr_unlock(ced63f7c635d850d).();
464 }
465
466 /** Wake up the purge threads if there is work to do. */
467 void wake_if_not_activecxx . . $ purge_sys_t#wake_if_not_active(49f6e7a06ebc5aa8).();
468
469 /** Release undo pages and update end_view at the end of a purge batch.
470 @retval false when nothing is to be purged
471 @retval true when purge_sys.rseg->latch was locked */
472 inline void batch_cleanupcxx . . $ purge_sys_t#batch_cleanup(a74fbf3c0a7d2a41).(const iteratorcxx . . $ purge_sys_t#iterator# &head);
473
474 struct view_guardcxx . . $ purge_sys_t#view_guard#
475 {
476 enum guardcxx . . $ purge_sys_t#view_guard#guard# { END_VIEWcxx . . $ purge_sys_t#view_guard#END_VIEW.= -1, PURGEcxx . . $ purge_sys_t#view_guard#PURGE.= 0, VIEWcxx . . $ purge_sys_t#view_guard#VIEW.= 1};
477 guardcxx . . $ purge_sys_t#view_guard#guard# latchcxx . . $ purge_sys_t#view_guard#latch.;
478 inline view_guardcxx . . $ purge_sys_t#view_guard#view_guard(5109b1a2675d6def).(guardcxx . . $ purge_sys_t#view_guard#guard# latch);
479 inline ~cxx . . $ purge_sys_t#view_guard#`~view_guard`(ced63f7c635d850d).view_guardcxx . . $ purge_sys_t#view_guard#();
480 /** Fetch an undo log page.
481 @param id page identifier
482 @param trx transaction attached to current_thd
483 @param mtr mini-transaction
484 @return reference to buffer page, possibly buffer-fixed in mtr */
485 inline const buf_block_tcxx . . $ buf_block_t# *getcxx . . $ purge_sys_t#view_guard#get(de581e623cbc0ea5).(const page_id_tcxx . . $ page_id_t# id, trx_tcxx . . $ trx_t# *trx, mtr_tcxx . . $ mtr_t# *mtr);
486
487 /** @return purge_sys.view or purge_sys.end_view */
488 inline const ReadViewBasecxx . . $ ReadViewBase# &viewcxx . . $ purge_sys_t#view_guard#view(ea6329f428f0031b).() const;
489
490 /** @return whether this is part of CHECK TABLE ... EXTENDED */
491 bool is_extendedcxx . . $ purge_sys_t#view_guard#is_extended(3482b152b9333168).() const noexcept { return latchcxx . . $ purge_sys_t#view_guard#latch. < END_VIEWcxx . . $ purge_sys_t#view_guard#END_VIEW.; }
492 };
493
494 struct end_view_guardcxx . . $ purge_sys_t#end_view_guard#
495 {
496 inline end_view_guardcxx . . $ purge_sys_t#end_view_guard#end_view_guard(49f6e7a06ebc5aa8).();
497 inline ~cxx . . $ purge_sys_t#end_view_guard#`~end_view_guard`(ced63f7c635d850d).end_view_guardcxx . . $ purge_sys_t#end_view_guard#();
498
499 /** @return purge_sys.end_view */
500 inline const ReadViewBasecxx . . $ ReadViewBase# &viewcxx . . $ purge_sys_t#end_view_guard#view(ea6329f428f0031b).() const;
501 };
502
503 /** Stop the purge thread and check n_ref_count of all auxiliary
504 and common table associated with the fts table.
505 @param table parent FTS table
506 @param already_stopped True indicates purge threads were
507 already stopped */
508 void stop_FTScxx . . $ purge_sys_t#stop_FTS(4ab4a10c1ed48046).(const dict_table_tcxx . . $ dict_table_t# &table, bool already_stopped=false);
509
510 /** Cleanse purge queue to remove the rseg that reside in undo-tablespace
511 marked for truncate.
512 @param space undo tablespace being truncated */
513 void cleanse_purge_queuecxx . . $ purge_sys_t#cleanse_purge_queue(ac809d97151e1e2d).(const fil_space_tcxx . . $ fil_space_t# &space);
514
515 /** Reset the state of a purge_worker_task at the end of a batch */
516 inline void reset_worker_thdcxx . . $ purge_sys_t#reset_worker_thd(db60e84b6837d0f0).(THDcxx . . $ THD# *thd) const noexcept;
517 };
518
519 /** The global data structure coordinating a purge */
520 extern purge_sys_tcxx . . $ purge_sys_t# purge_syscxx . . $ purge_sys.;
521
522 purge_sys_tcxx . . $ purge_sys_t#::view_guardcxx . . $ purge_sys_t#view_guard#::view_guardcxx . . $ purge_sys_t#view_guard#view_guard(5109b1a2675d6def).(purge_sys_tcxx . . $ purge_sys_t#::view_guardcxx . . $ purge_sys_t#view_guard#::guardcxx . . $ purge_sys_t#view_guard#guard# latch) :
523 latchcxx . . $ purge_sys_t#view_guard#latch.(latch)
524 {
525 switch (latch) {
526 case VIEWcxx . . $ purge_sys_t#view_guard#VIEW.:
527 purge_syscxx . . $ purge_sys..latchcxx . . $ purge_sys_t#latch..rd_lockcxx . . $ srw_lock_impl#rd_lock(9bb8261ff8654062).(SRW_LOCK_CALLcxx . . $ `storage/innobase/include/srw_lock.h:44:10`!);
528 break;
529 case END_VIEWcxx . . $ purge_sys_t#view_guard#END_VIEW.:
530 purge_syscxx . . $ purge_sys..end_latchcxx . . $ purge_sys_t#end_latch..rd_lockcxx . . $ ssux_lock_impl#rd_lock(ced63f7c635d850d).();
531 break;
532 case PURGEcxx . . $ purge_sys_t#view_guard#PURGE.:
533 /* the access is within a purge batch; purge_coordinator_task
534 will wait for all workers to complete before updating the views */
535 break;
536 }
537 }
538
539 purge_sys_tcxx . . $ purge_sys_t#::view_guardcxx . . $ purge_sys_t#view_guard#::~cxx . . $ purge_sys_t#view_guard#`~view_guard`(ced63f7c635d850d).view_guardcxx . . $ purge_sys_t#view_guard#()
540 {
541 switch (latchcxx . . $ purge_sys_t#view_guard#latch.) {
542 case VIEWcxx . . $ purge_sys_t#view_guard#VIEW.:
543 purge_syscxx . . $ purge_sys..latchcxx . . $ purge_sys_t#latch..rd_unlockcxx . . $ srw_lock_impl#rd_unlock(ced63f7c635d850d).();
544 break;
545 case END_VIEWcxx . . $ purge_sys_t#view_guard#END_VIEW.:
546 purge_syscxx . . $ purge_sys..end_latchcxx . . $ purge_sys_t#end_latch..rd_unlockcxx . . $ ssux_lock_impl#rd_unlock(ced63f7c635d850d).();
547 break;
548 case PURGEcxx . . $ purge_sys_t#view_guard#PURGE.:
549 break;
550 }
551 }
552
553 const ReadViewBasecxx . . $ ReadViewBase# &purge_sys_tcxx . . $ purge_sys_t#::view_guardcxx . . $ purge_sys_t#view_guard#::viewcxx . . $ purge_sys_t#view_guard#view(ea6329f428f0031b).() const
554 { return latchcxx . . $ purge_sys_t#view_guard#latch. == END_VIEWcxx . . $ purge_sys_t#view_guard#END_VIEW. ? purge_syscxx . . $ purge_sys..end_viewcxx . . $ purge_sys_t#end_view. : purge_syscxx . . $ purge_sys..viewcxx . . $ purge_sys_t#view.; }
555
556 purge_sys_tcxx . . $ purge_sys_t#::end_view_guardcxx . . $ purge_sys_t#end_view_guard#::end_view_guardcxx . . $ purge_sys_t#end_view_guard#end_view_guard(49f6e7a06ebc5aa8).()
557 { purge_syscxx . . $ purge_sys..end_latchcxx . . $ purge_sys_t#end_latch..rd_lockcxx . . $ ssux_lock_impl#rd_lock(ced63f7c635d850d).(); }
558
559 purge_sys_tcxx . . $ purge_sys_t#::end_view_guardcxx . . $ purge_sys_t#end_view_guard#::~cxx . . $ purge_sys_t#end_view_guard#`~end_view_guard`(ced63f7c635d850d).end_view_guardcxx . . $ purge_sys_t#end_view_guard#()
560 { purge_syscxx . . $ purge_sys..end_latchcxx . . $ purge_sys_t#end_latch..rd_unlockcxx . . $ ssux_lock_impl#rd_unlock(ced63f7c635d850d).(); }
561
562 const ReadViewBasecxx . . $ ReadViewBase# &purge_sys_tcxx . . $ purge_sys_t#::end_view_guardcxx . . $ purge_sys_t#end_view_guard#::viewcxx . . $ purge_sys_t#end_view_guard#view(ea6329f428f0031b).() const
563 { return purge_syscxx . . $ purge_sys..end_viewcxx . . $ purge_sys_t#end_view.; }