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