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