MySQL 8.4.2
Source Code Documentation
binlog_cache_data Class Reference

Caches for non-transactional and transactional data before writing it to the binary log. More...

Inheritance diagram for binlog_cache_data:
[legend]

Classes

struct  cache_state
 
struct  Flags
 

Public Member Functions

 binlog_cache_data (class binlog_cache_mngr &cache_mngr, bool trx_cache_arg, ulong *ptr_binlog_cache_use_arg, ulong *ptr_binlog_cache_disk_use_arg)
 
bool open (my_off_t cache_size, my_off_t max_cache_size)
 
Binlog_cache_storageget_cache ()
 
int finalize (THD *thd, Log_event *end_event)
 This function finalizes the cache preparing for commit or rollback. More...
 
int finalize (THD *thd, Log_event *end_event, XID_STATE *xs)
 The method writes XA END query to XA-prepared transaction's cache and calls the "basic" finalize(). More...
 
int flush (THD *thd, my_off_t *bytes, bool *wrote_xid, bool parallelization_barrier)
 Flush caches to the binary log. More...
 
int write_event (Log_event *event)
 
void set_event_counter (size_t event_counter)
 
size_t get_event_counter () const
 
size_t get_compressed_size () const
 
size_t get_decompressed_size () const
 
mysql::binlog::event::compression::type get_compression_type () const
 
void set_compressed_size (size_t s)
 
void set_decompressed_size (size_t s)
 
void set_compression_type (mysql::binlog::event::compression::type t)
 
virtual ~binlog_cache_data ()
 
bool is_binlog_empty () const
 
bool is_finalized () const
 
Rows_log_eventpending () const
 
void set_pending (Rows_log_event *const pending)
 
void set_incident (std::string_view incident_message="Non-transactional changes were not written to the binlog.")
 
bool has_incident (void) const
 
bool has_xid () const
 
bool is_trx_cache () const
 
my_off_t get_byte_position () const
 
void cache_state_checkpoint (my_off_t pos_to_checkpoint)
 
void cache_state_rollback (my_off_t pos_to_rollback)
 
virtual void reset ()
 Reset the cache to unused state when the transaction is finished. More...
 
bool may_have_sbr_stmts ()
 Returns information about the cache content with respect to the binlog_format of the events. More...
 
bool has_empty_transaction ()
 Check if the binlog cache contains an empty transaction, which has two binlog events "BEGIN" and "COMMIT". More...
 
bool is_empty_or_has_empty_transaction ()
 Check if the binlog cache is empty or contains an empty transaction, which has two binlog events "BEGIN" and "COMMIT". More...
 

Protected Member Functions

void truncate (my_off_t pos)
 
int flush_pending_event (THD *thd)
 Flush pending event to the cache buffer. More...
 
int remove_pending_event ()
 Remove the pending event. More...
 
bool compress (THD *thd)
 Compress the current transaction "in-place", if possible. More...
 

Protected Attributes

std::map< my_off_t, cache_statecache_state_map
 
size_t m_event_counter = 0
 
size_t m_compressed_size = 0
 
size_t m_decompressed_size = 0
 
mysql::binlog::event::compression::type m_compression_type
 
struct binlog_cache_data::Flags flags
 

Private Member Functions

void compute_statistics ()
 This function computes binlog cache and disk usage. More...
 
binlog_cache_dataoperator= (const binlog_cache_data &info)
 
 binlog_cache_data (const binlog_cache_data &info)
 

Private Attributes

class binlog_cache_mngrm_cache_mngr
 
Binlog_cache_storage m_cache
 
Rows_log_eventm_pending
 
ulong * ptr_binlog_cache_use
 
ulong * ptr_binlog_cache_disk_use
 

Detailed Description

Caches for non-transactional and transactional data before writing it to the binary log.

Constructor & Destructor Documentation

◆ binlog_cache_data() [1/2]

binlog_cache_data::binlog_cache_data ( class binlog_cache_mngr cache_mngr,
bool  trx_cache_arg,
ulong *  ptr_binlog_cache_use_arg,
ulong *  ptr_binlog_cache_disk_use_arg 
)
inline

◆ ~binlog_cache_data()

virtual binlog_cache_data::~binlog_cache_data ( )
inlinevirtual

◆ binlog_cache_data() [2/2]

binlog_cache_data::binlog_cache_data ( const binlog_cache_data info)
private

Member Function Documentation

◆ cache_state_checkpoint()

void binlog_cache_data::cache_state_checkpoint ( my_off_t  pos_to_checkpoint)
inline

◆ cache_state_rollback()

void binlog_cache_data::cache_state_rollback ( my_off_t  pos_to_rollback)
inline

◆ compute_statistics()

void binlog_cache_data::compute_statistics ( )
inlineprivate

This function computes binlog cache and disk usage.

◆ flush_pending_event()

int binlog_cache_data::flush_pending_event ( THD thd)
inlineprotected

Flush pending event to the cache buffer.

◆ get_byte_position()

my_off_t binlog_cache_data::get_byte_position ( ) const
inline

◆ get_cache()

Binlog_cache_storage * binlog_cache_data::get_cache ( )
inline

◆ get_compressed_size()

size_t binlog_cache_data::get_compressed_size ( ) const
inline

◆ get_compression_type()

mysql::binlog::event::compression::type binlog_cache_data::get_compression_type ( ) const
inline

◆ get_decompressed_size()

size_t binlog_cache_data::get_decompressed_size ( ) const
inline

◆ get_event_counter()

size_t binlog_cache_data::get_event_counter ( ) const
inline

◆ has_empty_transaction()

bool binlog_cache_data::has_empty_transaction ( )
inline

Check if the binlog cache contains an empty transaction, which has two binlog events "BEGIN" and "COMMIT".

Returns
true The binlog cache contains an empty transaction.
false Otherwise.

◆ has_xid()

bool binlog_cache_data::has_xid ( ) const
inline

◆ is_binlog_empty()

bool binlog_cache_data::is_binlog_empty ( ) const
inline

◆ is_empty_or_has_empty_transaction()

bool binlog_cache_data::is_empty_or_has_empty_transaction ( )
inline

Check if the binlog cache is empty or contains an empty transaction, which has two binlog events "BEGIN" and "COMMIT".

Returns
true The binlog cache is empty or contains an empty transaction.
false Otherwise.

◆ is_finalized()

bool binlog_cache_data::is_finalized ( ) const
inline

◆ is_trx_cache()

bool binlog_cache_data::is_trx_cache ( ) const
inline

◆ may_have_sbr_stmts()

bool binlog_cache_data::may_have_sbr_stmts ( )
inline

Returns information about the cache content with respect to the binlog_format of the events.

This will be used to set a flag on GTID_LOG_EVENT stating that the transaction may have SBR statements or not, but the binlog dump will show this flag as "rbr_only" when it is not set. That's why an empty transaction should return true below, or else an empty transaction would be assumed as "rbr_only" even not having RBR events.

When dumping a binary log content using mysqlbinlog client program, for any transaction assumed as "rbr_only" it will be printed a statement changing the transaction isolation level to READ COMMITTED. It doesn't make sense to have an empty transaction "requiring" this isolation level change.

Returns
true The cache have SBR events or is empty.
false The cache contains a transaction with no SBR events.

◆ open()

bool binlog_cache_data::open ( my_off_t  cache_size,
my_off_t  max_cache_size 
)
inline

◆ operator=()

binlog_cache_data & binlog_cache_data::operator= ( const binlog_cache_data info)
private

◆ pending()

Rows_log_event * binlog_cache_data::pending ( ) const
inline

◆ remove_pending_event()

int binlog_cache_data::remove_pending_event ( )
inlineprotected

Remove the pending event.

◆ reset()

virtual void binlog_cache_data::reset ( )
inlinevirtual

Reset the cache to unused state when the transaction is finished.

It drops all data in the cache and clears the flags of the transaction state.

Reimplemented in binlog_trx_cache_data.

◆ set_compressed_size()

void binlog_cache_data::set_compressed_size ( size_t  s)
inline

◆ set_compression_type()

void binlog_cache_data::set_compression_type ( mysql::binlog::event::compression::type  t)
inline

◆ set_decompressed_size()

void binlog_cache_data::set_decompressed_size ( size_t  s)
inline

◆ set_event_counter()

void binlog_cache_data::set_event_counter ( size_t  event_counter)
inline

◆ set_pending()

void binlog_cache_data::set_pending ( Rows_log_event *const  pending)
inline

◆ truncate()

void binlog_cache_data::truncate ( my_off_t  pos)
inlineprotected

Member Data Documentation

◆ cache_state_map

std::map<my_off_t, cache_state> binlog_cache_data::cache_state_map
protected

◆ flags

struct binlog_cache_data::Flags binlog_cache_data::flags
protected

◆ m_cache

Binlog_cache_storage binlog_cache_data::m_cache
private

◆ m_cache_mngr

class binlog_cache_mngr& binlog_cache_data::m_cache_mngr
private

◆ m_compressed_size

size_t binlog_cache_data::m_compressed_size = 0
protected

◆ m_compression_type

mysql::binlog::event::compression::type binlog_cache_data::m_compression_type
protected

◆ m_decompressed_size

size_t binlog_cache_data::m_decompressed_size = 0
protected

◆ m_event_counter

size_t binlog_cache_data::m_event_counter = 0
protected

◆ m_pending

Rows_log_event* binlog_cache_data::m_pending
private

◆ ptr_binlog_cache_disk_use

ulong* binlog_cache_data::ptr_binlog_cache_disk_use
private

◆ ptr_binlog_cache_use

ulong* binlog_cache_data::ptr_binlog_cache_use
private

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