| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 1995, 2026, Oracle and/or its affiliates. |
| 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 designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 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 |
| 46 |
struct 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, |
| 66 |
only one buffer pool instance is used. */ |
| 67 |
constexpr 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(). */ |
| 71 |
void srv_free_paths_and_sizes(void); |
| 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 */ |
| 76 |
char *srv_add_path_separator_if_needed( |
| 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 */ |
| 83 |
dberr_t srv_undo_tablespace_open(undo::Tablespace &undo_space); |
| 84 |
|
| 85 |
/** Upgrade undo tablespaces by deleting the old undo tablespaces |
| 86 |
referenced by the TRX_SYS page. |
| 87 |
@return error code */ |
| 88 |
dberr_t srv_undo_tablespaces_upgrade(); |
| 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 |
| 96 |
when the server crashed. This is the second call and is done after the DD |
| 97 |
is 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 */ |
| 102 |
dberr_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 |
| 106 |
any tables (including data dictionary tables) can be accessed. */ |
| 107 |
void srv_dict_recover_on_restart(); |
| 108 |
|
| 109 |
/** Start up the InnoDB service threads which are independent of DDL recovery. |
| 110 |
*/ |
| 111 |
void srv_start_threads(); |
| 112 |
|
| 113 |
/** Start the remaining InnoDB service threads which must wait for |
| 114 |
complete DD recovery(post the DDL recovery) */ |
| 115 |
void srv_start_threads_after_ddl_recovery(); |
| 116 |
|
| 117 |
/** Start purge threads. During upgrade we start |
| 118 |
purge threads early to apply purge. */ |
| 119 |
void srv_start_purge_threads(); |
| 120 |
|
| 121 |
/** Get the encryption-data filename from the table name for a |
| 122 |
single-table tablespace. |
| 123 |
@param[in] table table object |
| 124 |
@param[out] filename filename |
| 125 |
@param[in] max_len filename max length */ |
| 126 |
void srv_get_encryption_data_filename(dict_table_t *table, char *filename, |
| 127 |
ulint max_len); |
| 128 |
#endif /* !UNIV_HOTBACKUP */ |
| 129 |
|
| 130 |
/** true if the server is being started */ |
| 131 |
extern bool srv_is_being_started; |
| 132 |
/** true if SYS_TABLESPACES is available for lookups */ |
| 133 |
extern bool srv_sys_tablespaces_open; |
| 134 |
/** true if the server is being started, before rolling back any |
| 135 |
incomplete transactions */ |
| 136 |
extern bool srv_startup_is_before_trx_rollback_phase; |
| 137 |
|
| 138 |
/** true if a raw partition is in use */ |
| 139 |
extern bool srv_start_raw_disk_in_use; |
| 140 |
|
| 141 |
#endif |