MySQL 8.3.0
Source Code Documentation
log0types.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2013, 2023, Oracle and/or its affiliates.
4
5Portions of this file contain modifications contributed and copyrighted by
6Google, Inc. Those modifications are gratefully acknowledged and are described
7briefly in the InnoDB documentation. The contributions by Google are
8incorporated with their permission, and subject to the conditions contained in
9the file COPYING.Google.
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GNU General Public License, version 2.0, as published by the
13Free Software Foundation.
14
15This program is also distributed with certain software (including but not
16limited to OpenSSL) that is licensed under separate terms, as designated in a
17particular file or component or in included license documentation. The authors
18of MySQL hereby grant you an additional permission to link the program and
19your derivative works with the separately licensed software that they have
20included with MySQL.
21
22This program is distributed in the hope that it will be useful, but WITHOUT
23ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
25for more details.
26
27You should have received a copy of the GNU General Public License along with
28this program; if not, write to the Free Software Foundation, Inc.,
2951 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
31*****************************************************************************/
32
33/**************************************************/ /**
34 @file include/log0types.h
35
36 Redo log basic types
37
38 *******************************************************/
39
40#ifndef log0types_h
41#define log0types_h
42
43/* std::atomic<X> */
44#include <atomic>
45
46/* std::chrono::X */
47#include <chrono>
48
49/* std::string */
50#include <string>
51
52/* byte */
53#include "univ.i"
54
55/* os_offset_t */
56#include "os0file.h"
57
58/* ut::INNODB_CACHE_LINE_SIZE */
59#include "ut0cpu_cache.h"
60
61/** Type used for all log sequence number storage and arithmetic. */
62typedef uint64_t lsn_t;
63
64/** Log file id (0 for ib_redo0) */
65typedef size_t Log_file_id;
66
67/** Log flags (stored in file header of log file). */
68typedef uint32_t Log_flags;
69
70/** Number which tries to uniquely identify a created set of redo log files.
71Redo log files, which have different values of Log_uuid, most likely have been
72created for different directories and cannot be mixed. This way foreign redo
73files might be easily recognized. When that is the case, most likely something
74went wrong when copying files. */
75typedef uint32_t Log_uuid;
76
77/** Print format for lsn_t values, used in functions like printf. */
78#define LSN_PF UINT64PF
79
80/** Alias for atomic based on lsn_t. */
81using atomic_lsn_t = std::atomic<lsn_t>;
82
83/** Type used for sn values, which enumerate bytes of data stored in the log.
84Note that these values skip bytes of headers and footers of log blocks. */
85typedef uint64_t sn_t;
86
87/** Alias for atomic based on sn_t. */
88using atomic_sn_t = std::atomic<sn_t>;
89
90/* The lsn_t, sn_t, Log_file_id are known so constants can be expressed. */
91#include "log0constants.h"
92
93/** Enumerates checkpoint headers in the redo log file. */
94enum class Log_checkpoint_header_no : uint32_t {
95 /** The first checkpoint header. */
97
98 /** The second checkpoint header. */
100};
101
102/** Type used for counters in log_t: flushes_requested and flushes_expected.
103They represent number of requests to flush the redo log to disk. */
104typedef std::atomic<int64_t> log_flushes_t;
105
106/** Type of redo log file. */
107enum class Log_file_type {
108 /** Usual redo log file, most likely with important redo data. */
109 NORMAL,
110 /** Unused redo log file, might always be removed. */
111 UNUSED
112};
113
114/** Callback called on each read or write operation on a redo log file.
115@param[in] file_id id of the redo log file (target of the IO operation)
116@param[in] file_type type of the redo log file
117@param[in] offset offset in the file, at which read or write operation
118 is going to start (expressed in bytes and computed
119 from the beginning of the file)
120@param[in] size size of data that is going to be read or written in
121 the IO operation */
122typedef std::function<void(Log_file_id file_id, Log_file_type file_type,
123 os_offset_t offset, os_offset_t size)>
125
126/** Function used to calculate checksums of log blocks. */
127typedef std::atomic<uint32_t (*)(const byte *log_block)>
129
130/** Clock used to measure time spent in redo log (e.g. when flushing). */
131using Log_clock = std::chrono::high_resolution_clock;
132
133/** Time point defined by the Log_clock. */
134using Log_clock_point = std::chrono::time_point<Log_clock>;
135
136/** Supported redo log formats. Stored in LOG_HEADER_FORMAT. */
137enum class Log_format : uint32_t {
138 /** Unknown format of redo file. */
139 LEGACY = 0,
140
141 /** The MySQL 5.7.9 redo log format identifier. We can support recovery
142 from this format if the redo log is clean (logically empty). */
143 VERSION_5_7_9 = 1,
144
145 /** Remove MLOG_FILE_NAME and MLOG_CHECKPOINT, introduce MLOG_FILE_OPEN
146 redo log record. */
147 VERSION_8_0_1 = 2,
148
149 /** Allow checkpoint_lsn to point any data byte within redo log (before
150 it had to point the beginning of a group of log records). */
151 VERSION_8_0_3 = 3,
152
153 /** Expand ulint compressed form. */
154 VERSION_8_0_19 = 4,
155
156 /** Row versioning header. */
157 VERSION_8_0_28 = 5,
158
159 /** Introduced with innodb_redo_log_capacity:
160 - write LSN does not re-enter file with checkpoint_lsn,
161 - epoch_no is checked strictly during recovery. */
162 VERSION_8_0_30 = 6,
163
164 /** The redo log format identifier
165 corresponding to the current format version. */
167};
168
169/** Ruleset defining how redo log files are named, where they are stored,
170when they are created and what sizes could they have. */
172 /** Redo log files were named ib_logfile0, ib_logfile1, ... ib_logfile99.
173 Redo log files were pre-created during startup and re-used after wrapping.
174 Redo log files had the same file size and supported formats < VERSION_8_0_30.
175 The non-initialized set of redo log files was denoted by existence of the
176 ib_logfile101. The log files were located directly in the root directory
177 (innodb_log_group_home_dir if specified; else: datadir). */
179
180 /** Redo log files are named #ib_redo0, #ib_redo1, ... and no longer wrapped.
181 Redo log files are created on-demand during runtime and might have different
182 sizes. Formats >= VERSION_8_0_30 are supported. The redo log files are located
183 in #innodb_redo subdirectory in the root directory - for example:
184 - if innodb_log_group_home_dir = '/srv/my_db/logs', then redo files are in
185 '/srv/my_db/logs/#innodb_redo/',
186 - if innodb_log_group_home_dir is not specified and datadir='/srv/my_db',
187 then redo files are in '/srv/my_db/#innodb_redo'. */
188 CURRENT
189};
190
191/** Direction of resize operation. */
192enum class Log_resize_mode {
193 /** No pending resize. */
194 NONE,
195
196 /** Resizing down. */
198};
199
200/** Configures path to the root directory, where redo subdirectory might be
201located (or redo log files if the ruleset is older). Configures the ruleset
202that should be used when locating redo log files. */
204 explicit Log_files_context(
205 const std::string &root_path = "",
207
208 /** Path to the root directory. */
209 std::string m_root_path;
210
211 /** Ruleset determining how file paths are built. */
213};
214
215/** Meta data stored in log file header. */
217 /** Format of the log file. */
218 uint32_t m_format;
219
220 /** LSN of the first log block (%512 == 0). */
222
223 /** Creator name. */
224 std::string m_creator_name;
225
226 /** Log flags. Meaning of bit positions is to be found in documentation
227 of LOG_HEADER_FLAG_* constants in log0constants.h. */
229
230 /** UUID value describing the whole group of log files. */
232};
233
234/** Meta data stored in one of two checkpoint headers. */
236 /** Checkpoint LSN (oldest_lsn_lwm from the moment of checkpoint). */
238};
239
240/** Meta data stored in header of a log data block. */
242 /** Together with m_hdr_no form unique identifier of this block,
243 @see LOG_BLOCK_EPOCH_NO. */
244 uint32_t m_epoch_no;
245
246 /** Together with m_epoch_no form unique identifier of this block,
247 @see log_block_get_hdr_no. Each next log data block has hdr_no
248 incremented by 1 (unless wrapped). */
249 uint32_t m_hdr_no;
250
251 /** Offset up to which this block has data inside, computed from the
252 beginning of the block. */
253 uint16_t m_data_len;
254
255 /** Offset to the first mtr starting in this block, or 0 if there is no
256 mtr starting in this block. */
258
259 /** Sets m_epoch_no and m_hdr_no from a single lsn
260 */
261 void set_lsn(lsn_t lsn);
262};
263
264/** Pair of: log file id and log file size (expressed in bytes). */
267
269 : m_id(id), m_size_in_bytes(size) {}
270
271 /** Id of the file. */
273
274 /** Size of file, expressed in bytes. */
276};
277
278/** Pair of: log file id and log file header. */
281
283 : m_id(id), m_header(header) {}
284
285 /** Id of the file. */
287
288 /** Main header of the file. */
290};
291
292/** Type of access allowed for the opened redo log file. */
294 /** The opened file can be both read and written. */
296 /** The opened file can be only read. */
297 READ_ONLY,
298 /** The opened file can be only written. */
300};
301
302/** Handle which allows to do reads / writes for the opened file.
303For particular kind of reads or writes (for checkpoint headers,
304data blocks, main file header or encryption header) there are helper
305functions defined outside this class. Unless you wanted to transfer
306the whole file as-is, you should rather use those functions for
307read/write operations. */
309 public:
310 explicit Log_file_handle(Encryption_metadata &encryption_metadata);
311
314
315 /** Closes handle if was opened (calling fsync if was modified).
316 Destructs the handle object. */
318
319 /** @return true iff file is opened (by this handle) */
320 bool is_open() const;
321
322 /** Closes file represented by this handle (must be opened). */
323 void close();
324
325 /** @return id of the log file */
326 Log_file_id file_id() const;
327
328 /** @return path to the log file (including the file name) */
329 const std::string &file_path() const;
330
331 /** @return file size in bytes */
332 os_offset_t file_size() const;
333
334 /** Reads from the log file at the given offset (to the provided buffer).
335 @param[in] read_offset offset in bytes from the beginning of the file
336 @param[in] read_size number of bytes to read
337 @param[out] buf allocated buffer to fill when reading
338 @return DB_SUCCESS or error */
339 dberr_t read(os_offset_t read_offset, os_offset_t read_size, byte *buf);
340
341 /** Writes the provided buffer to the log file at the given offset.
342 @param[in] write_offset offset in bytes from the beginning of the file
343 @param[in] write_size number of bytes to write
344 @param[in] buf buffer to write
345 @return DB_SUCCESS or error */
346 dberr_t write(os_offset_t write_offset, os_offset_t write_size,
347 const byte *buf);
348
349 /** Executes fsync operation for this redo log file. */
350 void fsync();
351
352 /** @return number of fsyncs in-progress */
353 static uint64_t fsyncs_in_progress() { return s_fsyncs_in_progress.load(); }
354
355 /** @return total number of fsyncs that have been started since
356 the server has started */
357 static uint64_t total_fsyncs() { return s_total_fsyncs.load(); }
358
359 /** Callback called on each read operation. */
361
362 /** Callback called on each write operation. */
364
365 /** True iff all fsyncs should be no-op. */
366 static bool s_skip_fsyncs;
367
368 private:
369 friend struct Log_file;
370
371 /** Tries to open a given redo log file with with a given access mode.
372 If succeeded then this handle represents the opened file and allows to
373 performs reads and/or writes (depends on the requested access mode).
374 If encountered error during the attempt to open, error message is emitted
375 to the error log, in which case this handle remains closed.
376 @param[in] files_ctx context within which files exist
377 @param[in] id id of the log file
378 @param[in] access_mode access mode for the opened file
379 @param[in] encryption_metadata encryption metadata
380 @param[in] file_type type of redo file */
381 Log_file_handle(const Log_files_context &files_ctx, Log_file_id id,
382 Log_file_access_mode access_mode,
383 Encryption_metadata &encryption_metadata,
384 Log_file_type file_type);
385
386 Log_file_handle(const Log_file_handle &other) = delete;
388
389 /** Open the log file with the configured access mode.
390 @return DB_SUCCESS or error */
391 dberr_t open();
392
393 /** Creates and configures an io request object according to currently
394 configured encryption metadata (m_encryption_*) and m_block_size.
395 @param[in] req_type defines type of IO operation (read or write)
396 @param[in] offset offset in bytes from the beginning of the file
397 @param[in] size number of bytes to write or read
398 @param[in] can_use_encryption e.g. whether newly blocks should be encrypted
399 @return IORequest instance */
401 os_offset_t size, bool can_use_encryption);
402
403#ifdef UNIV_DEBUG
404 /** Number of all opened Log_file_handle existing currently. */
405 static std::atomic<size_t> s_n_open;
406#endif /* UNIV_DEBUG */
407
408 /** Number of fsyncs in-progress. */
409 static std::atomic<uint64_t> s_fsyncs_in_progress;
410
411 /** Total number of fsyncs that have been started since
412 the server has started. */
413 static std::atomic<uint64_t> s_total_fsyncs;
414
415 /** Id of the redo log file (part of its file name) */
417
418 /** Access mode allowed for this handle (if not yet closed). */
420
421 /** Encryption metadata to be used for all IO operations on this file
422 except those related to the first LOG_FILE_HDR_SIZE bytes.
423 @remarks If Encryption::set_key() and Encryption::set_initial_vector()
424 started to accept their arguments as const pointers, this could become
425 a const pointer too). In such case, all usages of Encryption_metadata*
426 inside redo log code, could also become changed to usages of the const
427 pointer. */
429
430 /** Type of redo log file. */
432
433 /** Whether file is opened */
435
436 /** Whether file has been modified using this handle since it was opened. */
438
439 /** File name */
440 std::string m_file_path;
441
442 /** OS handle for file (if opened) */
444
445 /** Size of single physical block (if opened) */
447
448 /** Size of file in bytes (if opened) */
450};
451
452/** Meta information about single log file. */
453struct Log_file {
454 Log_file(const Log_files_context &files_ctx,
455 Encryption_metadata &encryption_metadata);
456
457 Log_file(const Log_files_context &files_ctx, Log_file_id id, bool consumed,
458 bool full, os_offset_t size_in_bytes, lsn_t start_lsn, lsn_t end_lsn,
459 Encryption_metadata &encryption_metadata);
460
461 Log_file(const Log_file &other) = default;
462
463 Log_file &operator=(const Log_file &other);
464
465 /** Context within which this file exists. */
467
468 /** ID of the file. */
470
471 /** Set to true when file becomes consumed. */
473
474 /** Set to true when file became full and next file exists. */
475 bool m_full;
476
477 /** Size, expressed in bytes, including LOG_FILE_HDR_SIZE. */
479
480 /** LSN of the first byte within the file, aligned to
481 OS_FILE_LOG_BLOCK_SIZE. */
483
484 /** LSN of the first byte after the file, aligned to
485 OS_FILE_LOG_BLOCK_SIZE. */
487
488 /** Encryption metadata passed to opened file handles
489 @see Log_file_handle::m_encryption_metadata */
491
492 /** Checks if this object is equal to a given another object.
493 @param[in] rhs the object to compare against
494 @return true iff all related fields of the two objects are equal */
495 bool operator==(const Log_file &rhs) const {
496 return m_id == rhs.m_id && m_consumed == rhs.m_consumed &&
497 m_full == rhs.m_full && m_size_in_bytes == rhs.m_size_in_bytes &&
499 }
500
501 /** Validates that lsn fields seem correct (m_start_lsn, m_end_lsn) */
502 void lsn_validate() const {
507 }
508
509 /** Checks if a given lsn belongs to [m_start_lsn, m_end_lsn).
510 In other words, checks that the given lsn belongs to this file.
511 @param[in] lsn lsn to test against lsn range
512 @return true iff lsn is in the file */
513 bool contains(lsn_t lsn) const {
514 return m_start_lsn <= lsn && lsn < m_end_lsn;
515 }
516
517 /** Provides offset for the given LSN (from the beginning of the log file).
518 @param[in] lsn lsn to locate (must exist in the file)
519 @return offset from the beginning of the file for the given lsn */
521 lsn_validate();
522 ut_a(contains(lsn) || lsn == m_end_lsn);
523 return offset(lsn, m_start_lsn);
524 }
525
526 /** Provides offset for the given LSN and log file with the given start_lsn
527 (offset from the beginning of the log file).
528 @param[in] lsn lsn to locate (must be >= file_start_lsn)
529 @param[in] file_start_lsn start lsn of the log file
530 @return offset from the beginning of the file for the given lsn */
531 static os_offset_t offset(lsn_t lsn, lsn_t file_start_lsn) {
532 return LOG_FILE_HDR_SIZE + (lsn - file_start_lsn);
533 }
534
535 /** Computes id of the next log file. Does not check if such file exists.
536 @return id of the next log file */
537 Log_file_id next_id() const { return next_id(m_id, 1); }
538
539 /** Opens this file and provides handle that allows to read from this file
540 and / or write to this file (depends on the requested access mode).
541 @param[in] access_mode requested access mode (reads and/or writes)
542 @return handle to the opened file or empty handle with error information */
543 Log_file_handle open(Log_file_access_mode access_mode) const;
544
545 /** Opens a given redo log file and provides handle that allows to read from
546 that file and / or write to that file (depends on the requested access mode).
547 @param[in] files_ctx context within which file exists
548 @param[in] file_id id of the redo log file to open
549 @param[in] access_mode requested access mode (reads and/or writes)
550 @param[in] encryption_metadata encryption metadata
551 @param[in] file_type type of underlying file on disk to open
552 @return handle to the opened file or empty handle with error information */
553 static Log_file_handle open(const Log_files_context &files_ctx,
554 Log_file_id file_id,
555 Log_file_access_mode access_mode,
556 Encryption_metadata &encryption_metadata,
558
559 /** Computes id + inc, asserting it does not overflow the maximum value.
560 @param[in] id base id of file, to which inc is added
561 @param[in] inc number of log files ahead (1 = directly next one)
562 @return id + inc */
563 static Log_file_id next_id(Log_file_id id, size_t inc = 1) {
564 constexpr Log_file_id MAX_FILE_ID = std::numeric_limits<Log_file_id>::max();
565 ut_a(0 < inc);
566 ut_a(inc <= MAX_FILE_ID);
567 ut_a(id <= MAX_FILE_ID - inc);
568 return id + inc;
569 }
570};
571
572struct alignas(ut::INNODB_CACHE_LINE_SIZE) log_t;
573
574/** Runtime statistics related to redo log files management. These stats are
575not persisted to disk. */
577 /** Last time stats were updated (last successful call to @see update()). */
579
580 /** LSN difference by which result of log_files_oldest_needed_lsn() advanced
581 during last second. This is basically average consumption speed.
582 Updated by successful calls to @see update(). */
584
585 /** LSN difference by which result of log_files_newest_needed_lsn() advanced
586 during last second. This is basically average production speed.
587 Updated by successful calls to @see update(). */
589
590 /** Oldest LSN returned by log_files_oldest_needed_lsn() during last
591 successful call to @see update(). */
593
594 /** Newest LSN returned by log_files_newest_needed_lsn() during last
595 successful call to @see update(). */
597
598 /** Tries to update stats. Fails and skips updating if less than 1s elapsed
599 since last successful update, else: updates the stats and succeeds.
600 @param[in] log redo log */
601 void update(const log_t &log);
602};
603
604#endif /* !log0types_h */
@ NORMAL
Get always.
The IO Context that is passed down to the low level IO code.
Definition: os0file.h:277
Handle which allows to do reads / writes for the opened file.
Definition: log0types.h:308
static uint64_t fsyncs_in_progress()
Definition: log0types.h:353
Log_file_id m_file_id
Id of the redo log file (part of its file name)
Definition: log0types.h:416
Log_file_handle(Encryption_metadata &encryption_metadata)
Definition: log0files_io.cc:184
static Log_file_io_callback s_on_before_read
Callback called on each read operation.
Definition: log0types.h:360
Log_file_access_mode m_access_mode
Access mode allowed for this handle (if not yet closed).
Definition: log0types.h:419
os_offset_t file_size() const
Definition: log0files_io.cc:323
os_offset_t m_file_size
Size of file in bytes (if opened)
Definition: log0types.h:449
dberr_t write(os_offset_t write_offset, os_offset_t write_size, const byte *buf)
Writes the provided buffer to the log file at the given offset.
Definition: log0files_io.cc:371
os_offset_t m_block_size
Size of single physical block (if opened)
Definition: log0types.h:446
bool is_open() const
Definition: log0files_io.cc:302
dberr_t open()
Open the log file with the configured access mode.
Definition: log0files_io.cc:263
IORequest prepare_io_request(int req_type, os_offset_t offset, os_offset_t size, bool can_use_encryption)
Creates and configures an io request object according to currently configured encryption metadata (m_...
Definition: log0files_io.cc:325
static std::atomic< size_t > s_n_open
Number of all opened Log_file_handle existing currently.
Definition: log0types.h:405
std::string m_file_path
File name.
Definition: log0types.h:440
pfs_os_file_t m_raw_handle
OS handle for file (if opened)
Definition: log0types.h:443
Log_file_handle(const Log_file_handle &other)=delete
static uint64_t total_fsyncs()
Definition: log0types.h:357
static bool s_skip_fsyncs
True iff all fsyncs should be no-op.
Definition: log0types.h:366
bool m_is_open
Whether file is opened.
Definition: log0types.h:434
dberr_t read(os_offset_t read_offset, os_offset_t read_size, byte *buf)
Reads from the log file at the given offset (to the provided buffer).
Definition: log0files_io.cc:354
Encryption_metadata & m_encryption_metadata
Encryption metadata to be used for all IO operations on this file except those related to the first L...
Definition: log0types.h:428
Log_file_handle & operator=(const Log_file_handle &rhs)=delete
void close()
Closes file represented by this handle (must be opened).
Definition: log0files_io.cc:290
static std::atomic< uint64_t > s_fsyncs_in_progress
Number of fsyncs in-progress.
Definition: log0types.h:409
Log_file_type m_file_type
Type of redo log file.
Definition: log0types.h:431
~Log_file_handle()
Closes handle if was opened (calling fsync if was modified).
Definition: log0files_io.cc:255
static std::atomic< uint64_t > s_total_fsyncs
Total number of fsyncs that have been started since the server has started.
Definition: log0types.h:413
Log_file_handle & operator=(Log_file_handle &&rhs)
Definition: log0files_io.cc:212
const std::string & file_path() const
Definition: log0files_io.cc:261
Log_file_id file_id() const
Definition: log0files_io.cc:321
bool m_is_modified
Whether file has been modified using this handle since it was opened.
Definition: log0types.h:437
void fsync()
Executes fsync operation for this redo log file.
Definition: log0files_io.cc:304
static Log_file_io_callback s_on_before_write
Callback called on each write operation.
Definition: log0types.h:363
dberr_t
Definition: db0err.h:38
Redo log constant values.
constexpr lsn_t LOG_START_LSN
The counting of lsn's starts from this value: this must be non-zero.
Definition: log0constants.h:149
constexpr os_offset_t LOG_FILE_HDR_SIZE
Size of log file's header.
Definition: log0constants.h:172
size_t Log_file_id
Log file id (0 for ib_redo0)
Definition: log0types.h:65
Log_file_access_mode
Type of access allowed for the opened redo log file.
Definition: log0types.h:293
@ READ_ONLY
The opened file can be only read.
@ READ_WRITE
The opened file can be both read and written.
@ WRITE_ONLY
The opened file can be only written.
Log_checkpoint_header_no
Enumerates checkpoint headers in the redo log file.
Definition: log0types.h:94
@ HEADER_2
The second checkpoint header.
@ HEADER_1
The first checkpoint header.
std::chrono::time_point< Log_clock > Log_clock_point
Time point defined by the Log_clock.
Definition: log0types.h:134
uint32_t Log_uuid
Number which tries to uniquely identify a created set of redo log files.
Definition: log0types.h:75
std::atomic< uint32_t(*)(const byte *log_block)> Log_checksum_algorithm_atomic_ptr
Function used to calculate checksums of log blocks.
Definition: log0types.h:128
Log_resize_mode
Direction of resize operation.
Definition: log0types.h:192
@ RESIZING_DOWN
Resizing down.
@ NONE
No pending resize.
uint64_t sn_t
Type used for sn values, which enumerate bytes of data stored in the log.
Definition: log0types.h:85
Log_format
Supported redo log formats.
Definition: log0types.h:137
@ LEGACY
Unknown format of redo file.
@ VERSION_8_0_1
Remove MLOG_FILE_NAME and MLOG_CHECKPOINT, introduce MLOG_FILE_OPEN redo log record.
@ VERSION_8_0_3
Allow checkpoint_lsn to point any data byte within redo log (before it had to point the beginning of ...
@ VERSION_8_0_19
Expand ulint compressed form.
@ VERSION_8_0_28
Row versioning header.
@ VERSION_5_7_9
The MySQL 5.7.9 redo log format identifier.
@ VERSION_8_0_30
Introduced with innodb_redo_log_capacity:
Log_file_type
Type of redo log file.
Definition: log0types.h:107
@ NORMAL
Usual redo log file, most likely with important redo data.
@ UNUSED
Unused redo log file, might always be removed.
std::chrono::high_resolution_clock Log_clock
Clock used to measure time spent in redo log (e.g.
Definition: log0types.h:131
Log_files_ruleset
Ruleset defining how redo log files are named, where they are stored, when they are created and what ...
Definition: log0types.h:171
@ CURRENT
Redo log files are named ib_redo0, ib_redo1, ... and no longer wrapped.
@ PRE_8_0_30
Redo log files were named ib_logfile0, ib_logfile1, ... ib_logfile99.
std::atomic< int64_t > log_flushes_t
Type used for counters in log_t: flushes_requested and flushes_expected.
Definition: log0types.h:104
std::atomic< lsn_t > atomic_lsn_t
Alias for atomic based on lsn_t.
Definition: log0types.h:81
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:62
std::atomic< sn_t > atomic_sn_t
Alias for atomic based on sn_t.
Definition: log0types.h:88
uint32_t Log_flags
Log flags (stored in file header of log file).
Definition: log0types.h:68
std::function< void(Log_file_id file_id, Log_file_type file_type, os_offset_t offset, os_offset_t size)> Log_file_io_callback
Callback called on each read or write operation on a redo log file.
Definition: log0types.h:124
Type inc(Shards< COUNT > &shards, size_t id)
Increment the counter of a shard by 1.
Definition: ut0counter.h:292
Definition: buf0block_hint.cc:29
The interface to the operating system file io.
constexpr uint32_t OS_FILE_LOG_BLOCK_SIZE
The next value should be smaller or equal to the smallest sector size used on any disk.
Definition: os0file.h:195
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:86
Encryption metadata.
Definition: os0enc.h:444
Meta data stored in one of two checkpoint headers.
Definition: log0types.h:235
lsn_t m_checkpoint_lsn
Checkpoint LSN (oldest_lsn_lwm from the moment of checkpoint).
Definition: log0types.h:237
Meta data stored in header of a log data block.
Definition: log0types.h:241
uint16_t m_data_len
Offset up to which this block has data inside, computed from the beginning of the block.
Definition: log0types.h:253
uint32_t m_hdr_no
Together with m_epoch_no form unique identifier of this block,.
Definition: log0types.h:249
void set_lsn(lsn_t lsn)
Sets m_epoch_no and m_hdr_no from a single lsn.
Definition: log0files_io.cc:1246
uint32_t m_epoch_no
Together with m_hdr_no form unique identifier of this block,.
Definition: log0types.h:244
uint16_t m_first_rec_group
Offset to the first mtr starting in this block, or 0 if there is no mtr starting in this block.
Definition: log0types.h:257
Meta data stored in log file header.
Definition: log0types.h:216
Log_uuid m_log_uuid
UUID value describing the whole group of log files.
Definition: log0types.h:231
Log_flags m_log_flags
Log flags.
Definition: log0types.h:228
lsn_t m_start_lsn
LSN of the first log block (%512 == 0).
Definition: log0types.h:221
std::string m_creator_name
Creator name.
Definition: log0types.h:224
uint32_t m_format
Format of the log file.
Definition: log0types.h:218
Pair of: log file id and log file header.
Definition: log0types.h:279
Log_file_id_and_header(Log_file_id id, Log_file_header header)
Definition: log0types.h:282
Log_file_id m_id
Id of the file.
Definition: log0types.h:286
Log_file_id_and_header()=default
Log_file_header m_header
Main header of the file.
Definition: log0types.h:289
Pair of: log file id and log file size (expressed in bytes).
Definition: log0types.h:265
Log_file_id m_id
Id of the file.
Definition: log0types.h:272
Log_file_id_and_size(Log_file_id id, os_offset_t size)
Definition: log0types.h:268
Log_file_id_and_size()=default
os_offset_t m_size_in_bytes
Size of file, expressed in bytes.
Definition: log0types.h:275
Meta information about single log file.
Definition: log0types.h:453
bool contains(lsn_t lsn) const
Checks if a given lsn belongs to [m_start_lsn, m_end_lsn).
Definition: log0types.h:513
Log_file_id m_id
ID of the file.
Definition: log0types.h:469
Log_file & operator=(const Log_file &other)
Definition: log0files_io.cc:428
Log_file(const Log_file &other)=default
Log_file_id next_id() const
Computes id of the next log file.
Definition: log0types.h:537
bool m_consumed
Set to true when file becomes consumed.
Definition: log0types.h:472
static Log_file_id next_id(Log_file_id id, size_t inc=1)
Computes id + inc, asserting it does not overflow the maximum value.
Definition: log0types.h:563
bool operator==(const Log_file &rhs) const
Checks if this object is equal to a given another object.
Definition: log0types.h:495
bool m_full
Set to true when file became full and next file exists.
Definition: log0types.h:475
lsn_t m_start_lsn
LSN of the first byte within the file, aligned to OS_FILE_LOG_BLOCK_SIZE.
Definition: log0types.h:482
const Log_files_context & m_files_ctx
Context within which this file exists.
Definition: log0types.h:466
static os_offset_t offset(lsn_t lsn, lsn_t file_start_lsn)
Provides offset for the given LSN and log file with the given start_lsn (offset from the beginning of...
Definition: log0types.h:531
void lsn_validate() const
Validates that lsn fields seem correct (m_start_lsn, m_end_lsn)
Definition: log0types.h:502
Log_file(const Log_files_context &files_ctx, Encryption_metadata &encryption_metadata)
Definition: log0files_io.cc:404
lsn_t m_end_lsn
LSN of the first byte after the file, aligned to OS_FILE_LOG_BLOCK_SIZE.
Definition: log0types.h:486
os_offset_t m_size_in_bytes
Size, expressed in bytes, including LOG_FILE_HDR_SIZE.
Definition: log0types.h:478
Log_file_handle open(Log_file_access_mode access_mode) const
Opens this file and provides handle that allows to read from this file and / or write to this file (d...
Definition: log0files_io.cc:390
os_offset_t offset(lsn_t lsn) const
Provides offset for the given LSN (from the beginning of the log file).
Definition: log0types.h:520
Encryption_metadata & m_encryption_metadata
Encryption metadata passed to opened file handles.
Definition: log0types.h:490
Configures path to the root directory, where redo subdirectory might be located (or redo log files if...
Definition: log0types.h:203
Log_files_context(const std::string &root_path="", Log_files_ruleset files_ruleset=Log_files_ruleset::CURRENT)
Definition: log0files_io.cc:1240
Log_files_ruleset m_files_ruleset
Ruleset determining how file paths are built.
Definition: log0types.h:212
std::string m_root_path
Path to the root directory.
Definition: log0types.h:209
Runtime statistics related to redo log files management.
Definition: log0types.h:576
Log_clock_point m_last_update_time
Last time stats were updated (last successful call to.
Definition: log0types.h:578
lsn_t m_newest_lsn_on_update
Newest LSN returned by log_files_newest_needed_lsn() during last successful call to.
Definition: log0types.h:596
lsn_t m_lsn_production_per_1s
LSN difference by which result of log_files_newest_needed_lsn() advanced during last second.
Definition: log0types.h:588
void update(const log_t &log)
Tries to update stats.
Definition: log0files_governor.cc:1180
lsn_t m_oldest_lsn_on_update
Oldest LSN returned by log_files_oldest_needed_lsn() during last successful call to.
Definition: log0types.h:592
lsn_t m_lsn_consumption_per_1s
LSN difference by which result of log_files_oldest_needed_lsn() advanced during last second.
Definition: log0types.h:583
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:76
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:175
Version control for database, common definitions, and include files.
Utilities related to CPU cache.
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:92
static uint64_t lsn
Definition: xcom_base.cc:445
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:509