MySQL 8.0.31
Source Code Documentation
log0types.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2013, 2022, 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
260/** Pair of: log file id and log file size (expressed in bytes). */
263
265 : m_id(id), m_size_in_bytes(size) {}
266
267 /** Id of the file. */
269
270 /** Size of file, expressed in bytes. */
272};
273
274/** Pair of: log file id and log file header. */
277
279 : m_id(id), m_header(header) {}
280
281 /** Id of the file. */
283
284 /** Main header of the file. */
286};
287
288/** Type of access allowed for the opened redo log file. */
290 /** The opened file can be both read and written. */
292 /** The opened file can be only read. */
293 READ_ONLY,
294 /** The opened file can be only written. */
296};
297
298/** Handle which allows to do reads / writes for the opened file.
299For particular kind of reads or writes (for checkpoint headers,
300data blocks, main file header or encryption header) there are helper
301functions defined outside this class. Unless you wanted to transfer
302the whole file as-is, you should rather use those functions for
303read/write operations. */
305 public:
306 explicit Log_file_handle(Encryption_metadata &encryption_metadata);
307
310
311 /** Closes handle if was opened (calling fsync if was modified).
312 Destructs the handle object. */
314
315 /** @return true iff file is opened (by this handle) */
316 bool is_open() const;
317
318 /** Closes file represented by this handle (must be opened). */
319 void close();
320
321 /** @return id of the log file */
322 Log_file_id file_id() const;
323
324 /** @return path to the log file (including the file name) */
325 const std::string &file_path() const;
326
327 /** @return file size in bytes */
328 os_offset_t file_size() const;
329
330 /** Reads from the log file at the given offset (to the provided buffer).
331 @param[in] read_offset offset in bytes from the beginning of the file
332 @param[in] read_size number of bytes to read
333 @param[out] buf allocated buffer to fill when reading
334 @return DB_SUCCESS or error */
335 dberr_t read(os_offset_t read_offset, os_offset_t read_size, byte *buf);
336
337 /** Writes the provided buffer to the log file at the given offset.
338 @param[in] write_offset offset in bytes from the beginning of the file
339 @param[in] write_size number of bytes to write
340 @param[in] buf buffer to write
341 @return DB_SUCCESS or error */
342 dberr_t write(os_offset_t write_offset, os_offset_t write_size,
343 const byte *buf);
344
345 /** Executes fsync operation for this redo log file. */
346 void fsync();
347
348 /** @return number of fsyncs in-progress */
349 static uint64_t fsyncs_in_progress() { return s_fsyncs_in_progress.load(); }
350
351 /** @return total number of fsyncs that have been started since
352 the server has started */
353 static uint64_t total_fsyncs() { return s_total_fsyncs.load(); }
354
355 /** Callback called on each read operation. */
357
358 /** Callback called on each write operation. */
360
361 /** True iff all fsyncs should be no-op. */
362 static bool s_skip_fsyncs;
363
364 private:
365 friend struct Log_file;
366
367 /** Tries to open a given redo log file with with a given access mode.
368 If succeeded then this handle represents the opened file and allows to
369 performs reads and/or writes (depends on the requested access mode).
370 If encountered error during the attempt to open, error message is emitted
371 to the error log, in which case this handle remains closed.
372 @param[in] files_ctx context within which files exist
373 @param[in] id id of the log file
374 @param[in] access_mode access mode for the opened file
375 @param[in] encryption_metadata encryption metadata
376 @param[in] file_type type of redo file */
377 Log_file_handle(const Log_files_context &files_ctx, Log_file_id id,
378 Log_file_access_mode access_mode,
379 Encryption_metadata &encryption_metadata,
380 Log_file_type file_type);
381
382 Log_file_handle(const Log_file_handle &other) = delete;
384
385 /** Open the log file with the configured access mode.
386 @return DB_SUCCESS or error */
387 dberr_t open();
388
389 /** Configures a given io request object accordingly to currently configured
390 encryption metadata (m_encryption_*) and m_block_size.
391 @param[in,out] io_request io request object to configure
392 @param[in] encrypted_area true iff IO request is done to the fragment
393 of file that potentially might be encrypted;
394 it's based on offset only - does not depend
395 on current m_encryption_metadata */
396 void prepare_io_request(IORequest &io_request, bool encrypted_area);
397
398 /** Performs a given IO operation on the opened file.
399 NOTE: io_req internals are ignored (except type), because io_req is copied
400 and overwritten by prepare_io_request().
401 @param[in] io_req defines type of IO operation (read or write)
402 @param[in] offset offset in bytes from the beginning of the file
403 @param[in] size number of bytes to write or read
404 @param[in] buf buffer to write or fill (if read operation)
405 @return DB_SUCCESS or error */
407 byte *buf);
408
409#ifdef UNIV_DEBUG
410 /** Number of all opened Log_file_handle existing currently. */
411 static std::atomic<size_t> s_n_open;
412#endif /* UNIV_DEBUG */
413
414 /** Number of fsyncs in-progress. */
415 static std::atomic<uint64_t> s_fsyncs_in_progress;
416
417 /** Total number of fsyncs that have been started since
418 the server has started. */
419 static std::atomic<uint64_t> s_total_fsyncs;
420
421 /** Id of the redo log file (part of its file name) */
423
424 /** Access mode allowed for this handle (if not yet closed). */
426
427 /** Encryption metadata to be used for all IO operations on this file
428 except those related to the first LOG_FILE_HDR_SIZE bytes.
429 @remarks If Encryption::set_key() and Encryption::set_initial_vector()
430 started to accept their arguments as const pointers, this could become
431 a const pointer too). In such case, all usages of Encryption_metadata*
432 inside redo log code, could also become changed to usages of the const
433 pointer. */
435
436 /** Type of redo log file. */
438
439 /** Whether file is opened */
441
442 /** Whether file has been modified using this handle since it was opened. */
444
445 /** File name */
446 std::string m_file_path;
447
448 /** OS handle for file (if opened) */
450
451 /** Size of single physical block (if opened) */
453
454 /** Size of file in bytes (if opened) */
456};
457
458/** Meta information about single log file. */
459struct Log_file {
460 Log_file(const Log_files_context &files_ctx,
461 Encryption_metadata &encryption_metadata);
462
463 Log_file(const Log_files_context &files_ctx, Log_file_id id, bool consumed,
464 bool full, os_offset_t size_in_bytes, lsn_t start_lsn, lsn_t end_lsn,
465 Encryption_metadata &encryption_metadata);
466
467 Log_file(const Log_file &other) = default;
468
469 Log_file &operator=(const Log_file &other);
470
471 /** Context within which this file exists. */
473
474 /** ID of the file. */
476
477 /** Set to true when file becomes consumed. */
479
480 /** Set to true when file became full and next file exists. */
481 bool m_full;
482
483 /** Size, expressed in bytes, including LOG_FILE_HDR_SIZE. */
485
486 /** LSN of the first byte within the file, aligned to
487 OS_FILE_LOG_BLOCK_SIZE. */
489
490 /** LSN of the first byte after the file, aligned to
491 OS_FILE_LOG_BLOCK_SIZE. */
493
494 /** Encryption metadata passed to opened file handles
495 @see Log_file_handle::m_encryption_metadata */
497
498 /** Checks if this object is equal to a given another object.
499 @param[in] rhs the object to compare against
500 @return true iff all related fields of the two objects are equal */
501 bool operator==(const Log_file &rhs) const {
502 return m_id == rhs.m_id && m_consumed == rhs.m_consumed &&
503 m_full == rhs.m_full && m_size_in_bytes == rhs.m_size_in_bytes &&
505 }
506
507 /** Validates that lsn fields seem correct (m_start_lsn, m_end_lsn) */
508 void lsn_validate() const {
513 }
514
515 /** Checks if a given lsn belongs to [m_start_lsn, m_end_lsn).
516 In other words, checks that the given lsn belongs to this file.
517 @param[in] lsn lsn to test against lsn range
518 @return true iff lsn is in the file */
519 bool contains(lsn_t lsn) const {
520 return m_start_lsn <= lsn && lsn < m_end_lsn;
521 }
522
523 /** Provides offset for the given LSN (from the beginning of the log file).
524 @param[in] lsn lsn to locate (must exist in the file)
525 @return offset from the beginning of the file for the given lsn */
527 lsn_validate();
528 ut_a(contains(lsn) || lsn == m_end_lsn);
529 return offset(lsn, m_start_lsn);
530 }
531
532 /** Provides offset for the given LSN and log file with the given start_lsn
533 (offset from the beginning of the log file).
534 @param[in] lsn lsn to locate (must be >= file_start_lsn)
535 @param[in] file_start_lsn start lsn of the log file
536 @return offset from the beginning of the file for the given lsn */
537 static os_offset_t offset(lsn_t lsn, lsn_t file_start_lsn) {
538 return LOG_FILE_HDR_SIZE + (lsn - file_start_lsn);
539 }
540
541 /** Computes id of the next log file. Does not check if such file exists.
542 @return id of the next log file */
543 Log_file_id next_id() const { return next_id(m_id, 1); }
544
545 /** Opens this file and provides handle that allows to read from this file
546 and / or write to this file (depends on the requested access mode).
547 @param[in] access_mode requested access mode (reads and/or writes)
548 @return handle to the opened file or empty handle with error information */
549 Log_file_handle open(Log_file_access_mode access_mode) const;
550
551 /** Opens a given redo log file and provides handle that allows to read from
552 that file and / or write to that file (depends on the requested access mode).
553 @param[in] files_ctx context within which file exists
554 @param[in] file_id id of the redo log file to open
555 @param[in] access_mode requested access mode (reads and/or writes)
556 @param[in] encryption_metadata encryption metadata
557 @param[in] file_type type of underlying file on disk to open
558 @return handle to the opened file or empty handle with error information */
559 static Log_file_handle open(const Log_files_context &files_ctx,
560 Log_file_id file_id,
561 Log_file_access_mode access_mode,
562 Encryption_metadata &encryption_metadata,
564
565 /** Computes id + inc, asserting it does not overflow the maximum value.
566 @param[in] id base id of file, to which inc is added
567 @param[in] inc number of log files ahead (1 = directly next one)
568 @return id + inc */
569 static Log_file_id next_id(Log_file_id id, size_t inc = 1) {
570 constexpr Log_file_id MAX_FILE_ID = std::numeric_limits<Log_file_id>::max();
571 ut_a(0 < inc);
572 ut_a(inc <= MAX_FILE_ID);
573 ut_a(id <= MAX_FILE_ID - inc);
574 return id + inc;
575 }
576};
577
578struct alignas(ut::INNODB_CACHE_LINE_SIZE) log_t;
579
580/** Runtime statistics related to redo log files management. These stats are
581not persisted to disk. */
583 /** Last time stats were updated (last successful call to @see update()). */
585
586 /** LSN difference by which result of log_files_oldest_needed_lsn() advanced
587 during last second. This is basically average consumption speed.
588 Updated by successful calls to @see update(). */
590
591 /** LSN difference by which result of log_files_newest_needed_lsn() advanced
592 during last second. This is basically average production speed.
593 Updated by successful calls to @see update(). */
595
596 /** Oldest LSN returned by log_files_oldest_needed_lsn() during last
597 successful call to @see update(). */
599
600 /** Newest LSN returned by log_files_newest_needed_lsn() during last
601 successful call to @see update(). */
603
604 /** Tries to update stats. Fails and skips updating if less than 1s elapsed
605 since last successful update, else: updates the stats and succeeds.
606 @param[in] log redo log */
607 void update(const log_t &log);
608};
609
610#endif /* !log0types_h */
@ NORMAL
Get always.
The IO Context that is passed down to the low level IO code.
Definition: os0file.h:276
Handle which allows to do reads / writes for the opened file.
Definition: log0types.h:304
static uint64_t fsyncs_in_progress()
Definition: log0types.h:349
Log_file_id m_file_id
Id of the redo log file (part of its file name)
Definition: log0types.h:422
Log_file_handle(Encryption_metadata &encryption_metadata)
Definition: log0files_io.cc:181
static Log_file_io_callback s_on_before_read
Callback called on each read operation.
Definition: log0types.h:356
Log_file_access_mode m_access_mode
Access mode allowed for this handle (if not yet closed).
Definition: log0types.h:425
os_offset_t file_size() const
Definition: log0files_io.cc:320
os_offset_t m_file_size
Size of file in bytes (if opened)
Definition: log0types.h:455
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:380
os_offset_t m_block_size
Size of single physical block (if opened)
Definition: log0types.h:452
bool is_open() const
Definition: log0files_io.cc:299
dberr_t open()
Open the log file with the configured access mode.
Definition: log0files_io.cc:260
static std::atomic< size_t > s_n_open
Number of all opened Log_file_handle existing currently.
Definition: log0types.h:411
std::string m_file_path
File name.
Definition: log0types.h:446
pfs_os_file_t m_raw_handle
OS handle for file (if opened)
Definition: log0types.h:449
Log_file_handle(const Log_file_handle &other)=delete
static uint64_t total_fsyncs()
Definition: log0types.h:353
static bool s_skip_fsyncs
True iff all fsyncs should be no-op.
Definition: log0types.h:362
bool m_is_open
Whether file is opened.
Definition: log0types.h:440
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:375
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:434
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:287
static std::atomic< uint64_t > s_fsyncs_in_progress
Number of fsyncs in-progress.
Definition: log0types.h:415
Log_file_type m_file_type
Type of redo log file.
Definition: log0types.h:437
~Log_file_handle()
Closes handle if was opened (calling fsync if was modified).
Definition: log0files_io.cc:252
static std::atomic< uint64_t > s_total_fsyncs
Total number of fsyncs that have been started since the server has started.
Definition: log0types.h:419
Log_file_handle & operator=(Log_file_handle &&rhs)
Definition: log0files_io.cc:209
void prepare_io_request(IORequest &io_request, bool encrypted_area)
Configures a given io request object accordingly to currently configured encryption metadata (m_encry...
Definition: log0files_io.cc:322
dberr_t do_io(const IORequest &io_req, os_offset_t offset, os_offset_t size, byte *buf)
Performs a given IO operation on the opened file.
Definition: log0files_io.cc:336
const std::string & file_path() const
Definition: log0files_io.cc:258
Log_file_id file_id() const
Definition: log0files_io.cc:318
bool m_is_modified
Whether file has been modified using this handle since it was opened.
Definition: log0types.h:443
void fsync()
Executes fsync operation for this redo log file.
Definition: log0files_io.cc:301
static Log_file_io_callback s_on_before_write
Callback called on each write operation.
Definition: log0types.h:359
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:146
constexpr os_offset_t LOG_FILE_HDR_SIZE
Size of log file's header.
Definition: log0constants.h:169
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:289
@ 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:192
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:83
Encryption metadata.
Definition: os0enc.h:452
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
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:275
Log_file_id_and_header(Log_file_id id, Log_file_header header)
Definition: log0types.h:278
Log_file_id m_id
Id of the file.
Definition: log0types.h:282
Log_file_id_and_header()=default
Log_file_header m_header
Main header of the file.
Definition: log0types.h:285
Pair of: log file id and log file size (expressed in bytes).
Definition: log0types.h:261
Log_file_id m_id
Id of the file.
Definition: log0types.h:268
Log_file_id_and_size(Log_file_id id, os_offset_t size)
Definition: log0types.h:264
Log_file_id_and_size()=default
os_offset_t m_size_in_bytes
Size of file, expressed in bytes.
Definition: log0types.h:271
Meta information about single log file.
Definition: log0types.h:459
bool contains(lsn_t lsn) const
Checks if a given lsn belongs to [m_start_lsn, m_end_lsn).
Definition: log0types.h:519
Log_file_id m_id
ID of the file.
Definition: log0types.h:475
Log_file & operator=(const Log_file &other)
Definition: log0files_io.cc:424
Log_file(const Log_file &other)=default
Log_file_id next_id() const
Computes id of the next log file.
Definition: log0types.h:543
bool m_consumed
Set to true when file becomes consumed.
Definition: log0types.h:478
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:569
bool operator==(const Log_file &rhs) const
Checks if this object is equal to a given another object.
Definition: log0types.h:501
bool m_full
Set to true when file became full and next file exists.
Definition: log0types.h:481
lsn_t m_start_lsn
LSN of the first byte within the file, aligned to OS_FILE_LOG_BLOCK_SIZE.
Definition: log0types.h:488
const Log_files_context & m_files_ctx
Context within which this file exists.
Definition: log0types.h:472
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:537
void lsn_validate() const
Validates that lsn fields seem correct (m_start_lsn, m_end_lsn)
Definition: log0types.h:508
Log_file(const Log_files_context &files_ctx, Encryption_metadata &encryption_metadata)
Definition: log0files_io.cc:400
lsn_t m_end_lsn
LSN of the first byte after the file, aligned to OS_FILE_LOG_BLOCK_SIZE.
Definition: log0types.h:492
os_offset_t m_size_in_bytes
Size, expressed in bytes, including LOG_FILE_HDR_SIZE.
Definition: log0types.h:484
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:386
os_offset_t offset(lsn_t lsn) const
Provides offset for the given LSN (from the beginning of the log file).
Definition: log0types.h:526
Encryption_metadata & m_encryption_metadata
Encryption metadata passed to opened file handles.
Definition: log0types.h:496
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:1236
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:582
Log_clock_point m_last_update_time
Last time stats were updated (last successful call to.
Definition: log0types.h:584
lsn_t m_newest_lsn_on_update
Newest LSN returned by log_files_newest_needed_lsn() during last successful call to.
Definition: log0types.h:602
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:594
void update(const log_t &log)
Tries to update stats.
Definition: log0files_governor.cc:1179
lsn_t m_oldest_lsn_on_update
Oldest LSN returned by log_files_oldest_needed_lsn() during last successful call to.
Definition: log0types.h:598
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:589
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:74
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:172
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:56
static uint64_t lsn
Definition: xcom_base.cc:442
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:506