![]() |
MySQL 26.7.0
Source Code Documentation
|
Doublewrite implementation. More...
Classes | |
| struct | Buf_pages |
| For collecting pages to write. More... | |
Public Member Functions | |
| 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 issue asynchronous writes to the data files. More... | |
| virtual uint16_t | write_dblwr_pages (buf_flush_t flush_type) noexcept |
| 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 (Double_write &&)=delete | |
| Double_write & | operator= (Double_write &&)=delete |
| Double_write & | operator= (const Double_write &)=delete |
Static Public Member Functions | |
| static Double_write * | instance (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_write * | instance (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, std::function< void(dberr_t err)> pre_io_complete_callback) 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, byte **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 | |
| unsigned long long | m_bytes_written {} |
| Number of bytes written to disk by this instance. More... | |
Static Public Attributes | |
| static uint32_t | s_n_instances {} |
| Number of instances. More... | |
| static std::vector< dblwr::File > | s_files |
| Files to use for atomic writes. More... | |
| static std::vector< dblwr::File > | s_r_files |
| Reduced batch doublewrite files to use for atomic writes. More... | |
| static Instances * | s_instances {} |
| The global instances. More... | |
| static Instances * | s_r_instances {} |
| The global Reduced Doublewrite instances. More... | |
Protected Types | |
| using | Segments = mpmc_bq< Segment * > |
| using | Instances = std::vector< Double_write * > |
| using | Batch_segments = mpmc_bq< Batch_segment * > |
Static Protected Member Functions | |
| 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 | |
| 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 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 | |
| static Batch_segments * | s_LRU_batch_segments {} |
| File segments to use for LRU batched writes. More... | |
| static Batch_segments * | s_flush_list_batch_segments {} |
| File segments to use for flush list batched writes. More... | |
| static Segments * | s_single_segments {} |
| File segments to use for single page writes. More... | |
| static Batch_segments * | s_r_LRU_batch_segments {} |
| File segments to use for LRU batched writes in reduced dblwr mode. More... | |
| static Batch_segments * | s_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... | |
Static Private Member Functions | |
| static dberr_t | start () noexcept |
| Create the singleton instance, start the flush thread. More... | |
| static void | croak (const buf_block_t *block) noexcept |
| Asserts when a corrupt block is found during writing out data to the disk. More... | |
| static void | check_block (const buf_block_t *block) noexcept |
| Check the LSN values on the page with which this block is associated. More... | |
| static void | check_page_lsn (const page_t *page) noexcept |
| Check the LSN values on the page. More... | |
| static byte * | get (mtr_t *mtr) noexcept |
| Calls buf_page_get() on the TRX_SYS_PAGE and returns a pointer to the doublewrite buffer within it. More... | |
Doublewrite implementation.
Assumes it can use DBLWR_PAGES.
|
protected |
|
protected |
|
protected |
|
noexcept |
Constructor.
| [in] | id | Instance ID |
| [in] | n_pages | Number of pages handled by this instance. |
|
virtualnoexcept |
Destructor.
|
delete |
|
delete |
|
inlinenoexcept |
Wake up all the threads that were waiting for the batch to complete.
|
inlinenoexcept |
Note that the IO batch has started.
|
staticprivatenoexcept |
Check the LSN values on the page with which this block is associated.
Also validate the page if the option is set.
| [in] | block | Block to check |
|
staticprivatenoexcept |
Check the LSN values on the page.
| [in] | page | Page to check |
|
staticnoexcept |
Create the batch write segments.
| [in] | segments_per_file | Number of configured segments per file. |
|
staticnoexcept |
Create the data structures for reduced doublewrite buffer.
|
staticnoexcept |
Create the Reduced batch write segments.
These segments are mapped to separate file which has extension .bdblwr
|
staticnoexcept |
Create the single page flush segments.
Creates the V1 doublewrite buffer extents.
The header of the doublewrite buffer is placed on the trx system header page.
| [in,out] | block1 | Starting block number for the first extent. |
| [in,out] | block2 | Starting block number for the second extent. |
|
staticnoexcept |
Create the v2 data structures.
|
staticprivatenoexcept |
Asserts when a corrupt block is found during writing out data to the disk.
| [in] | block | Block that was corrupt |
|
inlinenoexcept |
Add a page to the flush batch.
If the flush batch is full then write the batch to disk.
| [in] | flush_type | Flush type. |
| [in] | bpage | Page to flush to disk. |
| [in] | e_block | Encrypted block frame or nullptr. |
|
inlinenoexcept |
Flush buffered pages to disk, clear the buffers.
| [in] | flush_type | FLUSH LIST or LRU LIST flush. |
|
inlinenoexcept |
Force a flush of the page queue.
| [in] | flush_type | FLUSH LIST or LRU LIST flush. |
|
inlinestaticnoexcept |
Force a flush of the page queue.
| [in] | flush_type | FLUSH LIST or LRU LIST flush. |
| [in] | buf_pool_index | Buffer pool instance for which called. |
|
staticprotectednoexcept |
Utility function to free batch segments.
| [in] | segments | batch segment to free |
Calls buf_page_get() on the TRX_SYS_PAGE and returns a pointer to the doublewrite buffer within it.
| [in,out] | mtr | To manage the page latches |
|
inlinenoexcept |
|
staticnoexcept |
Write zeros to the file if it is "empty".
| [in] | file | File instance. |
| [in] | n_pages | Size in physical pages. |
| [in] | phy_size | Physical page size in DBLWR file (For reduced DBLW file, it is not UNIV_PAGE_SIZE, it is hardcoded to 8K page size) |
REad the V1 doublewrite buffer extents boundaries.
| [in,out] | block1 | Starting block number for the first extent. |
| [in,out] | block2 | Starting block number for the second extent. |
|
inlinestaticnoexcept |
| [in] | flush_type | LRU or Flush list write. |
| [in] | bpage | Page to write to disk. |
|
inlinestaticnoexcept |
| [in] | buf_pool_index | Buffer pool instance number. |
| [in] | flush_type | LRU or Flush list write. |
| [in] | is_reduced | true if reduced mode of dblwr is being used. |
|
inlinestaticnoexcept |
|
staticprotected |
| [in] | batch_id | Batch segment id |
|
staticnoexcept |
Load the doublewrite buffer pages from an external file.
| [in,out] | file | File handle |
| [in,out] | pages | For storing the doublewrite pages read from the file |
|
staticnoexcept |
Load the reduced doublewrite buffer page entries from an reduced batch double write buffer file (.bdblwr)
| [in,out] | file | File handle |
| [in,out] | pages | For storing the doublewrite pages read from the file |
|
delete |
|
delete |
|
staticnoexcept |
Extract the data and length to write to the doublewrite file.
| [in] | bpage | Page to write |
| [out] | ptr | Start of buffer to write |
| [out] | len | Length of the data to write |
|
staticnoexcept |
Reset the size in bytes to the configured size.
| [in,out] | file | File to reset |
| [in] | pages_per_file | Number of pages to be created in doublewrite file |
| [in] | phy_size | physical page size |
|
staticnoexcept |
Reset the size in bytes to the configured size.
| [in,out] | file | File to reset. |
| [in] | truncate | Truncate the file to configured size if true. |
|
inlinestaticnoexcept |
Reset the size in bytes to the configured size of all files.
|
staticnoexcept |
Free the data structures.
|
staticnoexcept |
Write the data to disk synchronously.
| [in] | segment | Segment to write to. |
| [in] | bpage | Page to write. |
| [in] | e_block | Encrypted block. Can be nullptr. |
|
staticprivatenoexcept |
Create the singleton instance, start the flush thread.
|
inlinestaticnoexcept |
Get the instance that handles a particular page's IO.
Submit the write request to the a double write queue that is empty.
| [in] | flush_type | Flush type. |
| [in] | bpage | Page from the buffer pool. |
| [in] | e_block | compressed + encrypted frame contents or nullptr. |
|
staticnoexcept |
Writes a single page to the doublewrite buffer on disk, syncs it, then writes the page to the datafile.
The page will be evicted from the Buffer Pool.
| [in] | bpage | Data page to write to disk. |
| [in] | e_block | Encrypted data block. |
|
inlinestaticnoexcept |
Toggle the doublewrite buffer dynamically.
| [in] | value | Current value |
|
inlinenoexcept |
Wait for any pending batch to complete.
|
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.
|
staticnoexcept |
Updates the double write buffer when a write request is completed.
| [in,out] | bpage | Block that has just been written to disk. |
| [in] | flush_type | Flush type that triggered the write. |
|
noexcept |
|
virtualnoexcept |
Reimplemented in Reduced_double_write.
|
noexcept |
Process the requests in the flush queue, write the blocks to the double write file, sync the file if required and then issue asynchronous writes to the data files.
The pages are not evicted from the Buffer Pool on successful write.
| [in] | flush_type | LRU or FLUSH request. |
|
staticnoexcept |
Writes a page that has already been written to the doublewrite buffer to the data file.
It is the job of the caller to sync the datafile. If the sync is true, the page will be evicted from the LRU.
| [in] | in_bpage | Page to write. |
| [in] | sync | true if it's a synchronous write. |
| [in] | e_block | block containing encrypted data frame. |
| [in] | pre_io_complete_callback | A callback to be called after the IO completes, but before the buf_page_io_complete() is called. |
|
protected |
true if the batch hasn't completed yet.
|
protected |
Pages that should be written to the data files.
|
protected |
The copy of the page frame, the page must be in in m_buf_pages.
| unsigned long long Double_write::m_bytes_written {} |
Number of bytes written to disk by this instance.
It is never reset. It is printed to server log during shutdown.
|
protected |
Wait for IO batch to complete.
|
protected |
Instance ID.
|
protected |
Protects m_buf_pages.
|
static |
Files to use for atomic writes.
|
staticprotected |
File segments to use for flush list batched writes.
|
static |
The global instances.
|
staticprotected |
File segments to use for LRU batched writes.
|
static |
Number of instances.
|
static |
Reduced batch doublewrite files to use for atomic writes.
|
staticprotected |
File segments to use for flush list batched writes (reduced mode)
|
static |
The global Reduced Doublewrite instances.
|
staticprotected |
File segments to use for LRU batched writes in reduced dblwr mode.
|
staticprotected |
Last used batch_id for regular batch segments.
Any id greater than this belongs to reduced double write
|
staticprotected |
For indexing batch segments by ID.
|
staticprotected |
File segments to use for single page writes.