MySQL 8.3.0
Source Code Documentation
meb::Block Class Reference

Encapsulates a log block of size QUEUE_BLOCK_SIZE, enqueued by the producer, dequeued by the consumer and written into the redo log archive file. More...

Public Member Functions

 Block ()
 Constructor initializes the byte array to all 0's and sets that the log block is not the last log block enqueued (is_final_block = false). More...
 
 ~Block ()
 Destructor initializes the byte array to all 0's and sets that the log block is not the last log block enqueued (is_final_block = false). More...
 
Blockoperator= (const Block &)=default
 
void reset ()
 Resets the data in the log block, initializing the byte array to all 0's and sets that the block is not the last log block enqueued (is_final_block = false) More...
 
const byteget_queue_block () const
 Get the byte array of size QUEUE_BLOCK_SIZE associated with this object. More...
 
bool put_log_block (const byte block[], const size_t pos)
 Copy a log block from the given position inside the input byte array. More...
 
bool get_is_final_block () const
 Return the is_final_block flag. More...
 
void set_is_final_block (const bool is_final_block)
 Set the is_final_block flag. More...
 
bool full () const
 Return if the log block is full. More...
 

Public Attributes

bool m_is_flush_block {false}
 Whether this block is a flush block. More...
 

Private Attributes

byte m_block [QUEUE_BLOCK_SIZE]
 The bytes in the log block object. More...
 
size_t m_offset {0}
 Offset inside the byte array of the log block object at which the next redo log block should be written. More...
 
bool m_is_final_block {false}
 Flag indicating if this is the last block enqueued by the producer. More...
 

Detailed Description

Encapsulates a log block of size QUEUE_BLOCK_SIZE, enqueued by the producer, dequeued by the consumer and written into the redo log archive file.

Constructor & Destructor Documentation

◆ Block()

meb::Block::Block ( )
inline

Constructor initializes the byte array to all 0's and sets that the log block is not the last log block enqueued (is_final_block = false).

◆ ~Block()

meb::Block::~Block ( )
inline

Destructor initializes the byte array to all 0's and sets that the log block is not the last log block enqueued (is_final_block = false).

Member Function Documentation

◆ full()

bool meb::Block::full ( ) const
inline

Return if the log block is full.

Condition is (m_offset == QUEUE_BLOCK_SIZE). Since we increment m_offset by OS_FILE_LOG_BLOCK_SIZE only, the equivalent condition is (m_offset > QUEUE_BLOCK_SIZE - OS_FILE_LOG_BLOCK_SIZE). The latter one convinces the fortify tool, that we will never overrun the buffer, while the first one is insufficient for the tool.

Return values
trueif the log block has QUEUE_BLOCK_SIZE bytes.
falseotherwise.

◆ get_is_final_block()

bool meb::Block::get_is_final_block ( ) const
inline

Return the is_final_block flag.

Return values
trueif the is_final_block flag is true. false if the is_final_block flag is false.

◆ get_queue_block()

const byte * meb::Block::get_queue_block ( ) const
inline

Get the byte array of size QUEUE_BLOCK_SIZE associated with this object.

Return values
byte[]The byte array of size QUEUE_BLOCK_SIZE in this object.

◆ operator=()

Block & meb::Block::operator= ( const Block )
default

◆ put_log_block()

bool meb::Block::put_log_block ( const byte  block[],
const size_t  pos 
)
inline

Copy a log block from the given position inside the input byte array.

Note that a complete log block is of size OS_FILE_LOG_BLOCK_SIZE. A log block could also be of size less than OS_FILE_LOG_BLOCK_SIZE, in which case it is overwritten in the next iteration of log writing by InnoDB.

Parameters
[in]blockThe byte array containing the log block to be stored in this log block object.
[in]posThe position inside the byte array from which a log block should be copied.
Return values
trueif a complete redo log block (multiple of OS_FILE_LOG_BLOCK_SIZE) was copied.
falseotherwise.

◆ reset()

void meb::Block::reset ( void  )
inline

Resets the data in the log block, initializing the byte array to all 0's and sets that the block is not the last log block enqueued (is_final_block = false)

◆ set_is_final_block()

void meb::Block::set_is_final_block ( const bool  is_final_block)
inline

Set the is_final_block flag.

Parameters
[in]is_final_blockthe state of the is_final_block flag.

Member Data Documentation

◆ m_block

byte meb::Block::m_block[QUEUE_BLOCK_SIZE]
private

The bytes in the log block object.

◆ m_is_final_block

bool meb::Block::m_is_final_block {false}
private

Flag indicating if this is the last block enqueued by the producer.

◆ m_is_flush_block

bool meb::Block::m_is_flush_block {false}

Whether this block is a flush block.

A flush block is made from the current temporary block redo_log_archive_tmp_block on a flush request. A flush block may be full or not, depending on the current work of the "producer". To avoid races set this variable only under the log writer mutex. The "consumer" shall not update its file write offset when it writes a flush block. The next regular block shall overwrite it.

◆ m_offset

size_t meb::Block::m_offset {0}
private

Offset inside the byte array of the log block object at which the next redo log block should be written.


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