147 for (
auto &
id : space_ids) {
149 const auto num =
id2num(
id);
174 std::unordered_map<space_id_t, space_id_t>
m_num2id{};
265#ifndef UNIV_HOTBACKUP
300 const char *location);
446 *marked_space_id =
m_id;
512 std::vector<Tablespace *, ut::allocator<Tablespace *>>;
576 auto undo_space =
m_spaces.at(slot);
577 if (undo_space->num() == num) {
584 if (undo_space->num() == num) {
605 if (undo_space->is_inactive_explicit()) {
609 if (num_active !=
nullptr && undo_space->is_active()) {
703 return (undo_space->
num());
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:49
This is a wrapper for a std::vector of trx_rseg_t object pointers.
Definition: trx0types.h:331
void set_empty()
Set the state of the undo tablespace to empty so that it can be dropped.
Definition: trx0types.h:450
void set_inactive_implicit()
Set the state of the rollback segments in this undo tablespace to inactive_implicit.
Definition: trx0types.h:438
void set_active()
Set the state of the rollback segments in this undo tablespace to ACTIVE for use by new transactions.
Definition: trx0types.h:431
void s_lock()
Acquire the shared lock on m_rsegs.
Definition: trx0types.h:395
bool is_empty()
Return whether the undo tablespace is empty and ready to be dropped.
Definition: trx0types.h:423
bool is_inactive_implicit()
Return whether the undo tablespace is inactive due to implicit selection by the purge thread.
Definition: trx0types.h:413
bool is_inactive_explicit()
Return whether the undo tablespace was made inactive by ALTER TABLESPACE.
Definition: trx0types.h:418
void s_unlock()
Release the shared lock on m_rsegs.
Definition: trx0types.h:398
void set_inactive_explicit()
Make the undo tablespace inactive so that it will not be used for new transactions.
Definition: trx0types.h:446
bool is_active()
Return whether the undo tablespace is active.
Definition: trx0types.h:408
void x_unlock()
Release the exclusive lock on m_rsegs.
Definition: trx0types.h:404
void x_lock()
Acquire the exclusive lock on m_rsegs.
Definition: trx0types.h:401
trx_rseg_t * at(ulint slot)
Find the rseg at the given slot in this vector.
Definition: trx0types.h:375
For measuring time elapsed.
Definition: ut0ut.h:303
void reset()
Reset the timer to the current time.
Definition: ut0ut.h:312
int64_t elapsed() const noexcept
Definition: ut0ut.h:316
Inject a failure in the undo truncation debug compiled code at various places so that it fails the fi...
Definition: trx0undo_trunc.h:810
Inject_failure_once(const char *inject_name)
Definition: trx0undo_trunc.h:815
bool m_already_failed
Definition: trx0undo_trunc.h:811
bool should_fail()
If a certain SET GLOBAL DEBUG has been set and this is the first time this has been called for that i...
Definition: trx0undo_trunc.cc:516
const char * m_inject_name
Definition: trx0undo_trunc.h:812
List of undo tablespaces, each containing a list of rollback segments.
Definition: trx0undo_trunc.h:510
bool own_latch()
Determine if this thread owns a lock on m_latch.
Definition: trx0undo_trunc.h:619
void clear()
Clear the contents of the list of Tablespace objects.
Definition: trx0undo_trunc.h:527
bool contains(space_id_t num)
Check if the given space_id is in the vector.
Definition: trx0undo_trunc.h:561
ulint size()
Get the number of tablespaces tracked by this object.
Definition: trx0undo_trunc.h:535
void add(Tablespace &ref_undo_space)
Add a new undo_truncate::Tablespace to the back of the vector.
Definition: trx0purge.cc:2082
rw_lock_t * m_latch
RW lock to protect m_spaces.
Definition: trx0undo_trunc.h:641
Tablespace * find_first_inactive_explicit(size_t *num_active)
Find the first undo space that is marked inactive explicitly.
Definition: trx0undo_trunc.h:597
Tablespaces_Vector m_spaces
Definition: trx0undo_trunc.h:636
Tablespaces()
Definition: trx0undo_trunc.h:515
void s_lock(ut::Location location)
Get a shared lock on m_spaces.
Definition: trx0undo_trunc.h:625
std::vector< Tablespace *, ut::allocator< Tablespace * > > Tablespaces_Vector
Definition: trx0undo_trunc.h:512
void drop(Tablespace *undo_space)
Drop an existing explicit undo_truncate::Tablespace.
Definition: trx0purge.cc:2095
Tablespace * at(size_t pos)
Get the Tablespace tracked at a position.
Definition: trx0undo_trunc.h:541
Tablespace * find(space_id_t num)
Find the given space_num in the vector.
Definition: trx0undo_trunc.h:566
bool empty()
See if the list of tablespaces is empty.
Definition: trx0undo_trunc.h:538
void s_unlock()
Release a shared lock on m_spaces.
Definition: trx0undo_trunc.h:628
void x_lock(ut::Location location)
Get an exclusive lock on m_spaces.
Definition: trx0undo_trunc.h:631
void init()
Initialize.
Definition: trx0purge.cc:2058
void x_unlock()
Release an exclusive lock on m_spaces.
Definition: trx0undo_trunc.h:634
void deinit()
De-initialize.
Definition: trx0purge.cc:2073
~Tablespaces()
Definition: trx0undo_trunc.h:517
Track an UNDO tablespace marked for truncate.
Definition: trx0undo_trunc.h:654
void reset()
Reset for next rseg truncate.
Definition: trx0undo_trunc.h:689
bool m_marked_space_is_empty
This is true if the marked space is empty of undo logs and ready to truncate.
Definition: trx0undo_trunc.h:739
ib::Timer m_timer
Elapsed time since last truncate check.
Definition: trx0undo_trunc.h:742
void set_marked_space_empty()
Mark the undo tablespace selected for truncate as empty so that it will be truncated next.
Definition: trx0undo_trunc.h:670
Truncate()
Constructor.
Definition: trx0undo_trunc.h:657
space_id_t get_marked_space_num() const
Get the number of the tablespace marked for truncate.
Definition: trx0undo_trunc.h:684
~Truncate()=default
Destructor.
int64_t check_timer() const
Definition: trx0undo_trunc.h:726
bool is_marked() const
Is tablespace selected for truncate.
Definition: trx0undo_trunc.h:664
static size_t s_scan_pos
Start scanning for UNDO tablespace from this vector position.
Definition: trx0undo_trunc.h:746
space_id_t increment_scan() const
Increment the scanning position in a round-robin fashion.
Definition: trx0undo_trunc.h:708
void reset_timer()
Reset the timer.
Definition: trx0undo_trunc.h:729
bool is_equal(space_id_t space_id) const
Check if the given space id is equal to the space ID that is marked for truncation.
Definition: trx0undo_trunc.h:721
space_id_t get_scan_space_num() const
Get the undo tablespace number to start a scan.
Definition: trx0undo_trunc.h:698
bool is_marked_space_empty() const
Is the tablespace selected for truncate empty of undo logs yet?
Definition: trx0undo_trunc.h:674
void mark(Tablespace *undo_space)
Mark the tablespace for truncate.
Definition: trx0purge.cc:780
space_id_t m_space_id_marked
UNDO space ID that is marked for truncate.
Definition: trx0undo_trunc.h:733
Map from undo tablespace number to space id to allow a reserved undo space ID to be found quickly.
Definition: trx0undo_trunc.h:141
std::unordered_map< space_id_t, space_id_t > m_num2id
Map from undo space_num to undo space_id.
Definition: trx0undo_trunc.h:174
bool contains(space_id_t num)
check if mapping contains an entry for given UNDO space number.
Definition: trx0undo_trunc.h:168
space_id_t get(space_id_t num)
Find the UNDO space_id for a given UNDO space number from the mapping.
Definition: trx0undo_trunc.h:159
Undo_num2id_map(const std::vector< space_id_t > &space_ids)
Constructor which will create the mapping from UNDO space number to UNDO space id from the given spac...
Definition: trx0undo_trunc.h:146
bool fsp_is_undo_tablespace(space_id_t space_id)
Check whether a space id is an undo tablespace ID Undo tablespaces have space_id's starting 1 less th...
Definition: fsp0fsp.cc:264
constexpr size_t FSP_MAX_UNDO_TABLESPACES
The maximum number of non-temporary Undo Tablespaces (implicit + explicit) that can exist at the same...
Definition: fsp0types.h:439
constexpr size_t FSP_IMPLICIT_UNDO_TABLESPACES
There are exactly two implicit Undo Tablespaces present at any moment (undo_001 and undo_002),...
Definition: fsp0types.h:444
size_t size(const char *const c)
Definition: base64.h:46
Definition: srv0start.h:50
void mark_undo_tablespace_usable(space_id_t space_id, mtr_t *mtr)
Unset the FSP_FLAGS_MASK_UNDO_UNUSABLE in the undo tablespace header to indicate that the undo file i...
Definition: trx0undo_trunc.cc:498
space_id_t id2num(space_id_t space_id)
Get the corresponding UNDO space number for a given UNDO space id.
Definition: trx0undo_trunc.cc:462
Tablespaces * spaces
A global object that contains a vector of undo_truncate::Tablespace structs.
Definition: trx0undo_trunc.cc:46
space_id_t num2id(space_id_t space_num, size_t ndx)
Convert an undo space number (from 1 to 127) into the undo space_id, given an index indicating which ...
Definition: trx0undo_trunc.cc:437
char * make_file_name(space_id_t space_id)
Build a standard undo tablespace file name from a space_id.
Definition: trx0undo_trunc.cc:406
void set_active(space_id_t space_id)
Set an undo tablespace active.
Definition: trx0undo_trunc.cc:378
space_id_t next_space_id(space_id_t space_id)
Given a valid undo space_id, return the next space_id for that space number.
Definition: trx0undo_trunc.cc:206
constexpr ulint TRUNCATE_FREQUENCY
Definition: trx0undo_trunc.h:651
space_id_t get_next_available_space_id()
Return the next available undo space ID to be used for a new explicit undo tablespaces.
Definition: trx0undo_trunc.cc:198
void inject_crash(const char *injection_point_name)
Inject a crash if a certain SET GLOBAL DEBUG has been set.
Definition: trx0undo_trunc.cc:509
void unuse_space_id(space_id_t space_id)
Mark an undo number associated with a given space_id as unused and available to be reused.
Definition: trx0undo_trunc.cc:202
space_id_t use_next_space_id(space_id_t space_num)
Mark that the given undo space number is being used and return the next available space_id for that s...
Definition: trx0undo_trunc.cc:210
space_id_t id2next_id(space_id_t space_id)
Definition: trx0undo_trunc.cc:473
static constexpr char s_log_prefix[]
Truncate Log file Prefix.
Definition: trx0undo_trunc.h:76
void mark_undo_tablespace_unusable(space_id_t space_id, mtr_t *mtr)
Set the FSP_FLAGS_MASK_UNDO_UNUSABLE flag in the undo tablespace header to indicate that the undo fil...
Definition: trx0undo_trunc.cc:486
void remove_truncate_log_file(space_id_t space_num)
Remove TRUNCATE_DDL_LOG file if it exists.
Definition: trx0undo_trunc.cc:363
bool is_reserved(space_id_t space_id)
Check if the space_id is an undo space ID in the reserved range.
Definition: trx0undo_trunc.h:111
bool is_active_truncate_log_present(space_id_t space_num)
Check if TRUNCATE_DDL_LOG file exist.
Definition: trx0undo_trunc.cc:356
ut::unique_ptr< Undo_num2id_map > num2id_map
Definition: trx0undo_trunc.cc:44
static constexpr char s_log_ext[]
Truncate Log file Extension.
Definition: trx0undo_trunc.h:79
ib_mutex_t ddl_mutex
Mutex for serializing undo tablespace related DDL.
Definition: trx0undo_trunc.cc:42
void use_space_id(space_id_t space_id)
Note that the undo space number for a space ID is being used.
Definition: trx0undo_trunc.cc:196
char * make_space_name(space_id_t space_id)
Build a standard undo tablespace name from a space_id.
Definition: trx0undo_trunc.cc:391
void delete_(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new*() variants.
Definition: ut0new.h:651
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2284
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:559
char * srv_undo_dir
Server undo tablespaces directory, can be absolute path.
Definition: srv0srv.cc:155
static constexpr space_id_t s_max_undo_space_id
The highest undo tablespace ID.
Definition: dict0dict.h:1120
static constexpr space_id_t s_min_undo_space_id
The lowest undo tablespace ID.
Definition: dict0dict.h:1116
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:174
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:362
The rollback segment memory object.
Definition: trx0types.h:214
std::atomic< size_t > trx_ref_count
Reference counter to track rseg allocated transactions.
Definition: trx0types.h:313
An undo_truncate::Tablespace object is used to easily convert between undo_space_id and undo_space_nu...
Definition: trx0undo_trunc.h:188
space_id_t id()
Get the undo tablespace ID.
Definition: trx0undo_trunc.h:317
Rsegs * rsegs()
Get a reference to the List of rollback segments within this undo tablespace.
Definition: trx0undo_trunc.h:331
void alter_active()
Make the undo tablespace active again so that it will be used for new transactions.
Definition: trx0undo_trunc.cc:334
char * m_file_name
The tablespace file name, auto-generated when needed from the space number.
Definition: trx0undo_trunc.h:493
bool is_inactive_explicit()
Return whether the undo tablespace was made inactive by ALTER TABLESPACE.
Definition: trx0undo_trunc.h:406
char * space_name()
Get the undo tablespace name.
Definition: trx0undo_trunc.h:263
void set_empty()
Set the state of the undo tablespace to empty so that it can be dropped.
Definition: trx0undo_trunc.h:473
void set_new()
Note that this undo tablespace is being created.
Definition: trx0undo_trunc.h:346
char * file_name()
Get the undo space filename.
Definition: trx0undo_trunc.h:287
space_id_t m_id
Undo Tablespace ID.
Definition: trx0undo_trunc.h:481
char * m_log_file_name
The truncation log file name, auto-generated when needed from the space number and the srv_undo_dir.
Definition: trx0undo_trunc.h:497
~Tablespace()
Destructor.
Definition: trx0undo_trunc.h:222
char * m_space_name
The tablespace name, auto-generated when needed from the space number.
Definition: trx0undo_trunc.h:489
bool is_empty()
Return whether the undo tablespace is empty and ready to be dropped.
Definition: trx0undo_trunc.h:419
bool is_inactive_implicit()
Return whether the undo tablespace is inactive due to implicit selection by the purge thread.
Definition: trx0undo_trunc.h:393
void set_space_name(const char *new_space_name)
Replace the standard undo space name if it exists with a copy of the undo tablespace name provided.
Definition: trx0undo_trunc.cc:262
bool is_active()
Return whether the undo tablespace is active.
Definition: trx0undo_trunc.h:350
void set_file_name(const char *file_name)
Replace the standard undo file name if it exists with a copy of the file name provided.
Definition: trx0undo_trunc.cc:275
void set_inactive_implicit(space_id_t *marked_space_id)
Set the state of the rollback segments in this undo tablespace to inactive_implicit if currently acti...
Definition: trx0undo_trunc.h:441
void set_space_id(space_id_t space_id)
Change the space_id from its current value.
Definition: trx0undo_trunc.cc:257
space_id_t num()
Get the undo tablespace number.
Definition: trx0undo_trunc.h:322
void set_active()
Set the undo tablespace active for use by transactions.
Definition: trx0undo_trunc.h:430
trx_rseg_t * get_active(ulint slot)
Return the rseg at the requested rseg slot if the undo space is active.
Definition: trx0undo_trunc.h:373
char * log_file_name()
Get the undo log filename.
Definition: trx0undo_trunc.h:307
bool needs_truncation()
Definition: trx0undo_trunc.cc:215
Tablespace(Tablespace &other)
Copy Constructor.
Definition: trx0undo_trunc.h:202
Rsegs * m_rsegs
List of rollback segments within this tablespace.
Definition: trx0undo_trunc.h:501
bool truncate_in_progress
True if truncation of this undo tablespace is in progress.
Definition: trx0undo_trunc.h:505
bool is_active_no_latch()
Return whether the undo tablespace is active.
Definition: trx0undo_trunc.h:363
bool m_new
True if this undo tablespace was implicitly created when this instance started up.
Definition: trx0undo_trunc.h:485
char * make_log_file_name(space_id_t space_id, const char *location)
Build a log file name based on space_id.
Definition: trx0undo_trunc.cc:310
void set_inactive_explicit()
Make the undo tablespace inactive so that it will not be used for new transactions.
Definition: trx0undo_trunc.h:454
bool is_explicit()
Report whether this undo tablespace was explicitly created by an SQL statement.
Definition: trx0undo_trunc.h:336
bool is_new()
Report whether this undo tablespace was created at startup.
Definition: trx0undo_trunc.h:343
Tablespace(space_id_t id)
Constructor.
Definition: trx0undo_trunc.h:191
bool rw_lock_own(const rw_lock_t *lock, ulint lock_type)
Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0.
Definition: sync0rw.cc:858
static void rw_lock_s_unlock(rw_lock_t *L)
Definition: sync0rw.h:807
static void rw_lock_x_lock(rw_lock_t *M, ut::Location L)
Definition: sync0rw.h:781
static void rw_lock_s_lock(rw_lock_t *M, ut::Location L)
Definition: sync0rw.h:730
static void rw_lock_x_unlock(rw_lock_t *L)
Definition: sync0rw.h:810
@ RW_LOCK_S
Definition: sync0types.h:203
@ RW_LOCK_X
Definition: sync0types.h:204
unsigned long int ulint
Definition: univ.i:403
constexpr space_id_t SPACE_UNKNOWN
Unknown space id.
Definition: univ.i:452
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:109
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:97
#define UT_NEW_THIS_FILE_PSI_KEY
Definition: ut0new.h:408
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:510
int n
Definition: xcom_base.cc:509