MySQL 26.7.0
Source Code Documentation
mysql::csa::Event_set_fetchable_relay_log Class Reference

Implementation of Event_set_fetchable that fetches events from the relay log. More...

#include <event_set_fetchable_relay_log.h>

Inheritance diagram for mysql::csa::Event_set_fetchable_relay_log:
[legend]

Public Types

using Log_event_ptr = std::shared_ptr< Log_event >
 Shared pointer to a Log_event. More...
 
using Return_status = mysql::utils::Return_status
 Type alias for return status. More...
 
using Stream_type = ::binlog::Decompressing_event_object_istream
 Type alias for the decompressing event stream. More...
 
using Stream_ptr = std::unique_ptr< Stream_type >
 Unique pointer to the decompressing stream. More...
 
- Public Types inherited from mysql::csa::Event_set_fetchable
using Fde_type = Format_description_log_event
 
using Fde_ptr = Fde_type *
 
using Log_event_ptr = std::shared_ptr< Log_event >
 

Public Member Functions

 Event_set_fetchable_relay_log (std::string filename, std::size_t start_file_pos, std::size_t end_file_pos, Relay_log_deleter_handle deleter, bool checksum_validation, bool is_trx, Log_event_ptr fde, bool streaming_open=false)
 Constructs an Event_set_fetchable_relay_log with relay log coordinates. More...
 
bool wait_next () override
 Fetches the next event from the initialized internal stream. More...
 
std::optional< Managed_eventfetch_next () override
 Fetches the next event if possible. More...
 
const std::string & get_error_str () const override
 Retrieves the error message if any error occurred. More...
 
bool is_done () const override
 Checks if the fetchable stream has finished without error. More...
 
bool is_error () const override
 Checks if an error occurred in the fetchable stream. More...
 
bool is_trx () const override
 Checks if this event set represents a transaction. More...
 
void reset (bool reset_events) override
 Resets the state to allow fetching again, clearing error state. More...
 
void set_success () override
 Callback notifying that task was executed successfully. More...
 
virtual ~Event_set_fetchable_relay_log () override
 Destructor. More...
 
std::string to_string () const
 Returns a string representation of this batch's information. More...
 
Fde_ptr get_fde () override
 Obtains non-owning pointer to current transaction FDE. More...
 
void append_event_end (std::size_t end_file_pos, bool seal_after=false)
 Appends one published event boundary for stream-open batch. More...
 
void seal_stream ()
 Seals stream-open batch. No more events will be appended. More...
 
void set_stream_truncated ()
 Marks stream-open batch as truncated and wakes blocked readers. More...
 
- Public Member Functions inherited from mysql::csa::Event_set_fetchable
virtual ~Event_set_fetchable ()=default
 Sets the end of the stream if needed. More...
 

Private Member Functions

bool decompressing () const
 Checks if currently decompressing the internal stream (TPLE). More...
 
std::optional< Managed_eventfetch_from_stream ()
 Fetches the next event from the stream. More...
 
bool wait_for_event_availability ()
 Waits until stream has at least one more event available. More...
 
void safe_close_reader ()
 Safely closes the reader if it is open. More...
 
void safe_open_reader ()
 Safely opens the reader (closes if already open and reopens). More...
 
void start_reading ()
 Starts reading from the file by opening it and creating the input stream. More...
 

Private Attributes

bool m_is_initialized = false
 Flag indicating if the reader is open. More...
 
bool m_is_done = false
 Flag indicating if processing is done (finished or error). More...
 
std::string m_file_name {""}
 Name of the relay log file to read from. More...
 
std::size_t m_start_file_pos {0}
 Starting file position for reading. More...
 
std::string m_failure_msg {""}
 Detailed error message if any. More...
 
Return_status m_status
 Status of the object. More...
 
Relay_log_deleter_handle m_delete_file_handle
 Handle to the relay log deleter. More...
 
Stream_ptr m_input_stream
 Decompressing stream object for handling compressed events. More...
 
Relaylog_file_reader m_reader
 Relay log file reader used by the decompressing stream. More...
 
bool m_is_trx {false}
 Flag indicating if this is a transaction. More...
 
bool m_decompressing {false}
 Flag indicating if currently decompressing an internal event (TPLE). More...
 
Log_event_ptr m_fde_base {}
 owning pointer to FDE. More...
 
Fde_ptr m_fde {}
 non-owning pointer to FDE. More...
 
std::mutex m_stream_mutex
 Stream synchronization state. More...
 
std::condition_variable m_stream_cv
 
std::size_t m_published_end_file_pos {0}
 
bool m_stream_open {false}
 
bool m_stream_sealed {true}
 
bool m_stream_truncated {false}
 

Detailed Description

Implementation of Event_set_fetchable that fetches events from the relay log.

If the stream is compressed, the fetching function will perform decompression. Objects of this class are created by the relay log reader and used to fetch consecutive parts of a transaction (relay log events). Typically, a transaction will contain as many event sets as the number of files it spans.

Note
Each object initializes its own reader and sets it to the position of the first event metadata it contains.

Member Typedef Documentation

◆ Log_event_ptr

Shared pointer to a Log_event.

◆ Return_status

◆ Stream_ptr

Unique pointer to the decompressing stream.

◆ Stream_type

Constructor & Destructor Documentation

◆ Event_set_fetchable_relay_log()

mysql::csa::Event_set_fetchable_relay_log::Event_set_fetchable_relay_log ( std::string  filename,
std::size_t  start_file_pos,
std::size_t  end_file_pos,
Relay_log_deleter_handle  deleter,
bool  checksum_validation,
bool  is_trx,
Event_set_fetchable::Log_event_ptr  fde,
bool  streaming_open = false 
)

Constructs an Event_set_fetchable_relay_log with relay log coordinates.

The coordinates must remain valid until the transaction is applied or deemed non-appliable. Uses a relay log deleter handler to ensure the file is not deleted while in use.

Parameters
filenameThe name of the relay log file.
start_file_posThe starting position in the file.
end_file_posThe "end" position for this event set.
deleterHandle to the relay log deleter.
checksum_validationFlag to enable checksum validation.
is_trxFlag indicating if this set represents a transaction.
fdeShared pointer to FDE for this event set.
streaming_openIf true, this set is stream-open and accepts incremental end position updates.

◆ ~Event_set_fetchable_relay_log()

mysql::csa::Event_set_fetchable_relay_log::~Event_set_fetchable_relay_log ( )
overridevirtual

Destructor.

Member Function Documentation

◆ append_event_end()

void mysql::csa::Event_set_fetchable_relay_log::append_event_end ( std::size_t  end_file_pos,
bool  seal_after = false 
)

Appends one published event boundary for stream-open batch.

Parameters
end_file_posEnd position (exclusive) for the next available event.
seal_afterWhen true, the batch is sealed together with publish.

◆ decompressing()

bool mysql::csa::Event_set_fetchable_relay_log::decompressing ( ) const
private

Checks if currently decompressing the internal stream (TPLE).

Returns
true if decompressing, false otherwise.

◆ fetch_from_stream()

std::optional< Managed_event > mysql::csa::Event_set_fetchable_relay_log::fetch_from_stream ( )
private

Fetches the next event from the stream.

Returns
Managed_event or empty optional in case of stream end or error.

◆ fetch_next()

std::optional< Managed_event > mysql::csa::Event_set_fetchable_relay_log::fetch_next ( )
overridevirtual

Fetches the next event if possible.

Callers are expected to wait for availability with wait_next() first when the underlying implementation supports streaming updates.

Returns
Managed_event object or an empty optional if the stream ended (with or without error).

Implements mysql::csa::Event_set_fetchable.

◆ get_error_str()

const std::string & mysql::csa::Event_set_fetchable_relay_log::get_error_str ( ) const
overridevirtual

Retrieves the error message if any error occurred.

Returns
Const reference to the error message string.

Implements mysql::csa::Event_set_fetchable.

◆ get_fde()

Event_set_fetchable::Fde_ptr mysql::csa::Event_set_fetchable_relay_log::get_fde ( )
overridevirtual

Obtains non-owning pointer to current transaction FDE.

Returns
Non-owning pointer to FDE

Implements mysql::csa::Event_set_fetchable.

◆ is_done()

bool mysql::csa::Event_set_fetchable_relay_log::is_done ( ) const
overridevirtual

Checks if the fetchable stream has finished without error.

Returns
true if finished without error, false otherwise.

Implements mysql::csa::Event_set_fetchable.

◆ is_error()

bool mysql::csa::Event_set_fetchable_relay_log::is_error ( ) const
overridevirtual

Checks if an error occurred in the fetchable stream.

Returns
true if an error occurred, false otherwise.

Implements mysql::csa::Event_set_fetchable.

◆ is_trx()

bool mysql::csa::Event_set_fetchable_relay_log::is_trx ( ) const
overridevirtual

Checks if this event set represents a transaction.

Returns
true if it contains a transaction, false otherwise.

Implements mysql::csa::Event_set_fetchable.

◆ reset()

void mysql::csa::Event_set_fetchable_relay_log::reset ( bool  reset_events)
overridevirtual

Resets the state to allow fetching again, clearing error state.

Leaves the reader closed to conserve file descriptors.

Parameters
reset_eventsWhen true events states need to be reset

Implements mysql::csa::Event_set_fetchable.

◆ safe_close_reader()

void mysql::csa::Event_set_fetchable_relay_log::safe_close_reader ( )
private

Safely closes the reader if it is open.

◆ safe_open_reader()

void mysql::csa::Event_set_fetchable_relay_log::safe_open_reader ( )
private

Safely opens the reader (closes if already open and reopens).

◆ seal_stream()

void mysql::csa::Event_set_fetchable_relay_log::seal_stream ( )

Seals stream-open batch. No more events will be appended.

◆ set_stream_truncated()

void mysql::csa::Event_set_fetchable_relay_log::set_stream_truncated ( )

Marks stream-open batch as truncated and wakes blocked readers.

◆ set_success()

void mysql::csa::Event_set_fetchable_relay_log::set_success ( )
overridevirtual

Callback notifying that task was executed successfully.

Reimplemented from mysql::csa::Event_set_fetchable.

◆ start_reading()

void mysql::csa::Event_set_fetchable_relay_log::start_reading ( )
private

Starts reading from the file by opening it and creating the input stream.

◆ to_string()

std::string mysql::csa::Event_set_fetchable_relay_log::to_string ( ) const

Returns a string representation of this batch's information.

Returns
String containing basic information about the batch.

◆ wait_for_event_availability()

bool mysql::csa::Event_set_fetchable_relay_log::wait_for_event_availability ( )
private

Waits until stream has at least one more event available.

Return values
trueAt least one more event can be fetched.
falseStream is sealed/truncated/error and no more fetch is possible.

◆ wait_next()

bool mysql::csa::Event_set_fetchable_relay_log::wait_next ( )
overridevirtual

Fetches the next event from the initialized internal stream.

Returns
Managed_event or empty optional in case of stream end or error. Error can be checked with 'is_error'.

Implements mysql::csa::Event_set_fetchable.

Member Data Documentation

◆ m_decompressing

bool mysql::csa::Event_set_fetchable_relay_log::m_decompressing {false}
private

Flag indicating if currently decompressing an internal event (TPLE).

◆ m_delete_file_handle

Relay_log_deleter_handle mysql::csa::Event_set_fetchable_relay_log::m_delete_file_handle
private

Handle to the relay log deleter.

◆ m_failure_msg

std::string mysql::csa::Event_set_fetchable_relay_log::m_failure_msg {""}
private

Detailed error message if any.

◆ m_fde

Fde_ptr mysql::csa::Event_set_fetchable_relay_log::m_fde {}
private

non-owning pointer to FDE.

◆ m_fde_base

Log_event_ptr mysql::csa::Event_set_fetchable_relay_log::m_fde_base {}
private

owning pointer to FDE.

◆ m_file_name

std::string mysql::csa::Event_set_fetchable_relay_log::m_file_name {""}
private

Name of the relay log file to read from.

◆ m_input_stream

Stream_ptr mysql::csa::Event_set_fetchable_relay_log::m_input_stream
private

Decompressing stream object for handling compressed events.

◆ m_is_done

bool mysql::csa::Event_set_fetchable_relay_log::m_is_done = false
private

Flag indicating if processing is done (finished or error).

◆ m_is_initialized

bool mysql::csa::Event_set_fetchable_relay_log::m_is_initialized = false
private

Flag indicating if the reader is open.

◆ m_is_trx

bool mysql::csa::Event_set_fetchable_relay_log::m_is_trx {false}
private

Flag indicating if this is a transaction.

◆ m_published_end_file_pos

std::size_t mysql::csa::Event_set_fetchable_relay_log::m_published_end_file_pos {0}
private

◆ m_reader

Relaylog_file_reader mysql::csa::Event_set_fetchable_relay_log::m_reader
private

Relay log file reader used by the decompressing stream.

◆ m_start_file_pos

std::size_t mysql::csa::Event_set_fetchable_relay_log::m_start_file_pos {0}
private

Starting file position for reading.

◆ m_status

Return_status mysql::csa::Event_set_fetchable_relay_log::m_status
private

Status of the object.

◆ m_stream_cv

std::condition_variable mysql::csa::Event_set_fetchable_relay_log::m_stream_cv
private

◆ m_stream_mutex

std::mutex mysql::csa::Event_set_fetchable_relay_log::m_stream_mutex
mutableprivate

Stream synchronization state.

◆ m_stream_open

bool mysql::csa::Event_set_fetchable_relay_log::m_stream_open {false}
private

◆ m_stream_sealed

bool mysql::csa::Event_set_fetchable_relay_log::m_stream_sealed {true}
private

◆ m_stream_truncated

bool mysql::csa::Event_set_fetchable_relay_log::m_stream_truncated {false}
private

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