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