MySQL 9.3.0
Source Code Documentation
srv0srv.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1995, 2025, Oracle and/or its affiliates.
4Copyright (c) 2008, 2009, Google Inc.
5Copyright (c) 2009, Percona Inc.
6
7Portions of this file contain modifications contributed and copyrighted by
8Google, Inc. Those modifications are gratefully acknowledged and are described
9briefly in the InnoDB documentation. The contributions by Google are
10incorporated with their permission, and subject to the conditions contained in
11the file COPYING.Google.
12
13Portions of this file contain modifications contributed and copyrighted
14by Percona Inc.. Those modifications are
15gratefully acknowledged and are described briefly in the InnoDB
16documentation. The contributions by Percona Inc. are incorporated with
17their permission, and subject to the conditions contained in the file
18COPYING.Percona.
19
20This program is free software; you can redistribute it and/or modify it under
21the terms of the GNU General Public License, version 2.0, as published by the
22Free Software Foundation.
23
24This program is designed to work with certain software (including
25but not limited to OpenSSL) that is licensed under separate terms,
26as designated in a particular file or component or in included license
27documentation. The authors of MySQL hereby grant you an additional
28permission to link the program and your derivative works with the
29separately licensed software that they have either included with
30the program or referenced in the documentation.
31
32This program is distributed in the hope that it will be useful, but WITHOUT
33ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
34FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
35for more details.
36
37You should have received a copy of the GNU General Public License along with
38this program; if not, write to the Free Software Foundation, Inc.,
3951 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
40
41*****************************************************************************/
42
43/** @file include/srv0srv.h
44 The server main program
45
46 Created 10/10/1995 Heikki Tuuri
47 *******************************************************/
48
49#ifndef srv0srv_h
50#define srv0srv_h
51
52#include "buf0checksum.h"
53#include "fil0fil.h"
55#include "univ.i"
56
57#ifndef UNIV_HOTBACKUP
58#include "log0ddl.h"
59#include "os0event.h"
60#include "os0file.h"
61#include "os0thread.h"
62#include "que0types.h"
63#include "srv0conc.h"
64#include "trx0types.h"
65#include "ut0counter.h"
66
67#include <cstdint>
68#include <future>
69
70/* Global counters used inside InnoDB. */
77
78 /** Count the amount of data written in total (in bytes) */
80
81 /** Number of the log write requests done */
83
84 /** Number of physical writes to the log performed */
86
87 /** Amount of data written to the log files in bytes */
89
90 /** Number of writes being done to the log files */
92
93 /** We increase this counter, when we don't have enough
94 space in the log buffer and have to flush it */
96
97 /** Count the number of times the doublewrite buffer was flushed */
99
100 /** Store the number of pages that have been flushed to the
101 doublewrite buffer */
103
104 /** Store the number of write requests issued */
106
107 /** Store the number of times when we had to wait for a free page
108 in the buffer pool. It happens when the buffer pool is full and we
109 need to make a flush, in order to be able to read or create a page. */
111
112 /** Count the number of pages that were written from buffer
113 pool to the disk */
115
116 /** Number of buffer pool reads that led to the reading of
117 a disk page */
119
120 /** Number of data read in total (in bytes) */
122
123 /** Wait time of database locks */
125
126 /** Number of database lock waits */
128
129 /** Number of threads currently waiting on database locks */
131
132 /** Number of rows read. */
134
135 /** Number of rows updated */
137
138 /** Number of rows deleted */
140
141 /** Number of rows inserted */
143
144 /** Number of system rows read. */
146
147 /** Number of system rows updated */
149
150 /** Number of system rows deleted */
152
153 /** Number of system rows inserted */
155
156 /** Number of sampled pages read */
158
159 /** Number of sampled pages skipped */
161};
162
163/** Structure which keeps shared future objects for InnoDB background
164threads. One should use these objects to check if threads exited. */
166 /** Monitor thread (prints info). */
168
169 /** Error monitor thread. */
171
172 /** Redo files governor thread. */
174
175 /** Redo checkpointer thread. */
177
178 /** Redo writer thread. */
180
181 /** Redo flusher thread. */
183
184 /** Redo write notifier thread. */
186
187 /** Redo flush notifier thread. */
189
190 /** Redo log archiver (used by backup). */
192
193 /** Buffer pool dump thread. */
195
196 /** Buffer pool resize thread. */
198
199 /** Dict stats background thread. */
201
202 /** Thread detecting lock wait timeouts. */
204
205 /** The master thread. */
207
208 /** The ts_alter_encrypt thread. */
210
211 /** Thread doing rollbacks during recovery. */
213
214 /** Thread writing recovered pages during recovery. */
216
217 /** Purge coordinator (also being a worker) */
219
220 /** Number of purge workers and size of array below. */
222
223 /** Purge workers. Note that the m_purge_workers[0] is the same shared
224 state as m_purge_coordinator. */
226
227 /** Page cleaner coordinator (also being a worker). */
229
230 /** Number of page cleaner workers and size of array below. */
232
233 /** Page cleaner workers. Note that m_page_cleaner_workers[0] is the
234 same shared state as m_page_cleaner_coordinator. */
236
237 /** Archiver's log archiver (used by Clone). */
239
240 /** Archiver's page archiver (used by Clone). */
242
243 /** Thread doing optimization for FTS index. */
245
246 /** Thread for GTID persistence */
248
249#ifdef UNIV_DEBUG
250 /** Used in test scenario to delay threads' cleanup until the pre_dd_shutdown
251 is ended and final plugin's shutdown is started (when plugin is DELETED).
252 Note that you may only delay the shutdown for threads for which there is no
253 waiting procedure used in the pre_dd_shutdown. */
255#endif /* UNIV_DEBUG */
256
257 /** When the master thread notices that shutdown has started (by noticing
258 srv_shutdown_state >= SRV_SHUTDOWN_PRE_DD_AND_SYSTEM_TRANSACTIONS), it exits
259 its main loop. Then the master thread proceeds with actions related to tasks:
260 - which it has been responsible for,
261 - and which might depend on DD objects.
262 After finishing them, the master thread sets this event.
263 @remarks We use this event to wait in srv_pre_dd_shutdown before we enter
264 next phase (SRV_SHUTDOWN_PURGE) in which master thread is not allowed to
265 use system transactions or touch DD objects. */
267};
268
269/** Check if given thread is still active. */
270bool srv_thread_is_active(const IB_thread &thread);
271
272/** Check if given thread is cleaned-up and stopped. */
273bool srv_thread_is_stopped(const IB_thread &thread);
274
275/** Delay the thread after it discovered that the shutdown_state
276is greater or equal to SRV_SHUTDOWN_CLEANUP, before it proceeds
277with further clean up. This is used in the tests to see if such
278a possible delay does not have impact on the clean shutdown.
279@param[in] wait_for_signal wait until shutdown phase starts */
280void srv_thread_delay_cleanup_if_needed(bool wait_for_signal);
281