MySQL 26.7.0
Source Code Documentation
log0files_governor.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2019, 2026, 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 designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/**************************************************/ /**
29 @file include/log0files_governor.h
30
31Redo log management of log files.
32
33 *******************************************************/
34
35#ifndef log0files_governor_h
36#define log0files_governor_h
37
38/* Log_files_dict */
39#include "log0files_dict.h"
40
41/* Log_files_find_result */
42#include "log0files_finder.h"
43
44/* log_t& */
45#include "log0types.h"
46
47/* os_offset_t */
48#include "os0file.h"
49
50/* srv_threads */
51#include "srv0srv.h"
52
53#ifndef UNIV_HOTBACKUP
54
55/** Checks if log file governor thread is active.
56@return true if and only if the log checkpointer thread is active */
59}
60
61#define log_files_mutex_enter(log) mutex_enter(&((log).m_files_mutex))
62
63#define log_files_mutex_exit(log) mutex_exit(&((log).m_files_mutex))
64
65#define log_files_mutex_own(log) mutex_own(&((log).m_files_mutex))
66
67#endif /* !UNIV_HOTBACKUP */
68
69/** Creates a new set of redo log files.
70@remarks
71Before creating the new log files, function asserts that there are no existing
72log files in the directory specified for the redo log.
73The flushed_lsn should be exactly at the beginning of its block body.
74The new set of log files starts at the beginning of this block.
75Checkpoint is written LOG_BLOCK_HDR_SIZE bytes after the beginning of that
76block, that is at flushed_lsn.
77The set is marked as initialized if this call succeeded and information about
78the initial LSN is emitted to the error log. In such case, a new value is
79generated and assigned to the log.m_log_uuid (identifying the new log files).
80@param[in,out] log redo log
81@param[in] flushed_lsn the new set of log files should start with log
82 block in which flushed_lsn is located, and
83 flushed_lsn should point right after this block
84 header.
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/** Disallows to generate dummy redo records and waits until
148the log_files_governor thread promised not to generate them.
149@param[in,out] log redo log */
151
152/** Disallows to generate dummy redo records but does not wait until
153the log_files_governor promised not to generate them anymore.
154@param[in,out] log redo log */
156
157/** Updates the encryption metadata stored in-memory for all redo log files.
158Caller needs to have the log.m_files_mutex acquired before calling this.
159@param[in,out] log redo log
160@param[in] encryption_metadata encryption metadata */
162 log_t &log, const Encryption_metadata &encryption_metadata);
163
164#endif /* !log0files_governor_h */
dberr_t
Definition: db0err.h:39
In-memory dictionary of log files (keeps their meta data).
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:1963
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:1844
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:1887
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:2050
void log_files_governor(log_t *log_ptr)
The log files governor thread routine.
Definition: log0files_governor.cc:1378
void log_files_remove(log_t &log)
Removes all log files.
Definition: log0files_governor.cc:1636
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:1417
bool log_files_governor_is_active()
Checks if log file governor thread is active.
Definition: log0files_governor.h:57
dberr_t log_files_start(log_t &log)
Starts the log file management.
Definition: log0files_governor.cc:1681
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:1967
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:1857
void log_files_resize_requested(log_t &log)
Updates capacity limitations after srv_redo_log_capacity_used has been changed.
Definition: log0files_governor.cc:2071
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:2046
dberr_t log_files_produce_file(log_t &log)
Creates a next log file, ready for writes.
Definition: log0files_governor.cc:1059
dberr_t log_files_create(log_t &log, lsn_t flushed_lsn)
Creates a new set of redo log files.
Definition: log0files_governor.cc:1566
Redo log basic types.
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:63
uint32_t Log_flags
Log flags (stored in file header of log file).
Definition: log0types.h:69
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:3246
Srv_threads srv_threads
Structure with state of srv background threads.
Definition: srv0srv.cc:112
Encryption metadata.
Definition: os0enc.h:445
IB_thread m_log_files_governor
Redo files governor thread.
Definition: srv0srv.h:173
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:77