MySQL 26.7.0
Source Code Documentation
srv0start.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1995, 2026, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/srv0start.h
29 Starts the Innobase database server
30
31 Created 10/10/1995 Heikki Tuuri
32 *******************************************************/
33
34#ifndef srv0start_h
35#define srv0start_h
36
37#ifndef UNIV_HOTBACKUP
38#if !defined(UNIV_LIBRARY) && !defined(INNORWLOCKTEST)
39#include "os0thread-create.h"
40#endif
41#include "sync0rw.h"
42#endif /* !UNIV_HOTBACKUP */
43#include "srv0srv.h" // srv_force_recovery_crash
44#include "univ.i"
45#include "ut0byte.h"
46#include "ut0dbg.h"
47
48// Forward declaration
49struct dict_table_t;
50namespace undo_truncate {
51struct Tablespace;
52}
53
54static inline void srv_recovery_crash([[maybe_unused]] ulong x) {
55#ifdef UNIV_DEBUG
56 if (srv_force_recovery_crash == x) {
57 fprintf(stderr, "innodb_force_recovery_crash=%lu\n", x);
58 /* This causes the ut_fatal_error to not generate core file nor print
59 stacks, just terminate. */
60 set_my_abort([]() { std::_Exit(3); });
62 }
63#endif
64}
65
66/** If buffer pool is less than the size,
67only one buffer pool instance is used. */
68constexpr uint32_t BUF_POOL_SIZE_THRESHOLD = 1024 * 1024 * 1024;
69
70/** Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
71 and srv_parse_log_group_home_dirs(). */
73
74/** Adds a slash or a backslash to the end of a string if it is missing
75 and the string is not empty.
76 @return string which has the separator if the string is not empty */
78 char *str); /*!< in: null-terminated character string */
79#ifndef UNIV_HOTBACKUP
80
81/** Open an undo tablespace.
82@param[in] undo_space Undo tablespace
83@param[in] expected_to_be_unusable true if tablespace is expected to be
84 unusable
85@return DB_SUCCESS or error code */
87 undo_truncate::Tablespace &undo_space, bool expected_to_be_unusable);
88
89/** Start InnoDB.
90@param[in] create_new_db Whether to create a new database
91@return DB_SUCCESS or error code */
92[[nodiscard]] dberr_t srv_start(bool create_new_db);
93
94/** Fix up an undo tablespace if it was in the process of being truncated
95when the server crashed. This is the second call and is done after the DD
96is available so now we know the space_name, file_name and previous space_id.
97@param[in] space_name undo tablespace name
98@param[in] file_name undo tablespace file name
99@param[in] space_id undo tablespace ID
100@return DB_SUCCESS or error code */
101dberr_t srv_undo_tablespace_fixup(const char *space_name, const char *file_name,
102 space_id_t space_id);
103
104/** On a restart, initialize the remaining InnoDB subsystems so that
105any tables (including data dictionary tables) can be accessed. */
107
108/** Start up the InnoDB service threads which are independent of DDL recovery.
109 */
110void srv_start_threads();
111
112/** Start the remaining InnoDB service threads which must wait for
113complete DD recovery(post the DDL recovery) */
115
116/** Start purge threads. During upgrade we start
117purge threads early to apply purge. */
119
120/** Get the encryption-data filename from the table name for a
121single-table tablespace.
122@param[in] table table object
123@param[out] filename filename
124@param[in] max_len filename max length */
126 ulint max_len);
127#endif /* !UNIV_HOTBACKUP */
128
129/** true if the server is being started */
130extern bool srv_is_being_started;
131/** true if SYS_TABLESPACES is available for lookups */
132extern bool srv_sys_tablespaces_open;
133
134#ifndef UNIV_HOTBACKUP
135/** true if the server is being started, before rolling back any
136incomplete transactions */
138#endif
139
140/** true if a raw partition is in use */
141extern bool srv_start_raw_disk_in_use;
142
143#endif
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:49
dberr_t
Definition: db0err.h:39
void set_my_abort(void(*new_my_abort_func)())
Sets a new function to be called on my_abort().
Definition: my_init.cc:272
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:45
Definition: srv0start.h:50
The interface to the threading wrapper.
const char * filename
Definition: pfs_example_component_population.cc:67
The server main program.
ulong srv_force_recovery_crash
Inject a crash at different steps of the recovery process.
Definition: srv0srv.cc:531
void srv_get_encryption_data_filename(dict_table_t *table, char *filename, ulint max_len)
Get the encryption-data filename from the table name for a single-table tablespace.
Definition: srv0start.cc:2861
static void srv_recovery_crash(ulong x)
Definition: srv0start.h:54
void srv_dict_recover_on_restart()
On a restart, initialize the remaining InnoDB subsystems so that any tables (including data dictionar...
Definition: srv0start.cc:2126
void srv_free_paths_and_sizes(void)
Frees the memory allocated by srv_parse_data_file_paths_and_sizes() and srv_parse_log_group_home_dirs...
dberr_t srv_undo_tablespace_fixup(const char *space_name, const char *file_name, space_id_t space_id)
Fix up an undo tablespace if it was in the process of being truncated when the server crashed.
Definition: srv0start.cc:384
bool srv_startup_is_before_trx_rollback_phase
true if the server is being started, before rolling back any incomplete transactions
Definition: srv0start.cc:136
void srv_start_threads_after_ddl_recovery()
Start the remaining InnoDB service threads which must wait for complete DD recovery(post the DDL reco...
Definition: srv0start.cc:2274
void srv_start_purge_threads()
Start purge threads.
Definition: srv0start.cc:2185
void srv_start_threads()
Start up the InnoDB service threads which are independent of DDL recovery.
Definition: srv0start.cc:2213
bool srv_start_raw_disk_in_use
true if a raw partition is in use
Definition: srv0start.cc:132
bool srv_sys_tablespaces_open
true if SYS_TABLESPACES is available for lookups
Definition: srv0start.cc:135
dberr_t srv_undo_tablespace_open(undo_truncate::Tablespace &undo_space, bool expected_to_be_unusable)
Open an undo tablespace.
Definition: srv0start.cc:524
constexpr uint32_t BUF_POOL_SIZE_THRESHOLD
If buffer pool is less than the size, only one buffer pool instance is used.
Definition: srv0start.h:68
dberr_t srv_start(bool create_new_db)
Start InnoDB.
Definition: srv0start.cc:1415
bool srv_is_being_started
true if the server is being started
Definition: srv0start.cc:134
char * srv_add_path_separator_if_needed(char *str)
Adds a slash or a backslash to the end of a string if it is missing and the string is not empty.
Data structure for a database table.
Definition: dict0mem.h:1927
An undo_truncate::Tablespace object is used to easily convert between undo_space_id and undo_space_nu...
Definition: trx0undo_trunc.h:188
The read-write lock (for threads, not for database transactions)
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:403
Utilities for byte operations.
Debug utilities for Innobase.
void ut_fatal_error()
Terminates execution of the current process.
Definition: ut0dbg.cc:99