MySQL 8.0.40
Source Code Documentation
buf0dblwr.cc File Reference

Atomic writes handling. More...

#include <sys/types.h>
#include "buf0buf.h"
#include "buf0checksum.h"
#include "log0chkp.h"
#include "os0enc.h"
#include "os0thread-create.h"
#include "page0zip.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "ut0mpmcbq.h"
#include "ut0mutex.h"
#include "ut0test.h"
#include <iomanip>
#include <iostream>
#include <regex>
#include <vector>

Classes

struct  dblwr::File
 
struct  dblwr::recv::Page
 Page recovered from the doublewrite buffer. More...
 
struct  dblwr::recv::Page_entry
 A record from reduced doublewrite buffer. More...
 
class  dblwr::recv::Pages
 Pages recovered from the doublewrite buffer. More...
 
class  Double_write
 Doublewrite implementation. More...
 
struct  Double_write::Buf_pages
 For collecting pages to write. More...
 
class  Segment
 File segment of a double write file. More...
 
class  Batch_segment
 Segment for batched writes. More...
 
class  Reduced_double_write
 Reduced doublewrite implementation. More...
 
class  Reduced_batch_deserializer
 Reduced doublewrite file deserializer. More...
 

Namespaces

namespace  dblwr
 
namespace  dblwr::recv
 

Functions

bool dblwr::is_odd (uint32_t val)
 
std::ostream & dblwr::operator<< (std::ostream &out, const File &obj) noexcept
 Overload the global output operator to work with dblwr::File type. More...
 
static bool is_buffer_pool_size_ok () noexcept
 
static dberr_t dblwr_file_open (const std::string &dir_name, int id, dblwr::File &file, ulint file_type, ib_file_suffix extension=DWR) noexcept
 Create the file and or open it if it exists. More...
 
static bool is_dblwr_page_corrupted (byte *page, fil_space_t *space, page_no_t page_no, dberr_t *err) noexcept
 Check if the dblwr page is corrupted. More...
 
static bool dblwr::is_encrypted_page (const byte *page) noexcept
 
bool dblwr::has_encrypted_pages () noexcept
 Check if the dblwr files contain encrypted pages. More...
 

Variables

constexpr ulint DBLWR_V1_FSEG = 0
 Doublewrite buffer. More...
 
constexpr ulint DBLWR_V1_REPEAT = 12
 We repeat DBLWR_VER, DBLWR_V1_BLOCK1, DBLWR_V1_BLOCK2 so that if the trx sys header is half-written to disk, we still may be able to recover the information. More...
 
constexpr ulint DBLWR_V1_SPACE_ID_STORED = (24 + FSEG_HEADER_SIZE)
 If this is not yet set to DBLWR_V1_SPACE_ID_STORED_N, we must reset the doublewrite buffer, because starting from 4.1.x the space id of a data page is stored into FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID. More...
 
constexpr ulint DBLWR_V1 = 536853855
 Contents of DBLWR_VER. More...
 
constexpr ulint DBLWR_V1_SPACE_ID_STORED_N = 1783657386
 Contents of DBLWR_V1_SPACE_ID_STORED. More...
 
constexpr uint32_t SYNC_PAGE_FLUSH_SLOTS = 512
 DBLWR file pages reserved per instance for single page flushes. More...
 
std::string dblwr::dir {"."}
 Double write files location. More...
 
ulong dblwr::n_files {1}
 Number of files to use for the double write buffer. More...
 
ulong dblwr::batch_size {}
 Maximum number of pages to write in one batch. More...
 
ulong dblwr::n_pages {64}
 Number of pages per doublewrite thread/segment. More...
 
ulong dblwr::g_mode {Mode::ON}
 DBLWR mode. More...
 
bool dblwr::is_reduced_inited = false
 true if DETECT_ONLY (aka reduced) mode is inited More...
 
static page_no_t dblwr::LEGACY_PAGE1
 Legacy dblwr buffer first segment page number. More...
 
static page_no_t dblwr::LEGACY_PAGE2
 Legacy dblwr buffer second segment page number. More...
 
page_id_t dblwr::Force_crash {UINT32_UNDEFINED, UINT32_UNDEFINED}
 Crash the server after writing this page to the data file. More...
 

Detailed Description

Atomic writes handling.

Function Documentation

◆ dblwr_file_open()

static dberr_t dblwr_file_open ( const std::string &  dir_name,
int  id,
dblwr::File file,
ulint  file_type,
ib_file_suffix  extension = DWR 
)
staticnoexcept

Create the file and or open it if it exists.

Parameters
[in]dir_nameDirectory where to create the file.
[in]idInstance ID.
[out]fileFile handle.
[in]file_typeThe file type.
[in]extension.dblwr/.bdblwr
Returns
DB_SUCCESS if all went well.

◆ is_buffer_pool_size_ok()

static bool is_buffer_pool_size_ok ( )
staticnoexcept

◆ is_dblwr_page_corrupted()

static bool is_dblwr_page_corrupted ( byte page,
fil_space_t space,
page_no_t  page_no,
dberr_t err 
)
staticnoexcept

Check if the dblwr page is corrupted.

Parameters
[in]pagethe dblwr page.
[in]spacetablespace to which the page belongs.
[in]page_nopage_no within the actual tablespace.
[out]errerror code to check if decryption or decompression failed.
Returns
true if dblwr page is corrupted, false otherwise.

Variable Documentation

◆ DBLWR_V1

constexpr ulint DBLWR_V1 = 536853855
constexpr

Contents of DBLWR_VER.

Legacy version, stores the blocks in the system tablespace.

◆ DBLWR_V1_FSEG

constexpr ulint DBLWR_V1_FSEG = 0
constexpr

Doublewrite buffer.

fseg header of the fseg containing the doublewrite buffer

◆ DBLWR_V1_REPEAT

constexpr ulint DBLWR_V1_REPEAT = 12
constexpr

We repeat DBLWR_VER, DBLWR_V1_BLOCK1, DBLWR_V1_BLOCK2 so that if the trx sys header is half-written to disk, we still may be able to recover the information.

◆ DBLWR_V1_SPACE_ID_STORED

constexpr ulint DBLWR_V1_SPACE_ID_STORED = (24 + FSEG_HEADER_SIZE)
constexpr

If this is not yet set to DBLWR_V1_SPACE_ID_STORED_N, we must reset the doublewrite buffer, because starting from 4.1.x the space id of a data page is stored into FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID.

◆ DBLWR_V1_SPACE_ID_STORED_N

constexpr ulint DBLWR_V1_SPACE_ID_STORED_N = 1783657386
constexpr

Contents of DBLWR_V1_SPACE_ID_STORED.

◆ SYNC_PAGE_FLUSH_SLOTS

constexpr uint32_t SYNC_PAGE_FLUSH_SLOTS = 512
constexpr

DBLWR file pages reserved per instance for single page flushes.