![]() |
MySQL 26.7.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 "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 "fil0pages_persistence_interface.h"#include "fil0tablespace_scan.h"#include "fil0tablespaces_nodes_interface.h"#include "fsp0fsp.h"#include "fsp0sysspace.h"#include "ha_prototypes.h"#include "ibuf0ibuf.h"#include "log0chkp.h"#include "log0handler.h"#include "log0helpers.h"#include "log0recv.h"#include "log0write.h"#include "mem0mem.h"#include "mtr0mtr.h"#include "my_dbug.h"#include "my_psi_config.h"#include "mysql/psi/mysql_stage.h"#include "mysqld.h"#include "scope_guard.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 "ut0dbg.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_truncate::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 (ib::fil::Tablespace_node_handle_interface *file_handle, fil_space_t *space) |
| Try to read encryption metadata from an undo tablespace. More... | |
| static dberr_t | srv_undo_tablespace_fixup_num (space_id_t space_num) |
| Handles the undo_$num_trunc.log marker generated by 9.x, by removing the space with corresponding space_id, if it was found during tablespace scanning. 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_truncate::Tablespace &undo_space, bool expected_to_be_unusable) |
| Open an undo tablespace. More... | |
| static dberr_t | srv_undo_tablespace_open_by_num (const 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_create_implicit_tablespaces () |
| Create the implicit undo tablespaces for the new instance. More... | |
| static dberr_t | srv_undo_prepare_empty_structure (space_id_t space_id, bool enable_undo_encryption) |
| Initialize FSP structures (such as fragment and inode lists) and the (empty) rseg array of an undo tablespace. More... | |
| static void | srv_undo_mark_tablespace_usable (space_id_t space_id) |
| Mark the point in which an undo tablespace is fully constructed and ready to use. More... | |
| static void | srv_undo_mark_all_tablespaces_usable () |
| Mark any fully constructed undo tablespaces ready to use. More... | |
| dberr_t | srv_undo_tablespace_create (const char *space_name, const char *file_name, space_id_t space_id) |
| Create an undo tablespace. More... | |
| void | undo_truncate_spaces_init () |
| Initialize undo_truncate::spaces, called once during srv_start(). More... | |
| void | undo_truncate_spaces_deinit () |
| Free the resources occupied by undo_truncate::spaces, called once during srv_shutdown(). More... | |
| static dberr_t | srv_undo_create_implicit_tablespaces_with_empty_structure () |
| Create the implicit undo tablespaces for the new instance, and create their rseg arrrays, but not their rollback segments. More... | |
| static void | srv_start_wait_for_purge_to_start () |
| Wait for the purge thread(s) to start up. More... | |
| static void | srv_delete_temporary_space_files (ib::fsp::SysTablespace &tmp_space) |
| Deletes all files used by the System Temporary Tablespace. More... | |
| static dberr_t | srv_open_tmp_tablespace (ib::fsp::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 void | verify_page_type (page_id_t page_id, page_type_t type) |
| Check the page type, if there is a mismatch then throw fatal error. 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... | |
Variables | |
| 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.
|
static |
Create SDI Indexes in system tablespace.
|
static |
Deletes all files used by the System Temporary 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_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,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 |
Minimum expected tablespace size. TBD Why is it 5MB exactly?
| 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 |
Wait for the purge thread(s) to start up.
| 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 |
|
static |
Create the implicit undo tablespaces for the new instance.
It only ensures the Undo Tablespace exists, has a minimal valid header and is open. It doesn't create rseg arrays, nor rollback segments.
|
static |
Create the implicit undo tablespaces for the new instance, and create their rseg arrrays, but not their rollback segments.
|
static |
Mark any fully constructed undo tablespaces ready to use.
|
static |
Mark the point in which an undo tablespace is fully constructed and ready to use.
| [in] | space_id | undo tablespace id |
|
static |
Initialize FSP structures (such as fragment and inode lists) and the (empty) rseg array of an undo tablespace.
Before the call this tablespace file should be created and filled with zeros with a minimal tablespace header. This function does not create any rollback segments.
| [in] | space_id | undo tablespace id |
| [in] | enable_undo_encryption | whether to update global undo encryption metadata after construction |
| dberr_t srv_undo_tablespace_create | ( | const char * | space_name, |
| const char * | file_name, | ||
| space_id_t | space_id | ||
| ) |
Create an 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 |
Handles the undo_$num_trunc.log marker generated by 9.x, by removing the space with corresponding space_id, if it was found during tablespace scanning.
This ensures:
| [in] | space_num | undo tablespace number |
| dberr_t srv_undo_tablespace_open | ( | undo_truncate::Tablespace & | undo_space, |
| bool | expected_to_be_unusable | ||
| ) |
Open an undo tablespace.
| [in] | undo_space | Undo tablespace |
| [in] | expected_to_be_unusable | true if tablespace is expected to be unusable |
|
static |
Open an undo tablespace with a specified undo number.
If the undo space is undergoing truncation, we will delete the undo file.
| [in] | space_num | undo tablespace number |
|
static |
Try to read encryption metadata from an undo tablespace.
| [in] | file_handle | file handle of undo log file |
| [in] | space | undo tablespace |
|
static |
| void undo_truncate_spaces_deinit | ( | ) |
Free the resources occupied by undo_truncate::spaces, called once during srv_shutdown().
| void undo_truncate_spaces_init | ( | ) |
Initialize undo_truncate::spaces, called once during srv_start().
|
static |
Check the page type, if there is a mismatch then throw fatal error.
It may so happen that data file before 5.7 GA version may contain uninitialized bytes in the FIL_PAGE_TYPE field.
| [in] | page_id | Page id to verify |
| [in] | type | Expected page type |
|
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 |