49#define mtr_start(m) (m)->start()
52#define mtr_start_sync(m) (m)->start(true)
55#define mtr_start_ro(m) (m)->start(true, true)
58#define mtr_commit(m) (m)->commit()
62#define mtr_set_savepoint(m) (m)->get_savepoint()
66#define mtr_release_s_latch_at_savepoint(m, s, l) \
67 (m)->release_s_latch_at_savepoint((s), (l))
71#define mtr_get_log_mode(m) (m)->get_log_mode()
75#define mtr_set_log_mode(m, d) (m)->set_log_mode((d))
79#define mtr_get_flush_observer(m) (m)->get_flush_observer()
82#define mtr_set_flush_observer(m, d) (m)->set_flush_observer((d))
86#define mtr_read_ulint(p, t, m) (m)->read_ulint((p), (t))
90#define mtr_memo_release(m, o, t) (m)->memo_release((o), (t))
96#define mtr_is_block_fix(m, o, t, table) \
97 (mtr_memo_contains(m, o, t) || table->is_intrinsic())
101#define mtr_is_page_fix(m, p, t, table) \
102 (mtr_memo_contains_page(m, p, t) || table->is_intrinsic())
106#define mtr_memo_contains(m, o, t) (m)->memo_contains((m)->get_memo(), (o), (t))
110#define mtr_memo_contains_page(m, p, t) \
111 (m)->memo_contains_page_flagged((p), (t))
115#define mtr_print(m) (m)->print()
119#define mtr_get_log(m) (m)->get_log()
122#define mtr_memo_push(m, o, t) (m)->memo_push(o, t)
125#define mtr_s_lock(l, m, loc) (m)->s_lock((l), loc)
128#define mtr_x_lock(l, m, loc) (m)->x_lock((l), loc)
131#define mtr_x_lock_space(s, m) (m)->x_lock_space((s), UT_LOCATION_HERE)
134#define mtr_sx_lock(l, m, loc) (m)->sx_lock((l), loc)
136#define mtr_memo_contains_flagged(m, p, l) (m)->memo_contains_flagged((p), (l))
138#define mtr_memo_contains_page_flagged(m, p, l) \
139 (m)->memo_contains_page_flagged((p), (l))
141#define mtr_release_block_at_savepoint(m, s, b) \
142 (m)->release_block_at_savepoint((s), (b))
144#define mtr_block_sx_latch_at_savepoint(m, s, b) \
145 (m)->sx_latch_at_savepoint((s), (b))
147#define mtr_block_x_latch_at_savepoint(m, s, b) \
148 (m)->x_latch_at_savepoint((s), (b))
168 std::ostream &
print(std::ostream &out)
const;
172 return obj.
print(out);
224#ifndef UNIV_HOTBACKUP
369#ifndef UNIV_HOTBACKUP
388 void start(
bool sync =
true);
436 [[nodiscard]]
inline uint32_t
read_ulint(
const byte *ptr,
531 std::ostream &
print_memos(std::ostream &out)
const;
641 it->check_is_not_latching();
658#ifndef UNIV_HOTBACKUP
683#ifndef UNIV_HOTBACKUP
The database buffer pool global types for the directory.
We use Flush_observer to track flushing of non-redo logged pages in bulk create index(btr0load....
Definition: buf0flu.h:268
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
ulint size() const
Returns the size of the total stored data.
Definition: dyn0buf.h:279
Definition: mtr0mtr.cc:384
mtr global logging
Definition: mtr0mtr.h:226
bool dblwr_disabled() const
Definition: mtr0mtr.h:315
State
mtr global redo logging state.
Definition: mtr0mtr.h:235
@ ENABLED
Definition: mtr0mtr.h:237
@ ENABLED_RESTRICT
Definition: mtr0mtr.h:245
@ ENABLED_DBLWR
Definition: mtr0mtr.h:241
@ DISABLED
Definition: mtr0mtr.h:248
void unmark_mtr(size_t index)
unmark a no logging mtr.
Definition: mtr0mtr.h:298
bool mark_mtr(size_t index)
Mark a no-logging mtr to indicate that it would not generate redo log and system is crash unsafe.
Definition: mtr0mtr.h:279
int disable(THD *thd)
Disable mtr redo logging.
Definition: mtr0mtr.cc:943
uint32_t get_nolog_flush_loop() const
Definition: mtr0mtr.h:305
int wait_no_log_mtr(THD *thd)
Wait till all no-logging mtrs are finished.
Definition: mtr0mtr.cc:989
static constexpr uint32_t NOLOG_MAX_FLUSH_LOOP
Definition: mtr0mtr.h:323
bool is_disabled() const
Definition: mtr0mtr.h:312
int enable(THD *thd)
Enable mtr redo logging.
Definition: mtr0mtr.cc:897
std::atomic< State > m_state
Global redo logging state.
Definition: mtr0mtr.h:332
void init()
Initialize logging state at server start up.
Definition: mtr0mtr.h:252
bool is_enabled() const
Definition: mtr0mtr.h:308
Shards m_count_nologging_mtr
Number of no logging mtrs currently running.
Definition: mtr0mtr.h:337
The dynamically allocated buffer implementation.
The low-level file system.
static int flags[50]
Definition: hp_test1.cc:39
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:62
std::ostream & operator<<(std::ostream &out, const mtr_memo_slot_t &obj)
Definition: mtr0mtr.h:171
lsn_t mtr_commit_mlog_test(size_t payload=0)
Reserves space in the log buffer and writes a single MLOG_TEST.
Definition: mtr0mtr.cc:1103
void mtr_commit_mlog_test_filling_block(log_t &log, size_t space_left=0)
Reserves space in the log buffer and writes a single MLOG_TEST.
Definition: mtr0mtr.cc:1232
Mini-transaction buffer global types.
mlog_id_t
Definition: mtr0types.h:62
constexpr uint32_t MTR_MAGIC_N
Definition: mtr0types.h:316
mtr_log_t
Logging modes for a mini-transaction.
Definition: mtr0types.h:41
@ MTR_LOG_ALL
Default mode: log all operations modifying disk-based data.
Definition: mtr0types.h:43
@ MTR_LOG_NO_REDO
Don't generate REDO log but add dirty pages to flush list.
Definition: mtr0types.h:49
@ MTR_LOG_MODE_MAX
Last element.
Definition: mtr0types.h:55
mtr_state_t
Definition: mtr0types.h:319
@ MTR_STATE_COMMITTING
Definition: mtr0types.h:322
@ MTR_STATE_ACTIVE
Definition: mtr0types.h:321
@ MTR_STATE_INIT
Definition: mtr0types.h:320
@ MTR_STATE_COMMITTED
Definition: mtr0types.h:323
mtr_memo_type_t
Types for the mlock objects to store in the mtr memo; NOTE that the first 3 values must be RW_S_LATCH...
Definition: mtr0types.h:269
@ MTR_MEMO_X_LOCK
Definition: mtr0types.h:284
@ MTR_MEMO_S_LOCK
Definition: mtr0types.h:282
@ MTR_MEMO_SX_LOCK
Definition: mtr0types.h:286
Type inc(Shards< COUNT > &shards, size_t id)
Increment the counter of a shard by 1.
Definition: ut0counter.h:292
Type dec(Shards< COUNT > &shards, size_t id)
Decrement the counter of a shard by 1.
Definition: ut0counter.h:301
Type total(const Shards< COUNT > &shards) noexcept
Get the total value of all shards.
Definition: ut0counter.h:332
void clear(Shards< COUNT > &shards) noexcept
Clear the counter - reset to 0.
Definition: ut0counter.h:343
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:78
mode
Definition: file_handle.h:59
std::unordered_set< Key, std::hash< Key >, std::equal_to< Key >, ut::allocator< Key > > unordered_set
Definition: ut0new.h:2886
required string type
Definition: replication_group_member_actions.proto:33
void set_order(std::memory_order memory_order)
Override default memory order.
Definition: ut0counter.h:255
The buffer control block structure.
Definition: buf0buf.h:1689
Tablespace or log data space.
Definition: fil0fil.h:231
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:76
Mini-transaction memo stack slot.
Definition: mtr0mtr.h:154
bool is_lock() const
Check if the object stored in this slot is a lock (rw_lock_t).
Definition: mtr0mtr.h:163
ulint type
type of the stored object (MTR_MEMO_S_LOCK, ...)
Definition: mtr0mtr.h:159
std::ostream & print(std::ostream &out) const
Definition: mtr0mtr.cc:883
void * object
Pointer to the object - either buf_block_t or rw_lock_t.
Definition: mtr0mtr.h:156
State variables of the mtr.
Definition: mtr0mtr.h:178
Flush_observer * m_flush_observer
Flush Observer.
Definition: mtr0mtr.h:212
bool m_inside_ibuf
true if inside ibuf changes
Definition: mtr0mtr.h:186
mtr_log_t m_log_mode
specifies which operations should be logged; default value MTR_LOG_ALL
Definition: mtr0mtr.h:206
mtr_state_t m_state
State of the transaction.
Definition: mtr0mtr.h:209
mtr_t * m_mtr
Owning mini-transaction.
Definition: mtr0mtr.h:221
size_t m_shard_index
Shard index used for incrementing global counter at start.
Definition: mtr0mtr.h:198
ulint m_magic_n
For checking corruption.
Definition: mtr0mtr.h:216
mtr_buf_t m_log
mini-transaction log
Definition: mtr0mtr.h:183
bool m_modifications
true if the mini-transaction might have modified buffer pool pages
Definition: mtr0mtr.h:189
mtr_buf_t m_memo
memo stack for locks etc.
Definition: mtr0mtr.h:180
uint32_t m_n_log_recs
Count of how many page initial log records have been written to the mtr log.
Definition: mtr0mtr.h:202
bool m_marked_nolog
true if mtr is forced to NO_LOG mode because redo logging is disabled globally.
Definition: mtr0mtr.h:194
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:176
void check_nolog_and_unmark()
Check if the mtr has marked the global no log counter and unmark it.
Definition: mtr0mtr.cc:621
bool conflicts_with(const mtr_t *mtr2) const
Check if the changes done in this mtr conflicts with changes done in the given mtr.
Definition: mtr0mtr.cc:222
void sx_latch_at_savepoint(ulint savepoint, buf_block_t *block)
SX-latch a not yet latched block after a savepoint.
Definition: mtr0mtr.ic:81
void memo_modify_page(const byte *ptr)
Mark the given latched page as modified.
Definition: mtr0mtr.cc:1086
void release_block_at_savepoint(ulint savepoint, buf_block_t *block)
Release the block in an mtr memo after a savepoint.
Definition: mtr0mtr.ic:131
bool m_sync
true if it is synchronous mini-transaction
Definition: mtr0mtr.h:670
Impl m_impl
Definition: mtr0mtr.h:664
void x_lock_space(fil_space_t *space, ut::Location location)
Acquire a tablespace X-latch.
Definition: mtr0mtr.cc:710
Flush_observer * get_flush_observer() const
Get flush observer.
Definition: mtr0mtr.h:515
bool has_modifications() const
Checks if this mtr has modified any buffer pool page.
Definition: mtr0mtr.h:484
bool has_any_log_record()
Checks if this mtr has generated any redo log records which should be written to the redo log during ...
Definition: mtr0mtr.h:612
bool is_async() const
Definition: mtr0mtr.h:391
lsn_t m_commit_lsn
LSN at commit time.
Definition: mtr0mtr.h:667
void memo_push(void *object, mtr_memo_type_t type)
Push an object to an mtr memo stack.
Definition: mtr0mtr.ic:37
const mtr_buf_t * get_log() const
Get the buffered redo log of this mini-transaction.
Definition: mtr0mtr.h:616
bool is_active() const
Definition: mtr0mtr.h:509
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.
Definition: mtr0mtr.ic:192
mtr_buf_t * get_log()
Get the buffered redo log of this mini-transaction.
Definition: mtr0mtr.h:624
mtr_log_t set_log_mode(mtr_log_t mode)
Change the logging mode.
Definition: mtr0mtr.cc:470
void exit_ibuf()
Note that we have exited from the change buffer code.
Definition: mtr0mtr.h:502
void x_latch_at_savepoint(ulint savepoint, buf_block_t *block)
X-latch a not yet latched block after a savepoint.
Definition: mtr0mtr.ic:106
void set_modified()
Note that the mini-transaction might have modified a buffer pool page.
Definition: mtr0mtr.h:477
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 (ex...
Definition: mtr0mtr.h:592
size_t m_restart_count
Count the number of times the same mtr object has been committed and restarted.
Definition: mtr0mtr.h:655
void commit()
Commit the mini-transaction.
Definition: mtr0mtr.cc:661
mtr_log_t get_log_mode() const
Get the logging mode.
Definition: mtr0mtr.ic:152
static void check_my_thread_mtrs_are_not_latching()
Iterate all MTRs created in this thread to assure they are not latching any resources.
Definition: mtr0mtr.h:639
static bool memo_contains(const mtr_buf_t *memo, const void *object, ulint type)
Check if memo contains the given item.
Definition: mtr0mtr.cc:1028
void wait_for_flush()
Definition: mtr0mtr.cc:1236
void set_sync()
Request a future commit to be synchronous.
Definition: mtr0mtr.h:394
void start(bool sync=true)
Start a mini-transaction.
Definition: mtr0mtr.cc:564
mtr_t()
Definition: mtr0mtr.h:349
buf_block_t * memo_contains_page_flagged(const byte *ptr, ulint flags) const
Check if memo contains the given page.
Definition: mtr0mtr.cc:1075
void added_rec()
Note that a record has been added to the log.
Definition: mtr0mtr.h:600
bool is_inside_ibuf() const
Definition: mtr0mtr.h:505
bool is_committing() const
Definition: mtr0mtr.h:571
bool memo_contains_flagged(const void *ptr, ulint flags) const
Check if memo contains the given item.
Definition: mtr0mtr.cc:1059
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.
Definition: mtr0mtr.ic:56
void set_flush_observer(Flush_observer *observer)
Set flush observer.
Definition: mtr0mtr.h:521
mtr_buf_t * get_memo()
Definition: mtr0mtr.h:586
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.
Definition: mtr0mtr.h:675
void check_is_not_latching() const
Assure that there are no slots that are latching any resources.
Definition: mtr0mtr.cc:696
bool has_committed() const
Definition: mtr0mtr.h:566
ulint get_savepoint() const
Return current size of the buffer.
Definition: mtr0mtr.h:401
lsn_t commit_lsn() const
Get the LSN of commit().
Definition: mtr0mtr.h:492
void enter_ibuf()
Note that we are inside the change buffer code.
Definition: mtr0mtr.h:499
std::ostream & print_memos(std::ostream &out) const
Print the memo objects (mtr_memo_slot_t) of mtr_t to the given output stream.
Definition: mtr0mtr.cc:189
static Logging s_logging
Instance level logging information for all mtrs.
Definition: mtr0mtr.h:660
const mtr_buf_t * get_memo() const
Definition: mtr0mtr.h:583
void remove_from_debug_list() const
Removed the MTR from the s_my_thread_active_mtrs list.
Definition: mtr0mtr.cc:688
static bool s_mode_update[MTR_LOG_MODE_MAX][MTR_LOG_MODE_MAX]
Matrix to check if a mode update request should be ignored.
Definition: mtr0mtr.h:647
void memo_release(const void *object, ulint type)
Release an object in the memo stack.
Definition: mtr0mtr.cc:718
~mtr_t()
Definition: mtr0mtr.h:355
void s_lock(rw_lock_t *lock, ut::Location location)
Locks a rw-latch in S mode.
Definition: mtr0mtr.ic:163
void x_lock(rw_lock_t *lock, ut::Location location)
Locks a rw-latch in X mode.
Definition: mtr0mtr.ic:172
static bool s_mode_update_valid[MTR_LOG_MODE_MAX][MTR_LOG_MODE_MAX]
For checking invalid mode update requests.
Definition: mtr0mtr.h:651
void release_page(const void *ptr, mtr_memo_type_t type)
Release a page latch.
Definition: mtr0mtr.cc:737
void print() const
Print info of an mtr handle.
Definition: mtr0mtr.cc:1097
void sx_lock(rw_lock_t *lock, ut::Location location)
Locks a rw-latch in X mode.
Definition: mtr0mtr.ic:181
void check_nolog_and_mark()
Check if redo logging is disabled globally and mark the global counter till mtr ends.
Definition: mtr0mtr.cc:604
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:359
Transaction system global type definitions.
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:405
#define ut_error
Abort execution.
Definition: ut0dbg.h:64
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68
#define ut_d(EXPR)
Debug statement.
Definition: ut0dbg.h:70