43#define DBLWR_V1_EXTENT_SIZE FSP_EXTENT_SIZE
46#define TRX_SYS_DBLWR_V1 (UNIV_PAGE_SIZE - 200)
87 bool append(
const void *ptr,
size_t n_bytes)
noexcept {
94 memcpy(
m_next, ptr, n_bytes);
144#ifndef UNIV_HOTBACKUP
153extern std::string
dir;
174void close() noexcept;
290 offset +=
sizeof(
m_lsn);
365 static bool is_same(ulong new_value);
428void create(Pages *&pages)
noexcept;
453[[nodiscard]]
const byte *
find(
const Pages *pages,
462[[nodiscard]] std::tuple<bool, lsn_t>
find_entry(
463 const Pages *pages,
const page_id_t &page_id)
noexcept;
472void destroy(Pages *&pages)
noexcept;
528#ifndef UNIV_HOTBACKUP
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:47
uint32_t page_no_t
Page number.
Definition: api0api.h:45
static ulint buf_pool_index(const buf_pool_t *buf_pool)
Calculates the index of a buffer pool to the buf_pool[] array.
constexpr ulint DBLWR_VER
4-byte ver number which shows if we have created the doublewrite buffer.
Definition: buf0dblwr.h:49
constexpr ulint DBLWR_V1_BLOCK1
Page number of the first page in the first sequence of 64 (= FSP_EXTENT_SIZE) consecutive pages in th...
Definition: buf0dblwr.h:53
constexpr ulint DBLWR_V1_BLOCK2
Page number of the first page in the second sequence of 64 consecutive pages in the doublewrite buffe...
Definition: buf0dblwr.h:57
The database buffer pool global types for the directory.
buf_flush_t
Flags for flush types.
Definition: buf0types.h:68
Doublewrite implementation.
Definition: buf0dblwr.cc:430
The IO Context that is passed down to the low level IO code.
Definition: os0file.h:278
Definition: buf0buf.h:1153
Redo recovery configuration.
Definition: buf0dblwr.h:475
const byte * find(const page_id_t &page_id) noexcept
Find a doublewrite copy of a page.
Definition: buf0dblwr.h:508
void recovered() noexcept
Note that recovery is complete.
Definition: buf0dblwr.h:530
DBLWR() noexcept
Constructor.
Definition: buf0dblwr.h:478
DBLWR(const DBLWR &&)=delete
void check_missing_tablespaces() noexcept
Check if some pages from the double write buffer could not be restored because of the missing tablesp...
Definition: buf0dblwr.h:524
Pages * m_pages
Pages read from the double write file.
Definition: buf0dblwr.h:541
void recover(fil_space_t *space=nullptr) noexcept
Restore pages from the double write buffer to the tablespace.
Definition: buf0dblwr.h:500
DBLWR & operator=(const DBLWR &)=delete
~DBLWR() noexcept
Destructor.
Definition: buf0dblwr.h:481
DBLWR(const DBLWR &)=delete
Disably copying.
DBLWR & operator=(DBLWR &&)=delete
std::tuple< bool, lsn_t > find_entry(const page_id_t &page_id) noexcept
Find the LSN of the given page id in the dblwr.
Definition: buf0dblwr.h:517
bool empty() const noexcept
Definition: buf0dblwr.h:484
dberr_t reduced_load() noexcept
Load the doublewrite buffer pages.
Definition: buf0dblwr.h:492
dberr_t load() noexcept
Load the doublewrite buffer pages.
Definition: buf0dblwr.h:488
Pages recovered from the doublewrite buffer.
Definition: buf0dblwr.cc:249
Page identifier.
Definition: buf0types.h:207
size_t physical() const
Retrieve the physical page size (on-disk).
Definition: page0size.h:121
dberr_t
Definition: db0err.h:39
The low-level file system.
constexpr uint32_t FSEG_HEADER_SIZE
Length of the file system header, in bytes.
Definition: fsp0types.h:94
mysql_service_status_t recv(const char *tag, const unsigned char *data, size_t data_length) noexcept
Definition: gr_message_service_example.cc:39
flush_type
Definition: my_sys.h:297
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:63
static void mach_write_to_8(void *b, uint64_t n)
The following function is used to store data in 8 consecutive bytes.
static void mach_write_to_4(byte *b, ulint n)
The following function is used to store data in 4 consecutive bytes.
void recover(Pages *pages, fil_space_t *space) noexcept
Restore pages from the double write buffer to the tablespace.
Definition: buf0dblwr.cc:2618
const byte * find(const Pages *pages, const page_id_t &page_id) noexcept
Find a doublewrite copy of a page.
Definition: buf0dblwr.cc:3564
dberr_t load(Pages *pages) noexcept
Load the doublewrite buffer pages.
Definition: buf0dblwr.cc:3352
void destroy(Pages *&pages) noexcept
Free the recovery dblwr data structures.
Definition: buf0dblwr.cc:3579
std::tuple< bool, lsn_t > find_entry(const Pages *pages, const page_id_t &page_id) noexcept
Find the LSN of the given page id in the dblwr.
Definition: buf0dblwr.cc:3569
void check_missing_tablespaces(const Pages *pages) noexcept
Check if some pages from the double write buffer could not be restored because of the missing tablesp...
Definition: buf0dblwr.cc:3586
dberr_t reduced_load(Pages *pages) noexcept
Load the doublewrite buffer pages.
Definition: buf0dblwr.cc:3464
void create(Pages *&pages) noexcept
Create the recovery dblwr data structures.
Definition: buf0dblwr.cc:3574
bool is_inside(page_no_t page_no) noexcept
Check if the read is of a page inside the legacy dblwr buffer.
Definition: buf0dblwr.cc:2903
dberr_t init() noexcept
Read the boundaries of the legacy dblwr buffer extents.
Definition: buf0dblwr.cc:2887
Definition: buf0dblwr.cc:75
ulong n_files
Number of files to use for the double write buffer.
Definition: buf0dblwr.cc:79
constexpr const uint32_t RB_OFF_UNUSED
Definition: buf0dblwr.h:250
dberr_t reduced_open() noexcept
Check and open the reduced doublewrite files if necessary.
Definition: buf0dblwr.cc:2714
dberr_t open() noexcept
Startup the background thread(s) and create the instance.
Definition: buf0dblwr.cc:2753
constexpr const uint32_t REDUCED_MAX_ENTRIES
Definition: buf0dblwr.h:265
void set()
Toggle the doublewrite buffer.
Definition: buf0dblwr.cc:2879
dberr_t enable_reduced() noexcept
Enable the doublewrite reduced mode by creating the necessary dblwr files and in-memory structures.
Definition: buf0dblwr.cc:2854
void close() noexcept
Shutdown the background thread and destroy the instance.
Definition: buf0dblwr.cc:2877
const uint32_t REDUCED_BATCH_PAGE_SIZE
Definition: buf0dblwr.h:233
void force_flush(buf_flush_t flush_type, uint32_t buf_pool_index) noexcept
Force a write of all pages in the queue.
Definition: buf0dblwr.cc:3135
ulong n_pages
Number of pages per doublewrite thread/segment.
Definition: buf0dblwr.cc:83
constexpr const uint32_t REDUCED_HEADER_SIZE
Definition: buf0dblwr.h:252
ulong g_mode
DBLWR mode.
Definition: buf0dblwr.cc:85
page_id_t Force_crash
Crash the server after writing this page to the data file.
Definition: buf0dblwr.cc:198
constexpr const uint32_t RB_OFF_CHECKSUM
Definition: buf0dblwr.h:247
file::Block * get_encrypted_frame(buf_page_t *bpage, IORequest &type) noexcept
Obtain the encrypted frame and store it in bpage->m_io_frame.
Definition: buf0dblwr.cc:2416
const uint32_t RB_BATCH_TYPE_SIZE
Definition: buf0dblwr.h:242
void force_flush_all() noexcept
Force a write of all pages in all dblwr segments (reduced or regular) This is used only when switchin...
Definition: buf0dblwr.cc:3140
std::string dir
Double write files location.
Definition: buf0dblwr.cc:77
constexpr const uint32_t RB_OFF_BATCH_TYPE
Definition: buf0dblwr.h:249
ulong batch_size
Maximum number of pages to write in one batch.
Definition: buf0dblwr.cc:81
const uint32_t RB_BATCH_ID_SIZE
Definition: buf0dblwr.h:239
bool has_encrypted_pages() noexcept
Check if the dblwr files contain encrypted pages.
Definition: buf0dblwr.cc:3602
constexpr const uint32_t REDUCED_DATA_SIZE
Definition: buf0dblwr.h:262
bool is_enabled()
Check if doublewrite is enabled.
Definition: buf0dblwr.h:390
const char * to_string(ulong mode)
constexpr const uint32_t REDUCED_ENTRY_SIZE
Definition: buf0dblwr.h:259
void reset_files() noexcept
Delete or adjust the dblwr file size if required.
Definition: buf0dblwr.cc:2885
const uint32_t RB_DATA_LEN_SIZE
Definition: buf0dblwr.h:241
dberr_t write(buf_flush_t flush_type, buf_page_t *bpage, bool sync) noexcept
Writes a page to the doublewrite buffer on disk, syncs it, then writes the page to the datafile.
Definition: buf0dblwr.cc:2481
bool is_disabled()
Check if the doublewrite mode is disabled.
Definition: buf0dblwr.h:398
bool is_reduced()
Check if the doublewrite mode is detect-only (aka reduced).
Definition: buf0dblwr.h:394
constexpr const uint32_t RB_OFF_DATA_LEN
Definition: buf0dblwr.h:248
bool is_reduced_inited
true if DETECT_ONLY (aka reduced) mode is inited
Definition: buf0dblwr.cc:87
const uint32_t RB_CHECKSUM_SIZE
Definition: buf0dblwr.h:240
void write_complete(buf_page_t *bpage, buf_flush_t flush_type) noexcept
Updates the double write buffer when a write request is completed.
Definition: buf0dblwr.cc:2614
constexpr const uint32_t RB_OFF_BATCH_ID
Definition: buf0dblwr.h:246
const uint32_t RB_UNUSED_BYTES_SIZE
Definition: buf0dblwr.h:243
mode
Definition: file_handle.h:61
void * aligned_zalloc(std::size_t size, std::size_t alignment) noexcept
Dynamically allocates zero-initialized storage of given size and at the address aligned to the reques...
Definition: ut0new.h:1549
void aligned_free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the aligned_alloc_*() or aligned...
Definition: ut0new.h:1563
page_size_t univ_page_size
required string type
Definition: replication_group_member_actions.proto:34
IO buffer in UNIV_PAGE_SIZE units and aligned on UNIV_PAGE_SIZE.
Definition: buf0dblwr.h:62
Buffer & operator=(const Buffer &)=delete
Buffer(size_t n_pages) noexcept
Constructor.
Definition: buf0dblwr.h:65
size_t capacity() const noexcept
Definition: buf0dblwr.h:113
Buffer(const Buffer &&)=delete
uint32_t m_phy_size
Page size on disk (aka physical page size).
Definition: buf0dblwr.h:122
Buffer(const Buffer &)=delete
~Buffer() noexcept
Destructor.
Definition: buf0dblwr.h:80
bool append(const void *ptr, size_t n_bytes) noexcept
Add the contents of ptr up to n_bytes to the buffer.
Definition: buf0dblwr.h:87
const byte * begin() const noexcept
Definition: buf0dblwr.h:104
byte * m_next
Start of next write to the buffer.
Definition: buf0dblwr.h:130
byte * m_ptr
Write buffer used in writing to the doublewrite buffer, aligned to an address divisible by UNIV_PAGE_...
Definition: buf0dblwr.h:127
void clear() noexcept
Empty the buffer.
Definition: buf0dblwr.h:119
bool empty() const noexcept
Definition: buf0dblwr.h:116
size_t size() const noexcept
Definition: buf0dblwr.h:107
byte * begin() noexcept
Definition: buf0dblwr.h:101
const size_t m_n_bytes
Size of the unaligned (raw) buffer.
Definition: buf0dblwr.h:133
Buffer & operator=(Buffer &&)=delete
Buffer(size_t n_pages, uint32_t phy_size) noexcept
Constructor.
Definition: buf0dblwr.h:71
Definition: buf0dblwr.h:296
static bool is_disabled_low(ulong mode)
Check if the doublewrite mode is disabled.
Definition: buf0dblwr.h:377
static bool is_same(ulong new_value)
Check if the mode transition is equivalent.
Definition: buf0dblwr.cc:108
static bool is_enabled_to_disabled(ulong new_value)
Check if the mode transition is from enabled to disabled.
Definition: buf0dblwr.h:400
static bool is_atomic(ulong mode)
Check if the dblwr mode provides atomic writes.
Definition: buf0dblwr.h:368
static const char * to_string(ulong mode)
Convert the dblwr mode into a string representation.
Definition: buf0dblwr.cc:89
static bool is_disabled_to_enabled(ulong new_value)
Check if the mode transition is from disabled to enabled.
Definition: buf0dblwr.h:404
static bool is_enabled_low(ulong mode)
Check if doublewrite is enabled.
Definition: buf0dblwr.h:372
static bool is_reduced_low(ulong mode)
Check if the doublewrite mode is detect-only (aka reduced).
Definition: buf0dblwr.h:379
mode_t
The operating mode of doublewrite.
Definition: buf0dblwr.h:303
@ DETECT_ONLY
In this mode, dblwr is used only to detect torn writes.
Definition: buf0dblwr.h:313
@ FALSEE
Equal to OFF mode.
Definition: buf0dblwr.h:320
@ TRUEE
Equal to ON, DETECT_AND_RECOVER mode.
Definition: buf0dblwr.h:324
@ DETECT_AND_RECOVER
This mode is synonymous with ON, TRUEE.
Definition: buf0dblwr.h:316
@ ON
Equal to TRUEE and DETECT_AND_RECOVER modes.
Definition: buf0dblwr.h:308
@ OFF
Equal to FALSEE.
Definition: buf0dblwr.h:305
When –innodb-doublewrite=DETECT_ONLY, page contents are not written to the dblwr buffer.
Definition: buf0dblwr.h:271
lsn_t m_lsn
Definition: buf0dblwr.h:274
page_no_t m_page_no
Definition: buf0dblwr.h:273
space_id_t m_space_id
Definition: buf0dblwr.h:272
Reduced_entry(space_id_t space_id, page_no_t page_no, lsn_t lsn)
Definition: buf0dblwr.h:278
Reduced_entry(buf_page_t *bpage)
Definition: buf0dblwr.cc:3634
byte * write(byte *ptr)
Definition: buf0dblwr.h:281
Tablespace or log data space.
Definition: fil0fil.h:238
unsigned long int ulint
Definition: univ.i:406
Utilities for byte operations.
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:93
static uint64_t lsn
Definition: xcom_base.cc:446