MySQL 8.0.39
Source Code Documentation
srv0start.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1995, 2024, 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#include "os0thread-create.h"
38#ifndef UNIV_HOTBACKUP
39#include "sync0rw.h"
40#endif /* !UNIV_HOTBACKUP */
41#include "trx0purge.h"
42#include "univ.i"
43#include "ut0byte.h"
44
45// Forward declaration
46struct dict_table_t;
47
48#ifndef UNIV_DEBUG
49#define RECOVERY_CRASH(x) \
50 do { \
51 } while (0)
52#else
53#define RECOVERY_CRASH(x) \
54 do { \
55 if (srv_force_recovery_crash == x) { \
56 flush_error_log_messages(); \
57 fprintf(stderr, "innodb_force_recovery_crash=%lu\n", \
58 srv_force_recovery_crash); \
59 fflush(stderr); \
60 _exit(3); \
61 } \
62 } while (0)
63#endif /* UNIV_DEBUG */
64
65/** If buffer pool is less than the size,
66only one buffer pool instance is used. */
67constexpr uint32_t BUF_POOL_SIZE_THRESHOLD = 1024 * 1024 * 1024;
68
69/** Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
70 and srv_parse_log_group_home_dirs(). */
72
73/** Adds a slash or a backslash to the end of a string if it is missing
74 and the string is not empty.
75 @return string which has the separator if the string is not empty */
77 char *str); /*!< in: null-terminated character string */
78#ifndef UNIV_HOTBACKUP
79
80/** Open an undo tablespace.
81@param[in] undo_space Undo tablespace
82@return DB_SUCCESS or error code */
84
85/** Upgrade undo tablespaces by deleting the old undo tablespaces
86referenced by the TRX_SYS page.
87@return error code */
89
90/** Start InnoDB.
91@param[in] create_new_db Whether to create a new database
92@return DB_SUCCESS or error code */
93[[nodiscard]] dberr_t srv_start(bool create_new_db);
94
95/** Fix up an undo tablespace if it was in the process of being truncated
96when the server crashed. This is the second call and is done after the DD
97is available so now we know the space_name, file_name and previous space_id.
98@param[in] space_name undo tablespace name
99@param[in] file_name undo tablespace file name
100@param[in] space_id undo tablespace ID
101@return error code */
102dberr_t srv_undo_tablespace_fixup(const char *space_name, const char *file_name,
103 space_id_t space_id);
104
105/** On a restart, initialize the remaining InnoDB subsystems so that
106any tables (including data dictionary tables) can be accessed. */
108
109/** Start up the InnoDB service threads which are independent of DDL recovery.
110 */
111void srv_start_threads();
112
113/** Start the remaining InnoDB service threads which must wait for
114complete DD recovery(post the DDL recovery) */
116
117/** Start purge threads. During upgrade we start
118purge threads early to apply purge. */
120
121/** Get the encryption-data filename from the table name for a
122single-table tablespace.
123@param[in] table table object
124@param[out] filename filename
125@param[in] max_len filename max length */
127 ulint max_len);
128#endif /* !UNIV_HOTBACKUP */
129
130/** true if the server is being started */
131extern bool srv_is_being_started;
132/** true if SYS_TABLESPACES is available for lookups */
133extern bool srv_sys_tablespaces_open;
134/** true if the server is being started, before rolling back any
135incomplete transactions */
137
138/** true if a raw partition is in use */
139extern bool srv_start_raw_disk_in_use;
140
141#endif
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:51
dberr_t
Definition: db0err.h:39
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1052
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:94
The interface to the threading wrapper.
const char * filename
Definition: pfs_example_component_population.cc:67
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:3107
dberr_t srv_undo_tablespaces_upgrade()
Upgrade undo tablespaces by deleting the old undo tablespaces referenced by the TRX_SYS page.
Definition: srv0start.cc:994
void srv_dict_recover_on_restart()
On a restart, initialize the remaining InnoDB subsystems so that any tables (including data dictionar...
Definition: srv0start.cc:2380
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_open(undo::Tablespace &undo_space)
Open an undo tablespace.
Definition: srv0start.cc:530
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:467
bool srv_startup_is_before_trx_rollback_phase
true if the server is being started, before rolling back any incomplete transactions
Definition: srv0start.cc:141
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:2530
void srv_start_purge_threads()
Start purge threads.
Definition: srv0start.cc:2439
void srv_start_threads()
Start up the InnoDB service threads which are independent of DDL recovery.
Definition: srv0start.cc:2467
bool srv_start_raw_disk_in_use
true if a raw partition is in use
Definition: srv0start.cc:133
bool srv_sys_tablespaces_open
true if SYS_TABLESPACES is available for lookups
Definition: srv0start.cc:138
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:67
dberr_t srv_start(bool create_new_db)
Start InnoDB.
Definition: srv0start.cc:1541
bool srv_is_being_started
true if the server is being started
Definition: srv0start.cc:136
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:1909
An undo::Tablespace object is used to easily convert between undo_space_id and undo_space_num and to ...
Definition: trx0purge.h:314
The read-write lock (for threads, not for database transactions)
Purge old versions.
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:406
Utilities for byte operations.