MySQL  8.0.19
Source Code Documentation
log0recv.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1997, 2019, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 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 "log0types.h"
40 #include "mtr0types.h"
41 #include "os0file.h" /* OS_FILE_LOG_BLOCK_SIZE */
42 #include "univ.i"
43 #include "ut0byte.h"
44 #include "ut0new.h"
45 
46 #include <list>
47 #include <set>
48 #include <unordered_map>
49 
50 class MetadataRecover;
52 
53 #ifdef UNIV_HOTBACKUP
54 
55 struct recv_addr_t;
56 
57 /** This is set to FALSE if the backup was originally taken with the
58 mysqlbackup --include regexp option: then we do not want to create tables in
59 directories which were not included */
60 extern bool meb_replay_file_ops;
61 /** list of tablespaces, that experienced an inplace DDL during a backup op */
62 extern std::list<std::pair<space_id_t, lsn_t>> index_load_list;
63 /** the last redo log flush len as seen by MEB */
64 extern volatile lsn_t backup_redo_log_flushed_lsn;
65 /** TRUE when the redo log is being backed up */
66 extern bool recv_is_making_a_backup;
67 
68 /** Scans the log segment and n_bytes_scanned is set to the length of valid
69 log 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
73 lsn
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.
76 checkpoint number so far
77 @param[out] n_bytes_scanned how much we were able to scan, smaller
78 than buf_len if log data ended here
79 @param[out] has_encrypted_log set true, if buffer contains encrypted
80 redo log, set false otherwise */
81 void meb_scan_log_seg(byte *buf, ulint buf_len, lsn_t *scanned_lsn,
82  uint32_t *scanned_checkpoint_no, uint32_t *block_no,
83  ulint *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
86 lsn of a log record. This can be called when a buffer page has just been
87 read in, or also for a page already in the buffer pool.
88 @param[in,out] block buffer block */
90 
91 /** Wrapper for recv_recover_page_func().
92 Applies the hashed log records to the page, if the page lsn is less than the
93 lsn of a log record. This can be called when a buffer page has just been
94 read 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
96 a freshly read page)
97 @param block in,out: the buffer block
98 */
99 #define recv_recover_page(jri, block) recv_recover_page_func(block)
100 
101 /** Applies log records in the hash table to a backup. */
102 void meb_apply_log_recs(void);
103 
104 /** Applies log records in the hash table to a backup using a callback
105 functions.
106 @param[in] function function for apply
107 @param[in] wait_till_finished function for wait */
108 void meb_apply_log_recs_via_callback(
109  void (*apply_log_record_function)(recv_addr_t *),
110  void (*wait_till_done_function)());
111 
112 /** Applies a log record in the hash table to a backup.
113 @param[in] recv_addr chain of log records
114 @param[in,out] block buffer block to apply the records to */
115 void meb_apply_log_record(recv_addr_t *recv_addr, buf_block_t *block);
116 
117 /** Process a file name passed as an input
118 @param[in] name absolute path of tablespace file
119 @param[in] space_id the tablespace ID
120 @retval true if able to process file successfully.
121 @retval false if unable to process the file */
122 void meb_fil_name_process(const char *name, space_id_t space_id);
123 
124 /** Scans log from a buffer and stores new log data to the parsing buffer.
125 Parses and hashes the log records if new data found. Unless
126 UNIV_HOTBACKUP is defined, this function will apply log records
127 automatically when the hash table becomes full.
128 @param[in] available_memory we let the hash table of recs
129 to grow to this size, at the maximum
130 @param[in] buf buffer containing a log
131 segment or garbage
132 @param[in] len buffer length
133 @param[in] checkpoint_lsn latest checkpoint LSN
134 @param[in] start_lsn buffer start lsn
135 @param[in] contiguous_lsn it is known that all log
136 groups contain contiguous log data up to this 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
139 more in this log group
140 @retval false otherwise */
141 bool meb_scan_log_recs(ulint available_memory, const byte *buf, ulint len,
142  lsn_t checkpoint_lsn, lsn_t start_lsn,
143  lsn_t *contiguous_lsn, lsn_t *group_scanned_lsn);
144 
145 /** Creates an IORequest object for decrypting redo log with
146 Encryption::decrypt_log() method. If the encryption_info parameter is
147 a null pointer, then encryption information is read from
148 "ib_logfile0". If the encryption_info parameter is not null, then it
149 should contain a copy of the encryption info stored in the header of
150 "ib_logfile0".
151 @param[in,out] encryption_request an IORequest object
152 @param[in] encryption_info a copy of the encryption info in
153 the header of "ib_logfile0", or a null pointer
154 @retval true if the call succeeded
155 @retval false otherwise */
156 bool meb_read_log_encryption(IORequest &encryption_request,
157  byte *encryption_info = nullptr);
158 
159 bool recv_check_log_header_checksum(const byte *buf);
160 /** Check the 4-byte checksum to the trailer checksum field of a log
161 block.
162 @param[in] block pointer to a log block
163 @return whether the checksum matches */
164 bool log_block_checksum_is_ok(const byte *block);
165 #else /* UNIV_HOTBACKUP */
166 
167 /** Applies the hashed log records to the page, if the page lsn is less than the
168 lsn of a log record. This can be called when a buffer page has just been
169 read in, or also for a page already in the buffer pool.
170 @param[in] just_read_in true if the IO handler calls this for a freshly
171  read page
172 @param[in,out] block buffer block */
173 void recv_recover_page_func(bool just_read_in, buf_block_t *block);
174 
175 /** Wrapper for recv_recover_page_func().
176 Applies the hashed log records to the page, if the page lsn is less than the
177 lsn of a log record. This can be called when a buffer page has just been
178 read in, or also for a page already in the buffer pool.
179 @param jri in: TRUE if just read in (the i/o handler calls this for
180 a freshly read page)
181 @param[in,out] block buffer block */
182 #define recv_recover_page(jri, block) recv_recover_page_func(jri, block)
183 
184 /** Frees the recovery system. */
185 void recv_sys_free();
186 
187 /** Reset the state of the recovery system variables. */
188 void recv_sys_var_init();
189 
190 #endif /* UNIV_HOTBACKUP */
191 
192 #ifdef UNIV_HOTBACKUP
193 /** Get the number of bytes used by all the heaps
194 @return number of bytes used */
195 size_t meb_heap_used();
196 #endif /* UNIV_HOTBACKUP */
197 
198 /** Returns true if recovery is currently running.
199 @return recv_recovery_on */
200 UNIV_INLINE
201 bool recv_recovery_is_on() MY_ATTRIBUTE((warn_unused_result));
202 
203 /** Start recovering from a redo log checkpoint.
204 @see recv_recovery_from_checkpoint_finish
205 @param[in,out] log redo log
206 @param[in] flush_lsn FIL_PAGE_FILE_FLUSH_LSN
207  of first system tablespace page
208 @return error code or DB_SUCCESS */
210  MY_ATTRIBUTE((warn_unused_result));
211 
212 /** Complete the recovery from the latest checkpoint.
213 @param[in,out] log redo log
214 @param[in] aborting true if the server has to abort due to an error
215 @return recovered persistent metadata or nullptr if aborting*/
217  MY_ATTRIBUTE((warn_unused_result));
218 
219 /** Creates the recovery system. */
220 void recv_sys_create();
221 
222 /** Release recovery system mutexes. */
223 void recv_sys_close();
224 
225 /** Inits the recovery system for a recovery operation.
226 @param[in] max_mem Available memory in bytes */
227 void recv_sys_init(ulint max_mem);
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
237 pages.
238 @param[in,out] log redo log
239 @param[in] allow_ibuf if true, ibuf operations are allowed during
240  the application; if false, no ibuf operations
241  are allowed, and after the application all
242  file pages are flushed to disk and invalidated
243  in buffer pool: this alternative means that
244  no new log records can be generated during
245  the application; the caller must in this case
246  own the log mutex */
247 void recv_apply_hashed_log_recs(log_t &log, bool allow_ibuf);
248 
249 #if defined(UNIV_DEBUG) || defined(UNIV_HOTBACKUP)
250 /** Return string name of the redo log record type.
251 @param[in] type record log record enum
252 @return string name of record log record */
253 const char *get_mlog_string(mlog_id_t type);
254 #endif /* UNIV_DEBUG || UNIV_HOTBACKUP */
255 
256 /** Block of log record data */
257 struct recv_data_t {
258  /** pointer to the next block or NULL. The log record data
259  is stored physically immediately after this struct, max amount
260  RECV_DATA_BLOCK_SIZE bytes of it */
261 
263 };
264 
265 /** Stored log record struct */
266 struct recv_t {
268 
269  /** Log record type */
271 
272  /** Log record body length in bytes */
273  ulint len;
274 
275  /** Chain of blocks containing the log record body */
277 
278  /** Start lsn of the log segment written by the mtr which generated
279  this log record: NOTE that this is not necessarily the start lsn of
280  this log record */
282 
283  /** End lsn of the log segment written by the mtr which generated
284  this log record: NOTE that this is not necessarily the end LSN of
285  this log record */
287 
288  /** List node, list anchored in recv_addr_t */
290 };
291 
292 /** States of recv_addr_t */
294 
295  /** not yet processed */
297 
298  /** page is being read */
300 
301  /** log records are being applied on the page */
303 
304  /** log records have been applied on the page */
306 
307  /** log records have been discarded because the tablespace
308  does not exist */
310 };
311 
312 /** Hashed page file address struct */
313 struct recv_addr_t {
315 
316  /** recovery state of the page */
318 
319  /** Space ID */
321 
322  /** Page number */
324 
325  /** List of log records for this page */
327 };
328 
329 struct recv_dblwr_t {
330  // Default constructor
332 
333  /** Add a page frame to the doublewrite recovery buffer. */
334  void add(const byte *page) { pages.push_back(page); }
335 
336  /** Find a doublewrite copy of a page.
337  @param[in] space_id tablespace identifier
338  @param[in] page_no page number
339  @return page frame
340  @retval NULL if no page was found */
341  const byte *find_page(space_id_t space_id, page_no_t page_no);
342 
343  using List = std::list<const byte *>;
344 
345  struct Page {
346  /** Default constructor */
347  Page() : m_no(), m_ptr(), m_page() {}
348 
349  /** Constructor
350  @param[in] no Doublewrite page number
351  @param[in] page Page read from no */
352  Page(page_no_t no, const byte *page);
353 
354  /** Free the memory */
355  void close() {
356  ut_free(m_ptr);
357  m_ptr = nullptr;
358  m_page = nullptr;
359  }
360 
361  /** Page number if the doublewrite buffer */
363 
364  /** Unaligned pointer */
365  byte *m_ptr;
366 
367  /** Aligned pointer derived from ptr */
368  byte *m_page;
369  };
370 
371  using Deferred = std::list<Page>;
372 
373  /** Pages that could not be recovered from the doublewrite
374  buffer at the start and need to be recovered once we process an
375  MLOG_FILE_OPEN redo log record */
377 
378  /** Recovered doublewrite buffer page frames */
380 
381  // Disable copying
382  recv_dblwr_t(const recv_dblwr_t &) = delete;
383  recv_dblwr_t &operator=(const recv_dblwr_t &) = delete;
384 };
385 
386 /** Class to parse persistent dynamic metadata redo log, store and
387 merge them and apply them to in-memory table objects finally */
389  using PersistentTables = std::map<
390  table_id_t, PersistentTableMetadata *, std::less<table_id_t>,
392 
393  public:
394  /** Default constructor */
395  MetadataRecover() UNIV_NOTHROW {}
396 
397  /** Destructor */
399 
400  /** Parse a dynamic metadata redo log of a table and store
401  the metadata locally
402  @param[in] id table id
403  @param[in] version table dynamic metadata version
404  @param[in] ptr redo log start
405  @param[in] end end of redo log
406  @retval ptr to next redo log record, NULL if this log record
407  was truncated */
408  byte *parseMetadataLog(table_id_t id, uint64_t version, byte *ptr, byte *end);
409 
410  /** Apply the collected persistent dynamic metadata to in-memory
411  table objects */
412  void apply();
413 
414  /** Store the collected persistent dynamic metadata to
415  mysql.innodb_dynamic_metadata */
416  void store();
417 
418  /** If there is any metadata to be applied
419  @return true if any metadata to be applied, otherwise false */
420  bool empty() const { return (m_tables.empty()); }
421 
422  private:
423  /** Get the dynamic metadata of a specified table,
424  create a new one if not exist
425  @param[in] id table id
426  @return the metadata of the specified table */
428 
429  private:
430  /** Map used to store and merge persistent dynamic metadata */
432 };
433 
434 /** Recovery system data structure */
435 struct recv_sys_t {
436  using Pages =
437  std::unordered_map<page_no_t, recv_addr_t *, std::hash<page_no_t>,
438  std::equal_to<page_no_t>>;
439 
440  /** Every space has its own heap and pages that belong to it. */
441  struct Space {
442  /** Constructor
443  @param[in,out] heap Heap to use for the log records. */
444  explicit Space(mem_heap_t *heap) : m_heap(heap), m_pages() {}
445 
446  /** Default constructor */
447  Space() : m_heap(), m_pages() {}
448 
449  /** Memory heap of log records and file addresses */
451 
452  /** Pages that need to be recovered */
454  };
455 
456  using Missing_Ids = std::set<space_id_t>;
457 
458  using Spaces = std::unordered_map<space_id_t, Space, std::hash<space_id_t>,
459  std::equal_to<space_id_t>>;
460 
461  /* Recovery encryption information */
462  struct Encryption_Key {
463  /** Tablespace ID */
465 
466  /** Encryption key */
467  byte *ptr;
468 
469  /** Encryption IV */
470  byte *iv;
471  };
472 
473  using Encryption_Keys = std::vector<Encryption_Key>;
474 
475 #ifndef UNIV_HOTBACKUP
476 
477  /*!< mutex protecting the fields apply_log_recs, n_addrs, and the
478  state field in each recv_addr struct */
479  ib_mutex_t mutex;
480 
481  /** mutex coordinating flushing between recv_writer_thread and
482  the recovery thread. */
483  ib_mutex_t writer_mutex;
484 
485  /** event to activate page cleaner threads */
487 
488  /** event to signal that the page cleaner has finished the request */
490 
491  /** type of the flush request. BUF_FLUSH_LRU: flush end of LRU,
492  keeping free blocks. BUF_FLUSH_LIST: flush all of blocks. */
494 
495 #else /* !UNIV_HOTBACKUP */
496  bool apply_file_operations;
497 #endif /* !UNIV_HOTBACKUP */
498 
499  /** This is true when log rec application to pages is allowed;
500  this flag tells the i/o-handler if it should do log record
501  application */
503 
504  /** This is true when a log rec application batch is running */
506 
507  /** Possible incomplete last recovered log block */
508  byte *last_block;
509 
510  /** The nonaligned start address of the preceding buffer */
512 
513  /** Buffer for parsing log records */
514  byte *buf;
515 
516  /** Size of the parsing buffer */
517  size_t buf_len;
518 
519  /** Amount of data in buf */
520  ulint len;
521 
522  /** This is the lsn from which we were able to start parsing
523  log records and adding them to the hash table; zero if a suitable
524  start point not found yet */
526 
527  /** Checkpoint lsn that was used during recovery (read from file). */
529 
530  /** Number of data bytes to ignore until we reach checkpoint_lsn. */
532 
533  /** The log data has been scanned up to this lsn */
535 
536  /** The log data has been scanned up to this checkpoint
537  number (lowest 4 bytes) */
539 
540  /** Start offset of non-parsed log records in buf */
542 
543  /** The log records have been parsed up to this lsn */
545 
546  /** The previous value of recovered_lsn - before we parsed the last mtr.
547  It is equal to recovered_lsn before we parsed any mtr. This is used to
548  find moments in which recovered_lsn moves to the next block in which case
549  we should update the last_block_first_rec_group (described below). */
551 
552  /** Tracks what should be the proper value of first_rec_group field in the
553  header of the block to which recovered_lsn belongs. It might be also zero,
554  in which case it means we do not know. */
556 
557  /** Set when finding a corrupt log block or record, or there
558  is a log parsing buffer overflow */
560 
561  /** Set when an inconsistency with the file system contents
562  is detected during log scan or apply */
564 
565  /** If the recovery is from a cloned database. */
567 
568  /** Hash table of pages, indexed by SpaceID. */
570 
571  /** Number of not processed hashed file addresses in the hash table */
572  ulint n_addrs;
573 
574  /** Doublewrite buffer state during recovery. */
576 
577  /** We store and merge all table persistent data here during
578  scanning redo logs */
580 
581  /** Encryption Key information per tablespace ID */
583 
584  /** Tablespace IDs that were ignored during redo log apply. */
586 
587  /** Tablespace IDs that were explicitly deleted. */
589 };
590 
591 /** The recovery system */
592 extern recv_sys_t *recv_sys;
593 
594 /** TRUE when applying redo log records during crash recovery; FALSE
595 otherwise. Note that this is FALSE while a background thread is
596 rolling back incomplete transactions. */
597 extern volatile bool recv_recovery_on;
598 
599 /** If the following is TRUE, the buffer pool file pages must be invalidated
600 after recovery and no ibuf operations are allowed; this becomes TRUE if
601 the log record hash table becomes too full, and log records must be merged
602 to file pages already before the recovery is finished: in this case no
603 ibuf operations are allowed, as they could modify the pages read in the
604 buffer pool before the pages have been recovered to the up-to-date state.
605 
606 TRUE means that recovery is running and no operations on the log files
607 are allowed yet: the variable name is misleading. */
608 extern bool recv_no_ibuf_operations;
609 
610 /** TRUE when recv_init_crash_recovery() has been called. */
611 extern bool recv_needed_recovery;
612 
613 /** TRUE if buf_page_is_corrupted() should check if the log sequence
614 number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by
615 recv_recovery_from_checkpoint_start(). */
616 extern bool recv_lsn_checks_on;
617 
618 /** Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many
619 times! */
620 #define RECV_PARSING_BUF_SIZE (2 * 1024 * 1024)
621 
622 /** Size of block reads when the log groups are scanned forward to do a
623 roll-forward */
624 #define RECV_SCAN_SIZE (4 * UNIV_PAGE_SIZE)
625 
626 /** This many frames must be left free in the buffer pool when we scan
627 the log and store the scanned log records in the buffer pool: we will
628 use these free frames to read in pages when we start applying the
629 log records to the database. */
630 extern ulint recv_n_pool_free_frames;
631 
632 /** A list of tablespaces for which (un)encryption process was not
633 completed before crash. */
634 extern std::list<space_id_t> recv_encr_ts_list;
635 
636 #include "log0recv.ic"
637 
638 #endif
lsn
static uint64_t lsn
Definition: xcom_base.c:406
RECV_NOT_PROCESSED
@ RECV_NOT_PROCESSED
not yet processed
Definition: log0recv.h:296
recv_dblwr_t::add
void add(const byte *page)
Add a page frame to the doublewrite recovery buffer.
Definition: log0recv.h:334
page_no_t
uint32 page_no_t
Page number.
Definition: api0api.h:57
recv_sys_t::n_addrs
ulint n_addrs
Number of not processed hashed file addresses in the hash table.
Definition: log0recv.h:572
lsn_t
uint64_t lsn_t
Type used for all log sequence number storage and arithmetics.
Definition: log0types.h:59
recv_addr_t::rec_list
List rec_list
List of log records for this page.
Definition: log0recv.h:326
recv_sys_t::scanned_lsn
lsn_t scanned_lsn
The log data has been scanned up to this lsn.
Definition: log0recv.h:534
recv_sys_t::apply_log_recs
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:502
recv_sys_init
void recv_sys_init(ulint max_mem)
Inits the recovery system for a recovery operation.
Definition: log0recv.cc:597
dict0types.h
recv_sys_t::last_block_first_rec_group
uint32_t last_block_first_rec_group
Tracks what should be the proper value of first_rec_group field in the header of the block to which r...
Definition: log0recv.h:555
recv_sys_t::spaces
Spaces * spaces
Hash table of pages, indexed by SpaceID.
Definition: log0recv.h:569
recv_sys_t::metadata_recover
MetadataRecover * metadata_recover
We store and merge all table persistent data here during scanning redo logs.
Definition: log0recv.h:579
recv_sys_create
void recv_sys_create()
Creates the recovery system.
Definition: log0recv.cc:394
UT_LIST_BASE_NODE_T
#define UT_LIST_BASE_NODE_T(TYPE)
Definition: innodb_utility.h:46
recv_dblwr_t::recv_dblwr_t
recv_dblwr_t()
Definition: log0recv.h:331
recv_dblwr_t::find_page
const byte * find_page(space_id_t space_id, page_no_t page_no)
Find a doublewrite copy of a page.
Definition: log0recv.cc:4032
recv_sys_t::writer_mutex
ib_mutex_t writer_mutex
mutex coordinating flushing between recv_writer_thread and the recovery thread.
Definition: log0recv.h:483
recv_t
Stored log record struct.
Definition: log0recv.h:266
MetadataRecover::m_tables
PersistentTables m_tables
Map used to store and merge persistent dynamic metadata.
Definition: log0recv.h:431
recv_addr_t::page_no
page_no_t page_no
Page number.
Definition: log0recv.h:323
recv_t::start_lsn
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:281
version
const string version("\"Version\"")
UT_LIST_NODE_T
#define UT_LIST_NODE_T(TYPE)
Definition: innodb_utility.h:40
recv_addr_t::space
space_id_t space
Space ID.
Definition: log0recv.h:320
recv_sys_t::deleted
Missing_Ids deleted
Tablespace IDs that were explicitly deleted.
Definition: log0recv.h:588
RECV_PROCESSED
@ RECV_PROCESSED
log records have been applied on the page
Definition: log0recv.h:305
recv_encr_ts_list
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:86
recv_t::data
recv_data_t * data
Chain of blocks containing the log record body.
Definition: log0recv.h:276
recv_sys_t::Space::Space
Space(mem_heap_t *heap)
Constructor.
Definition: log0recv.h:444
os_event
InnoDB condition variable.
Definition: os0event.cc:66
recv_sys_t::mutex
ib_mutex_t mutex
Definition: log0recv.h:479
recv_sys_t::buf
byte * buf
Buffer for parsing log records.
Definition: log0recv.h:514
recv_sys_t::buf_len
size_t buf_len
Size of the parsing buffer.
Definition: log0recv.h:517
recv_sys_t::flush_start
os_event_t flush_start
event to activate page cleaner threads
Definition: log0recv.h:486
MetadataRecover::parseMetadataLog
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:294
IORequest
The IO Context that is passed down to the low level IO code.
Definition: os0file.h:516
recv_sys_t::Encryption_Key::space_id
space_id_t space_id
Tablespace ID.
Definition: log0recv.h:464
dberr_t
dberr_t
Definition: db0err.h:38
recv_t::type
mlog_id_t type
Log record type.
Definition: log0recv.h:270
recv_data_t
Block of log record data.
Definition: log0recv.h:257
recv_sys_t::apply_batch_on
bool apply_batch_on
This is true when a log rec application batch is running.
Definition: log0recv.h:505
buf_block_t
The buffer control block structure.
Definition: buf0buf.h:1318
RECV_DISCARDED
@ RECV_DISCARDED
log records have been discarded because the tablespace does not exist
Definition: log0recv.h:309
recv_sys_t::last_block
byte * last_block
Possible incomplete last recovered log block.
Definition: log0recv.h:508
recv_dblwr_t::Page::m_no
page_no_t m_no
Page number if the doublewrite buffer.
Definition: log0recv.h:362
recv_dblwr_t::Page::m_page
byte * m_page
Aligned pointer derived from ptr.
Definition: log0recv.h:368
recv_sys_t::parse_start_lsn
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:525
recv_sys_t::Missing_Ids
std::set< space_id_t > Missing_Ids
Definition: log0recv.h:456
recv_sys_t::flush_type
buf_flush_t flush_type
type of the flush request.
Definition: log0recv.h:493
recv_dblwr_t::deferred
Deferred deferred
Pages that could not be recovered from the doublewrite buffer at the start and need to be recovered o...
Definition: log0recv.h:376
recv_sys_t
Recovery system data structure.
Definition: log0recv.h:435
mem_block_info_t
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:337
recv_dblwr_t
Definition: log0recv.h:329
MetadataRecover::MetadataRecover
MetadataRecover() 1
Default constructor.
Definition: log0recv.h:395
recv_dblwr_t::Deferred
std::list< Page > Deferred
Definition: log0recv.h:371
recv_sys_t::Encryption_Keys
std::vector< Encryption_Key > Encryption_Keys
mutex protecting the fields apply_log_recs, n_addrs, and the state field in each recv_addr struct
Definition: log0recv.h:478
recv_sys
recv_sys_t * recv_sys
The recovery system.
Definition: log0recv.cc:96
hash0hash.h
log0types.h
recv_t::len
ulint len
Log record body length in bytes.
Definition: log0recv.h:273
recv_recover_page_func
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:2413
recv_data_t::next
recv_data_t * next
pointer to the next block or NULL.
Definition: log0recv.h:262
MetadataRecover::apply
void apply()
Apply the collected persistent dynamic metadata to in-memory table objects.
Definition: log0recv.cc:327
recv_sys_t::Encryption_Key::ptr
byte * ptr
Encryption key.
Definition: log0recv.h:467
os0file.h
recv_sys_t::flush_end
os_event_t flush_end
event to signal that the page cleaner has finished the request
Definition: log0recv.h:489
log_t
Redo log - single data structure with state of the redo log system.
Definition: log0types.h:133
MetadataRecover::~MetadataRecover
~MetadataRecover()
Destructor.
Definition: log0recv.cc:259
buf_flush_t
buf_flush_t
Flags for flush types.
Definition: buf0types.h:65
recv_recovery_from_checkpoint_finish
MetadataRecover * recv_recovery_from_checkpoint_finish(log_t &log, bool aborting)
Complete the recovery from the latest checkpoint.
Definition: log0recv.cc:3938
table_id_t
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:215
page
int page
Definition: ctype-mb.cc:1232
recv_sys_t::Space
Every space has its own heap and pages that belong to it.
Definition: log0recv.h:441
List::push_back
bool push_back(T *a)
Definition: sql_list.h:442
recv_sys_t::missing_ids
Missing_Ids missing_ids
Tablespace IDs that were ignored during redo log apply.
Definition: log0recv.h:585
recv_n_pool_free_frames
ulint recv_n_pool_free_frames
This many frames must be left free in the buffer pool when we scan the log and store the scanned log ...
Definition: log0recv.cc:199
MetadataRecover::empty
bool empty() const
If there is any metadata to be applied.
Definition: log0recv.h:420
recv_dblwr_t::operator=
recv_dblwr_t & operator=(const recv_dblwr_t &)=delete
recv_dblwr_t::Page::close
void close()
Free the memory.
Definition: log0recv.h:355
log_block_checksum_is_ok
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:706
recv_addr_state
recv_addr_state
States of recv_addr_t.
Definition: log0recv.h:293
recv_sys_t::found_corrupt_fs
bool found_corrupt_fs
Set when an inconsistency with the file system contents is detected during log scan or apply.
Definition: log0recv.h:563
recv_check_log_header_checksum
static bool recv_check_log_header_checksum(const byte *buf)
Check the consistency of a log header block.
Definition: log0recv.cc:691
recv_sys_t::Space::Space
Space()
Default constructor.
Definition: log0recv.h:447
PersistentTableMetadata
Persistent dynamic metadata for a table.
Definition: dict0mem.h:2229
recv_sys_t::Encryption_Key
Definition: log0recv.h:462
MetadataRecover::getMetadata
PersistentTableMetadata * getMetadata(table_id_t id)
Get the dynamic metadata of a specified table, create a new one if not exist.
Definition: log0recv.cc:269
recv_dblwr_t::Page
Definition: log0recv.h:345
MetadataRecover::store
void store()
Store the collected persistent dynamic metadata to mysql.innodb_dynamic_metadata.
Definition: log0recv.cc:761
ut0new.h
recv_is_making_a_backup
bool recv_is_making_a_backup
true When the redo log is being backed up
Definition: log0recv.cc:173
rules_table_service::end
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:188
RECV_BEING_READ
@ RECV_BEING_READ
page is being read
Definition: log0recv.h:299
recv_sys_t::checkpoint_lsn
lsn_t checkpoint_lsn
Checkpoint lsn that was used during recovery (read from file).
Definition: log0recv.h:528
recv_sys_free
void recv_sys_free()
Frees the recovery system.
Definition: log0recv.cc:889
recv_needed_recovery
bool recv_needed_recovery
TRUE when recv_init_crash_recovery() has been called.
Definition: log0recv.cc:154
MetadataRecover
Class to parse persistent dynamic metadata redo log, store and merge them and apply them to in-memory...
Definition: log0recv.h:388
recv_sys_t::Pages
std::unordered_map< page_no_t, recv_addr_t *, std::hash< page_no_t >, std::equal_to< page_no_t > > Pages
Definition: log0recv.h:438
buf0types.h
recv_t::Node
UT_LIST_NODE_T(recv_t) Node
Definition: log0recv.h:267
name
const string name("\"Name\"")
recv_addr_t
Hashed page file address struct.
Definition: log0recv.h:313
recv_recovery_is_on
UNIV_INLINE bool recv_recovery_is_on()
Returns true if recovery is currently running.
recv_sys_t::previous_recovered_lsn
lsn_t previous_recovered_lsn
The previous value of recovered_lsn - before we parsed the last mtr.
Definition: log0recv.h:550
recv_sys_var_init
void recv_sys_var_init()
Reset the state of the recovery system variables.
Definition: log0recv.cc:517
recv_sys_t::len
ulint len
Amount of data in buf.
Definition: log0recv.h:520
recv_dblwr_t::pages
List pages
Recovered doublewrite buffer page frames.
Definition: log0recv.h:379
MetadataRecover::PersistentTables
std::map< table_id_t, PersistentTableMetadata *, std::less< table_id_t >, ut_allocator< std::pair< const table_id_t, PersistentTableMetadata * > >> PersistentTables
Definition: log0recv.h:391
recv_sys_t::dblwr
recv_dblwr_t dblwr
Doublewrite buffer state during recovery.
Definition: log0recv.h:575
recv_sys_t::Encryption_Key::iv
byte * iv
Encryption IV.
Definition: log0recv.h:470
recv_sys_t::keys
Encryption_Keys * keys
Encryption Key information per tablespace ID.
Definition: log0recv.h:582
recv_calc_lsn_on_data_add
lsn_t recv_calc_lsn_on_data_add(lsn_t lsn, uint64_t len)
Calculates the new value for lsn when more data is added to the log.
Definition: log0recv.cc:239
RECV_BEING_PROCESSED
@ RECV_BEING_PROCESSED
log records are being applied on the page
Definition: log0recv.h:302
get_mlog_string
const char * get_mlog_string(mlog_id_t type)
Return string name of the redo log record type.
Definition: log0recv.cc:4074
HttpMethod::type
int type
Definition: http_common.h:411
recv_recovery_on
volatile bool recv_recovery_on
TRUE when applying redo log records during crash recovery; FALSE otherwise.
Definition: log0recv.cc:101
recv_sys_t::is_cloned_db
bool is_cloned_db
If the recovery is from a cloned database.
Definition: log0recv.h:566
recv_dblwr_t::Page::Page
Page()
Default constructor.
Definition: log0recv.h:347
recv_sys_t::found_corrupt_log
bool found_corrupt_log
Set when finding a corrupt log block or record, or there is a log parsing buffer overflow.
Definition: log0recv.h:559
mlog_id_t
mlog_id_t
Definition: mtr0types.h:59
recv_recovery_from_checkpoint_start
dberr_t recv_recovery_from_checkpoint_start(log_t &log, lsn_t flush_lsn)
Start recovering from a redo log checkpoint.
Definition: log0recv.cc:3669
space_id_t
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
recv_sys_t::last_block_buf_start
byte * last_block_buf_start
The nonaligned start address of the preceding buffer.
Definition: log0recv.h:511
recv_sys_t::Spaces
std::unordered_map< space_id_t, Space, std::hash< space_id_t >, std::equal_to< space_id_t > > Spaces
Definition: log0recv.h:459
recv_t::end_lsn
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:286
recv_t::rec_list
Node rec_list
List node, list anchored in recv_addr_t.
Definition: log0recv.h:289
List
Definition: aggregate_check.h:523
recv_sys_t::Space::m_heap
mem_heap_t * m_heap
Memory heap of log records and file addresses.
Definition: log0recv.h:450
recv_lsn_checks_on
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:159
recv_dblwr_t::Page::m_ptr
byte * m_ptr
Unaligned pointer.
Definition: log0recv.h:365
recv_sys_t::recovered_lsn
lsn_t recovered_lsn
The log records have been parsed up to this lsn.
Definition: log0recv.h:544
recv_addr_t::state
recv_addr_state state
recovery state of the page
Definition: log0recv.h:317
recv_sys_t::Space::m_pages
Pages m_pages
Pages that need to be recovered.
Definition: log0recv.h:453
recv_sys_t::bytes_to_ignore_before_checkpoint
ulint bytes_to_ignore_before_checkpoint
Number of data bytes to ignore until we reach checkpoint_lsn.
Definition: log0recv.h:531
recv_no_ibuf_operations
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:170
recv_sys_close
void recv_sys_close()
Release recovery system mutexes.
Definition: log0recv.cc:485
recv_apply_hashed_log_recs
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:1239
ut_allocator
Allocator class for allocating memory from inside std::* containers.
Definition: ut0new.h:567
recv_sys_t::recovered_offset
ulint recovered_offset
Start offset of non-parsed log records in buf.
Definition: log0recv.h:541
ut_free
#define ut_free(ptr)
Definition: ut0new.h:1095
mtr0types.h
recv_sys_t::scanned_checkpoint_no
ulint scanned_checkpoint_no
The log data has been scanned up to this checkpoint number (lowest 4 bytes)
Definition: log0recv.h:538
ut0byte.h