MySQL 8.0.31
Source Code Documentation
log0files_governor.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2019, 2022, 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 also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27/**************************************************/ /**
28 @file include/log0files_governor.h
29
30Redo log management of log files.
31
32 *******************************************************/
33
34#ifndef log0files_governor_h
35#define log0files_governor_h
36
37/* Log_files_dict */
38#include "log0files_dict.h"
39
40/* Log_files_find_result */
41#include "log0files_finder.h"
42
43/* log_t& */
44#include "log0types.h"
45
46/* os_offset_t */
47#include "os0file.h"
48
49/* srv_threads */
50#include "srv0srv.h"
51
52#ifndef UNIV_HOTBACKUP
53
54/** Checks if log file governor thread is active.
55@return true if and only if the log checkpointer thread is active */
58}
59
60#define log_files_mutex_enter(log) mutex_enter(&((log).m_files_mutex))
61
62#define log_files_mutex_exit(log) mutex_exit(&((log).m_files_mutex))
63
64#define log_files_mutex_own(log) mutex_own(&((log).m_files_mutex))
65
66#endif /* !UNIV_HOTBACKUP */
67
68/** Creates a new set of redo log files.
69@remarks
70Before creating the new log files, function asserts that there are no existing
71log files in the directory specified for the redo log.
72The new set of log files starts at the beginning of the first log block after
73the given lsn (block which start_lsn is greater than the given flushed_lsn).
74Checkpoint is written LOG_BLOCK_HDR_SIZE bytes after the beginning of that
75block.
76The set is marked as initialized if this call succeeded and information about
77the initial LSN is emitted to the error log. In such case, a new value is
78generated and assigned to the log.m_log_uuid (identifying the new log files).
79@param[in,out] log redo log
80@param[in] flushed_lsn the new set of log files should start with log
81 block which first data byte is addressed by lsn
82 greater or equal to this value
83@param[out] checkpoint_lsn lsn of the first created checkpoint
84@return DB_SUCCESS or error code */
85dberr_t log_files_create(log_t &log, lsn_t flushed_lsn, lsn_t &checkpoint_lsn);
86
87/** Removes all log files.
88@param[in,out] log redo log */
89void log_files_remove(log_t &log);
90
91/** Creates a next log file, ready for writes. Updates log.m_current_file.
92@param[in,out] log redo log
93@retval DB_SUCCESS if created successfully
94@retval DB_OUT_OF_DISK_SPACE if there was no free space to create next file,
95 according to limitations we have for redo files,
96 or according to space physically available on
97 the disk
98@retval other errors are possible */
100
101/** Persists log flags to the newest log file. Flushes header of the
102log file and updates log.m_log_flags if succeeded.
103@param[in,out] log redo log
104@param[in] log_flags log_flags to persist
105@return DB_SUCCESS or error */
107
108/** Resets creator name to the current creator and marks all files as full in
109their headers by setting LOG_HEADER_FLAG_FILE_FULL bit in the log_flags field.
110Flushes headers of all log files and updates log.m_creator_name and log.m_files
111accordingly if succeeded (if fails, then some files might remain updated and
112some not; metadata stored in log.m_files should reflect that).
113@param[in,out] log redo log
114@return DB_SUCCESS or error */
116
117/** Waits until a next log file is available and can be produced.
118@param[in] log redo log */
120
121/** The log files governor thread routine.
122@param[in,out] log_ptr pointer to redo log */
123void log_files_governor(log_t *log_ptr);
124
125/** Starts the log file management.
126@param[in] log redo log
127@return DB_SUCCESS or error */
129
130/** Computes initial capacity limits and size suggested for the next log file.
131Called when logically empty redo log is being initialized.
132@param[in,out] log redo log */
134
135/** Computes initial capacity limits and size suggested for the next log file.
136Called after existing redo log files have been discovered (log.m_files).
137@param[in,out] log redo log */
139
140/** Updates capacity limitations after srv_redo_log_capacity_used has been
141changed. It is called when user requests to change innodb_redo_log_capacity
142in runtime.
143@param[in,out] log redo log */
145
146/** Updates capacity limitations after srv_thread_concurrency has been changed.
147It is called when user requests to change innodb_thread_concurrency in runtime.
148@param[in,out] log redo log */
150
151/** Disallows to generate dummy redo records and waits until
152the log_files_governor thread promised not to generate them.
153@param[in,out] log redo log */
155
156/** Disallows to generate dummy redo records but does not wait until
157the log_files_governor promised not to generate them anymore.
158@param[in,out] log redo log */
160
161/** Updates the encryption metadata stored in-memory for all redo log files.
162Caller needs to have the log.m_files_mutex acquired before calling this.
163@param[in,out] log redo log
164@param[in] encryption_metadata encryption metadata */
166 log_t &log, const Encryption_metadata &encryption_metadata);
167
168#endif /* !log0files_governor_h */
dberr_t
Definition: db0err.h:38
In-memory dictionary of log files (keeps their meta data).
void log_files_thread_concurrency_updated(log_t &log)
Updates capacity limitations after srv_thread_concurrency has been changed.
Definition: log0files_governor.cc:2033
void log_files_dummy_records_request_disable(log_t &log)
Disallows to generate dummy redo records but does not wait until the log_files_governor promised not ...
Definition: log0files_governor.cc:1932
dberr_t log_files_persist_flags(log_t &log, Log_flags log_flags)
Persists log flags to the newest log file.
Definition: log0files_governor.cc:1814
void log_files_update_encryption(log_t &log, const Encryption_metadata &encryption_metadata)
Updates the encryption metadata stored in-memory for all redo log files.
Definition: log0files_governor.cc:1857
void log_files_initialize_on_existing_redo(log_t &log)
Computes initial capacity limits and size suggested for the next log file.
Definition: log0files_governor.cc:2012
void log_files_governor(log_t *log_ptr)
The log files governor thread routine.
Definition: log0files_governor.cc:1347
void log_files_remove(log_t &log)
Removes all log files.
Definition: log0files_governor.cc:1609
void log_files_wait_for_next_file_available(log_t &log)
Waits until a next log file is available and can be produced.
Definition: log0files_governor.cc:1386
bool log_files_governor_is_active()
Checks if log file governor thread is active.
Definition: log0files_governor.h:56
dberr_t log_files_start(log_t &log)
Starts the log file management.
Definition: log0files_governor.cc:1654
void log_files_dummy_records_disable(log_t &log)
Disallows to generate dummy redo records and waits until the log_files_governor thread promised not t...
Definition: log0files_governor.cc:1936
dberr_t log_files_reset_creator_and_set_full(log_t &log)
Resets creator name to the current creator and marks all files as full in their headers by setting LO...
Definition: log0files_governor.cc:1827
void log_files_resize_requested(log_t &log)
Updates capacity limitations after srv_redo_log_capacity_used has been changed.
Definition: log0files_governor.cc:2029
void log_files_initialize_on_empty_redo(log_t &log)
Computes initial capacity limits and size suggested for the next log file.
Definition: log0files_governor.cc:2008
dberr_t log_files_produce_file(log_t &log)
Creates a next log file, ready for writes.
Definition: log0files_governor.cc:1045
dberr_t log_files_create(log_t &log, lsn_t flushed_lsn, lsn_t &checkpoint_lsn)
Creates a new set of redo log files.
Definition: log0files_governor.cc:1535
Redo log basic types.
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:62
uint32_t Log_flags
Log flags (stored in file header of log file).
Definition: log0types.h:68
The interface to the operating system file io.
The server main program.
bool srv_thread_is_active(const IB_thread &thread)
Check if given thread is still active.
Definition: srv0srv.cc:3256
Srv_threads srv_threads
Structure with state of srv background threads.
Definition: srv0srv.cc:101
Encryption metadata.
Definition: os0enc.h:452
IB_thread m_log_files_governor
Redo files governor thread.
Definition: srv0srv.h:171
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:74