54#include <unordered_map>
55#include <unordered_set>
75 return ut::make_unique<ib::redo::Redo_applier>(
110extern std::list<std::pair<space_id_t, lsn_t>> index_load_list;
125void meb_scan_log_seg(
byte *
buf,
size_t buf_len,
lsn_t *scanned_lsn,
126 uint32_t *scanned_checkpoint_no, uint32_t *block_no,
127 size_t *n_bytes_scanned,
bool *has_encrypted_log);
151void meb_apply_log_recs(
void);
157void meb_apply_log_recs_via_callback(
159 void (*wait_till_done_function)());
183[[nodiscard]]
bool meb_scan_log_recs(
const byte *
buf,
size_t len,
225size_t meb_heap_used();
258#ifndef UNIV_HOTBACKUP
289#if defined(UNIV_DEBUG) || defined(UNIV_HOTBACKUP)
424 std::unordered_map<page_no_t, recv_addr_t *, std::hash<page_no_t>,
425 std::equal_to<page_no_t>>;
445 using Spaces = std::unordered_map<space_id_t, Space, std::hash<space_id_t>,
446 std::equal_to<space_id_t>>;
465#ifndef UNIV_HOTBACKUP
487 bool apply_file_operations;
491 bool found_corrupt_fs;
607#define RECV_SCAN_SIZE (4 * UNIV_PAGE_SIZE)
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:49
uint32_t page_no_t
Page number.
Definition: api0api.h:47
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
Redo recovery configuration.
Definition: buf0dblwr.h:481
Registry of per-thread Redo_applier instances, which can be all freed by calling reset().
Definition: log0recv.h:69
ut::unique_ptr< Storage > m_storage
Definition: log0recv.h:100
Redo_applier_registry()
Definition: log0recv.h:73
Redo_applier_registry(const Redo_applier_registry &)=delete
Redo_applier_registry & operator=(const Redo_applier_registry &)=delete
ib::redo::Redo_applier * operator->()
Return the Redo_applier associated with the calling thread.
Definition: log0recv.h:94
void reset()
Destroy all per-thread appliers owned by this registry.
Definition: log0recv.h:86
This class allows to parse and apply redo records.
Definition: log0redo.h:341
Registry of per-thread values owned by one enclosing object.
Definition: ut0per_thread.h:42
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 library ...
Definition: ut0new.h:2023
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:216
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.
static void recv_reset_buffer()
Moves the parsing buffer data left to the buffer start.
Definition: log0recv.cc:2124
dberr_t recv_parse_and_apply_log_recs(size_t mem_limit)
Parse log records from a buffer and stores them to a hash table.
Definition: log0recv.cc:2081
bool recv_sys_resize_buf()
Resize the recovery parsing buffer up to log_buffer_size.
Definition: log0recv.cc:312
void recv_track_changes_of_recovered_lsn()
Definition: log0recv.cc:1801
dberr_t recv_recovery_begin(lsn_t checkpoint_lsn)
Scans log from a stream and stores new log data to the parsing buffer.
Definition: log0recv.cc:2134
MetadataRecover * recv_recovery_from_checkpoint_finish(bool aborting)
Complete the recovery from the latest checkpoint.
Definition: log0recv.cc:2465
void recv_sys_free()
Frees the recovery system.
Definition: log0recv.cc:667
void recv_sys_init()
Inits the recovery system for a recovery operation.
Definition: log0recv.cc:469
recv_addr_state
States of recv_addr_t.
Definition: log0recv.h:333
@ RECV_BEING_READ
page is being read
Definition: log0recv.h:339
@ RECV_DISCARDED
log records have been discarded because the tablespace does not exist
Definition: log0recv.h:349
@ RECV_BEING_PROCESSED
log records are being applied on the page
Definition: log0recv.h:342
@ RECV_NOT_PROCESSED
not yet processed
Definition: log0recv.h:336
@ RECV_PROCESSED
log records have been applied on the page
Definition: log0recv.h:345
bool log_block_checksum_is_ok(const byte *block)
Check the 4-byte checksum to the trailer checksum field of a log block.
Definition: log0handler.cc:1731
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:201
void recv_sys_close()
Release recovery system mutexes.
Definition: log0recv.cc:380
constexpr uint32_t RECV_PARSING_BUF_SIZE
Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many times!
Definition: log0recv.h:603
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.
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:169
void recv_sys_var_init()
Reset the state of the recovery system variables.
Definition: log0recv.cc:413
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:1367
static void recv_recover_page(bool jri, buf_block_t *block)
Wrapper for recv_recover_page_func().
Definition: log0recv.h:204
dberr_t recv_recovery_from_checkpoint_start(lsn_t flush_lsn)
Recovers all tablespaces from the redo log.
Definition: log0recv.cc:2387
const char * get_mlog_string(mlog_id_t type)
Return string name of the redo log record type.
Definition: log0recv.cc:2516
recv_sys_t * recv_sys
The recovery system.
Definition: log0recv.cc:104
bool recv_needed_recovery
true when recv_init_crash_recovery() has been called.
Definition: log0recv.cc:153
void recv_sys_create()
Creates the recovery system.
Definition: log0recv.cc:298
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:109
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:158
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:1522
Redo log parsing and applying.
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:79
Definition: log0common.h:32
Unique_ptr< T, std::nullptr_t > make_unique(size_t size)
In-place constructs a new unique pointer with no specific allocator and with array type T.
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:48
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2742
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2284
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:1759
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:295
InnoDB condition variable.
Definition: os0event.cc:63
Hashed page file address struct.
Definition: log0recv.h:353
page_no_t page_no
Page number.
Definition: log0recv.h:363
recv_addr_state state
recovery state of the page
Definition: log0recv.h:357
space_id_t space
Space ID.
Definition: log0recv.h:360
List rec_list
List of log records for this page.
Definition: log0recv.h:366
Block of log record data.
Definition: log0recv.h:297
recv_data_t * next
pointer to the next block or NULL.
Definition: log0recv.h:302
Definition: log0recv.h:449
byte * ptr
Encryption key.
Definition: log0recv.h:457
space_id_t space_id
Tablespace ID.
Definition: log0recv.h:451
byte * iv
Encryption IV.
Definition: log0recv.h:460
lsn_t lsn
LSN of REDO log encryption entry.
Definition: log0recv.h:454
Every space has its own heap and pages that belong to it.
Definition: log0recv.h:428
Pages m_pages
Pages that need to be recovered.
Definition: log0recv.h:440
mem_heap_t * m_heap
Memory heap of log records and file addresses.
Definition: log0recv.h:437
Space(mem_heap_t *heap)
Constructor.
Definition: log0recv.h:431
Space()
Default constructor.
Definition: log0recv.h:434
Recovery system data structure.
Definition: log0recv.h:422
std::vector< Encryption_Key > Encryption_Keys
Definition: log0recv.h:463
Missing_Ids deleted
Tablespace IDs that were explicitly deleted.
Definition: log0recv.h:577
ulint len
Amount of data in buf.
Definition: log0recv.h:506
ib::redo::Redo_applier_registry per_thread_applier
Registry of Per-thread Redo_applier instances.
Definition: log0recv.h:582
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:469
bool is_meb_db
Data directory has been recognized as data directory from MEB.
Definition: log0recv.h:547
lsn_t previous_recovered_lsn
The previous value of recovered_lsn - before we parsed the last mtr.
Definition: log0recv.h:532
os_event_t flush_end
event to signal that the page cleaner has finished the request
Definition: log0recv.h:479
dblwr::recv::DBLWR * dblwr
Doublewrite buffer pages, destroyed after recovery completes.
Definition: log0recv.h:564
Spaces * spaces
Hash table of pages, indexed by SpaceID.
Definition: log0recv.h:555
lsn_t recovered_lsn
The log records have been parsed up to this lsn.
Definition: log0recv.h:526
ut::Todo_counter n_pages_to_recover
Number of unique unprocessed page ids in the spaces nested hash table.
Definition: log0recv.h:561
ulint recovered_offset
Start offset of non-parsed log records in buf.
Definition: log0recv.h:523
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:537
std::unordered_map< page_no_t, recv_addr_t *, std::hash< page_no_t >, std::equal_to< page_no_t > > Pages
Definition: log0recv.h:425
std::unordered_map< space_id_t, Space, std::hash< space_id_t >, std::equal_to< space_id_t > > Spaces
Definition: log0recv.h:446
ib_mutex_t writer_mutex
mutex coordinating flushing between recv_writer_thread and the recovery thread.
Definition: log0recv.h:473
bool is_cloned_db
Data directory has been recognized as cloned data directory.
Definition: log0recv.h:544
os_event_t flush_start
event to activate page cleaner threads
Definition: log0recv.h:476
Missing_Ids missing_ids
Tablespace IDs that were ignored during redo log apply.
Definition: log0recv.h:574
std::unordered_set< space_id_t > Missing_Ids
Definition: log0recv.h:443
lsn_t checkpoint_lsn
Checkpoint lsn that was used during recovery (read from file).
Definition: log0recv.h:514
uint32_t scanned_epoch_no
The log data has been scanned up to this epoch_no.
Definition: log0recv.h:520
size_t buf_len
Size of the parsing buffer.
Definition: log0recv.h:503
buf_flush_t flush_type
type of the flush request.
Definition: log0recv.h:483
Encryption_Keys * keys
Encryption Key information per tablespace ID.
Definition: log0recv.h:571
bool dblwr_state
Doublewrite buffer state before MEB recovery starts.
Definition: log0recv.h:552
bool found_corrupt_log
Set when finding a corrupt log block or record, or there is a log parsing buffer overflow.
Definition: log0recv.h:541
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:511
lsn_t scanned_lsn
The log data has been scanned up to this lsn.
Definition: log0recv.h:517
byte * buf
Buffer for parsing log records.
Definition: log0recv.h:500
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:497
MetadataRecover * metadata_recover
We store and merge all table persistent data here during scanning redo logs.
Definition: log0recv.h:568
Stored log record struct.
Definition: log0recv.h:306
recv_data_t * data
Chain of blocks containing the log record body.
Definition: log0recv.h:316
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:321
UT_LIST_NODE_T(recv_t) Node
Definition: log0recv.h:307
ulint len
Log record body length in bytes.
Definition: log0recv.h:313
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:326
Node rec_list
List node, list anchored in recv_addr_t.
Definition: log0recv.h:329
mlog_id_t type
Log record type.
Definition: log0recv.h:310
typedef UT_LIST_BASE_NODE_T(rw_lock_t, list) rw_lock_list_t
#define UNIV_NOTHROW
Definition: univ.i:459
unsigned long int ulint
Definition: univ.i:403
Utilities for byte operations.
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:97
#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...
#define UT_NEW_THIS_FILE_PSI_KEY
Definition: ut0new.h:408
static uint64_t lsn
Definition: xcom_base.cc:446