MySQL 8.0.39
Source Code Documentation
log0files_governor.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2019, 2024, 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
86@return DB_SUCCESS or error code */
87dberr_t log_files_create(log_t &log, lsn_t flushed_lsn);
88
89/** Removes all log files.
90@param[in,out] log redo log */
91void log_files_remove(log_t &log);
92
93/** Creates a next log file, ready for writes. Updates log.m_current_file.
94@param[in,out] log redo log
95@retval DB_SUCCESS if created successfully
96@retval DB_OUT_OF_DISK_SPACE if there was no free space to create next file,
97 according to limitations we have for redo files,
98 or according to space physically available on
99 the disk
100@retval other errors are possible */
102
103/** Persists log flags to the newest log file. Flushes header of the
104log file and updates log.m_log_flags if succeeded.
105@param[in,out] log redo log
106@param[in] log_flags log_flags to persist
107@return DB_SUCCESS or error */
109
110/** Resets creator name to the current creator and marks all files as full in
111their headers by setting LOG_HEADER_FLAG_FILE_FULL bit in the log_flags field.
112Flushes headers of all log files and updates log.m_creator_name and log.m_files
113accordingly if succeeded (if fails, then some files might remain updated and
114some not; metadata stored in log.m_files should reflect that).
115@param[in,out] log redo log
116@return DB_SUCCESS or error */
118
119/** Waits until a next log file is available and can be produced.
120@param[in] log redo log */
122
123/** The log files governor thread routine.
124@param[in,out] log_ptr pointer to redo log */
125void log_files_governor(log_t *log_ptr);
126
127/** Starts the log file management.
128@param[in] log redo log
129@return DB_SUCCESS or error */
131
132/** Computes initial capacity limits and size suggested for the next log file.
133Called when logically empty redo log is being initialized.
134@param[in,out] log redo log */
136
137/** Computes initial capacity limits and size suggested for the next log file.
138Called after existing redo log files have been discovered (log.m_files).
139@param[in,out] log redo log */
141
142/** Updates capacity limitations after srv_redo_log_capacity_used has been
143changed. It is called when user requests to change innodb_redo_log_capacity
144in runtime.
145@param[in,out] log redo log */
147
148/** Updates capacity limitations after srv_thread_concurrency has been changed.
149It is called when user requests to change innodb_thread_concurrency in runtime.
150@param[in,out] log redo log */
152
153/** Disallows to generate dummy redo records and waits until
154the log_files_governor thread promised not to generate them.
155@param[in,out] log redo log */
157
158/** Disallows to generate dummy redo records but does not wait until
159the log_files_governor promised not to generate them anymore.
160@param[in,out] log redo log */
162
163/** Updates the encryption metadata stored in-memory for all redo log files.
164Caller needs to have the log.m_files_mutex acquired before calling this.
165@param[in,out] log redo log
166@param[in] encryption_metadata encryption metadata */
168 log_t &log, const Encryption_metadata &encryption_metadata);
169
170#endif /* !log0files_governor_h */
dberr_t
Definition: db0err.h:39
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:2030
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:1928
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:1809
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:1852
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:2009
void log_files_governor(log_t *log_ptr)
The log files governor thread routine.
Definition: log0files_governor.cc:1349
void log_files_remove(log_t &log)
Removes all log files.
Definition: log0files_governor.cc:1604
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:1388
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:1649
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:1932
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:1822
void log_files_resize_requested(log_t &log)
Updates capacity limitations after srv_redo_log_capacity_used has been changed.
Definition: log0files_governor.cc:2026
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:2005
dberr_t log_files_produce_file(log_t &log)
Creates a next log file, ready for writes.
Definition: log0files_governor.cc:1046
dberr_t log_files_create(log_t &log, lsn_t flushed_lsn)
Creates a new set of redo log files.
Definition: log0files_governor.cc:1537
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:3255
Srv_threads srv_threads
Structure with state of srv background threads.
Definition: srv0srv.cc:103
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