MySQL 8.3.0
Source Code Documentation
log0recv.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1997, 2023, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27/** @file include/log0recv.h
28 Recovery
29
30 Created 9/20/1997 Heikki Tuuri
31 *******************************************************/
32
33#ifndef log0recv_h
34#define log0recv_h
35
36#include "buf0types.h"
37#include "dict0types.h"
38#include "hash0hash.h"
39#include "log0sys.h"
40#include "mtr0types.h"
41
42/* OS_FILE_LOG_BLOCK_SIZE */
43#include "os0file.h"
44
45#include "ut0byte.h"
46#include "ut0new.h"
47
48#include <list>
49#include <set>
50#include <unordered_map>
51
52class MetadataRecover;
54
55#ifdef UNIV_HOTBACKUP
56
57struct recv_addr_t;
58
59/** list of tablespaces, that experienced an inplace DDL during a backup op */
60extern std::list<std::pair<space_id_t, lsn_t>> index_load_list;
61/** the last redo log flush len as seen by MEB */
62extern volatile lsn_t backup_redo_log_flushed_lsn;
63/** true when the redo log is being backed up */
64extern bool recv_is_making_a_backup;
65
66/** Scans the log segment and n_bytes_scanned is set to the length of valid
67log scanned.
68@param[in] buf buffer containing log data
69@param[in] buf_len data length in that buffer
70@param[in,out] scanned_lsn lsn of buffer start, we return scanned
71lsn
72@param[in,out] scanned_checkpoint_no 4 lowest bytes of the highest scanned
73@param[out] block_no highest block no in scanned buffer.
74checkpoint number so far
75@param[out] n_bytes_scanned how much we were able to scan, smaller
76than buf_len if log data ended here
77@param[out] has_encrypted_log set true, if buffer contains encrypted
78redo log, set false otherwise */
79void meb_scan_log_seg(byte *buf, size_t buf_len, lsn_t *scanned_lsn,
80 uint32_t *scanned_checkpoint_no, uint32_t *block_no,
81 size_t *n_bytes_scanned, bool *has_encrypted_log);
82
83/** Applies the hashed log records to the page, if the page lsn is less than the
84lsn of a log record. This can be called when a buffer page has just been
85read in, or also for a page already in the buffer pool.
86
87
88@param[in,out] block buffer block */
90
91/** Wrapper for recv_recover_page_func().
92Applies the hashed log records to the page, if the page lsn is less than the
93lsn of a log record. This can be called when a buffer page has just been
94read in, or also for a page already in the buffer pool.
95@param jri in: true if just read in (the i/o handler calls this for
96a freshly read page)
97@param block in,out: the buffer block
98*/
99static inline void recv_recover_page(bool jri [[maybe_unused]],
100 buf_block_t *block) {
102}
103
104/** Applies log records in the hash table to a backup. */
105void meb_apply_log_recs(void);
106
107/** Applies log records in the hash table to a backup using a callback
108functions.
109@param[in] apply_log_record_function function for apply
110@param[in] wait_till_done_function function for wait */
111void meb_apply_log_recs_via_callback(
112 void (*apply_log_record_function)(recv_addr_t *),
113 void (*wait_till_done_function)());
114
115/** Applies a log record in the hash table to a backup.
116@param[in] recv_addr chain of log records
117@param[in,out] block buffer block to apply the records to */
118void meb_apply_log_record(recv_addr_t *recv_addr, buf_block_t *block);
119
120/** Process a file name passed as an input
121@param[in] name absolute path of tablespace file
122@param[in] space_id the tablespace ID
123@retval true if able to process file successfully.
124@retval false if unable to process the file */
125void meb_fil_name_process(const char *name, space_id_t space_id);
126
127/** Scans log from a buffer and stores new log data to the parsing buffer.
128Parses and hashes the log records if new data found. Unless
129UNIV_HOTBACKUP is defined, this function will apply log records
130automatically when the hash table becomes full.
131@param[in] available_memory we let the hash table of recs
132to grow to this size, at the maximum
133@param[in] buf buffer containing a log
134segment or garbage
135@param[in] len buffer length
136@param[in] start_lsn buffer start lsn
137@param[out] group_scanned_lsn scanning succeeded up to this lsn
138@retval true if limit_lsn has been reached, or not able to scan any
139more in this log group
140@retval false otherwise */
141bool meb_scan_log_recs(size_t available_memory, const byte *buf, size_t len,
142 lsn_t start_lsn, lsn_t *group_scanned_lsn);
143
144/** Check the 4-byte checksum to the trailer checksum field of a log
145block.
146@param[in] block pointer to a log block
147@return whether the checksum matches */
148bool log_block_checksum_is_ok(const byte *block);
149#else /* UNIV_HOTBACKUP */
150
151/** Applies the hashed log records to the page, if the page lsn is less than the
152lsn of a log record. This can be called when a buffer page has just been
153read in, or also for a page already in the buffer pool.
154
155
156@param[in] just_read_in true if the IO handler calls this for a freshly
157 read page
158@param[in,out] block buffer block */
159void recv_recover_page_func(bool just_read_in, buf_block_t *block);
160
161/** Wrapper for recv_recover_page_func().
162Applies the hashed log records to the page, if the page lsn is less than the
163lsn of a log record. This can be called when a buffer page has just been
164read in, or also for a page already in the buffer pool.
165@param jri in: true if just read in (the i/o handler calls this for
166a freshly read page)
167@param[in,out] block buffer block */
168static inline void recv_recover_page(bool jri, buf_block_t *block) {
169 recv_recover_page_func(jri, block);
170}
171
172#endif /* UNIV_HOTBACKUP */
173
174/** Frees the recovery system. */
175void recv_sys_free();
176
177/** Reset the state of the recovery system variables. */
178void recv_sys_var_init();
179
180#ifdef UNIV_HOTBACKUP
181/** Get the number of bytes used by all the heaps
182@return number of bytes used */
183size_t meb_heap_used();
184#endif /* UNIV_HOTBACKUP */
185
186/** Returns true if recovery is currently running.
187@return recv_recovery_on */
188[[nodiscard]] static inline bool recv_recovery_is_on();
189
190/** Returns true if the page is brand new (the next log record is init_file_page
191or no records to apply).
192@param[in] block buffer block
193@return true if brand new */
195
196/** Start recovering from a redo log checkpoint.
197@see recv_recovery_from_checkpoint_finish
198@param[in,out] log redo log
199@param[in] flush_lsn lsn stored at offset FIL_PAGE_FILE_FLUSH_LSN
200 in the system tablespace header
201@return error code or DB_SUCCESS */
203 lsn_t flush_lsn);
204
205/** Determine if a redo log from a version before MySQL 8.0.30 is clean.
206@param[in,out] log redo log
207@return error code
208@retval DB_SUCCESS if the redo log is clean
209@retval DB_ERROR if the redo log is corrupted or dirty */
211
212/** Complete the recovery from the latest checkpoint.
213@param[in] aborting true if the server has to abort due to an error
214@return recovered persistent metadata or nullptr if aborting*/
216 bool aborting);
217
218/** Creates the recovery system. */
219void recv_sys_create();
220
221/** Release recovery system mutexes. */
222void recv_sys_close();
223
224/** Inits the recovery system for a recovery operation. */
225void recv_sys_init();
226
227/** Calculates the new value for lsn when more data is added to the log.
228@param[in] lsn Old LSN
229@param[in] len This many bytes of data is added, log block
230 headers not included
231@return LSN after data addition */
233
234/** Empties the hash table of stored log records, applying them to appropriate
235pages.
236@param[in,out] log redo log
237@param[in] allow_ibuf if true, ibuf operations are allowed during
238 the application; if false, no ibuf operations
239 are allowed, and after the application all
240 file pages are flushed to disk and invalidated
241 in buffer pool: this alternative means that
242 no new log records can be generated during
243 the application; the caller must in this case
244 own the log mutex */
245void recv_apply_hashed_log_recs(log_t &log, bool allow_ibuf);
246
247#if defined(UNIV_DEBUG) || defined(UNIV_HOTBACKUP)
248/** Return string name of the redo log record type.
249@param[in] type record log record enum
250@return string name of record log record */
251const char *get_mlog_string(mlog_id_t type);
252#endif /* UNIV_DEBUG || UNIV_HOTBACKUP */
253
254/** Block of log record data */
256 /** pointer to the next block or NULL. The log record data
257 is stored physically immediately after this struct, max amount
258 RECV_DATA_BLOCK_SIZE bytes of it */
259
261};
262
263/** Stored log record struct */
264struct recv_t {
266
267 /** Log record type */
269
270 /** Log record body length in bytes */
272
273 /** Chain of blocks containing the log record body */
275
276 /** Start lsn of the log segment written by the mtr which generated
277 this log record: NOTE that this is not necessarily the start lsn of
278 this log record */
280
281 /** End lsn of the log segment written by the mtr which generated
282 this log record: NOTE that this is not necessarily the end LSN of
283 this log record */
285
286 /** List node, list anchored in recv_addr_t */
288};
289
290/** States of recv_addr_t */
292
293 /** not yet processed */
295
296 /** page is being read */
298
299 /** log records are being applied on the page */
301
302 /** log records have been applied on the page */
304
305 /** log records have been discarded because the tablespace
306 does not exist */
309
310/** Hashed page file address struct */
313
314 /** recovery state of the page */
316
317 /** Space ID */
319
320 /** Page number */
322
323 /** List of log records for this page */
325};
326
327// Forward declaration
328namespace dblwr {
329namespace recv {
330class DBLWR;
331}
332} // namespace dblwr
333
334/** Class to parse persistent dynamic metadata redo log, store and
335merge them and apply them to in-memory table objects finally */
338 table_id_t, PersistentTableMetadata *, std::less<table_id_t>,
340
341 public:
342 /** Default constructor */
344
345 /** Destructor */
347
348 /** Parse a dynamic metadata redo log of a table and store
349 the metadata locally
350 @param[in] id table id
351 @param[in] version table dynamic metadata version
352 @param[in] ptr redo log start
353 @param[in] end end of redo log
354 @retval ptr to next redo log record, nullptr if this log record
355 was truncated */
356 byte *parseMetadataLog(table_id_t id, uint64_t version, byte *ptr, byte *end);
357
358 /** Store the collected persistent dynamic metadata to
359 mysql.innodb_dynamic_metadata */
360 void store();
361
362 /** If there is any metadata to be applied
363 @return true if any metadata to be applied, otherwise false */
364 bool empty() const { return m_tables.empty(); }
365
366 private:
367 /** Get the dynamic metadata of a specified table,
368 create a new one if not exist
369 @param[in] id table id
370 @return the metadata of the specified table */
372
373 private:
374 /** Map used to store and merge persistent dynamic metadata */
376};
377
378/** Recovery system data structure */
380 using Pages =
381 std::unordered_map<page_no_t, recv_addr_t *, std::hash<page_no_t>,
382 std::equal_to<page_no_t>>;
383
384 /** Every space has its own heap and pages that belong to it. */
385 struct Space {
386 /** Constructor
387 @param[in,out] heap Heap to use for the log records. */
388 explicit Space(mem_heap_t *heap) : m_heap(heap), m_pages() {}
389
390 /** Default constructor */
391 Space() : m_heap(), m_pages() {}
392
393 /** Memory heap of log records and file addresses */
395
396 /** Pages that need to be recovered */
398 };
399
400 using Missing_Ids = std::set<space_id_t>;
401
402 using Spaces = std::unordered_map<space_id_t, Space, std::hash<space_id_t>,
403 std::equal_to<space_id_t>>;
404
405 /* Recovery encryption information */
407 /** Tablespace ID */
409
410 /** LSN of REDO log encryption entry */
412
413 /** Encryption key */
414 byte *ptr;
415
416 /** Encryption IV */
417 byte *iv;
418 };
419
420 using Encryption_Keys = std::vector<Encryption_Key>;
421
422 /** Mini transaction log record. */
423 struct Mlog_record {
424 /* Space ID */
426 /* Page number */
428 /* Log type */
430 /* Log body */
431 const byte *body;
432 /* Record size */
433 size_t size;
434 };
435
436 using Mlog_records = std::vector<Mlog_record, ut::allocator<Mlog_record>>;
437
438 /** While scanning logs for multi-record mini-transaction (mtr), we have two
439 passes. In first pass, we check if all the logs of the mtr is present in
440 current recovery buffer or not. If yes, then in second pass we go through the
441 logs again the add to hash table for apply. To avoid parsing multiple times,
442 we save the parsed records in first pass and reuse them in second pass.
443
444 Parsing of redo log takes significant amount of time and this optimization of
445 avoiding second parse gave about 1.8x speed up on recovery scan time of 1G of
446 redo log from sysbench rw test.
447
448 There is currently no limit for maximum number of logs in an mtr. Practically,
449 from sysbench rw test recovery with 1G of redo log to recover from the record
450 count were spread from 3 - 1235 with majority between 600 - 700. So, it is
451 likely by saving 1k records we could avoid most of the re-parsing overhead.
452 Considering possible bigger number of records in other load and future changes
453 the limit for number of saved records is kept at 8k. The same value from the
454 contribution patch. The memory requirement 32 x 8k = 256k seems fine as one
455 time overhead for the entire instance. */
456 static constexpr size_t MAX_SAVED_MLOG_RECS = 8 * 1024;
457
458 /** Save mlog record information. Silently returns if cannot save. Works only
459 in single threaded recovery scanner.
460 @param[in] rec_num record number in multi record group
461 @param[in] space_id space ID for the log record
462 @param[in] page_no page number for the log record
463 @param[in] type log record type
464 @param[in] body pointer to log record body in recovery buffer
465 @param[in] len length of the log record */
466 void save_rec(size_t rec_num, space_id_t space_id, page_no_t page_no,
467 mlog_id_t type, const byte *body, size_t len) {
468 /* No more space to save log. */
469 if (rec_num >= MAX_SAVED_MLOG_RECS) {
470 return;
471 }
472
473 ut_ad(rec_num < saved_recs.size());
474
475 if (rec_num >= saved_recs.size()) {
476 return;
477 }
478
479 auto &saved_rec = saved_recs[rec_num];
480
481 saved_rec.space_id = space_id;
482 saved_rec.page_no = page_no;
483 saved_rec.type = type;
484 saved_rec.body = body;
485 saved_rec.size = len;
486 }
487
488 /** Return saved mlog record information, if there. Works only
489 in single threaded recovery scanner.
490 @param[in] rec_num record number in multi record group
491 @param[out] space_id space ID for the log record
492 @param[out] page_no page number for the log record
493 @param[out] type log record type
494 @param[out] body pointer to log record body in recovery buffer
495 @param[out] len length of the log record
496 @return true iff saved record data is found. */
497 bool get_saved_rec(size_t rec_num, space_id_t &space_id, page_no_t &page_no,
498 mlog_id_t &type, byte *&body, size_t &len) {
499 if (rec_num >= MAX_SAVED_MLOG_RECS) {
500 return false;
501 }
502
503 ut_ad(rec_num < saved_recs.size());
504
505 if (rec_num >= saved_recs.size()) {
506 return false;
507 }
508
509 auto &saved_rec = saved_recs[rec_num];
510
511 space_id = saved_rec.space_id;
512 page_no = saved_rec.page_no;
513 type = saved_rec.type;
514 body = const_cast<byte *>(saved_rec.body);
515 len = saved_rec.size;
516
517 return true;
518 }
519
520#ifndef UNIV_HOTBACKUP
521
522 /*!< mutex protecting the fields apply_log_recs, n_addrs, and the
523 state field in each recv_addr struct */
524 ib_mutex_t mutex;
525
526 /** mutex coordinating flushing between recv_writer_thread and
527 the recovery thread. */
528 ib_mutex_t writer_mutex;
529
530 /** event to activate page cleaner threads */
532
533 /** event to signal that the page cleaner has finished the request */
535
536 /** type of the flush request. BUF_FLUSH_LRU: flush end of LRU,
537 keeping free blocks. BUF_FLUSH_LIST: flush all of blocks. */
539
540#else /* !UNIV_HOTBACKUP */
541 bool apply_file_operations;
542#endif /* !UNIV_HOTBACKUP */
543
544 /** This is true when log rec application to pages is allowed;
545 this flag tells the i/o-handler if it should do log record
546 application */
548
549 /** This is true when a log rec application batch is running */
551
552 /** Buffer for parsing log records */
553 byte *buf;
554
555 /** Size of the parsing buffer */
556 size_t buf_len;
557
558 /** Amount of data in buf */
560
561 /** This is the lsn from which we were able to start parsing
562 log records and adding them to the hash table; zero if a suitable
563 start point not found yet */
565
566 /** Checkpoint lsn that was used during recovery (read from file). */
568
569 /** Number of data bytes to ignore until we reach checkpoint_lsn. */
571
572 /** The log data has been scanned up to this lsn */
574
575 /** The log data has been scanned up to this epoch_no */
577
578 /** Start offset of non-parsed log records in buf */
580
581 /** The log records have been parsed up to this lsn */
583
584 /** The previous value of recovered_lsn - before we parsed the last mtr.
585 It is equal to recovered_lsn before we parsed any mtr. This is used to
586 find moments in which recovered_lsn moves to the next block in which case
587 we should update the last_block_first_rec_group (described below). */
589
590 /** Tracks what should be the proper value of first_rec_group field in the
591 header of the block to which recovered_lsn belongs. It might be also zero,
592 in which case it means we do not know. */
594
595 /** Set when finding a corrupt log block or record, or there
596 is a log parsing buffer overflow */
598
599 /** Set when an inconsistency with the file system contents
600 is detected during log scan or apply */
602
603 /** Data directory has been recognized as cloned data directory. */
605
606 /** Data directory has been recognized as data directory from MEB. */
608
609 /** Doublewrite buffer state before MEB recovery starts. We restore to this
610 state after MEB recovery completes and disable the doublewrite buffer during
611 MEB recovery. */
613
614 /** Hash table of pages, indexed by SpaceID. */
616
617 /** Number of not processed hashed file addresses in the hash table */
619
620 /** Doublewrite buffer pages, destroyed after recovery completes */
622
623 /** We store and merge all table persistent data here during
624 scanning redo logs */
626
627 /** Encryption Key information per tablespace ID */
629
630 /** Tablespace IDs that were ignored during redo log apply. */
632
633 /** Tablespace IDs that were explicitly deleted. */
635
636 /* Saved log records to avoid second round parsing log. */
638};
639
640/** The recovery system */
641extern recv_sys_t *recv_sys;
642
643/** true when applying redo log records during crash recovery; false
644otherwise. Note that this is false while a background thread is
645rolling back incomplete transactions. */
646extern volatile bool recv_recovery_on;
647
648/** If the following is true, the buffer pool file pages must be invalidated
649after recovery and no ibuf operations are allowed; this becomes true if
650the log record hash table becomes too full, and log records must be merged
651to file pages already before the recovery is finished: in this case no
652ibuf operations are allowed, as they could modify the pages read in the
653buffer pool before the pages have been recovered to the up-to-date state.
654
655true means that recovery is running and no operations on the log files
656are allowed yet: the variable name is misleading. */
657extern bool recv_no_ibuf_operations;
658
659/** true when recv_init_crash_recovery() has been called. */
660extern bool recv_needed_recovery;
661
662/** true if buf_page_is_corrupted() should check if the log sequence
663number (FIL_PAGE_LSN) is in the future. Initially false, and set by
664recv_recovery_from_checkpoint_start(). */
665extern bool recv_lsn_checks_on;
666
667/** Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many
668times! */
669constexpr uint32_t RECV_PARSING_BUF_SIZE = 2 * 1024 * 1024;
670
671/** Size of block reads when the log groups are scanned forward to do a
672roll-forward */
673#define RECV_SCAN_SIZE (4 * UNIV_PAGE_SIZE)
674
676
677/** A list of tablespaces for which (un)encryption process was not
678completed before crash. */
679extern std::list<space_id_t> recv_encr_ts_list;
680
681#include "log0recv.ic"
682
683#endif
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:46
uint32_t page_no_t
Page number.
Definition: api0api.h:44
The database buffer pool global types for the directory.
buf_flush_t
Flags for flush types.
Definition: buf0types.h:67
Definition: sql_list.h:434
Class to parse persistent dynamic metadata redo log, store and merge them and apply them to in-memory...
Definition: log0recv.h:336
MetadataRecover() 1=default
Default constructor.
bool empty() const
If there is any metadata to be applied.
Definition: log0recv.h:364
void store()
Store the collected persistent dynamic metadata to mysql.innodb_dynamic_metadata.
Definition: log0recv.cc:683
PersistentTableMetadata * getMetadata(table_id_t id)
Get the dynamic metadata of a specified table, create a new one if not exist.
Definition: log0recv.cc:265
PersistentTables m_tables
Map used to store and merge persistent dynamic metadata.
Definition: log0recv.h:375
std::map< table_id_t, PersistentTableMetadata *, std::less< table_id_t >, ut::allocator< std::pair< const table_id_t, PersistentTableMetadata * > > > PersistentTables
Definition: log0recv.h:339
byte * parseMetadataLog(table_id_t id, uint64_t version, byte *ptr, byte *end)
Parse a dynamic metadata redo log of a table and store the metadata locally.
Definition: log0recv.cc:291
Persistent dynamic metadata for a table.
Definition: dict0mem.h:2755
Redo recovery configuration.
Definition: buf0dblwr.h:474
Allocator that allows std::* containers to manage their memory through ut::malloc* and ut::free libra...
Definition: ut0new.h:2180
dberr_t
Definition: db0err.h:38
Data dictionary global types.
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:217
mysql_service_status_t recv(const char *tag, const unsigned char *data, size_t data_length) noexcept
Definition: gr_message_service_example.cc:38
The simple hash table utility.
bool recv_is_making_a_backup
true When the redo log is being backed up
Definition: log0recv.cc:171
static bool log_block_checksum_is_ok(const byte *block)
Check the 4-byte checksum to the trailer checksum field of a log block.
Definition: log0recv.cc:616
bool recv_no_ibuf_operations
If the following is true, the buffer pool file pages must be invalidated after recovery and no ibuf o...
Definition: log0recv.cc:168
MetadataRecover * recv_recovery_from_checkpoint_finish(bool aborting)
Complete the recovery from the latest checkpoint.
Definition: log0recv.cc:3983
void recv_sys_free()
Frees the recovery system.
Definition: log0recv.cc:768
void recv_sys_init()
Inits the recovery system for a recovery operation.
Definition: log0recv.cc:527
recv_addr_state
States of recv_addr_t.
Definition: log0recv.h:291
@ RECV_BEING_READ
page is being read
Definition: log0recv.h:297
@ RECV_DISCARDED
log records have been discarded because the tablespace does not exist
Definition: log0recv.h:307
@ RECV_BEING_PROCESSED
log records are being applied on the page
Definition: log0recv.h:300
@ RECV_NOT_PROCESSED
not yet processed
Definition: log0recv.h:294
@ RECV_PROCESSED
log records have been applied on the page
Definition: log0recv.h:303
lsn_t recv_calc_lsn_on_data_add(lsn_t lsn, os_offset_t len)
Calculates the new value for lsn when more data is added to the log.
Definition: log0recv.cc:235
void recv_sys_close()
Release recovery system mutexes.
Definition: log0recv.cc:413
constexpr uint32_t RECV_PARSING_BUF_SIZE
Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many times!
Definition: log0recv.h:669
dberr_t recv_verify_log_is_clean_pre_8_0_30(log_t &log)
Determine if a redo log from a version before MySQL 8.0.30 is clean.
Definition: log0recv.cc:815
size_t recv_n_frames_for_pages_per_pool_instance
This many blocks must be left in each Buffer Pool instance to be managed by the LRU when we scan the ...
Definition: log0recv.cc:194
void recv_sys_var_init()
Reset the state of the recovery system variables.
Definition: log0recv.cc:450
bool recv_page_is_brand_new(buf_block_t *block)
Returns true if the page is brand new (the next log record is init_file_page or no records to apply).
Definition: log0recv.cc:2504
void recv_apply_hashed_log_recs(log_t &log, bool allow_ibuf)
Empties the hash table of stored log records, applying them to appropriate pages.
Definition: log0recv.cc:1117
static void recv_recover_page(bool jri, buf_block_t *block)
Wrapper for recv_recover_page_func().
Definition: log0recv.h:168
const char * get_mlog_string(mlog_id_t type)
Return string name of the redo log record type.
Definition: log0recv.cc:4048
recv_sys_t * recv_sys
The recovery system.
Definition: log0recv.cc:94
bool recv_needed_recovery
true when recv_init_crash_recovery() has been called.
Definition: log0recv.cc:152
void recv_sys_create()
Creates the recovery system.
Definition: log0recv.cc:331
static bool recv_recovery_is_on()
Returns true if recovery is currently running.
volatile bool recv_recovery_on
true when applying redo log records during crash recovery; false otherwise.
Definition: log0recv.cc:99
bool recv_lsn_checks_on
true if buf_page_is_corrupted() should check if the log sequence number (FIL_PAGE_LSN) is in the futu...
Definition: log0recv.cc:157
void recv_recover_page_func(bool just_read_in, buf_block_t *block)
Applies the hashed log records to the page, if the page lsn is less than the lsn of a log record.
Definition: log0recv.cc:2545
dberr_t recv_recovery_from_checkpoint_start(log_t &log, lsn_t flush_lsn)
Start recovering from a redo log checkpoint.
Definition: log0recv.cc:3773
std::list< space_id_t > recv_encr_ts_list
A list of tablespaces for which (un)encryption process was not completed before crash.
Definition: log0recv.cc:84
Recovery.
Redo log - the log_sys.
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:62
Mini-transaction buffer global types.
mlog_id_t
Definition: mtr0types.h:62
Definition: buf0block_hint.cc:29
Definition: buf0dblwr.cc:74
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2891
The interface to the operating system file io.
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:86
required uint64 version
Definition: replication_group_member_actions.proto:40
required string type
Definition: replication_group_member_actions.proto:33
case opt name
Definition: sslopt-case.h:32
The buffer control block structure.
Definition: buf0buf.h:1750
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:76
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:301
InnoDB condition variable.
Definition: os0event.cc:62
Hashed page file address struct.
Definition: log0recv.h:311
page_no_t page_no
Page number.
Definition: log0recv.h:321
recv_addr_state state
recovery state of the page
Definition: log0recv.h:315
space_id_t space
Space ID.
Definition: log0recv.h:318
List rec_list
List of log records for this page.
Definition: log0recv.h:324
Block of log record data.
Definition: log0recv.h:255
recv_data_t * next
pointer to the next block or NULL.
Definition: log0recv.h:260
Definition: log0recv.h:406
byte * ptr
Encryption key.
Definition: log0recv.h:414
space_id_t space_id
Tablespace ID.
Definition: log0recv.h:408
byte * iv
Encryption IV.
Definition: log0recv.h:417
lsn_t lsn
LSN of REDO log encryption entry.
Definition: log0recv.h:411
Mini transaction log record.
Definition: log0recv.h:423
space_id_t space_id
Definition: log0recv.h:425
size_t size
Definition: log0recv.h:433
const byte * body
Definition: log0recv.h:431
page_no_t page_no
Definition: log0recv.h:427
mlog_id_t type
Definition: log0recv.h:429
Every space has its own heap and pages that belong to it.
Definition: log0recv.h:385
Pages m_pages
Pages that need to be recovered.
Definition: log0recv.h:397
mem_heap_t * m_heap
Memory heap of log records and file addresses.
Definition: log0recv.h:394
Space(mem_heap_t *heap)
Constructor.
Definition: log0recv.h:388
Space()
Default constructor.
Definition: log0recv.h:391
Recovery system data structure.
Definition: log0recv.h:379
std::vector< Encryption_Key > Encryption_Keys
Definition: log0recv.h:420
Missing_Ids deleted
Tablespace IDs that were explicitly deleted.
Definition: log0recv.h:634
ulint n_addrs
Number of not processed hashed file addresses in the hash table.
Definition: log0recv.h:618
ulint len
Amount of data in buf.
Definition: log0recv.h:559
bool found_corrupt_fs
Set when an inconsistency with the file system contents is detected during log scan or apply.
Definition: log0recv.h:601
ib_mutex_t mutex
Definition: log0recv.h:524
bool is_meb_db
Data directory has been recognized as data directory from MEB.
Definition: log0recv.h:607
lsn_t previous_recovered_lsn
The previous value of recovered_lsn - before we parsed the last mtr.
Definition: log0recv.h:588
ulint bytes_to_ignore_before_checkpoint
Number of data bytes to ignore until we reach checkpoint_lsn.
Definition: log0recv.h:570
os_event_t flush_end
event to signal that the page cleaner has finished the request
Definition: log0recv.h:534
void save_rec(size_t rec_num, space_id_t space_id, page_no_t page_no, mlog_id_t type, const byte *body, size_t len)
Save mlog record information.
Definition: log0recv.h:466
dblwr::recv::DBLWR * dblwr
Doublewrite buffer pages, destroyed after recovery completes.
Definition: log0recv.h:621
std::set< space_id_t > Missing_Ids
Definition: log0recv.h:400
Spaces * spaces
Hash table of pages, indexed by SpaceID.
Definition: log0recv.h:615
bool get_saved_rec(size_t rec_num, space_id_t &space_id, page_no_t &page_no, mlog_id_t &type, byte *&body, size_t &len)
Return saved mlog record information, if there.
Definition: log0recv.h:497
lsn_t recovered_lsn
The log records have been parsed up to this lsn.
Definition: log0recv.h:582
bool apply_batch_on
This is true when a log rec application batch is running.
Definition: log0recv.h:550
std::vector< Mlog_record, ut::allocator< Mlog_record > > Mlog_records
Definition: log0recv.h:436
ulint recovered_offset
Start offset of non-parsed log records in buf.
Definition: log0recv.h:579
lsn_t last_block_first_mtr_boundary
Tracks what should be the proper value of first_rec_group field in the header of the block to which r...
Definition: log0recv.h:593
std::unordered_map< page_no_t, recv_addr_t *, std::hash< page_no_t >, std::equal_to< page_no_t > > Pages
Definition: log0recv.h:382
std::unordered_map< space_id_t, Space, std::hash< space_id_t >, std::equal_to< space_id_t > > Spaces
Definition: log0recv.h:403
ib_mutex_t writer_mutex
mutex coordinating flushing between recv_writer_thread and the recovery thread.
Definition: log0recv.h:528
Mlog_records saved_recs
Definition: log0recv.h:637
bool is_cloned_db
Data directory has been recognized as cloned data directory.
Definition: log0recv.h:604
os_event_t flush_start
event to activate page cleaner threads
Definition: log0recv.h:531
Missing_Ids missing_ids
Tablespace IDs that were ignored during redo log apply.
Definition: log0recv.h:631
lsn_t checkpoint_lsn
Checkpoint lsn that was used during recovery (read from file).
Definition: log0recv.h:567
uint32_t scanned_epoch_no
The log data has been scanned up to this epoch_no.
Definition: log0recv.h:576
size_t buf_len
Size of the parsing buffer.
Definition: log0recv.h:556
buf_flush_t flush_type
type of the flush request.
Definition: log0recv.h:538
Encryption_Keys * keys
Encryption Key information per tablespace ID.
Definition: log0recv.h:628
bool dblwr_state
Doublewrite buffer state before MEB recovery starts.
Definition: log0recv.h:612
bool found_corrupt_log
Set when finding a corrupt log block or record, or there is a log parsing buffer overflow.
Definition: log0recv.h:597
lsn_t parse_start_lsn
This is the lsn from which we were able to start parsing log records and adding them to the hash tabl...
Definition: log0recv.h:564
lsn_t scanned_lsn
The log data has been scanned up to this lsn.
Definition: log0recv.h:573
byte * buf
Buffer for parsing log records.
Definition: log0recv.h:553
bool apply_log_recs
This is true when log rec application to pages is allowed; this flag tells the i/o-handler if it shou...
Definition: log0recv.h:547
MetadataRecover * metadata_recover
We store and merge all table persistent data here during scanning redo logs.
Definition: log0recv.h:625
static constexpr size_t MAX_SAVED_MLOG_RECS
While scanning logs for multi-record mini-transaction (mtr), we have two passes.
Definition: log0recv.h:456
Stored log record struct.
Definition: log0recv.h:264
recv_data_t * data
Chain of blocks containing the log record body.
Definition: log0recv.h:274
lsn_t start_lsn
Start lsn of the log segment written by the mtr which generated this log record: NOTE that this is no...
Definition: log0recv.h:279
UT_LIST_NODE_T(recv_t) Node
Definition: log0recv.h:265
ulint len
Log record body length in bytes.
Definition: log0recv.h:271
lsn_t end_lsn
End lsn of the log segment written by the mtr which generated this log record: NOTE that this is not ...
Definition: log0recv.h:284
Node rec_list
List node, list anchored in recv_addr_t.
Definition: log0recv.h:287
mlog_id_t type
Log record type.
Definition: log0recv.h:268
typedef UT_LIST_BASE_NODE_T(rw_lock_t, list) rw_lock_list_t
#define UNIV_NOTHROW
Definition: univ.i:455
unsigned long int ulint
Definition: univ.i:405
Utilities for byte operations.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:104
#define UT_LIST_NODE_T(t)
Macro used for legacy reasons.
Definition: ut0lst.h:63
Dynamic memory allocation routines and custom allocators specifically crafted to support memory instr...
static uint64_t lsn
Definition: xcom_base.cc:445