MySQL 9.0.0
Source Code Documentation
Btree_multi::Bulk_flusher Class Reference

#include <btr0mtib.h>

Public Member Functions

dberr_t run ()
 Thread main function. More...
 
bool is_work_available ()
 Check if work is available for the bulk flusher thread. More...
 
void start (space_id_t space_id, size_t index, size_t queue_size)
 Start a new thread to do the flush work. More...
 
void add (Page_extent *page_extent, std::function< void()> &fn_wait_begin, std::function< void()> &fn_wait_end)
 Add a page extent to the bulk flush queue. More...
 
dberr_t check_and_notify () const
 Check for flusher error and wake up flusher thread. More...
 
void wait_to_stop ()
 Wait till the bulk flush thread stops. More...
 
size_t get_max_queue_size () const
 Get the maximum allowed queue size. More...
 
 ~Bulk_flusher ()
 Destructor. More...
 
bool is_error () const
 
dberr_t get_error () const
 
void add_to_free_queue (Page_extent *page_extent)
 
Page_extentget_free_extent ()
 

Public Attributes

std::vector< page_no_tm_flushed_page_nos
 Vector of page numbers that are flushed by this Bulk_flusher object. More...
 

Private Member Functions

void do_work (fil_node_t *node, void *iov, size_t iov_size)
 Do the actual work of flushing. More...
 
bool should_i_stop () const
 Check if the bulk flush thread should stop working. More...
 
void wait ()
 When no work is available, put the thread to sleep. More...
 
void info ()
 Print useful information to the server log file while exiting. More...
 
void set_error (dberr_t error_code)
 Set error code. More...
 

Private Attributes

std::vector< Page_extent * > m_queue
 This queue is protected by the m_mutex. More...
 
std::mutex m_mutex
 This mutex protects the m_queue. More...
 
std::condition_variable m_condition
 Condition variable to wait upon. More...
 
std::vector< Page_extent * > m_free_queue
 This queue is protected by the m_free_mutex. More...
 
std::mutex m_free_mutex
 This mutex protects the m_free_queue. More...
 
std::atomic< bool > m_stop {false}
 Flag to indicate if the bulk flusher thread should stop. More...
 
std::atomic< bool > m_is_error {false}
 Set if error is encountered during flush. More...
 
dberr_t m_error = DB_SUCCESS
 Error code, protected by m_mutex. More...
 
std::vector< Page_extent * > m_priv_queue
 Private queue (private to the bulk flush thread) containing the extents to flush. More...
 
std::thread m_flush_thread
 Bulk flusher thread. More...
 
size_t m_n_sleep {}
 Number of times slept. More...
 
std::chrono::microseconds m_wait_time
 Total sleep time in micro seconds. More...
 
size_t m_max_queue_size {4}
 Maximum queue size, defaults to 4. More...
 
size_t m_pages_flushed {}
 Number of pages flushed. More...
 
space_id_t m_space_id {}
 Bulk flusher is specific to a tablespace for now. More...
 
size_t m_id {}
 Flusher ID. More...
 

Static Private Attributes

static constexpr std::chrono::milliseconds s_sleep_duration {100}
 The sleep duration in milliseconds. More...
 

Constructor & Destructor Documentation

◆ ~Bulk_flusher()

Btree_multi::Bulk_flusher::~Bulk_flusher ( )

Destructor.

Member Function Documentation

◆ add()

void Btree_multi::Bulk_flusher::add ( Page_extent page_extent,
std::function< void()> &  fn_wait_begin,
std::function< void()> &  fn_wait_end 
)

Add a page extent to the bulk flush queue.

Parameters
[in,out]page_extentextent to be added to the queue
[in,out]fn_wait_beginbegin callback if wait is needed
[in,out]fn_wait_endend callback if wait is needed

◆ add_to_free_queue()

void Btree_multi::Bulk_flusher::add_to_free_queue ( Page_extent page_extent)

◆ check_and_notify()

dberr_t Btree_multi::Bulk_flusher::check_and_notify ( ) const

Check for flusher error and wake up flusher thread.

Returns
Innodb error code.

◆ do_work()

void Btree_multi::Bulk_flusher::do_work ( fil_node_t node,
void *  iov,
size_t  iov_size 
)
private

Do the actual work of flushing.

Parameters
[in,out]nodespace file node
[in,out]iovvector IO array
[in]iov_sizevector IO array size

◆ get_error()

dberr_t Btree_multi::Bulk_flusher::get_error ( ) const
Returns
error code

◆ get_free_extent()

Page_extent * Btree_multi::Bulk_flusher::get_free_extent ( )

◆ get_max_queue_size()

size_t Btree_multi::Bulk_flusher::get_max_queue_size ( ) const
inline

Get the maximum allowed queue size.

Returns
the maximum allowed queue size.

◆ info()

void Btree_multi::Bulk_flusher::info ( )
private

Print useful information to the server log file while exiting.

◆ is_error()

bool Btree_multi::Bulk_flusher::is_error ( ) const
inline
Returns
true iff error has occurred.

◆ is_work_available()

bool Btree_multi::Bulk_flusher::is_work_available ( )

Check if work is available for the bulk flusher thread.

Returns
true if work is available.

◆ run()

dberr_t Btree_multi::Bulk_flusher::run ( )

Thread main function.

Returns
innodb error code.

◆ set_error()

void Btree_multi::Bulk_flusher::set_error ( dberr_t  error_code)
private

Set error code.

Parameters
[in]error_codeerror code to set. It could be DB_SUCCESS.

◆ should_i_stop()

bool Btree_multi::Bulk_flusher::should_i_stop ( ) const
inlineprivate

Check if the bulk flush thread should stop working.

◆ start()

void Btree_multi::Bulk_flusher::start ( space_id_t  space_id,
size_t  index,
size_t  queue_size 
)

Start a new thread to do the flush work.

Parameters
[in]space_idspace for flushing pages to
[in]indexloader index
[in]queue_sizeflusher queue size

◆ wait()

void Btree_multi::Bulk_flusher::wait ( )
private

When no work is available, put the thread to sleep.

◆ wait_to_stop()

void Btree_multi::Bulk_flusher::wait_to_stop ( )

Wait till the bulk flush thread stops.

Member Data Documentation

◆ m_condition

std::condition_variable Btree_multi::Bulk_flusher::m_condition
mutableprivate

Condition variable to wait upon.

◆ m_error

dberr_t Btree_multi::Bulk_flusher::m_error = DB_SUCCESS
private

Error code, protected by m_mutex.

◆ m_flush_thread

std::thread Btree_multi::Bulk_flusher::m_flush_thread
private

Bulk flusher thread.

◆ m_flushed_page_nos

std::vector<page_no_t> Btree_multi::Bulk_flusher::m_flushed_page_nos

Vector of page numbers that are flushed by this Bulk_flusher object.

◆ m_free_mutex

std::mutex Btree_multi::Bulk_flusher::m_free_mutex
mutableprivate

This mutex protects the m_free_queue.

◆ m_free_queue

std::vector<Page_extent *> Btree_multi::Bulk_flusher::m_free_queue
private

This queue is protected by the m_free_mutex.

It is used to cache the Page_extent objects that have been flushed and ready for re-use.

◆ m_id

size_t Btree_multi::Bulk_flusher::m_id {}
private

Flusher ID.

◆ m_is_error

std::atomic<bool> Btree_multi::Bulk_flusher::m_is_error {false}
private

Set if error is encountered during flush.

◆ m_max_queue_size

size_t Btree_multi::Bulk_flusher::m_max_queue_size {4}
private

Maximum queue size, defaults to 4.

◆ m_mutex

std::mutex Btree_multi::Bulk_flusher::m_mutex
mutableprivate

This mutex protects the m_queue.

◆ m_n_sleep

size_t Btree_multi::Bulk_flusher::m_n_sleep {}
private

Number of times slept.

◆ m_pages_flushed

size_t Btree_multi::Bulk_flusher::m_pages_flushed {}
private

Number of pages flushed.

◆ m_priv_queue

std::vector<Page_extent *> Btree_multi::Bulk_flusher::m_priv_queue
private

Private queue (private to the bulk flush thread) containing the extents to flush.

◆ m_queue

std::vector<Page_extent *> Btree_multi::Bulk_flusher::m_queue
private

This queue is protected by the m_mutex.

◆ m_space_id

space_id_t Btree_multi::Bulk_flusher::m_space_id {}
private

Bulk flusher is specific to a tablespace for now.

◆ m_stop

std::atomic<bool> Btree_multi::Bulk_flusher::m_stop {false}
private

Flag to indicate if the bulk flusher thread should stop.

If true, the bulk flusher thread will stop after emptying the queue. If false, the bulk flusher thread will go to sleep after emptying the queue.

◆ m_wait_time

std::chrono::microseconds Btree_multi::Bulk_flusher::m_wait_time
private

Total sleep time in micro seconds.

◆ s_sleep_duration

constexpr std::chrono::milliseconds Btree_multi::Bulk_flusher::s_sleep_duration {100}
staticconstexprprivate

The sleep duration in milliseconds.


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