MySQL 9.1.0
Source Code Documentation
rpl::Relay_log_sanitizer Class Reference

Class used to recover relay log files. More...

#include <rpl_relay_log_sanitizer.h>

Inheritance diagram for rpl::Relay_log_sanitizer:
[legend]

Public Member Functions

 Relay_log_sanitizer ()
 Ctor. More...
 
 ~Relay_log_sanitizer () override=default
 Dtor. More...
 
void analyze_logs (MYSQL_BIN_LOG &log, bool checksum_validation)
 Given specific log, performs sanitization. More...
 
bool sanitize_log (MYSQL_BIN_LOG &log)
 Sanitize opened log. More...
 
void update_source_position (Master_info *mi)
 Updates source position if a valid source position has been found whilst reading the relay log files. More...
 
- Public Member Functions inherited from binlog::Log_sanitizer
 Log_sanitizer ()
 Ctor. More...
 
virtual ~Log_sanitizer ()=default
 Dtor. More...
 
my_off_t get_valid_pos () const
 Retrieves the position of the last binlog/relay log event that ended a transaction or position after the RLE/FDE/SE that comes from the source. More...
 
std::pair< my_off_t, bool > get_valid_source_pos () const
 Retrieves the last valid source position of an event in read from the binary log / relay log file, which may be: More...
 
std::pair< std::string, bool > get_valid_source_file () const
 Retrieves the updated name of the binlog source file. More...
 
bool is_log_malformed () const
 Retrieves whether or not the log was correctly processed in full. More...
 
std::string const & get_failure_message () const
 Retrieves the textual representation of the encontered failure, if any. More...
 
std::string get_valid_file () const
 
bool is_log_truncation_needed () const
 Checks whether a valid sanitized log file needs truncation of the last, partially written transaction or events that cannot be safely read. More...
 
bool is_fatal_error () const
 Checks whether the fatal error occurred during log sanitization (OOM / decompression error which we cannot handle) More...
 

Protected Member Functions

PSI_memory_keyget_memory_key () const override
 Function used to obtain memory key for derived classes. More...
 
- Protected Member Functions inherited from binlog::Log_sanitizer
template<class Type_reader >
void process_logs (Type_reader &reader)
 This function goes through the opened file and searches for a valid position in a binary log file. More...
 
template<class Type_reader >
void process_logs (Type_reader &reader, const std::list< std::string > &list_of_files, MYSQL_BIN_LOG &log)
 This function goes iterates over the relay log files in the 'list_of_files' container, starting from the most recent one. More...
 
template<class Type_reader >
void process_logs (Type_reader &reader, MYSQL_BIN_LOG &log)
 This function will obtain the list of relay log files using the object of MYSQL_BIN_LOG class and iterate over them to find the last valid position within a relay log file. More...
 
template<class Type_reader >
bool process_one_log (Type_reader &reader, const std::string &filename)
 Reads and validates one log file. More...
 
void process_query_event (Query_log_event const &ev)
 Invoked when a Query_log_event is read from the binary log file reader. More...
 
void process_xid_event (Xid_log_event const &ev)
 Invoked when a Xid_log_event is read from the binary log file reader. More...
 
void process_xa_prepare_event (XA_prepare_log_event const &ev)
 Invoked when a XA_prepare_log_event is read from the binary log file reader. More...
 
void process_start ()
 Invoked when a BEGIN or an ‘XA START’ is found in a Query_log_event. More...
 
void process_commit ()
 Invoked when a COMMIT is found in a Query_log_event. More...
 
void process_rollback ()
 Invoked when a ROLLBACK is found in a Query_log_event. More...
 
void process_atomic_ddl (Query_log_event const &ev)
 Invoked when a DDL is found in a Query_log_event. More...
 
void process_xa_commit (std::string const &query)
 Invoked when an XA COMMIT is found in a Query_log_event. More...
 
void process_xa_rollback (std::string const &query)
 Invoked when an XA ROLLBACK is found in a Query_log_event. More...
 
void add_external_xid (std::string const &query, enum_ha_recover_xa_state state)
 Parses the provided string for an XID and adds it to the externally coordinated transactions map, along side the provided state. More...
 

Additional Inherited Members

- Protected Attributes inherited from binlog::Log_sanitizer
bool m_validation_started {true}
 Indicates whether validation has started. More...
 
my_off_t m_valid_pos {0}
 Position of the last binlog/relay log event that ended a transaction. More...
 
my_off_t m_valid_source_pos {0}
 Position of the last binlog event that ended a transaction (source position which corresponds to m_valid_pos) More...
 
std::string m_valid_source_file {""}
 Currently processed binlog file set in case source rotation event is encountered. More...
 
std::string m_valid_file {""}
 Last log file containing finished transaction. More...
 
bool m_in_transaction {false}
 Whether or not the event being processed is within a transaction. More...
 
bool m_is_malformed {false}
 Whether or not the binary log is malformed/corrupted or error occurred. More...
 
bool m_fatal_error {false}
 Whether or not the binary log has a fatal error. More...
 
std::string m_failure_message {""}
 Textual representation of the encountered failure. More...
 
MEM_ROOT m_mem_root
 Memory pool to use for the XID lists. More...
 
Mem_root_allocator< my_xidm_set_alloc
 Memory pool allocator to use with the normal transaction list. More...
 
Mem_root_allocator< std::pair< const XID, XID_STATE::xa_states > > m_map_alloc
 Memory pool allocator to use with the XA transaction list. More...
 
Xid_commit_list m_internal_xids
 List of normal transactions fully written to the binary log. More...
 
Xa_state_list::list m_external_xids
 List of XA transactions and states that appear in the binary log. More...
 
bool m_is_log_truncation_needed {false}
 Information on whether log needs to be truncated, i.e. More...
 
bool m_has_valid_pos {false}
 Indicator on whether a valid position has been found in the log file. More...
 
bool m_has_valid_source_pos {false}
 Indicator on whether a valid source position has been found in the log file. More...
 
my_off_t m_last_file_size {0}
 Last opened file size. More...
 

Detailed Description

Class used to recover relay log files.

Recovery of the relay log files is:

  • finding the last valid position outside of a transaction boundary (analyze_logs)
  • removing relay logs appearing after the relay log with the last valid position (analyze_logs)
  • truncation of the relay log file containing the last valid position to remove partially written transaction from the log (sanitize log)

Constructor & Destructor Documentation

◆ Relay_log_sanitizer()

rpl::Relay_log_sanitizer::Relay_log_sanitizer ( )
inline

Ctor.

◆ ~Relay_log_sanitizer()

rpl::Relay_log_sanitizer::~Relay_log_sanitizer ( )
overridedefault

Dtor.

Member Function Documentation

◆ analyze_logs()

void rpl::Relay_log_sanitizer::analyze_logs ( MYSQL_BIN_LOG log,
bool  checksum_validation 
)

Given specific log, performs sanitization.

Reads log list obtained from the MYSQL_BIN_LOG object and searches for last, fully written transaction. Removes log files that are created after last finished transaction

Parameters
logHandle to MYSQL_BIN_LOG object, which does not need to be open. We need specific functions from the MYSQL_BIN_LOG, e.g. reading of the index file
checksum_validationTrue if we need to perform relay log file checksum validation

◆ get_memory_key()

PSI_memory_key & rpl::Relay_log_sanitizer::get_memory_key ( ) const
inlineoverrideprotectedvirtual

Function used to obtain memory key for derived classes.

Returns
Reference to a memory key

Implements binlog::Log_sanitizer.

◆ sanitize_log()

bool rpl::Relay_log_sanitizer::sanitize_log ( MYSQL_BIN_LOG log)

Sanitize opened log.

Parameters
logHandle to MYSQL_BIN_LOG object, which we will truncate if needed
Returns
false on no error or when no truncation was done, true otherwise

◆ update_source_position()

void rpl::Relay_log_sanitizer::update_source_position ( Master_info mi)

Updates source position if a valid source position has been found whilst reading the relay log files.

Parameters
miMaster_info for the receiver thread.

The documentation for this class was generated from the following files: