MySQL 8.0.40
Source Code Documentation
|
Segment for batched writes. More...
Public Member Functions | |
Batch_segment (uint16_t id, dblwr::File &file, page_no_t start, uint32_t n_pages) | |
Constructor. More... | |
Batch_segment (uint16_t id, dblwr::File &file, uint32_t phy_size, page_no_t start, uint32_t n_pages) | |
Constructor. More... | |
~Batch_segment () noexcept override | |
Destructor. More... | |
uint16_t | id () const noexcept |
void | write (const Buffer &buffer) noexcept |
Write a batch to the segment. More... | |
void | write (const byte *buf, uint32_t len) noexcept |
Write a batch to the segment. More... | |
bool | write_complete () noexcept |
Called on page write completion. More... | |
void | reset () noexcept |
Reset the state. More... | |
void | set_batch_size (uint32_t size) noexcept |
Set the batch size. More... | |
uint32_t | batch_size () const noexcept |
void | start (Double_write *dblwr) noexcept |
Note that the batch has started for the double write instance. More... | |
void | completed () noexcept |
Note that the batch has completed. More... | |
Public Member Functions inherited from Segment | |
Segment (dblwr::File &file, page_no_t start, uint32_t n_pages) | |
Constructor. More... | |
Segment (dblwr::File &file, uint32_t phy_size, page_no_t start, uint32_t n_pages) | |
Constructor. More... | |
virtual | ~Segment ()=default |
Destructor. More... | |
void | write (const void *ptr, uint32_t len) noexcept |
Write to the segment. More... | |
void | flush () noexcept |
Flush the segment to disk. More... | |
Segment (Segment &&)=delete | |
Segment (const Segment &)=delete | |
Segment & | operator= (Segment &&)=delete |
Segment & | operator= (const Segment &)=delete |
Public Attributes | |
uint16_t | m_id {} |
Batch segment ID. More... | |
Double_write * | m_dblwr {} |
The instance that is being written to disk. More... | |
byte | m_pad1 [ut::INNODB_CACHE_LINE_SIZE] |
uint32_t | m_batch_size {} |
Size of the batch. More... | |
byte | m_pad2 [ut::INNODB_CACHE_LINE_SIZE] |
std::atomic_int | m_uncompleted {} |
Number of page writes in the batch which are still not completed. More... | |
Public Attributes inherited from Segment | |
dblwr::File & | m_file |
File that owns the segment. More... | |
uint32_t | m_phy_size {} |
Physical page size of each entry/Segment. More... | |
os_offset_t | m_start {} |
Physical offset in the file for the segment. More... | |
os_offset_t | m_end {} |
Physical offset up to which this segment is responsible for. More... | |
Segment for batched writes.
|
inline |
Constructor.
[in] | id | Segment ID. |
[in] | file | File that owns the segment. |
[in] | start | Offset (page number) of segment in the file. |
[in] | n_pages | Number of pages in the segment. |
|
inline |
Constructor.
[in] | id | Segment ID. |
[in] | file | File that owns the segment. |
[in] | phy_size | physical size of each segment entry |
[in] | start | Offset (page number) of segment in the file. |
[in] | n_pages | Number of pages in the segment. |
|
inlineoverridenoexcept |
Destructor.
|
inlinenoexcept |
|
inlinenoexcept |
Note that the batch has completed.
|
inlinenoexcept |
|
inlinenoexcept |
Reset the state.
|
inlinenoexcept |
Set the batch size.
[in] | size | Number of pages to write to disk. |
|
inlinenoexcept |
Note that the batch has started for the double write instance.
[in] | dblwr | Instance for which batch has started. |
|
noexcept |
Write a batch to the segment.
[in] | buffer | Buffer to write. |
|
noexcept |
Write a batch to the segment.
[in] | buf | Buffer to write |
[in] | len | amount of data to write |
|
inlinenoexcept |
Called on page write completion.
uint32_t Batch_segment::m_batch_size {} |
Size of the batch.
Set to number of pages to be written with set_batch_size() before scheduling writes to data pages. Reset to zero with reset() after all IOs are completed. Read only by the thread which has observed the last IO completion, the one which will reset it back to zero and enqueue the segment for future reuse. Accesses to this field are ordered by happens-before relation: set_batch_size() sequenced-before fil_io() happens-before dblwr::write_complete() entry sequenced-before batch_size() sequenced-before reset() sequenced-before enqueue() synchronizes-with dequeue() sequenced-before set_batch_size() ...
Double_write* Batch_segment::m_dblwr {} |
The instance that is being written to disk.
uint16_t Batch_segment::m_id {} |
Batch segment ID.
byte Batch_segment::m_pad1[ut::INNODB_CACHE_LINE_SIZE] |
byte Batch_segment::m_pad2[ut::INNODB_CACHE_LINE_SIZE] |
std::atomic_int Batch_segment::m_uncompleted {} |
Number of page writes in the batch which are still not completed.
Set to equal m_batch_size by set_batch_size(), and decremented when a page write is finished (either by failing/not attempting or in IO completion). It serves a role of a reference counter: when it drops to zero, the segment can be enqueued back to the pool of available segments. Accessing a segment which has m_uncompleted == 0 is safe only from the thread which knows it can not be recycled - for example because it's the thread which has caused the m_uncompleted drop to 0 and will enqueue it, or it's the thread which has just dequeued it, or it is handling shutdown.