50#define mtr_start(m) (m)->start()
53#define mtr_start_sync(m) (m)->start(true)
56#define mtr_start_ro(m) (m)->start(true, true)
59#define mtr_commit(m) (m)->commit()
63#define mtr_set_savepoint(m) (m)->get_savepoint()
67#define mtr_release_s_latch_at_savepoint(m, s, l) \
68 (m)->release_s_latch_at_savepoint((s), (l))
72#define mtr_get_log_mode(m) (m)->get_log_mode()
76#define mtr_set_log_mode(m, d) (m)->set_log_mode((d))
80#define mtr_get_flush_observer(m) (m)->get_flush_observer()
83#define mtr_set_flush_observer(m, d) (m)->set_flush_observer((d))
87#define mtr_read_ulint(p, t, m) (m)->read_ulint((p), (t))
91#define mtr_memo_release(m, o, t) (m)->memo_release((o), (t))
97#define mtr_is_block_fix(m, o, t, table) \
98 (mtr_memo_contains(m, o, t) || table->is_intrinsic())
102#define mtr_is_page_fix(m, p, t, table) \
103 (mtr_memo_contains_page(m, p, t) || table->is_intrinsic())
107#define mtr_memo_contains(m, o, t) (m)->memo_contains((m)->get_memo(), (o), (t))
111#define mtr_memo_contains_page(m, p, t) \
112 (m)->memo_contains_page_flagged((p), (t))
116#define mtr_print(m) (m)->print()
120#define mtr_get_log(m) (m)->get_log()
123#define mtr_memo_push(m, o, t) (m)->memo_push(o, t)
126#define mtr_s_lock(l, m, loc) (m)->s_lock((l), loc)
129#define mtr_x_lock(l, m, loc) (m)->x_lock((l), loc)
132#define mtr_x_lock_space(s, m) (m)->x_lock_space((s), UT_LOCATION_HERE)
135#define mtr_sx_lock(l, m, loc) (m)->sx_lock((l), loc)
137#define mtr_memo_contains_flagged(m, p, l) (m)->memo_contains_flagged((p), (l))
139#define mtr_memo_contains_page_flagged(m, p, l) \
140 (m)->memo_contains_page_flagged((p), (l))
142#define mtr_release_block_at_savepoint(m, s, b) \
143 (m)->release_block_at_savepoint((s), (b))
145#define mtr_block_sx_latch_at_savepoint(m, s, b) \
146 (m)->sx_latch_at_savepoint((s), (b))
148#define mtr_block_x_latch_at_savepoint(m, s, b) \
149 (m)->x_latch_at_savepoint((s), (b))
169 std::ostream &
print(std::ostream &out)
const;
173 return obj.
print(out);
225#ifndef UNIV_HOTBACKUP
370#ifndef UNIV_HOTBACKUP
389 void start(
bool sync =
true);
437 [[nodiscard]]
inline uint32_t
read_ulint(
const byte *ptr,
532 std::ostream &
print_memos(std::ostream &out)
const;
642 it->check_is_not_latching();
666#ifndef UNIV_HOTBACKUP
691#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:269
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
ulint size() const
Returns the size of the total stored data.
Definition: dyn0buf.h:280
Definition: mtr0mtr.cc:385
mtr global logging
Definition: mtr0mtr.h:227
bool dblwr_disabled() const
Definition: mtr0mtr.h:316
State
mtr global redo logging state.
Definition: mtr0mtr.h:236
@ ENABLED
Definition: mtr0mtr.h:238
@ ENABLED_RESTRICT
Definition: mtr0mtr.h:246
@ ENABLED_DBLWR
Definition: mtr0mtr.h:242
@ DISABLED
Definition: mtr0mtr.h:249
void unmark_mtr(size_t index)
unmark a no logging mtr.
Definition: mtr0mtr.h:299
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:280
int disable(THD *thd)
Disable mtr redo logging.
Definition: mtr0mtr.cc:944
uint32_t get_nolog_flush_loop() const
Definition: mtr0mtr.h:306
int wait_no_log_mtr(THD *thd)
Wait till all no-logging mtrs are finished.
Definition: mtr0mtr.cc:990
static constexpr uint32_t NOLOG_MAX_FLUSH_LOOP
Definition: mtr0mtr.h:324
bool is_disabled() const
Definition: mtr0mtr.h:313
int enable(THD *thd)
Enable mtr redo logging.
Definition: mtr0mtr.cc:898
std::atomic< State > m_state
Global redo logging state.
Definition: mtr0mtr.h:333
void init()
Initialize logging state at server start up.
Definition: mtr0mtr.h:253
bool is_enabled() const
Definition: mtr0mtr.h:309
Shards m_count_nologging_mtr
Number of no logging mtrs currently running.
Definition: mtr0mtr.h:338
The dynamically allocated buffer implementation.
The low-level file system.
static int flags[50]
Definition: hp_test1.cc:40
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:63
std::ostream & operator<<(std::ostream &out, const mtr_memo_slot_t &obj)
Definition: mtr0mtr.h:172
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:1104
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:1233
Mini-transaction buffer global types.
mlog_id_t
Definition: mtr0types.h:63
constexpr uint32_t MTR_MAGIC_N
Definition: mtr0types.h:317
mtr_log_t
Logging modes for a mini-transaction.
Definition: mtr0types.h:42
@ MTR_LOG_ALL
Default mode: log all operations modifying disk-based data.
Definition: mtr0types.h:44
@ MTR_LOG_NO_REDO
Don't generate REDO log but add dirty pages to flush list.
Definition: mtr0types.h:50
@ MTR_LOG_MODE_MAX
Last element.
Definition: mtr0types.h:56
mtr_state_t
Definition: mtr0types.h:320
@ MTR_STATE_COMMITTING
Definition: mtr0types.h:323
@ MTR_STATE_ACTIVE
Definition: mtr0types.h:322
@ MTR_STATE_INIT
Definition: mtr0types.h:321
@ MTR_STATE_COMMITTED
Definition: mtr0types.h:324
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:270
@ MTR_MEMO_X_LOCK
Definition: mtr0types.h:285
@ MTR_MEMO_S_LOCK
Definition: mtr0types.h:283
@ MTR_MEMO_SX_LOCK
Definition: mtr0types.h:287
Type inc(Shards< COUNT > &shards, size_t id)
Increment the counter of a shard by 1.
Definition: ut0counter.h:293
Type dec(Shards< COUNT > &shards, size_t id)
Decrement the counter of a shard by 1.
Definition: ut0counter.h:302
Type total(const Shards< COUNT > &shards) noexcept
Get the total value of all shards.
Definition: ut0counter.h:333
void clear(Shards< COUNT > &shards) noexcept
Clear the counter - reset to 0.
Definition: ut0counter.h:344
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
mode
Definition: file_handle.h:60
std::unordered_set< Key, std::hash< Key >, std::equal_to< Key >, ut::allocator< Key > > unordered_set
Definition: ut0new.h:2887
required string type
Definition: replication_group_member_actions.proto:34
void set_order(std::memory_order memory_order)
Override default memory order.
Definition: ut0counter.h:256
The buffer control block structure.
Definition: buf0buf.h:1690
Tablespace or log data space.
Definition: fil0fil.h:236
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:77
Mini-transaction memo stack slot.
Definition: mtr0mtr.h:155
bool is_lock() const
Check if the object stored in this slot is a lock (rw_lock_t).
Definition: mtr0mtr.h:164
ulint type
type of the stored object (MTR_MEMO_S_LOCK, ...)
Definition: mtr0mtr.h:160
std::ostream & print(std::ostream &out) const
Definition: mtr0mtr.cc:884
void * object
Pointer to the object - either buf_block_t or rw_lock_t.
Definition: mtr0mtr.h:157
State variables of the mtr.
Definition: mtr0mtr.h:179
Flush_observer * m_flush_observer
Flush Observer.
Definition: mtr0mtr.h:213
bool m_inside_ibuf
true if inside ibuf changes
Definition: mtr0mtr.h:187
mtr_log_t m_log_mode
specifies which operations should be logged; default value MTR_LOG_ALL
Definition: mtr0mtr.h:207
mtr_state_t m_state
State of the transaction.
Definition: mtr0mtr.h:210
mtr_t * m_mtr
Owning mini-transaction.
Definition: mtr0mtr.h:222
size_t m_shard_index
Shard index used for incrementing global counter at start.
Definition: mtr0mtr.h:199
ulint m_magic_n
For checking corruption.
Definition: mtr0mtr.h:217
mtr_buf_t m_log
mini-transaction log
Definition: mtr0mtr.h:184
bool m_modifications
true if the mini-transaction might have modified buffer pool pages
Definition: mtr0mtr.h:190
mtr_buf_t m_memo
memo stack for locks etc.
Definition: mtr0mtr.h:181
uint32_t m_n_log_recs
Count of how many page initial log records have been written to the mtr log.
Definition: mtr0mtr.h:203
bool m_marked_nolog
true if mtr is forced to NO_LOG mode because redo logging is disabled globally.
Definition: mtr0mtr.h:195
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:177
void check_nolog_and_unmark()
Check if the mtr has marked the global no log counter and unmark it.
Definition: mtr0mtr.cc:622
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:223
void sx_latch_at_savepoint(ulint savepoint, buf_block_t *block)
SX-latch a not yet latched block after a savepoint.
Definition: mtr0mtr.ic:82
void memo_modify_page(const byte *ptr)
Mark the given latched page as modified.
Definition: mtr0mtr.cc:1087
void release_block_at_savepoint(ulint savepoint, buf_block_t *block)
Release the block in an mtr memo after a savepoint.
Definition: mtr0mtr.ic:132
bool m_sync
true if it is synchronous mini-transaction
Definition: mtr0mtr.h:678
Impl m_impl
Definition: mtr0mtr.h:672
void x_lock_space(fil_space_t *space, ut::Location location)
Acquire a tablespace X-latch.
Definition: mtr0mtr.cc:711
Flush_observer * get_flush_observer() const
Get flush observer.
Definition: mtr0mtr.h:516
bool has_modifications() const
Checks if this mtr has modified any buffer pool page.
Definition: mtr0mtr.h:485
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:613
bool is_async() const
Definition: mtr0mtr.h:392
lsn_t m_commit_lsn
LSN at commit time.
Definition: mtr0mtr.h:675
void memo_push(void *object, mtr_memo_type_t type)
Push an object to an mtr memo stack.
Definition: mtr0mtr.ic:38
const mtr_buf_t * get_log() const
Get the buffered redo log of this mini-transaction.
Definition: mtr0mtr.h:617
static bool is_this_thread_inside_mtr()
This method is useful to detect if the thread is already inside an mtr.
Definition: mtr0mtr.h:649
bool is_active() const
Definition: mtr0mtr.h:510
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:193
mtr_buf_t * get_log()
Get the buffered redo log of this mini-transaction.
Definition: mtr0mtr.h:625
mtr_log_t set_log_mode(mtr_log_t mode)
Change the logging mode.
Definition: mtr0mtr.cc:471
void exit_ibuf()
Note that we have exited from the change buffer code.
Definition: mtr0mtr.h:503
void x_latch_at_savepoint(ulint savepoint, buf_block_t *block)
X-latch a not yet latched block after a savepoint.
Definition: mtr0mtr.ic:107
void set_modified()
Note that the mini-transaction might have modified a buffer pool page.
Definition: mtr0mtr.h:478
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:593
size_t m_restart_count
Count the number of times the same mtr object has been committed and restarted.
Definition: mtr0mtr.h:663
void commit()
Commit the mini-transaction.
Definition: mtr0mtr.cc:662
mtr_log_t get_log_mode() const
Get the logging mode.
Definition: mtr0mtr.ic:153
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:640
static bool memo_contains(const mtr_buf_t *memo, const void *object, ulint type)
Check if memo contains the given item.
Definition: mtr0mtr.cc:1029
void wait_for_flush()
Definition: mtr0mtr.cc:1237
void set_sync()
Request a future commit to be synchronous.
Definition: mtr0mtr.h:395
void start(bool sync=true)
Start a mini-transaction.
Definition: mtr0mtr.cc:565
mtr_t()
Definition: mtr0mtr.h:350
buf_block_t * memo_contains_page_flagged(const byte *ptr, ulint flags) const
Check if memo contains the given page.
Definition: mtr0mtr.cc:1076
void added_rec()
Note that a record has been added to the log.
Definition: mtr0mtr.h:601
bool is_inside_ibuf() const
Definition: mtr0mtr.h:506
bool is_committing() const
Definition: mtr0mtr.h:572
bool memo_contains_flagged(const void *ptr, ulint flags) const
Check if memo contains the given item.
Definition: mtr0mtr.cc:1060
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:57
void set_flush_observer(Flush_observer *observer)
Set flush observer.
Definition: mtr0mtr.h:522
mtr_buf_t * get_memo()
Definition: mtr0mtr.h:587
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:683
void check_is_not_latching() const
Assure that there are no slots that are latching any resources.
Definition: mtr0mtr.cc:697
bool has_committed() const
Definition: mtr0mtr.h:567
ulint get_savepoint() const
Return current size of the buffer.
Definition: mtr0mtr.h:402
lsn_t commit_lsn() const
Get the LSN of commit().
Definition: mtr0mtr.h:493
void enter_ibuf()
Note that we are inside the change buffer code.
Definition: mtr0mtr.h:500
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:190
static Logging s_logging
Instance level logging information for all mtrs.
Definition: mtr0mtr.h:668
const mtr_buf_t * get_memo() const
Definition: mtr0mtr.h:584
void remove_from_debug_list() const
Removed the MTR from the s_my_thread_active_mtrs list.
Definition: mtr0mtr.cc:689
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:655
void memo_release(const void *object, ulint type)
Release an object in the memo stack.
Definition: mtr0mtr.cc:719
~mtr_t()
Definition: mtr0mtr.h:356
void s_lock(rw_lock_t *lock, ut::Location location)
Locks a rw-latch in S mode.
Definition: mtr0mtr.ic:164
void x_lock(rw_lock_t *lock, ut::Location location)
Locks a rw-latch in X mode.
Definition: mtr0mtr.ic:173
static bool s_mode_update_valid[MTR_LOG_MODE_MAX][MTR_LOG_MODE_MAX]
For checking invalid mode update requests.
Definition: mtr0mtr.h:659
void release_page(const void *ptr, mtr_memo_type_t type)
Release a page latch.
Definition: mtr0mtr.cc:738
void print() const
Print info of an mtr handle.
Definition: mtr0mtr.cc:1098
void sx_lock(rw_lock_t *lock, ut::Location location)
Locks a rw-latch in X mode.
Definition: mtr0mtr.ic:182
void check_nolog_and_mark()
Check if redo logging is disabled globally and mark the global counter till mtr ends.
Definition: mtr0mtr.cc:605
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:360
Transaction system global type definitions.
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:406
#define ut_error
Abort execution.
Definition: ut0dbg.h:65
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:69
#define ut_d(EXPR)
Debug statement.
Definition: ut0dbg.h:71