MySQL 8.4.2
Source Code Documentation
|
Mini-transaction handle and buffer. More...
#include <mtr0mtr.h>
Classes | |
class | Command |
struct | Impl |
State variables of the mtr. More... | |
class | Logging |
mtr global logging More... | |
Public Member Functions | |
void | check_nolog_and_mark () |
Check if redo logging is disabled globally and mark the global counter till mtr ends. More... | |
void | check_nolog_and_unmark () |
Check if the mtr has marked the global no log counter and unmark it. More... | |
mtr_t () | |
~mtr_t () | |
void | remove_from_debug_list () const |
Removed the MTR from the s_my_thread_active_mtrs list. More... | |
void | check_is_not_latching () const |
Assure that there are no slots that are latching any resources. More... | |
void | start (bool sync=true) |
Start a mini-transaction. More... | |
bool | is_async () const |
void | set_sync () |
Request a future commit to be synchronous. More... | |
void | commit () |
Commit the mini-transaction. More... | |
ulint | get_savepoint () const |
Return current size of the buffer. More... | |
void | release_s_latch_at_savepoint (ulint savepoint, rw_lock_t *lock) |
Release the (index tree) s-latch stored in an mtr memo after a savepoint. More... | |
void | release_block_at_savepoint (ulint savepoint, buf_block_t *block) |
Release the block in an mtr memo after a savepoint. More... | |
void | sx_latch_at_savepoint (ulint savepoint, buf_block_t *block) |
SX-latch a not yet latched block after a savepoint. More... | |
void | x_latch_at_savepoint (ulint savepoint, buf_block_t *block) |
X-latch a not yet latched block after a savepoint. More... | |
mtr_log_t | get_log_mode () const |
Get the logging mode. More... | |
mtr_log_t | set_log_mode (mtr_log_t mode) |
Change the logging mode. More... | |
uint32_t | read_ulint (const byte *ptr, mlog_id_t type) const |
Read 1 - 4 bytes from a file page buffered in the buffer pool. More... | |
void | s_lock (rw_lock_t *lock, ut::Location location) |
Locks a rw-latch in S mode. More... | |
void | x_lock (rw_lock_t *lock, ut::Location location) |
Locks a rw-latch in X mode. More... | |
void | sx_lock (rw_lock_t *lock, ut::Location location) |
Locks a rw-latch in X mode. More... | |
void | x_lock_space (fil_space_t *space, ut::Location location) |
Acquire a tablespace X-latch. More... | |
void | memo_release (const void *object, ulint type) |
Release an object in the memo stack. More... | |
void | release_page (const void *ptr, mtr_memo_type_t type) |
Release a page latch. More... | |
void | set_modified () |
Note that the mini-transaction might have modified a buffer pool page. More... | |
bool | has_modifications () const |
Checks if this mtr has modified any buffer pool page. More... | |
lsn_t | commit_lsn () const |
Get the LSN of commit(). More... | |
void | enter_ibuf () |
Note that we are inside the change buffer code. More... | |
void | exit_ibuf () |
Note that we have exited from the change buffer code. More... | |
bool | is_inside_ibuf () const |
bool | is_active () const |
Flush_observer * | get_flush_observer () const |
Get flush observer. More... | |
void | set_flush_observer (Flush_observer *observer) |
Set flush observer. More... | |
std::ostream & | print_memos (std::ostream &out) const |
Print the memo objects (mtr_memo_slot_t) of mtr_t to the given output stream. More... | |
bool | memo_contains_flagged (const void *ptr, ulint flags) const |
Check if memo contains the given item. More... | |
buf_block_t * | memo_contains_page_flagged (const byte *ptr, ulint flags) const |
Check if memo contains the given page. More... | |
void | memo_modify_page (const byte *ptr) |
Mark the given latched page as modified. More... | |
void | print () const |
Print info of an mtr handle. More... | |
bool | has_committed () const |
bool | is_committing () const |
bool | conflicts_with (const mtr_t *mtr2) const |
Check if the changes done in this mtr conflicts with changes done in the given mtr. More... | |
const mtr_buf_t * | get_memo () const |
mtr_buf_t * | get_memo () |
size_t | get_expected_log_size () const |
Computes the number of bytes that would be written to the redo log if mtr was committed right now (excluding headers of log blocks). More... | |
void | wait_for_flush () |
void | added_rec () |
Note that a record has been added to the log. More... | |
bool | has_any_log_record () |
Checks if this mtr has generated any redo log records which should be written to the redo log during commit(). More... | |
const mtr_buf_t * | get_log () const |
Get the buffered redo log of this mini-transaction. More... | |
mtr_buf_t * | get_log () |
Get the buffered redo log of this mini-transaction. More... | |
void | memo_push (void *object, mtr_memo_type_t type) |
Push an object to an mtr memo stack. More... | |
Static Public Member Functions | |
static bool | memo_contains (const mtr_buf_t *memo, const void *object, ulint type) |
Check if memo contains the given item. More... | |
static void | check_my_thread_mtrs_are_not_latching () |
Iterate all MTRs created in this thread to assure they are not latching any resources. More... | |
static bool | is_this_thread_inside_mtr () |
This method is useful to detect if the thread is already inside an mtr. More... | |
Public Attributes | |
size_t | m_restart_count {} |
Count the number of times the same mtr object has been committed and restarted. More... | |
Static Public Attributes | |
static bool | s_mode_update [MTR_LOG_MODE_MAX][MTR_LOG_MODE_MAX] |
Matrix to check if a mode update request should be ignored. More... | |
static bool | s_mode_update_valid [MTR_LOG_MODE_MAX][MTR_LOG_MODE_MAX] |
For checking invalid mode update requests. More... | |
static Logging | s_logging |
Instance level logging information for all mtrs. More... | |
Private Attributes | |
Impl | m_impl |
lsn_t | m_commit_lsn |
LSN at commit time. More... | |
bool | m_sync |
true if it is synchronous mini-transaction More... | |
Static Private Attributes | |
static thread_local ut::unordered_set< const mtr_t * > | s_my_thread_active_mtrs |
List of all non-committed MTR instances created in this thread. More... | |
Friends | |
class | Command |
Mini-transaction handle and buffer.
|
inline |
|
inline |
|
inline |
Note that a record has been added to the log.
void mtr_t::check_is_not_latching | ( | ) | const |
Assure that there are no slots that are latching any resources.
Only buffer fixing a page is allowed.
|
inlinestatic |
Iterate all MTRs created in this thread to assure they are not latching any resources.
Violating this could lead to deadlocks under log_free_check().
void mtr_t::check_nolog_and_mark | ( | ) |
Check if redo logging is disabled globally and mark the global counter till mtr ends.
void mtr_t::check_nolog_and_unmark | ( | ) |
Check if the mtr has marked the global no log counter and unmark it.
void mtr_t::commit | ( | ) |
Commit the mini-transaction.
Commit a mini-transaction.
|
inline |
Get the LSN of commit().
0 | if the transaction only modified temporary tablespaces or logging is disabled globally. |
bool mtr_t::conflicts_with | ( | const mtr_t * | mtr2 | ) | const |
Check if the changes done in this mtr conflicts with changes done in the given mtr.
Two mtrs are said to conflict with each other, if they modify the same buffer block.
[in] | mtr2 | the given mtr. |
|
inline |
Note that we are inside the change buffer code.
|
inline |
Note that we have exited from the change buffer code.
|
inline |
Computes the number of bytes that would be written to the redo log if mtr was committed right now (excluding headers of log blocks).
|
inline |
Get flush observer.
|
inline |
Get the buffered redo log of this mini-transaction.
|
inline |
Get the buffered redo log of this mini-transaction.
|
inline |
Get the logging mode.
Gets the logging mode of a mini-transaction.
|
inline |
|
inline |
|
inline |
Return current size of the buffer.
|
inline |
Checks if this mtr has generated any redo log records which should be written to the redo log during commit().
Note: If redo logging is disabled by set_log_mode(MTR_LOG_NONE) or set_log_mode(MTR_LOG_NO_REDO) or globally by s_logging.disable(..), then it will return false, even if set_modified() was called. Note: Redo log records can be generated for things other than page modifications, for example for tablespace rename, or other metadata updates. Note: Redo log records can be generated for modifications of pages which were already marked as dirty in BP.
|
inline |
|
inline |
Checks if this mtr has modified any buffer pool page.
It errs on the safe side: may return true even if it didn't modify any page. This is used in MTR_LOG_NO_REDO mode to detect that pages should be added to flush lists during commit() even though no redo log will be produced.
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
This method is useful to detect if the thread is already inside an mtr.
We should not do the log_free_check() in the child mtrs if a thread is already inside an mtr.
Check if memo contains the given item.
memo | memo stack |
object | object to search |
type | type of object |
bool mtr_t::memo_contains_flagged | ( | const void * | ptr, |
ulint | flags | ||
) | const |
Check if memo contains the given item.
ptr | object to search |
flags | specify types of object (can be ORred) of MTR_MEMO_PAGE_S_FIX ... values |
buf_block_t * mtr_t::memo_contains_page_flagged | ( | const byte * | ptr, |
ulint | flags | ||
) | const |
Check if memo contains the given page.
[in] | ptr | pointer to within buffer frame |
[in] | flags | specify types of object with OR of MTR_MEMO_PAGE_S_FIX... values |
NULL | if not found |
void mtr_t::memo_modify_page | ( | const byte * | ptr | ) |
Mark the given latched page as modified.
[in] | ptr | pointer to within buffer frame |
|
inline |
Push an object to an mtr memo stack.
Pushes an object to an mtr memo stack.
object | object |
type | object type: MTR_MEMO_S_LOCK, ... |
void mtr_t::memo_release | ( | const void * | object, |
ulint | type | ||
) |
Release an object in the memo stack.
object | object |
type | object type: MTR_MEMO_S_LOCK, ... |
void mtr_t::print | ( | ) | const |
Print info of an mtr handle.
std::ostream & mtr_t::print_memos | ( | std::ostream & | out | ) | const |
Print the memo objects (mtr_memo_slot_t) of mtr_t to the given output stream.
[in] | out | the output stream for printing |
Read 1 - 4 bytes from a file page buffered in the buffer pool.
Reads 1 - 4 bytes from a file page buffered in the buffer pool.
ptr | pointer from where to read |
type | MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES |
|
inline |
Release the block in an mtr memo after a savepoint.
Releases the block in an mtr memo after a savepoint.
void mtr_t::release_page | ( | const void * | ptr, |
mtr_memo_type_t | type | ||
) |
Release a page latch.
[in] | ptr | pointer to within a page frame |
[in] | type | object type: MTR_MEMO_PAGE_X_FIX, ... |
Release the (index tree) s-latch stored in an mtr memo after a savepoint.
Releases the (index tree) s-latch stored in an mtr memo after a savepoint.
savepoint | value returned by |
lock | latch to release |
void mtr_t::remove_from_debug_list | ( | ) | const |
Removed the MTR from the s_my_thread_active_mtrs list.
|
inline |
Locks a rw-latch in S mode.
Locks a lock in s-mode.
NOTE: use mtr_s_lock().
lock | rw-lock |
location | location from where called |
|
inline |
Set flush observer.
[in] | observer | flush observer |
Change the logging mode.
mode | logging mode |
|
inline |
Note that the mini-transaction might have modified a buffer pool page.
As it's called from mlog_open(), which is called from fil_op_write_log() and perhaps other places which do not modify any page, this can be a false positive.
|
inline |
Request a future commit to be synchronous.
void mtr_t::start | ( | bool | sync = true | ) |
Start a mini-transaction.
sync | true if it is a synchronous mini-transaction |
|
inline |
SX-latch a not yet latched block after a savepoint.
SX-latches the not yet latched block after a savepoint.
|
inline |
Locks a rw-latch in X mode.
Locks a lock in sx-mode.
NOTE: use mtr_sx_lock().
lock | rw-lock |
location | location from where called |
void mtr_t::wait_for_flush | ( | ) |
|
inline |
X-latch a not yet latched block after a savepoint.
X-latches the not yet latched block after a savepoint.
|
inline |
Locks a rw-latch in X mode.
Locks a lock in x-mode.
NOTE: use mtr_x_lock().
lock | rw-lock |
location | location where name from where called |
void mtr_t::x_lock_space | ( | fil_space_t * | space, |
ut::Location | location | ||
) |
Acquire a tablespace X-latch.
NOTE: use mtr_x_lock_space().
[in] | space | tablespace instance |
[in] | location | location from where called |
|
friend |
|
private |
LSN at commit time.
|
private |
size_t mtr_t::m_restart_count {} |
Count the number of times the same mtr object has been committed and restarted.
|
private |
true if it is synchronous mini-transaction
|
static |
Instance level logging information for all mtrs.
|
static |
Matrix to check if a mode update request should be ignored.
|
static |
For checking invalid mode update requests.
|
staticprivate |
List of all non-committed MTR instances created in this thread.
Used for debug purposes in the log_free_check().