MySQL 9.0.0
Source Code Documentation
Reduced_double_write Class Reference

Reduced doublewrite implementation. More...

Inheritance diagram for Reduced_double_write:
[legend]

Public Member Functions

 Reduced_double_write (uint16_t id, uint32_t n_pages)
 Constructor. More...
 
 ~Reduced_double_write () override
 Destructor. More...
 
virtual uint16_t write_dblwr_pages (buf_flush_t flush_type) noexcept override
 Process the requests in the flush queue, write the space_id, page_id, LSN to the reduced double write file (.bdblwr), sync the file if required and then write to the data files. More...
 
dberr_t allocate ()
 Allocate a temporary buffer for writing page entries. More...
 
- Public Member Functions inherited from Double_write
 Double_write (uint16_t id, uint32_t n_pages) noexcept
 Constructor. More...
 
virtual ~Double_write () noexcept
 Destructor. More...
 
uint16_t id () const noexcept
 
void write (buf_flush_t flush_type) noexcept
 Process the requests in the flush queue, write the blocks to the double write file, sync the file if required and then write to the data files. More...
 
bool wait_for_pending_batch () noexcept
 Wait for any pending batch to complete. More...
 
bool flush_to_disk (buf_flush_t flush_type) noexcept
 Flush buffered pages to disk, clear the buffers. More...
 
void write_pages (buf_flush_t flush_type) noexcept
 Process the requests in the flush queue, write the blocks to the double write file, sync the file if required and then write to the data files. More...
 
void write_data_pages (buf_flush_t flush_type, uint16_t batch_id) noexcept
 
void force_flush (buf_flush_t flush_type) noexcept
 Force a flush of the page queue. More...
 
void enqueue (buf_flush_t flush_type, buf_page_t *bpage, const file::Block *e_block) noexcept
 Add a page to the flush batch. More...
 
void batch_started () noexcept
 Note that the IO batch has started. More...
 
void batch_completed () noexcept
 Wake up all the threads that were waiting for the batch to complete. More...
 
 Double_write (const Double_write &)=delete
 
 Double_write (const Double_write &&)=delete
 
Double_writeoperator= (Double_write &&)=delete
 
Double_writeoperator= (const Double_write &)=delete
 

Private Member Functions

void clear ()
 Clear the temporary buffer used for writing reduced dblwr page. More...
 
void create_header (uint32_t batch_id, uint32_t checksum, uint16_t data_len, buf_flush_t flush_type)
 Create Reduced dblwr page header. More...
 
uint32_t calculate_checksum (uint16_t data_len)
 Calculate checksum for the Reduced dblwr page. More...
 

Private Attributes

bytem_buf
 Un-aligned temporary buffer. More...
 
bytem_page
 aligned temporary buffer. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Double_write
static Double_writeinstance (buf_flush_t flush_type, uint32_t buf_pool_index, bool is_reduced) noexcept
 
static dberr_t create_batch_segments (uint32_t segments_per_file) noexcept
 Create the batch write segments. More...
 
static dberr_t create_reduced_batch_segments () noexcept
 Create the Reduced batch write segments. More...
 
static dberr_t create_single_segments () noexcept
 Create the single page flush segments. More...
 
static void submit (buf_flush_t flush_type, buf_page_t *bpage, const file::Block *e_block) noexcept
 Get the instance that handles a particular page's IO. More...
 
static dberr_t sync_page_flush (buf_page_t *bpage, file::Block *e_block) noexcept
 Writes a single page to the doublewrite buffer on disk, syncs it, then writes the page to the datafile. More...
 
static Double_writeinstance (buf_flush_t flush_type, const buf_page_t *bpage) noexcept
 
static void write_complete (buf_page_t *bpage, buf_flush_t flush_type) noexcept
 Updates the double write buffer when a write request is completed. More...
 
static bool init_v1 (page_no_t &block1, page_no_t &block2) noexcept
 REad the V1 doublewrite buffer extents boundaries. More...
 
static bool create_v1 (page_no_t &block1, page_no_t &block2) noexcept
 Creates the V1 doublewrite buffer extents. More...
 
static dberr_t write_to_datafile (const buf_page_t *in_bpage, bool sync, const file::Block *e_block) noexcept
 Writes a page that has already been written to the doublewrite buffer to the data file. More...
 
static void force_flush (buf_flush_t flush_type, uint32_t buf_pool_index) noexcept
 Force a flush of the page queue. More...
 
static dberr_t load (dblwr::File &file, recv::Pages *pages) noexcept
 Load the doublewrite buffer pages from an external file. More...
 
static dberr_t load_reduced_batch (dblwr::File &file, recv::Pages *pages) noexcept
 Load the reduced doublewrite buffer page entries from an reduced batch double write buffer file (.bdblwr) More...
 
static dberr_t init_file (dblwr::File &file, uint32_t n_pages, uint32_t phy_size=univ_page_size.physical()) noexcept
 Write zeros to the file if it is "empty". More...
 
static void reset_file (dblwr::File &file, bool truncate) noexcept
 Reset the size in bytes to the configured size. More...
 
static void reduced_reset_file (dblwr::File &file, uint32_t pages_per_file, uint32_t phy_size) noexcept
 Reset the size in bytes to the configured size. More...
 
static void reset_files () noexcept
 Reset the size in bytes to the configured size of all files. More...
 
static dberr_t create_v2 () noexcept
 Create the v2 data structures. More...
 
static dberr_t create_reduced () noexcept
 Create the data structures for reduced doublewrite buffer. More...
 
static bool is_fsync_required () noexcept
 
static void prepare (const buf_page_t *bpage, void **ptr, uint32_t *len) noexcept
 Extract the data and length to write to the doublewrite file. More...
 
static void shutdown () noexcept
 Free the data structures. More...
 
static void toggle (ulong value) noexcept
 Toggle the doublewrite buffer dynamically. More...
 
static void single_write (Segment *segment, const buf_page_t *bpage, file::Block *e_block) noexcept
 Write the data to disk synchronously. More...
 
- Public Attributes inherited from Double_write
unsigned long long m_bytes_written {}
 Number of bytes written to disk by this instance. More...
 
- Static Public Attributes inherited from Double_write
static uint32_t s_n_instances {}
 Number of instances. More...
 
static std::vector< dblwr::Files_files
 Files to use for atomic writes. More...
 
static std::vector< dblwr::Files_r_files
 Reduced batch doublewrite files to use for atomic writes. More...
 
static Instancess_instances {}
 The global instances. More...
 
static Instancess_r_instances {}
 The global Reduced Doublewrite instances. More...
 
- Protected Types inherited from Double_write
using Segments = mpmc_bq< Segment * >
 
using Instances = std::vector< Double_write * >
 
using Batch_segments = mpmc_bq< Batch_segment * >
 
- Static Protected Member Functions inherited from Double_write
static void free_segments (Batch_segments *&segments) noexcept
 Utility function to free batch segments. More...
 
static bool is_reduced_batch_id (uint32_t batch_id)
 
- Protected Attributes inherited from Double_write
uint16_t m_id {}
 Instance ID. More...
 
ib_mutex_t m_mutex
 Protects m_buf_pages. More...
 
os_event_t m_event
 Wait for IO batch to complete. More...
 
std::atomic_bool m_batch_running {false}
 true if the the batch hasn't completed yet. More...
 
Buffer m_buffer
 The copy of the page frame, the page must be in in m_buf_pages. More...
 
Buf_pages m_buf_pages
 Pages that should be written to the data files. More...
 
- Static Protected Attributes inherited from Double_write
static Batch_segmentss_LRU_batch_segments {}
 File segments to use for LRU batched writes. More...
 
static Batch_segmentss_flush_list_batch_segments {}
 File segments to use for flush list batched writes. More...
 
static Segmentss_single_segments {}
 File segments to use for single page writes. More...
 
static Batch_segmentss_r_LRU_batch_segments {}
 File segments to use for LRU batched writes in reduced dblwr mode. More...
 
static Batch_segmentss_r_flush_list_batch_segments {}
 File segments to use for flush list batched writes (reduced mode) More...
 
static std::vector< Batch_segment * > s_segments {}
 For indexing batch segments by ID. More...
 
static uint32_t s_regular_last_batch_id {}
 Last used batch_id for regular batch segments. More...
 

Detailed Description

Reduced doublewrite implementation.

Uses separate .bdblwr files and can coexist with regular doublewrite buffer implementation

Constructor & Destructor Documentation

◆ Reduced_double_write()

Reduced_double_write::Reduced_double_write ( uint16_t  id,
uint32_t  n_pages 
)
inline

Constructor.

Parameters
[in]idInstance ID
[in]n_pagesNumber of pages handled by this instance.

◆ ~Reduced_double_write()

Reduced_double_write::~Reduced_double_write ( )
inlineoverride

Destructor.

Member Function Documentation

◆ allocate()

dberr_t Reduced_double_write::allocate ( )

Allocate a temporary buffer for writing page entries.

Returns
DB_SUCCESS on success, error code on failure.

◆ calculate_checksum()

uint32_t Reduced_double_write::calculate_checksum ( uint16_t  data_len)
inlineprivate

Calculate checksum for the Reduced dblwr page.

Parameters
[in]data_lenamount of data in page
Returns
checksum calcuated

◆ clear()

void Reduced_double_write::clear ( )
inlineprivate

Clear the temporary buffer used for writing reduced dblwr page.

◆ create_header()

void Reduced_double_write::create_header ( uint32_t  batch_id,
uint32_t  checksum,
uint16_t  data_len,
buf_flush_t  flush_type 
)
inlineprivate

Create Reduced dblwr page header.

Parameters
[in]batch_idBatch_id of the Reduced dblwr segment
[in]checksumChecksum of the page
[in]data_lenLength of data in page
[in]flush_typeLRU of FLUSH_LIST type

◆ write_dblwr_pages()

uint16_t Reduced_double_write::write_dblwr_pages ( buf_flush_t  flush_type)
overridevirtualnoexcept

Process the requests in the flush queue, write the space_id, page_id, LSN to the reduced double write file (.bdblwr), sync the file if required and then write to the data files.

Parameters
[in]flush_typeLRU or FLUSH request.

Reimplemented from Double_write.

Member Data Documentation

◆ m_buf

byte* Reduced_double_write::m_buf
private

Un-aligned temporary buffer.

◆ m_page

byte* Reduced_double_write::m_page
private

aligned temporary buffer.

Created from m_buf


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