MySQL 9.1.0
Source Code Documentation
|
Starts the InnoDB database server. More...
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <zlib.h>
#include "my_dbug.h"
#include "btr0btr.h"
#include "btr0cur.h"
#include "buf0buf.h"
#include "buf0dump.h"
#include "current_thd.h"
#include "data0data.h"
#include "data0type.h"
#include "dict0dd.h"
#include "dict0dict.h"
#include "fil0fil.h"
#include "fsp0fsp.h"
#include "fsp0sysspace.h"
#include "ha_prototypes.h"
#include "ibuf0ibuf.h"
#include "log0buf.h"
#include "log0chkp.h"
#include "log0recv.h"
#include "log0write.h"
#include "mem0mem.h"
#include "mtr0mtr.h"
#include "my_psi_config.h"
#include "mysql/psi/mysql_stage.h"
#include "mysqld.h"
#include "ddl0fts.h"
#include "os0file.h"
#include "os0thread-create.h"
#include "os0thread.h"
#include "page0cur.h"
#include "page0page.h"
#include "rem0rec.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "trx0sys.h"
#include "trx0trx.h"
#include "ut0mem.h"
#include "arch0arch.h"
#include "arch0recv.h"
#include "btr0pcur.h"
#include "btr0sea.h"
#include "buf0flu.h"
#include "buf0rea.h"
#include "clone0api.h"
#include "clone0clone.h"
#include "dict0boot.h"
#include "dict0crea.h"
#include "dict0load.h"
#include "dict0stats_bg.h"
#include "lock0lock.h"
#include "os0event.h"
#include "os0proc.h"
#include "pars0pars.h"
#include "que0que.h"
#include "rem0cmp.h"
#include "row0ins.h"
#include "row0mysql.h"
#include "row0row.h"
#include "row0sel.h"
#include "row0upd.h"
#include "srv0tmp.h"
#include "trx0purge.h"
#include "trx0roll.h"
#include "trx0rseg.h"
#include "usr0sess.h"
#include "ut0crc32.h"
#include "ut0new.h"
Classes | |
struct | Thread_to_stop |
struct | metadata_applier |
Applier of dynamic metadata. More... | |
Macros | |
#define | SRV_MAX_N_PENDING_SYNC_IOS 100 |
#define | srv_init_abort(_db_err) srv_init_abort_low(create_new_db, __FILE__, __LINE__, _db_err) |
Enumerations | |
enum | srv_start_state_t { SRV_START_STATE_NONE = 0 , SRV_START_STATE_IO = 1 , SRV_START_STATE_PURGE = 2 , SRV_START_STATE_STAT = 4 } |
Bit flags for tracking background thread creation. More... | |
Functions | |
static dberr_t | srv_undo_tablespace_create (undo::Tablespace &undo_space) |
Create undo tablespace. More... | |
static dberr_t | srv_undo_tablespace_enable_encryption (space_id_t space_id) |
Try to enable encryption of an undo log tablespace. More... | |
static dberr_t | srv_undo_tablespace_read_encryption (pfs_os_file_t fh, const char *file_name, fil_space_t *space) |
Try to read encryption metadata from an undo tablespace. More... | |
static dberr_t | srv_undo_tablespace_fixup_57 (space_id_t space_id) |
Fix up a v5.7 type undo tablespace that was being truncated. More... | |
static dberr_t | srv_undo_tablespace_fixup_num (space_id_t space_num) |
Start the fix-up process on an undo tablespace if it was in the process of being truncated when the server crashed. More... | |
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. More... | |
dberr_t | srv_undo_tablespace_open (undo::Tablespace &undo_space) |
Open an undo tablespace. More... | |
static dberr_t | srv_undo_tablespace_open_by_id (space_id_t space_id) |
Open an undo tablespace with a specified space_id. More... | |
static dberr_t | srv_undo_tablespace_open_by_num (space_id_t space_num) |
Open an undo tablespace with a specified undo number. More... | |
static dberr_t | srv_undo_tablespaces_open () |
static dberr_t | srv_undo_tablespaces_create () |
Create the implicit undo tablespaces if we are creating a new instance or if there was not enough implicit undo tablespaces previously existing. More... | |
static dberr_t | srv_undo_tablespaces_construct () |
Finish building an undo tablespace. More... | |
static void | srv_undo_tablespaces_mark_construction_done () |
Mark the point in which the undo tablespaces in the construction list are fully constructed and ready to use. More... | |
dberr_t | srv_undo_tablespaces_upgrade () |
Upgrade undo tablespaces by deleting the old undo tablespaces referenced by the TRX_SYS page. More... | |
static void | srv_undo_tablespaces_downgrade () |
Downgrade undo tablespaces by deleting the new undo tablespaces which are not referenced by the TRX_SYS page. More... | |
dberr_t | srv_undo_tablespace_create (const char *space_name, const char *file_name, space_id_t space_id) |
Create an undo tablespace with an explicit file name This is called during CREATE UNDO TABLESPACE. More... | |
void | undo_spaces_init () |
Initialize undo::spaces and trx_sys_undo_spaces, called once during srv_start(). More... | |
void | undo_spaces_deinit () |
Free the resources occupied by undo::spaces and trx_sys_undo_spaces, called once during thread de-initialization. More... | |
static dberr_t | srv_undo_tablespaces_init (bool create_new_db) |
Open the configured number of implicit undo tablespaces. More... | |
static void | srv_start_wait_for_purge_to_start () |
static dberr_t | srv_open_tmp_tablespace (bool create_new_db, SysTablespace *tmp_space) |
Create the temporary file tablespace. More... | |
static void | srv_create_sdi_indexes () |
Create SDI Indexes in system tablespace. More... | |
static void | srv_start_state_set (srv_start_state_t state) |
Set state to indicate start of particular group of threads in InnoDB. More... | |
static bool | srv_start_state_is_set (srv_start_state_t state) |
Check if following group of threads is started. More... | |
void | srv_shutdown_exit_threads () |
Attempt to shutdown all background threads created by InnoDB. More... | |
static dberr_t | srv_init_abort_low (bool create_new_db, const char *file, ulint line, dberr_t err) |
Innobase start-up aborted. More... | |
static dberr_t | recreate_redo_files (lsn_t &flushed_lsn) |
Recreate REDO log files. More... | |
dberr_t | srv_start (bool create_new_db) |
Start InnoDB. More... | |
static void | apply_dynamic_metadata () |
Apply the dynamic metadata to all tables. More... | |
void | srv_dict_recover_on_restart () |
On a restart, initialize the remaining InnoDB subsystems so that any tables (including data dictionary tables) can be accessed. More... | |
void | srv_start_purge_threads () |
Start purge threads. More... | |
void | srv_start_threads () |
Start up the InnoDB service threads which are independent of DDL recovery. More... | |
void | srv_start_threads_after_ddl_recovery () |
Start the remaining InnoDB service threads which must wait for complete DD recovery(post the DDL recovery) More... | |
static void | srv_shutdown_set_state (srv_shutdown_t new_state) |
Set srv_shutdown_state to a given state and validate change is proper. More... | |
static void | srv_shutdown_cleanup_and_master_stop () |
Shutdown background threads of InnoDB at the start of the shutdown phase. More... | |
bool | srv_shutdown_waits_for_rollback_of_recovered_transactions () |
Checks if all recovered transactions are supposed to be rolled back before shutdown is ended. More... | |
void | srv_pre_dd_shutdown () |
Shut down all InnoDB background tasks that may look up objects in the data dictionary. More... | |
static void | srv_shutdown_page_cleaners () |
Waits for page cleaners exit. More... | |
static lsn_t | srv_shutdown_log () |
Closes redo log. More... | |
static void | srv_shutdown_arch () |
Copy all remaining data and shutdown archiver threads. More... | |
void | srv_thread_delay_cleanup_if_needed (bool wait_for_signal) |
Delay the thread after it discovered that the shutdown_state is greater or equal to SRV_SHUTDOWN_CLEANUP, before it proceeds with further clean up. More... | |
void | srv_shutdown () |
Shut down the InnoDB database. More... | |
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. More... | |
void | srv_fatal_error () |
Call std::_Exit(3) More... | |
Variables | |
uint32_t | predefined_flags |
fil_space_t::flags for hard-coded tablespaces More... | |
bool | srv_start_raw_disk_in_use = false |
true if a raw partition is in use More... | |
bool | srv_is_being_started = false |
true if the server is being started More... | |
bool | srv_sys_tablespaces_open = false |
true if SYS_TABLESPACES is available for lookups More... | |
bool | srv_startup_is_before_trx_rollback_phase = false |
true if the server is being started, before rolling back any incomplete transactions More... | |
static bool | srv_start_has_been_called = false |
true if srv_start() has been called More... | |
static uint64_t | srv_start_state = SRV_START_STATE_NONE |
Track server thrd starting phases. More... | |
std::atomic< enum srv_shutdown_t > | srv_shutdown_state {SRV_SHUTDOWN_NONE} |
At a shutdown this value climbs from SRV_SHUTDOWN_NONE to SRV_SHUTDOWN_EXIT_THREADS. More... | |
static char * | srv_monitor_file_name |
Name of srv_monitor_file. More... | |
static PSI_stage_info * | srv_stages [] |
Array of all InnoDB stage events for monitoring activities via performance schema. More... | |
static constexpr uint32_t | SHUTDOWN_SLEEP_TIME_US = 100 |
Sleep time in loops which wait for pending tasks during shutdown. More... | |
static constexpr uint32_t | SHUTDOWN_SLEEP_ROUNDS |
Number of wait rounds during shutdown, after which error is produced, or other policy for timed out wait is applied. More... | |
static const Thread_to_stop | threads_to_stop [] |
Starts the InnoDB database server.
Created 2/16/1996 Heikki Tuuri
#define srv_init_abort | ( | _db_err | ) | srv_init_abort_low(create_new_db, __FILE__, __LINE__, _db_err) |
#define SRV_MAX_N_PENDING_SYNC_IOS 100 |
enum srv_start_state_t |
Bit flags for tracking background thread creation.
They are used to determine which threads need to be stopped if we need to abort during the initialisation step.
|
static |
Apply the dynamic metadata to all tables.
Recreate REDO log files.
[in,out] | flushed_lsn | flushed_lsn |
|
static |
Create SDI Indexes in system tablespace.
void srv_dict_recover_on_restart | ( | ) |
On a restart, initialize the remaining InnoDB subsystems so that any tables (including data dictionary tables) can be accessed.
void srv_fatal_error | ( | ) |
Call std::_Exit(3)
Call std::quick_exit(3)
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.
[in] | table | table object |
[out] | filename | filename |
[in] | max_len | filename max length |
|
static |
Innobase start-up aborted.
Perform cleanup actions.
[in] | create_new_db | true if new db is being created |
[in] | file | File name |
[in] | line | Line number |
[in] | err | Reason for aborting InnoDB startup |
|
static |
Create the temporary file tablespace.
[in] | create_new_db | whether we are creating a new database |
[in,out] | tmp_space | Shared Temporary SysTablespace |
void srv_pre_dd_shutdown | ( | ) |
Shut down all InnoDB background tasks that may look up objects in the data dictionary.
void srv_shutdown | ( | ) |
Shut down the InnoDB database.
|
static |
Copy all remaining data and shutdown archiver threads.
|
static |
Shutdown background threads of InnoDB at the start of the shutdown phase.
Handles shutdown phases: SRV_SHUTDOWN_CLEANUP and SRV_SHUTDOWN_MASTER_STOP.
void srv_shutdown_exit_threads | ( | ) |
Attempt to shutdown all background threads created by InnoDB.
NOTE: Does not guarantee they are actually shut down, only does the best effort. Changes state of shutdown to SHUTDOWN_EXIT_THREADS, wakes up the background threads and waits a little bit. It might be used within startup phase or when fatal error is discovered during some IO operation. Therefore you must not assume anything related to the state in which it might be used.
|
static |
Closes redo log.
If this is not fast shutdown, it forces to write a checkpoint which should be written for logically empty redo log. Note that we forced to flush all dirty pages in the last stages of page cleaners activity (unless it was fast shutdown). After checkpoint is written, the flushed_lsn is updated within header of the system tablespace. This is lsn of the last clean shutdown.
|
static |
Waits for page cleaners exit.
|
static |
Set srv_shutdown_state to a given state and validate change is proper.
[in] | new_state | new state to set |
bool srv_shutdown_waits_for_rollback_of_recovered_transactions | ( | ) |
Checks if all recovered transactions are supposed to be rolled back before shutdown is ended.
dberr_t srv_start | ( | bool | create_new_db | ) |
Start InnoDB.
[in] | create_new_db | Whether to create a new database |
void srv_start_purge_threads | ( | ) |
Start purge threads.
During upgrade we start purge threads early to apply purge.
|
inlinestatic |
Check if following group of threads is started.
state | in: state to check for |
|
inlinestatic |
Set state to indicate start of particular group of threads in InnoDB.
state | in: indicate current state of thread startup |
void srv_start_threads | ( | ) |
Start up the InnoDB service threads which are independent of DDL recovery.
void srv_start_threads_after_ddl_recovery | ( | ) |
Start the remaining InnoDB service threads which must wait for complete DD recovery(post the DDL recovery)
|
static |
void srv_thread_delay_cleanup_if_needed | ( | bool | wait_for_signal | ) |
Delay the thread after it discovered that the shutdown_state is greater or equal to SRV_SHUTDOWN_CLEANUP, before it proceeds with further clean up.
This is used in the tests to see if such a possible delay does not have impact on the clean shutdown.
[in] | wait_for_signal | wait until shutdown phase starts |
dberr_t srv_undo_tablespace_create | ( | const char * | space_name, |
const char * | file_name, | ||
space_id_t | space_id | ||
) |
Create an undo tablespace with an explicit file name This is called during CREATE UNDO TABLESPACE.
[in] | space_name | tablespace name |
[in] | file_name | file name |
[in] | space_id | Tablespace ID |
|
static |
Create undo tablespace.
[in] | undo_space | Undo Tablespace |
|
static |
Try to enable encryption of an undo log tablespace.
[in] | space_id | undo tablespace id |
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.
This is the second call and is done after the DD is available so now we know the space_name, file_name and previous space_id.
[in] | space_name | undo tablespace name |
[in] | file_name | undo tablespace file name |
[in] | space_id | undo tablespace ID |
|
static |
Fix up a v5.7 type undo tablespace that was being truncated.
The space_id is not a reserved undo space_id. We will just delete the file since it will be replaced.
[in] | space_id | Tablespace ID |
|
static |
Start the fix-up process on an undo tablespace if it was in the process of being truncated when the server crashed.
At this point, just delete the old file if it exists. We could do the whole reconstruction here for implicit undo spaces since we know the space_id, space_name, and file_name implicitly. But for explicit undo spaces, we must wait for the DD to be scanned in boot_tablespaces() in order to know the space_id, space_name, and file_name.
[in] | space_num | undo tablespace number |
dberr_t srv_undo_tablespace_open | ( | undo::Tablespace & | undo_space | ) |
Open an undo tablespace.
[in] | undo_space | Undo tablespace |
|
static |
Open an undo tablespace with a specified space_id.
[in] | space_id | tablespace ID |
|
static |
Open an undo tablespace with a specified undo number.
[in] | space_num | undo tablespace number |
|
static |
Try to read encryption metadata from an undo tablespace.
[in] | fh | file handle of undo log file |
[in] | file_name | file name |
[in] | space | undo tablespace |
|
static |
Finish building an undo tablespace.
So far these tablespace files in the construction list should be created and filled with zeros.
|
static |
Create the implicit undo tablespaces if we are creating a new instance or if there was not enough implicit undo tablespaces previously existing.
|
static |
Downgrade undo tablespaces by deleting the new undo tablespaces which are not referenced by the TRX_SYS page.
|
static |
Open the configured number of implicit undo tablespaces.
[in] | create_new_db | true if new db being created |
|
static |
Mark the point in which the undo tablespaces in the construction list are fully constructed and ready to use.
|
static |
dberr_t srv_undo_tablespaces_upgrade | ( | ) |
Upgrade undo tablespaces by deleting the old undo tablespaces referenced by the TRX_SYS page.
void undo_spaces_deinit | ( | ) |
Free the resources occupied by undo::spaces and trx_sys_undo_spaces, called once during thread de-initialization.
void undo_spaces_init | ( | ) |
Initialize undo::spaces and trx_sys_undo_spaces, called once during srv_start().
|
extern |
fil_space_t::flags for hard-coded tablespaces
|
staticconstexpr |
Number of wait rounds during shutdown, after which error is produced, or other policy for timed out wait is applied.
|
staticconstexpr |
Sleep time in loops which wait for pending tasks during shutdown.
bool srv_is_being_started = false |
true if the server is being started
|
static |
Name of srv_monitor_file.
std::atomic<enum srv_shutdown_t> srv_shutdown_state {SRV_SHUTDOWN_NONE} |
At a shutdown this value climbs from SRV_SHUTDOWN_NONE to SRV_SHUTDOWN_EXIT_THREADS.
|
static |
Array of all InnoDB stage events for monitoring activities via performance schema.
|
static |
true if srv_start() has been called
bool srv_start_raw_disk_in_use = false |
true if a raw partition is in use
|
static |
Track server thrd starting phases.
bool srv_startup_is_before_trx_rollback_phase = false |
true if the server is being started, before rolling back any incomplete transactions
bool srv_sys_tablespaces_open = false |
true if SYS_TABLESPACES is available for lookups
|
static |