MySQL 9.1.0
Source Code Documentation
log0pre_8_0_30.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2020, 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/log0pre_8_0_30.h
30
31 Redo log functions and constants related to redo formats
32 before 8.0.30.
33
34 *******************************************************/
35
36#ifndef log0pre_8_0_30_h
37#define log0pre_8_0_30_h
38
39/* lsn_t */
40#include "log0types.h"
41
42namespace log_pre_8_0_30 {
43
44/** Prefix of log file name in the old redo format (before 8.0.30).
45For more details @see Log_files_ruleset */
46constexpr const char *const FILE_BASE_NAME = "ib_logfile";
47
48/** Maximum redo log file id in the old format (before 8.0.30). */
49constexpr Log_file_id FILE_MAX_ID = 99;
50
51/* Offsets inside the checkpoint pages pre 8.0.30 redo format. */
52
53/** Checkpoint number. It was incremented by one for each next checkpoint.
54During recovery, all headers were scanned, and one with the maximum checkpoint
55number was used for the recovery (checkpoint_lsn from that header was used). */
57
58/** Checkpoint lsn. Recovery starts from this lsn and searches for the first
59log record group that starts since then. In InnoDB < 8.0.5, it was the exact
60value at which the first log record group started. Since 8.0.5, the order in
61flush lists became relaxed and because of that checkpoint lsn values were not
62precise anymore. */
64
65/** Offset within the log files, which corresponds to checkpoint lsn.
66Used for calibration of lsn and offset calculations. */
68
69/** Size of the log buffer, when the checkpoint write was started.
70It seems it was write-only field in InnoDB. Not used by recovery.
71
72@note
73Note that when the log buffer is being resized, all the log background threads
74were stopped, so there was no concurrent checkpoint write (the log_checkpointer
75thread was stopped). */
76constexpr uint32_t FIELD_CHECKPOINT_LOG_BUF_SIZE = 24;
77
78/** Meta data stored in one of two checkpoint headers. */
80 /** Checkpoint number stored in older formats of the redo log. */
82
83 /** Checkpoint LSN (oldest_lsn_lwm from the moment of checkpoint). */
85
86 /** Offset from the beginning of the redo file, which contains the
87 checkpoint LSN, to the checkpoint LSN. */
89
90 /** Size of the log buffer from the moment of checkpoint. */
92};
93
94/** Provides a file offset for the given lsn. For this function to work,
95some existing file lsn and corresponding offset to that file lsn have to
96be provided.
97@param[in] n_files number of log files
98@param[in] file_size size of each log file (in bytes)
99@param[in] some_file_lsn some file_lsn for which offset is known
100@param[in] some_file_offset file offset corresponding to the given
101 some_file_lsn
102@param[in] requested_lsn the given lsn for which offset is computed
103@return file offset corresponding to the given requested_lsn */
105 lsn_t some_file_lsn,
106 os_offset_t some_file_offset,
107 lsn_t requested_lsn);
108
109/** Deserializes the log checkpoint header stored in the given buffer.
110@param[in] buf the buffer to deserialize
111@param[out] header the deserialized header */
112bool checkpoint_header_deserialize(const byte *buf, Checkpoint_header &header);
113
114/** Provides name of the log file with the given file id, e.g. 'ib_logfile0'.
115@param[in] file_id id of the log file
116@return file name */
117std::string file_name(Log_file_id file_id);
118
119/** Validates that ib_logfile0 exists and has format older than VERSION_8_0_30.
120@param[in] files_ctx defines context within which redo log files exist
121@param[in] files non-empty list of file headers of existing log
122 files, ordered by file_id
123@param[out] format discovered redo format if true was returned
124@return true iff ib_logfile0 exists and has format older than VERSION_8_0_30 */
125bool files_validate_format(const Log_files_context &files_ctx,
127 Log_format &format);
128
129} // namespace log_pre_8_0_30
130
131#endif /* log0pre_8_0_30_h */
Redo log basic types.
size_t Log_file_id
Log file id (0 for ib_redo0)
Definition: log0types.h:66
Log_format
Supported redo log formats.
Definition: log0types.h:138
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:63
static size_t file_size
Definition: mysql_config_editor.cc:72
Definition: buf0block_hint.cc:30
ulong n_files
Number of files to use for the double write buffer.
Definition: buf0dblwr.cc:79
Definition: log0pre_8_0_30.h:42
os_offset_t compute_real_offset_for_lsn(size_t n_files, os_offset_t file_size, lsn_t some_file_lsn, os_offset_t some_file_offset, lsn_t requested_lsn)
Provides a file offset for the given lsn.
Definition: log0pre_8_0_30.cc:57
constexpr uint32_t FIELD_CHECKPOINT_LOG_BUF_SIZE
Size of the log buffer, when the checkpoint write was started.
Definition: log0pre_8_0_30.h:76
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:94
constexpr os_offset_t FIELD_CHECKPOINT_LSN
Checkpoint lsn.
Definition: log0pre_8_0_30.h:63
bool checkpoint_header_deserialize(const byte *buf, Checkpoint_header &header)
Deserializes the log checkpoint header stored in the given buffer.
Definition: log0pre_8_0_30.cc:82
constexpr os_offset_t FIELD_CHECKPOINT_OFFSET
Offset within the log files, which corresponds to checkpoint lsn.
Definition: log0pre_8_0_30.h:67
constexpr os_offset_t FIELD_CHECKPOINT_NO
Checkpoint number.
Definition: log0pre_8_0_30.h:56
constexpr Log_file_id FILE_MAX_ID
Maximum redo log file id in the old format (before 8.0.30).
Definition: log0pre_8_0_30.h:49
bool files_validate_format(const Log_files_context &files_ctx, const ut::vector< Log_file_id_and_header > &files, Log_format &format)
Validates that ib_logfile0 exists and has format older than VERSION_8_0_30.
Definition: log0pre_8_0_30.cc:101
constexpr const char *const FILE_BASE_NAME
Prefix of log file name in the old redo format (before 8.0.30).
Definition: log0pre_8_0_30.h:46
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:87
Configures path to the root directory, where redo subdirectory might be located (or redo log files if...
Definition: log0types.h:204
Meta data stored in one of two checkpoint headers.
Definition: log0pre_8_0_30.h:79
uint64_t m_checkpoint_no
Checkpoint number stored in older formats of the redo log.
Definition: log0pre_8_0_30.h:81
lsn_t m_checkpoint_lsn
Checkpoint LSN (oldest_lsn_lwm from the moment of checkpoint).
Definition: log0pre_8_0_30.h:84
os_offset_t m_checkpoint_offset
Offset from the beginning of the redo file, which contains the checkpoint LSN, to the checkpoint LSN.
Definition: log0pre_8_0_30.h:88
uint64_t m_log_buf_size
Size of the log buffer from the moment of checkpoint.
Definition: log0pre_8_0_30.h:91