Debian Codegraph @

storage/innobase/include/log0pre_8_0_30.h

raw
1 /*****************************************************************************
2
3 Copyright (c) 2020, 2026, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 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
42 namespace log_pre_8_0_30 {
43
44 /** Prefix of log file name in the old redo format (before 8.0.30).
45 For more details @see Log_files_ruleset */
46 constexpr const char *const FILE_BASE_NAME = "ib_logfile";
47
48 /** Maximum redo log file id in the old format (before 8.0.30). */
49 constexpr 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.
54 During recovery, all headers were scanned, and one with the maximum checkpoint
55 number was used for the recovery (checkpoint_lsn from that header was used). */
56 constexpr os_offset_t FIELD_CHECKPOINT_NO = 0;
57
58 /** Checkpoint lsn. Recovery starts from this lsn and searches for the first
59 log record group that starts since then. In InnoDB < 8.0.5, it was the exact
60 value at which the first log record group started. Since 8.0.5, the order in
61 flush lists became relaxed and because of that checkpoint lsn values were not
62 precise anymore. */
63 constexpr os_offset_t FIELD_CHECKPOINT_LSN = 8;
64
65 /** Offset within the log files, which corresponds to checkpoint lsn.
66 Used for calibration of lsn and offset calculations. */
67 constexpr os_offset_t FIELD_CHECKPOINT_OFFSET = 16;
68
69 /** Size of the log buffer, when the checkpoint write was started.
70 It seems it was write-only field in InnoDB. Not used by recovery.
71
72 @note
73 Note that when the log buffer is being resized, all the log background threads
74 were stopped, so there was no concurrent checkpoint write (the log_checkpointer
75 thread was stopped). */
76 constexpr uint32_t FIELD_CHECKPOINT_LOG_BUF_SIZE = 24;
77
78 /** Meta data stored in one of two checkpoint headers. */
79 struct Checkpoint_header {
80 /** Checkpoint number stored in older formats of the redo log. */
81 uint64_t m_checkpoint_no;
82
83 /** Checkpoint LSN (oldest_lsn_lwm from the moment of checkpoint). */
84 lsn_t m_checkpoint_lsn;
85
86 /** Offset from the beginning of the redo file, which contains the
87 checkpoint LSN, to the checkpoint LSN. */
88 os_offset_t m_checkpoint_offset;
89
90 /** Size of the log buffer from the moment of checkpoint. */
91 uint64_t m_log_buf_size;
92 };
93
94 /** Provides a file offset for the given lsn. For this function to work,
95 some existing file lsn and corresponding offset to that file lsn have to
96 be 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 */
104 os_offset_t compute_real_offset_for_lsn(size_t n_files, os_offset_t file_size,
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 */
112 bool 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 */
117 std::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 */
125 bool files_validate_format(const Log_files_context &files_ctx,
126 const ut::vector<Log_file_id_and_header> &files,
127 Log_format &format);
128
129 } // namespace log_pre_8_0_30
130
131 #endif /* log0pre_8_0_30_h */