MySQL 8.3.0
Source Code Documentation
log0files_governor.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2019, 2023, 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 flushed_lsn should be exactly at the beginning of its block body.
73The new set of log files starts at the beginning of this block.
74Checkpoint is written LOG_BLOCK_HDR_SIZE bytes after the beginning of that
75block, that is at flushed_lsn.
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 in which flushed_lsn is located, and
82 flushed_lsn should point right after this block
83 header.
84
85@return DB_SUCCESS or error code */
86dberr_t log_files_create(log_t &log, lsn_t flushed_lsn);
87
88/** Removes all log files.
89@param[in,out] log redo log */
90void log_files_remove(log_t &log);
91
92/** Creates a next log file, ready for writes. Updates log.m_current_file.
93@param[in,out] log redo log
94@retval DB_SUCCESS if created successfully
95@retval DB_OUT_OF_DISK_SPACE if there was no free space to create next file,
96 according to limitations we have for redo files,
97 or according to space physically available on
98 the disk
99@retval other errors are possible */
101
102/** Persists log flags to the newest log file. Flushes header of the
103log file and updates log.m_log_flags if succeeded.
104@param[in,out] log redo log
105@param[in] log_flags log_flags to persist
106@return DB_SUCCESS or error */
108
109/** Resets creator name to the current creator and marks all files as full in
110their headers by setting LOG_HEADER_FLAG_FILE_FULL bit in the log_flags field.
111Flushes headers of all log files and updates log.m_creator_name and log.m_files
112accordingly if succeeded (if fails, then some files might remain updated and
113some not; metadata stored in log.m_files should reflect that).
114@param[in,out] log redo log
115@return DB_SUCCESS or error */
117
118/** Waits until a next log file is available and can be produced.
119@param[in] log redo log */
121
122/** The log files governor thread routine.
123@param[in,out] log_ptr pointer to redo log */
124void log_files_governor(log_t *log_ptr);
125
126/** Starts the log file management.
127@param[in] log redo log
128@return DB_SUCCESS or error */
130
131/** Computes initial capacity limits and size suggested for the next log file.
132Called when logically empty redo log is being initialized.
133@param[in,out] log redo log */
135
136/** Computes initial capacity limits and size suggested for the next log file.
137Called after existing redo log files have been discovered (log.m_files).
138@param[in,out] log redo log */
140
141/** Updates capacity limitations after srv_redo_log_capacity_used has been
142changed. It is called when user requests to change innodb_redo_log_capacity
143in runtime.
144@param[in,out] log redo log */
146
147/** Updates capacity limitations after srv_thread_concurrency has been changed.
148It is called when user requests to change innodb_thread_concurrency in runtime.
149@param[in,out] log redo log */
151
152/** Disallows to generate dummy redo records and waits until
153the log_files_governor thread promised not to generate them.
154@param[in,out] log redo log */
156
157/** Disallows to generate dummy redo records but does not wait until
158the log_files_governor promised not to generate them anymore.
159@param[in,out] log redo log */
161
162/** Updates the encryption metadata stored in-memory for all redo log files.
163Caller needs to have the log.m_files_mutex acquired before calling this.
164@param[in,out] log redo log
165@param[in] encryption_metadata encryption metadata */
167 log_t &log, const Encryption_metadata &encryption_metadata);
168
169#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:1929
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:1810
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:1853
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:2010
void log_files_governor(log_t *log_ptr)
The log files governor thread routine.
Definition: log0files_governor.cc:1350
void log_files_remove(log_t &log)
Removes all log files.
Definition: log0files_governor.cc:1605
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:1389
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:1650
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:1933
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:1823
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:2006
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)
Creates a new set of redo log files.
Definition: log0files_governor.cc:1538
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:3254
Srv_threads srv_threads
Structure with state of srv background threads.
Definition: srv0srv.cc:102
Encryption metadata.
Definition: os0enc.h:444
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:76