24#ifndef RPL_GTID_H_INCLUDED
25#define RPL_GTID_H_INCLUDED
68#define BINLOG_ERROR(MYSQLBINLOG_ERROR, SERVER_ERROR) error MYSQLBINLOG_ERROR
70#define BINLOG_ERROR(MYSQLBINLOG_ERROR, SERVER_ERROR) my_error SERVER_ERROR
84#define SKIP_WHITESPACE() \
85 while (my_isspace(&my_charset_utf8mb3_general_ci, *s)) s++
93#undef NON_DISABLED_GTID
118class Locked_sidno_set;
166#define __CHECK_RETURN_STATUS(STATUS, ACTION, STATUS_NAME, ALLOW_UNREPORTED)
169 const char *status_name,
int allow_unreported);
170#define __CHECK_RETURN_STATUS(STATUS, ACTION, STATUS_NAME, ALLOW_UNREPORTED) \
171 check_return_status(STATUS, ACTION, STATUS_NAME, ALLOW_UNREPORTED);
178#define __PROPAGATE_ERROR(STATUS, RETURN_VALUE, ALLOW_UNREPORTED) \
180 enum_return_status __propagate_error_status = STATUS; \
181 if (__propagate_error_status != RETURN_STATUS_OK) { \
182 __CHECK_RETURN_STATUS(__propagate_error_status, "Propagating", #STATUS, \
184 return RETURN_VALUE; \
188#define __RETURN_STATUS(STATUS, ALLOW_UNREPORTED) \
190 enum_return_status __return_status_status = STATUS; \
191 __CHECK_RETURN_STATUS(__return_status_status, "Returning", #STATUS, \
193 return __return_status_status; \
199#define PROPAGATE_ERROR(STATUS) \
200 __PROPAGATE_ERROR(STATUS, __propagate_error_status, true)
206#define PROPAGATE_REPORTED_ERROR(STATUS) \
207 __PROPAGATE_ERROR(STATUS, __propagate_error_status, false)
213#define PROPAGATE_REPORTED_ERROR_INT(STATUS) __PROPAGATE_ERROR(STATUS, 1, false)
218#define RETURN_STATUS(STATUS) __RETURN_STATUS(STATUS, true)
224#define RETURN_REPORTED_STATUS(STATUS) __RETURN_STATUS(STATUS, false)
226#define RETURN_OK return RETURN_STATUS_OK
228#define RETURN_REPORTED_ERROR RETURN_STATUS(RETURN_STATUS_REPORTED_ERROR)
230#define RETURN_UNREPORTED_ERROR RETURN_STATUS(RETURN_STATUS_UNREPORTED_ERROR)
337 m_is_write_lock =
false;
339#if defined(HAVE_PSI_INTERFACE)
392 std::adopt_lock_t t [[maybe_unused]])
397 lock.assert_some_rdlock();
400 lock.assert_some_wrlock();
502 m_is_write_lock =
true;
518 m_is_write_lock =
false;
531 return m_is_write_lock;
547 m_is_write_lock =
true;
603 bool m_is_write_lock;
710 static std::pair<bool, value_type>
from_string(std::string s);
775 using Tsid_ref = std::reference_wrapper<const Tsid>;
1010 inline bool wait(
const THD *thd,
int sidno,
struct timespec *abstime)
const {
1017 if (abstime !=
nullptr)
1031 inline int get_max_index() const {
1033 return static_cast<int>(
m_array.size() - 1);
1055 bool is_thd_killed(
const THD *thd)
const;
1064 assert(
n <= get_max_index());
1116 assert(sidno_arg > 0);
1117 assert(gno_arg > 0);
1144 static bool is_valid(
const char *text);
1164 bool need_lock =
false)
const;
1184 static std::pair<Tag, std::size_t>
parse_tag_str(
const char *text,
1195 static std::pair<mysql::utils::Return_status, mysql::gtid::Gtid>
1206 printf(
"%s\n",
buf);
1211 const char *text [[maybe_unused]] =
"",
1212 bool need_lock [[maybe_unused]] =
false)
const {
1216 DBUG_PRINT(
"info", (
"%s%s%s", text, *text ?
": " :
"",
buf));
1230 static std::size_t
skip_whitespace(
const char *text, std::size_t pos);
1240 static std::tuple<mysql::utils::Return_status, rpl_sid, std::size_t>
1249 static std::tuple<mysql::utils::Return_status, rpl_gno, std::size_t>
1258 static std::pair<mysql::utils::Return_status, std::size_t>
1318 uint *gtid_length_arg,
1339 uint *gtid_length_arg,
1368 Tsid_map *tsid_map,
char *gtid_arg, uint *gtid_length_arg,
1370 ulonglong *start_time_arg, uint *last_transient_errno_arg,
1371 char *last_transient_errmsg_arg, uint *last_transient_errmsg_length_arg,
1372 ulonglong *last_transient_timestamp_arg, ulong *retries_count_arg)
const;
1401 Tsid_map *tsid_map,
char *gtid_arg, uint *gtid_length_arg,
1404 uint *last_transient_errno_arg,
char *last_transient_errmsg_arg,
1405 uint *last_transient_errmsg_length_arg,
1406 ulonglong *last_transient_timestamp_arg, ulong *retries_count_arg)
const;
1491 ulonglong immediate_ts_arg,
bool skipped_arg =
false);
1494 size_t uncompressed_size);
1532 const char *transient_err_message_arg,
1533 ulong trans_retries_arg);
1737 bool *starts_with_plus =
nullptr);
1756 size_t *actual_length =
nullptr);
1857 while (ivit.
get() !=
nullptr) {
1869 std::size_t
count{0};
1871 for (
rpl_sidno sidno = 1; sidno <= max_sidno; sidno++) {
1891 return ivit.
get() !=
nullptr;
1897 static bool is_valid(
const char *text);
1983 printf(
"%s\n",
str ?
str :
"out of memory in Gtid_set::print");
2001 bool need_lock [[maybe_unused]] =
false,
2003 [[maybe_unused]] =
nullptr)
const {
2007 DBUG_PRINT(
"info", (
"%s%s'%s'", text, *text ?
": " :
"",
2008 str ?
str :
"out of memory in Gtid_set::dbug_print"));
2080 template <
typename Gt
id_set_p,
typename Interval_p>
2091 init(gtid_set, sidno);
2095 p =
const_cast<Interval_p *
>(>id_set->free_intervals);
2099 p =
const_cast<Interval_p *
>(>id_set->m_intervals[sidno - 1]);
2103 assert(*
p !=
nullptr);
2104 p =
const_cast<Interval_p *
>(&(*p)->next);
2107 inline Interval_p
get()
const {
return *
p; }
2161 assert(
get() !=
nullptr);
2196 if (iv ==
nullptr) {
2199 if (
sidno == 0)
return;
2224 }
while (iv ==
nullptr);
2261 bool skip_tagged_gtids)
const;
2298 while (ivit.
get() !=
nullptr) {
2309 for (
rpl_sidno sidno = 1; sidno < max_sidno; sidno++)
2321 bool skip_tagged_gtids)
const;
2421 Free_intervals_lock *
lock);
2444 Free_intervals_lock *
lock);
2461 Free_intervals_lock *
lock);
2478 Free_intervals_lock *
lock);
2483 Const_interval_iterator *super);
2486 Const_interval_iterator *ivit2);
2513#ifdef FRIEND_OF_GTID_SET
2514 friend FRIEND_OF_GTID_SET;
2662 if (sidno > max_sidno)
continue;
2663 bool printed_sid =
false;
2664 for (
const auto &key_and_value : *
get_hash(sidno)) {
2665 Node *node = key_and_value.second.get();
2666 assert(node !=
nullptr);
2671 p += sprintf(
p,
":%" PRId64
"#%u", node->
gno, node->
owner);
2675 return (
int)(
p - out);
2686 for (
rpl_sidno sidno = 1; sidno <= max_sidno; sidno++) {
2687 size_t records =
get_hash(sidno)->size();
2702 while (node !=
nullptr) {
2703 if (node->
owner == thd_id)
return true;
2718 assert(
str !=
nullptr);
2725 printf(
"%s\n",
str);
2736 DBUG_PRINT(
"info", (
"%s%s%s", text, *text ?
": " :
"",
str));
2797 assert(
hash !=
nullptr);
2800 assert(
node !=
nullptr);
3017 (
"atomic_anonymous_gtid_count increased to %d", new_value));
3018 assert(new_value >= 1);
3032 (
"atomic_anonymous_gtid_count decreased to %d", new_value));
3033 assert(new_value >= 0);
3054 (
"ongoing_automatic_gtid_violating_transaction_count increased to %d",
3056 assert(new_value >= 1);
3076 (
"ongoing_automatic_gtid_violating_transaction_count decreased to %d",
3078 assert(new_value >= 0);
3102 DBUG_PRINT(
"info", (
"atomic_anonymous_gtid_violation_count increased to %d",
3104 assert(new_value >= 1);
3124 (
"ongoing_anonymous_gtid_violating_transaction_count decreased to %d",
3126 assert(new_value >= 0);
3151 DBUG_PRINT(
"info", (
"atomic_gtid_wait_count changed from %d to %d",
3152 new_value - 1, new_value));
3153 assert(new_value >= 1);
3168 DBUG_PRINT(
"info", (
"atomic_gtid_wait_count changed from %d to %d",
3169 new_value + 1, new_value));
3170 assert(new_value >= 0);
3294 bool update_thd_status =
true);
3301 struct timespec *abstime =
nullptr);
3317 bool update_thd_status =
true);
3435 p += sprintf(
p,
"Executed GTIDs:\n");
3437 p += sprintf(
p,
"\nOwned GTIDs:\n");
3439 p += sprintf(
p,
"\nLost GTIDs:\n");
3441 p += sprintf(
p,
"\nGTIDs only_in_table:\n");
3443 return (
int)(
p -
buf);
3467 DBUG_PRINT(
"info", (
"%s%s%s", text, *text ?
": " :
"",
str));
3567#ifdef HAVE_GTID_NEXT_LIST
3569 void lock_owned_sidnos(
const THD *thd);
3617#ifdef FRIEND_OF_GTID_STATE
3618 friend FRIEND_OF_GTID_STATE;
4120 static bool is_valid(
const char *text);
4124 static bool is_tagged(
const char *text);
4139 bool need_lock =
false)
const;
4156 printf(
"%s\n",
buf);
4164 bool need_lock [[maybe_unused]] =
false)
const {
4168 DBUG_PRINT(
"info", (
"%s%s%s", text, *text ?
": " :
"",
buf));
4173static_assert(std::is_trivial_v<Gtid_specification>);
4174static_assert(std::is_standard_layout_v<Gtid_specification>);
4281#ifdef HAVE_GTID_NEXT_LIST
4282int gtid_acquire_ownership_multiple(
THD *thd);
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
RAII class to acquire a lock for the duration of a block.
Definition: rpl_gtid.h:359
void unlock_if_locked()
Unlock the lock, if it was acquired by this guard.
Definition: rpl_gtid.h:467
Guard(Checkable_rwlock &lock, enum_lock_type lock_type)
Create a guard, and optionally acquire a lock on it.
Definition: rpl_gtid.h:367
Checkable_rwlock & m_lock
Definition: rpl_gtid.h:360
Guard(Checkable_rwlock &lock, enum_lock_type lock_type, std::adopt_lock_t t)
Create a guard, assuming the caller already holds a lock on it.
Definition: rpl_gtid.h:391
bool is_locked() const
Return true if this object is either read locked or write locked.
Definition: rpl_gtid.h:482
bool is_wrlocked() const
Return true if this object is write locked.
Definition: rpl_gtid.h:479
int tryrdlock()
Try to acquire a read lock, and fail if it cannot be immediately granted.
Definition: rpl_gtid.h:451
enum_lock_type m_lock_type
Definition: rpl_gtid.h:361
Guard(Guard const ©)=delete
Objects of this class should not be copied or moved.
void unlock()
Unlock the lock.
Definition: rpl_gtid.h:460
void rdlock()
Acquire the read lock.
Definition: rpl_gtid.h:420
Guard(Guard const &©)=delete
bool is_rdlocked() const
Return true if this object is read locked.
Definition: rpl_gtid.h:476
~Guard()
Unlock on destruct.
Definition: rpl_gtid.h:414
Checkable_rwlock & get_lock() const
Return the underlying Checkable_rwlock object.
Definition: rpl_gtid.h:473
int trywrlock()
Try to acquire the write lock, and fail if it cannot be immediately granted.
Definition: rpl_gtid.h:439
void wrlock()
Acquire the write lock.
Definition: rpl_gtid.h:428
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:325
int32 get_state() const
Read lock_state atomically and return the value.
Definition: rpl_gtid.h:598
void assert_no_rdlock() const
Assert that no thread holds the read lock.
Definition: rpl_gtid.h:580
int trywrlock()
Return 0 if the write lock is held, otherwise an error will be returned.
Definition: rpl_gtid.h:538
enum_lock_type
Definition: rpl_gtid.h:348
@ TRY_READ_LOCK
Definition: rpl_gtid.h:352
@ TRY_WRITE_LOCK
Definition: rpl_gtid.h:353
@ WRITE_LOCK
Definition: rpl_gtid.h:351
@ READ_LOCK
Definition: rpl_gtid.h:350
@ NO_LOCK
Definition: rpl_gtid.h:349
void rdlock()
Acquire the read lock.
Definition: rpl_gtid.h:486
void wrlock()
Acquire the write lock.
Definition: rpl_gtid.h:495
std::atomic< int32 > m_lock_state
The state of the lock: 0 - not locked -1 - write locked >0 - read locked by that many threads.
Definition: rpl_gtid.h:596
void assert_no_lock() const
Assert that no thread holds read or write lock.
Definition: rpl_gtid.h:582
int tryrdlock()
Return 0 if the read lock is held, otherwise an error will be returned.
Definition: rpl_gtid.h:557
~Checkable_rwlock()
Destroy this Checkable_lock.
Definition: rpl_gtid.h:346
void assert_no_wrlock() const
Assert that no thread holds the write lock.
Definition: rpl_gtid.h:578
void assert_some_lock() const
Assert that some thread holds either the read or the write lock.
Definition: rpl_gtid.h:572
Checkable_rwlock(PSI_rwlock_key psi_key=0)
Initialize this Checkable_rwlock.
Definition: rpl_gtid.h:328
void assert_some_rdlock() const
Assert that some thread holds the read lock.
Definition: rpl_gtid.h:574
void unlock()
Release the lock (whether it is a write or read lock).
Definition: rpl_gtid.h:506
bool m_dbug_trace
If enabled, print any lock/unlock operations to the DBUG trace.
Definition: rpl_gtid.h:587
bool is_wrlock()
Return true if the write lock is held.
Definition: rpl_gtid.h:526
void assert_some_wrlock() const
Assert that some thread holds the write lock.
Definition: rpl_gtid.h:576
mysql_rwlock_t m_rwlock
The rwlock.
Definition: rpl_gtid.h:607
Class to access the value of @global.gtid_mode in an efficient and thread-safe manner.
Definition: rpl_gtid.h:617
static std::pair< bool, value_type > from_string(std::string s)
Return the given string gtid_mode as an enumeration value.
Definition: rpl_gtid_mode.cc:56
static ulong sysvar_mode
The sys_var framework needs a variable of type ulong to store the value in.
Definition: rpl_gtid.h:630
std::atomic< int > m_atomic_mode
Definition: rpl_gtid.h:619
const char * get_string() const
Return the current gtid_mode as a string.
Definition: rpl_gtid_mode.cc:53
Gtid_mode()
Definition: rpl_gtid.h:622
static const char * names[]
Strings holding the enumeration values for gtid_mode.
Definition: rpl_gtid.h:662
void set(value_type value)
Set a new value for @global.gtid_mode.
Definition: rpl_gtid_mode.cc:44
value_type get() const
Return the current gtid_mode as an enumeration value.
Definition: rpl_gtid_mode.cc:48
static const char * to_string(value_type value)
Return the given gtid_mode as a string.
Definition: rpl_gtid_mode.cc:68
static Checkable_rwlock lock
Protects updates to @global.gtid_mode.
Definition: rpl_gtid.h:673
value_type
Possible values for @global.gtid_mode.
Definition: rpl_gtid.h:633
@ ON_PERMISSIVE
New transactions are GTID-transactions.
Definition: rpl_gtid.h:649
@ OFF
New transactions are anonymous.
Definition: rpl_gtid.h:638
@ OFF_PERMISSIVE
New transactions are anonyomus.
Definition: rpl_gtid.h:644
@ ON
New transactions are GTID-transactions.
Definition: rpl_gtid.h:655
@ DEFAULT
Definition: rpl_gtid.h:639
Stores information to monitor a transaction during the different replication stages.
Definition: rpl_gtid.h:1413
Trx_monitoring_info * last_processed_trx
Holds information about the last processed transaction.
Definition: rpl_gtid.h:1433
const Gtid * get_processing_trx_gtid()
Returns the GTID of the processing_trx.
Definition: rpl_gtid_misc.cc:602
void update(mysql::binlog::event::compression::type t, size_t payload_size, size_t uncompressed_size)
Definition: rpl_gtid_misc.cc:515
void clear()
Clear all monitoring information.
Definition: rpl_gtid_misc.cc:496
void finish()
Sets the final information, copy processing info to last_processed and clears processing info.
Definition: rpl_gtid_misc.cc:563
void start(Gtid gtid_arg, ulonglong original_ts_arg, ulonglong immediate_ts_arg, bool skipped_arg=false)
Sets the initial monitoring information.
Definition: rpl_gtid_misc.cc:523
~Gtid_monitoring_info()
Destroy this GTID monitoring info object.
Definition: rpl_gtid_misc.cc:455
Trx_monitoring_info * processing_trx
Holds information about transaction being processed.
Definition: rpl_gtid.h:1431
void atomic_lock()
Lock this object when no thread mutex is used to arbitrate the access.
Definition: rpl_gtid_misc.cc:460
void atomic_unlock()
Unlock this object when no thread mutex is used to arbitrate the access.
Definition: rpl_gtid_misc.cc:485
mysql_mutex_t * atomic_mutex
Mutex arbitrating the atomic access to the object.
Definition: rpl_gtid.h:1450
void copy_info_to(Trx_monitoring_info *processing_dest, Trx_monitoring_info *last_processed_dest)
Copies both processing_trx and last_processed_trx info to other Trx_monitoring_info structures.
Definition: rpl_gtid_misc.cc:580
std::atomic< bool > atomic_locked
The atomic locked flag.
Definition: rpl_gtid.h:1453
bool is_processing_trx_set()
Returns true if the processing_trx is set, false otherwise.
Definition: rpl_gtid_misc.cc:593
bool is_locked
Flag to assert the atomic lock behavior.
Definition: rpl_gtid.h:1456
void store_transient_error(uint transient_errno_arg, const char *transient_err_message_arg, ulong trans_retries_arg)
Stores the information about the last transient error in the current transaction, namely: the error n...
Definition: rpl_gtid_misc.cc:611
Gtid_monitoring_info(mysql_mutex_t *atomic_mutex_arg=nullptr)
Create this GTID monitoring info object.
Definition: rpl_gtid_misc.cc:449
void clear_last_processed_trx()
Clear only the last_processed_trx monitoring info.
Definition: rpl_gtid_misc.cc:509
void clear_processing_trx()
Clear only the processing_trx monitoring info.
Definition: rpl_gtid_misc.cc:503
Iterator over intervals of a const Gtid_set.
Definition: rpl_gtid.h:2122
Const_interval_iterator(const Gtid_set *gtid_set)
Create this Const_interval_iterator.
Definition: rpl_gtid.h:2129
Const_interval_iterator(const Gtid_set *gtid_set, rpl_sidno sidno)
Create this Const_interval_iterator.
Definition: rpl_gtid.h:2125
Class representing a lock on free_intervals_mutex.
Definition: rpl_gtid.h:2372
bool locked
Definition: rpl_gtid.h:2396
void unlock_if_locked()
Lock the lock if it is locked.
Definition: rpl_gtid.h:2385
Free_intervals_lock(Gtid_set *_gtid_set)
Create a new lock, but do not acquire it.
Definition: rpl_gtid.h:2375
~Free_intervals_lock()
Destroy this object and unlock the lock if it is locked.
Definition: rpl_gtid.h:2392
void lock_if_not_locked()
Lock the lock if it is not already locked.
Definition: rpl_gtid.h:2378
Gtid_set * gtid_set
Definition: rpl_gtid.h:2395
Iterator over all gtids in a Gtid_set.
Definition: rpl_gtid.h:2180
Gtid get() const
Return next gtid, or {0,0} if we reached the end.
Definition: rpl_gtid.h:2206
rpl_sidno sidno
The SIDNO of the current element, or 0 if the iterator is past the last element.
Definition: rpl_gtid.h:2233
const Gtid_set * gtid_set
The Gtid_set we iterate over.
Definition: rpl_gtid.h:2228
void next()
Advance to next gtid.
Definition: rpl_gtid.h:2187
rpl_gno gno
The GNO of the current element, or 0 if the iterator is past the last element.
Definition: rpl_gtid.h:2238
Const_interval_iterator ivit
Iterator over the intervals for the current SIDNO.
Definition: rpl_gtid.h:2240
Gtid_iterator(const Gtid_set *gs)
Definition: rpl_gtid.h:2182
void next_sidno()
Find the next sidno that has one or more intervals.
Definition: rpl_gtid.h:2213
Iterator over intervals for a given SIDNO.
Definition: rpl_gtid.h:2081
Interval_p get() const
Return current_elem.
Definition: rpl_gtid.h:2107
void init(Gtid_set_p gtid_set, rpl_sidno sidno)
Reset this iterator.
Definition: rpl_gtid.h:2098
Interval_iterator_base(Gtid_set_p gtid_set, rpl_sidno sidno)
Construct a new iterator over the GNO intervals for a given Gtid_set.
Definition: rpl_gtid.h:2089
Interval_p * p
Holds the address of the 'next' pointer of the previous element, or the address of the initial pointe...
Definition: rpl_gtid.h:2115
Interval_iterator_base(Gtid_set_p gtid_set)
Construct a new iterator over the free intervals of a Gtid_set.
Definition: rpl_gtid.h:2094
void next()
Advance current_elem one step.
Definition: rpl_gtid.h:2102
Iterator over intervals of a non-const Gtid_set, with additional methods to modify the Gtid_set.
Definition: rpl_gtid.h:2139
Interval_iterator(Gtid_set *gtid_set)
Destroy this Interval_iterator.
Definition: rpl_gtid.h:2145
void set(Interval *iv)
Set current_elem to the given Interval but do not touch the next pointer of the given Interval.
Definition: rpl_gtid.h:2153
void insert(Interval *iv)
Insert the given element before current_elem.
Definition: rpl_gtid.h:2155
void remove(Gtid_set *gtid_set)
Remove current_elem.
Definition: rpl_gtid.h:2160
Interval_iterator(Gtid_set *gtid_set, rpl_sidno sidno)
Create this Interval_iterator.
Definition: rpl_gtid.h:2142
Represents a set of GTIDs.
Definition: rpl_gtid.h:1557
void put_free_interval(Interval *iv)
Puts the given interval in the list of free intervals.
Definition: rpl_gtid_set.cc:268
rpl_gno get_last_gno(rpl_sidno sidno) const
Definition: rpl_gtid_set.cc:770
bool is_size_greater_than_or_equal(ulonglong num) const
Return true if the size of the set is greater than or equal to the given number.
Definition: rpl_gtid_set.cc:1337
bool is_intersection_nonempty(const Gtid_set *other) const
Returns true if there is a least one element of this Gtid_set in the other Gtid_set.
Definition: rpl_gtid_set.cc:1257
bool is_subset(const Gtid_set *super) const
Returns true if this Gtid_set is a subset of the other Gtid_set.
Definition: rpl_gtid_set.cc:1177
void add_interval_memory(int n_intervals, Interval *intervals_param)
Provides an array of Intervals that this Gtid_set can use when gtids are subsequently added.
Definition: rpl_gtid.h:2064
bool contains_sidno(rpl_sidno sidno) const
Returns true if this Gtid_set contains at least one GTID with the given SIDNO.
Definition: rpl_gtid.h:1887
void encode(uchar *buf, bool skip_tagged_gtids=false) const
Encodes this Gtid_set as a binary string.
Definition: rpl_gtid_set.cc:1388
Gtid_set(Tsid_map *tsid_map, Checkable_rwlock *tsid_lock=nullptr)
Constructs a new, empty Gtid_set.
Definition: rpl_gtid_set.cc:87
int get_n_intervals() const
Return the number of intervals in this Gtid_set.
Definition: rpl_gtid.h:2305
bool sidno_equals(rpl_sidno sidno, const Gtid_set *other, rpl_sidno other_sidno) const
Return true if the given sidno of this Gtid_set contains the same intervals as the given sidno of the...
Definition: rpl_gtid_set.cc:1000
friend std::ostream & operator<<(std::ostream &os, const Gtid_set &in)
For use with C++ std::ostream
Definition: rpl_gtid.h:1988
void add_gno_intervals(rpl_sidno sidno, Const_interval_iterator ivit, Free_intervals_lock *lock)
Adds a list of intervals to the given SIDNO.
Definition: rpl_gtid_set.cc:660
std::size_t get_count() const
Returns the number of GTIDs.
Definition: rpl_gtid.h:1866
static bool is_interval_subset(Const_interval_iterator *sub, Const_interval_iterator *super)
Returns true if every interval of sub is a subset of some interval of super.
Definition: rpl_gtid_set.cc:1073
void init()
Worker for the constructor.
Definition: rpl_gtid_set.cc:115
static const int CHUNK_GROW_SIZE
The default number of intervals in an Interval_chunk.
Definition: rpl_gtid.h:2280
Interval_chunk * chunks
Linked list of chunks.
Definition: rpl_gtid.h:2498
static const String_format commented_string_format
String_format for printing the Gtid_set commented: the string is not quote-wrapped,...
Definition: rpl_gtid.h:2032
bool contains_gtid(rpl_sidno sidno, rpl_gno gno) const
Return true iff the given GTID exists in this set.
Definition: rpl_gtid_set.cc:752
enum_return_status ensure_sidno(rpl_sidno sidno)
Allocates space for all sidnos up to the given sidno in the array of intervals.
Definition: rpl_gtid_set.cc:145
Tsid_map * tsid_map
Tsid_map associated with this Gtid_set.
Definition: rpl_gtid.h:2489
int get_n_intervals(rpl_sidno sidno) const
Return the number of intervals for the given sidno.
Definition: rpl_gtid.h:2295
bool contains_tags() const
Checks if this Gtid set contains any tagged GTIDs.
Definition: rpl_gtid_set.cc:925
void clear_set_and_tsid_map()
Removes all gtids from this Gtid_set and clear all the sidnos used by the Gtid_set and it's TSID map.
Definition: rpl_gtid_set.cc:301
enum_return_status add_gtid_set(const Gtid_set *other)
Adds all gtids from the given Gtid_set to this Gtid_set.
Definition: rpl_gtid_set.cc:695
Interval * free_intervals
Linked list of free intervals.
Definition: rpl_gtid.h:2496
bool contains_gtid(const Gtid >id) const
Return true iff the given GTID exists in this set.
Definition: rpl_gtid.h:1760
static const String_format default_string_format
The default String_format: the format understood by add_gtid_text(const char *).
Definition: rpl_gtid.h:2022
void add_interval_memory_lock_taken(int n_ivs, Interval *ivs)
Like add_interval_memory, but does not acquire free_intervals_mutex.
Definition: rpl_gtid_set.cc:193
void remove_gtid_set(const Gtid_set *other)
Removes all gtids in the given Gtid_set from this Gtid_set.
Definition: rpl_gtid_set.cc:726
void print(bool need_lock=false, const Gtid_set::String_format *sf=nullptr) const
Debug only: Print this Gtid_set to stdout.
Definition: rpl_gtid.h:1979
Prealloced_array< Interval *, 8 > m_intervals
Array where the N'th element contains the head pointer to the intervals of SIDNO N+1.
Definition: rpl_gtid.h:2494
mysql_mutex_t free_intervals_mutex
Lock protecting the list of free intervals.
Definition: rpl_gtid.h:2358
void dbug_print(const char *text="", bool need_lock=false, const Gtid_set::String_format *sf=nullptr) const
Print this Gtid_set to the trace file if debug is enabled; no-op otherwise.
Definition: rpl_gtid.h:2000
int n_chunks
The number of chunks.
Definition: rpl_gtid.h:2510
void remove_gno_intervals(rpl_sidno sidno, Const_interval_iterator ivit, Free_intervals_lock *lock)
Removes a list of intervals from the given SIDNO.
Definition: rpl_gtid_set.cc:673
static bool is_valid(const char *text)
Returns true if the given string is a valid specification of a Gtid_set, false otherwise.
Definition: rpl_gtid_set.cc:607
void clear()
Removes all gtids from this Gtid_set.
Definition: rpl_gtid_set.cc:276
static bool is_interval_intersection_nonempty(Const_interval_iterator *ivit1, Const_interval_iterator *ivit2)
Returns true if at least one sidno in ivit1 is also in ivit2.
Definition: rpl_gtid_set.cc:1220
bool is_subset_for_sid(const Gtid_set *super, const rpl_sid &sid) const
Returns true if this Gtid_set is a subset of the given gtid_set with respect to the given sid.
Definition: rpl_gtid_set.cc:1114
enum_return_status intersection(const Gtid_set *other, Gtid_set *result)
Add the intersection of this Gtid_set and the other Gtid_set to result.
Definition: rpl_gtid_set.cc:1311
void remove_gno_interval(Interval_iterator *ivitp, rpl_gno start, rpl_gno end, Free_intervals_lock *lock)
Removes the interval (start, end) from the given Interval_iterator.
Definition: rpl_gtid_set.cc:363
void get_gtid_intervals(std::list< Gtid_interval > *gtid_intervals) const
Gets all gtid intervals from this Gtid_set.
Definition: rpl_gtid_set.cc:884
bool is_subset_not_equals(const Gtid_set *super) const
Returns true if this Gtid_set is a non equal subset of the other Gtid_set.
Definition: rpl_gtid.h:1787
enum_return_status add_gtid(const mysql::gtid::Gtid >id)
Adds specified GTID (TSID+GNO) to this Gtid_set.
Definition: rpl_gtid_set.cc:437
size_t get_string_length(const String_format *string_format=nullptr) const
Returns the length of the output from to_string.
Definition: rpl_gtid_set.cc:942
size_t cached_string_length
The string length.
Definition: rpl_gtid.h:2502
enum_return_status add_gtid_text(const char *text, bool *anonymous=nullptr, bool *starts_with_plus=nullptr)
Adds the set of GTIDs represented by the given string to this Gtid_set.
Definition: rpl_gtid_set.cc:451
void add_gno_interval(Interval_iterator *ivitp, rpl_gno start, rpl_gno end, Free_intervals_lock *lock)
Adds the interval (start, end) to the given Interval_iterator.
Definition: rpl_gtid_set.cc:314
size_t get_encoded_length(bool skip_tagged_gtids=false) const
Returns the length of this Gtid_set when encoded using the encode() function.
Definition: rpl_gtid_set.cc:1557
void _add_gtid(rpl_sidno sidno, rpl_gno gno)
Adds the given GTID to this Gtid_set.
Definition: rpl_gtid.h:1627
bool is_empty() const
Returns true if this Gtid_set is empty.
Definition: rpl_gtid.h:1831
static PSI_mutex_key key_gtid_executed_free_intervals_mutex
Definition: rpl_gtid.h:1559
static const String_format sql_string_format
String_format useful to generate an SQL string: the string is wrapped in single quotes and there is a...
Definition: rpl_gtid.h:2027
bool equals(const Gtid_set *other) const
Returns true if this Gtid_set is equal to the other Gtid_set.
Definition: rpl_gtid_set.cc:1018
enum_return_status add_gtid_encoding(const uchar *encoded, size_t length, size_t *actual_length=nullptr)
Decodes a Gtid_set from the given string.
Definition: rpl_gtid_set.cc:1439
void remove_intervals_for_sidno(Gtid_set *other, rpl_sidno sidno)
Removes all intervals of 'other' for a given SIDNO, from 'this'.
Definition: rpl_gtid_set.cc:687
bool is_subset_for_sidno(const Gtid_set *super, rpl_sidno superset_sidno, rpl_sidno subset_sidno) const
Returns true if this Gtid_set is a subset of the given gtid_set on the given superset_sidno and subse...
Definition: rpl_gtid_set.cc:1139
~Gtid_set()
Destroy this Gtid_set.
Definition: rpl_gtid_set.cc:130
void claim_memory_ownership(bool claim)
Claim ownership of memory.
Definition: rpl_gtid_set.cc:104
bool has_cached_string_length
If the string is cached.
Definition: rpl_gtid.h:2500
const String_format * cached_string_format
The String_format that was used when cached_string_length was computed.
Definition: rpl_gtid.h:2504
void get_free_interval(Interval **out)
Returns a fresh new Interval object.
Definition: rpl_gtid_set.cc:255
size_t to_string(char *buf, bool need_lock=false, const String_format *string_format=nullptr) const
Formats this Gtid_set as a string and saves in a given buffer.
Definition: rpl_gtid_set.cc:807
void _remove_gtid(const Gtid >id)
Removes the given GTID from this Gtid_set.
Definition: rpl_gtid.h:1665
Checkable_rwlock * tsid_lock
Read-write lock that protects updates to the number of TSIDs.
Definition: rpl_gtid.h:2353
mysql::gtid::Gtid_format analyze_encoding_format(bool skip_tagged_gtids) const
Goes through recorded tsids.
Definition: rpl_gtid_set.cc:1521
void _remove_gtid(rpl_sidno sidno, rpl_gno gno)
Removes the given GTID from this Gtid_set.
Definition: rpl_gtid.h:1643
Tsid_map * get_tsid_map() const
Return the Tsid_map associated with this Gtid_set.
Definition: rpl_gtid.h:2035
void create_new_chunk(int size)
Allocates a new chunk of Intervals and adds them to the list of unused intervals.
Definition: rpl_gtid_set.cc:204
void _add_gtid(const Gtid >id)
Adds the given GTID to this Gtid_set.
Definition: rpl_gtid.h:1659
rpl_sidno get_max_sidno() const
Returns the maximal sidno that this Gtid_set currently has space for.
Definition: rpl_gtid.h:1766
void assert_free_intervals_locked()
Definition: rpl_gtid.h:2398
ulonglong get_gtid_count(rpl_sidno sidno) const
What is the count of all the GTIDs in all intervals for a sidno.
Definition: rpl_gtid.h:1854
Represents the server's GTID state: the set of committed GTIDs, the set of lost gtids,...
Definition: rpl_gtid.h:2875
bool update_gtids_impl_check_skip_gtid_rollback(THD *thd)
Used by unit tests that need to access private members.
Definition: rpl_gtid_state.cc:759
int init()
Add @GLOBAL.SERVER_UUID to this binlog's Tsid_map.
Definition: rpl_gtid_state.cc:651
Tsid_map * tsid_map
The Tsid_map used by this Gtid_state.
Definition: rpl_gtid.h:3578
bool update_gtids_impl_do_nothing(THD *thd)
This is a sub task of update_gtids_impl responsible only to handle the case of a thread that owns not...
Definition: rpl_gtid_state.cc:768
void end_automatic_gtid_violating_transaction()
Decrease the global counter when ending a GTID-violating transaction having GTID_NEXT=AUTOMATIC.
Definition: rpl_gtid.h:3064
void broadcast_owned_sidnos(const THD *thd)
Broadcast the condition for all SIDNOs owned by the given THD.
Definition: rpl_gtid_state.cc:146
const Gtid_set * get_executed_gtids() const
Definition: rpl_gtid.h:3378
void unlock_sidnos(const Gtid_set *set)
Unlocks the mutex for each SIDNO where the given Gtid_set has at least one GTID.
Definition: rpl_gtid_state.cc:547
void print() const
Debug only: print this Gtid_state to stdout.
Definition: rpl_gtid.h:3453
const Gtid_set * get_lost_gtids() const
Return a pointer to the Gtid_set that contains the lost gtids.
Definition: rpl_gtid.h:3373
enum_return_status ensure_sidno()
Ensure that owned_gtids, executed_gtids, lost_gtids, gtids_only_in_table, previous_gtids_logged and t...
Definition: rpl_gtid_state.cc:561
void decrease_gtid_automatic_tagged_count()
Decrements atomic_automatic_tagged_gtid_session_count.
Definition: rpl_gtid.h:3408
void begin_anonymous_gtid_violating_transaction()
Increase the global counter when starting a GTID-violating transaction having GTID_NEXT=ANONYMOUS.
Definition: rpl_gtid.h:3094
const Tsid & get_server_tsid() const
Return the server's TSID.
Definition: rpl_gtid.h:3398
rpl_sidno server_sidno
The SIDNO for this server.
Definition: rpl_gtid.h:3601
bool wait_for_gtid_set(THD *thd, Gtid_set *gtid_set, double timeout, bool update_thd_status=true)
Wait until the given Gtid_set is included in @GLOBAL.GTID_EXECUTED.
Definition: rpl_gtid_state.cc:304
enum_return_status acquire_ownership(THD *thd, const Gtid >id)
Acquires ownership of the given GTID, on behalf of the given thread.
Definition: rpl_gtid_state.cc:80
void update_gtids_impl_own_nothing(THD *thd)
Handle the case that the thread owns nothing.
Definition: rpl_gtid_state.cc:940
void update_gtids_impl_lock_sidno(rpl_sidno sidno)
Lock a given sidno of a transaction being updated.
Definition: rpl_gtid_state.cc:819
std::atomic< int32 > atomic_anonymous_gtid_count
The number of anonymous transactions owned by any client.
Definition: rpl_gtid.h:3604
int save_gtids_of_last_binlog_into_table()
Save the set of gtids logged in the last binlog into gtid_executed table.
Definition: rpl_gtid_state.cc:694
void end_gtid_wait()
Decrease the global counter when ending a call to WAIT_FOR_EXECUTED_GTID_SET.
Definition: rpl_gtid.h:3161
bool is_any_session_assigning_automatic_tagged_gtids()
Checks whether there are ongoing sessions executing transactions with GTID_NEXT set to AUTOMATIC:tag.
Definition: rpl_gtid.h:3416
Gtid_set lost_gtids
The set of GTIDs that existed in some previously purged binary log.
Definition: rpl_gtid.h:3585
const Owned_gtids * get_owned_gtids() const
Return a pointer to the Owned_gtids that contains the owned gtids.
Definition: rpl_gtid.h:3394
void unlock_owned_sidnos(const THD *thd)
Unlock all SIDNOs owned by the given THD.
Definition: rpl_gtid_state.cc:134
Owned_gtids owned_gtids
The set of GTIDs that are owned by some thread.
Definition: rpl_gtid.h:3599
rpl_sidno get_server_sidno() const
Return the server's SIDNO.
Definition: rpl_gtid.h:3396
const Gtid_set * get_previous_gtids_logged() const
Definition: rpl_gtid.h:3390
void update_gtids_impl_broadcast_and_unlock_sidno(rpl_sidno sidno)
Unlock a given sidno after broadcasting its changes.
Definition: rpl_gtid_state.cc:904
Gtid_state(Checkable_rwlock *_tsid_lock, Tsid_map *_tsid_map)
Constructs a new Gtid_state object.
Definition: rpl_gtid.h:2884
int32 get_gtid_wait_count()
Return the number of clients that have an ongoing call to WAIT_FOR_EXECUTED_GTID_SET.
Definition: rpl_gtid.h:3178
char * to_string() const
Debug only: return a newly allocated string, or NULL on out-of-memory.
Definition: rpl_gtid.h:3446
int read_gtid_executed_from_table()
Fetch gtids from gtid_executed table and store them into gtid_executed set.
Definition: rpl_gtid_state.cc:744
Mutex_cond_array tsid_locks
Contains one mutex/cond pair for every SIDNO.
Definition: rpl_gtid.h:3580
Gtid_set previous_gtids_logged
Definition: rpl_gtid.h:3597
std::atomic< int64_t > atomic_automatic_tagged_gtid_session_count
The number of sessions that have GTID_NEXT set to AUTOMATIC with tag assigned.
Definition: rpl_gtid.h:3614
enum_return_status add_lost_gtids(Gtid_set *gtid_set, bool starts_with_plus)
Adds the given Gtid_set to lost_gtids and executed_gtids.
Definition: rpl_gtid_state.cc:607
bool wait_for_sidno(THD *thd, rpl_sidno sidno, struct timespec *abstime, bool update_thd_status=true)
Wait for a signal on the given SIDNO.
Definition: rpl_gtid_state.cc:269
const Gtid_set * get_gtids_only_in_table() const
Definition: rpl_gtid.h:3383
int compress(THD *thd)
Compress the gtid_executed table, read each row by the PK(sid, gno_start) in increasing order,...
Definition: rpl_gtid_state.cc:748
std::unordered_map< rpl_sidno, rpl_gno > next_free_gno_map
The next_free_gno map contains next_free_gno for recorded sidnos.
Definition: rpl_gtid.h:3215
int32 get_anonymous_gtid_violating_transaction_count()
Return the number of ongoing GTID-violating transactions having GTID_NEXT=AUTOMATIC.
Definition: rpl_gtid.h:3136
void lock_sidnos(const Gtid_set *set)
Locks one mutex for each SIDNO where the given Gtid_set has at least one GTID.
Definition: rpl_gtid_state.cc:540
void assert_sidno_lock_owner(rpl_sidno sidno) const
Assert that we own the given SIDNO.
Definition: rpl_gtid.h:3268
enum_return_status ensure_commit_group_sidnos(rpl_sidno sidno)
Ensure that commit_group_sidnos have room for the SIDNO passed as parameter.
Definition: rpl_gtid_state.cc:950
void update_gtids_impl_own_anonymous(THD *thd, bool *more_trx)
Handle the case that the thread owns ANONYMOUS GTID.
Definition: rpl_gtid_state.cc:918
bool wait_for_gtid(THD *thd, const Gtid >id, struct timespec *abstime=nullptr)
This is only a shorthand for wait_for_sidno, which contains additional debug printouts and assertions...
Definition: rpl_gtid_state.cc:292
void acquire_anonymous_ownership()
Acquire anonymous ownership.
Definition: rpl_gtid.h:3008
int warn_or_err_on_modify_gtid_table(THD *thd, Table_ref *table)
Push a warning to client if user is modifying the gtid_executed table explicitly by a non-XA transact...
Definition: rpl_gtid_state.cc:752
void update_on_rollback(THD *thd)
Update the state after the given thread has rollbacked.
Definition: rpl_gtid_state.cc:213
Gtid_set gtids_only_in_table
Definition: rpl_gtid.h:3595
rpl_gno get_automatic_gno(rpl_sidno sidno) const
Computes the next available GNO.
Definition: rpl_gtid_state.cc:415
Gtid_set executed_gtids
Definition: rpl_gtid.h:3590
void update_gtids_impl_own_gtid(THD *thd, bool is_commit)
Handle the case that the thread own a single non-anonymous GTID.
Definition: rpl_gtid_state.cc:846
int32 get_automatic_gtid_violating_transaction_count()
Return the number of ongoing GTID-violating transactions having GTID_NEXT=AUTOMATIC.
Definition: rpl_gtid.h:3086
void dbug_print(const char *text="") const
Print this Gtid_state to the trace file if debug is enabled; no-op otherwise.
Definition: rpl_gtid.h:3463
void update_commit_group(THD *first_thd)
This function updates both the THD and the Gtid_state to reflect that the transaction set of transact...
Definition: rpl_gtid_state.cc:158
void unlock_sidno(rpl_sidno sidno)
Unlocks a mutex for the given SIDNO.
Definition: rpl_gtid.h:3264
bool is_owned(const Gtid >id) const
Returns true if GTID is owned, otherwise returns 0.
Definition: rpl_gtid.h:2941
int to_string(char *buf) const
Debug only: Generate a string in the given buffer and return the length.
Definition: rpl_gtid.h:3433
bool is_executed(const Gtid >id) const
Returns true if the given GTID is logged.
Definition: rpl_gtid.h:2928
Prealloced_array< bool, 8 > commit_group_sidnos
This array is used by Gtid_state_update_gtids_impl* functions.
Definition: rpl_gtid.h:3854
void update_prev_gtids(Gtid_set *write_gtid_set)
Updates previously logged GTID set before writing to table.
Definition: rpl_gtid_state.cc:588
Checkable_rwlock * tsid_lock
Read-write lock that protects updates to the number of TSIDs.
Definition: rpl_gtid.h:3576
void end_gtid_violating_transaction(THD *thd)
Definition: rpl_gtid_state.cc:256
void begin_automatic_gtid_violating_transaction()
Increase the global counter when starting a GTID-violating transaction having GTID_NEXT=AUTOMATIC.
Definition: rpl_gtid.h:3044
rpl_sidno specify_transaction_sidno(THD *thd, Gtid_state::Locked_sidno_set &sidno_set)
Determines sidno for thd transaction.
Definition: rpl_gtid_state.cc:479
void update_gtids_impl_broadcast_and_unlock_sidnos()
Unlocks all locked sidnos after broadcasting their changes.
Definition: rpl_gtid_state.cc:910
void lock_sidno(rpl_sidno sidno)
Locks a mutex for the given SIDNO.
Definition: rpl_gtid.h:3262
void update_gtids_impl_own_gtid_set(THD *thd, bool is_commit)
Handle the case that the thread own a set of GTIDs.
Definition: rpl_gtid_state.cc:791
void broadcast_sidnos(const Gtid_set *set)
Broadcasts the condition variable for each SIDNO where the given Gtid_set has at least one GTID.
Definition: rpl_gtid_state.cc:554
size_t get_max_string_length() const
Debug only: Returns an upper bound on the length of the string generated by to_string(),...
Definition: rpl_gtid.h:3426
std::atomic< int32 > atomic_automatic_gtid_violation_count
The number of GTID-violating transactions that use GTID_NEXT=AUTOMATIC.
Definition: rpl_gtid.h:3606
std::atomic< int32 > atomic_gtid_wait_count
The number of clients that are executing WAIT_FOR_EXECUTED_GTID_SET.
Definition: rpl_gtid.h:3611
void end_anonymous_gtid_violating_transaction()
Decrease the global counter when ending a GTID-violating transaction having GTID_NEXT=ANONYMOUS.
Definition: rpl_gtid.h:3112
rpl_gno get_last_executed_gno(rpl_sidno sidno) const
Return the last executed GNO for a given SIDNO, e.g.
Definition: rpl_gtid_state.cc:468
int clear(THD *thd)
Reset the state and persistor after RESET BINARY LOGS AND GTIDS: remove all logged and lost gtids,...
Definition: rpl_gtid_state.cc:58
std::atomic< int32 > atomic_anonymous_gtid_violation_count
The number of GTID-violating transactions that use GTID_NEXT=AUTOMATIC.
Definition: rpl_gtid.h:3608
void update_on_commit(THD *thd)
Remove the GTID owned by thread from owned GTIDs, stating that thd->owned_gtid was committed.
Definition: rpl_gtid_state.cc:206
void update_gtids_impl_lock_sidnos(THD *thd)
Locks the sidnos of all the GTIDs of the commit group starting on the transaction passed as parameter...
Definition: rpl_gtid_state.cc:825
int32 get_anonymous_ownership_count()
Return the number of clients that hold anonymous ownership.
Definition: rpl_gtid.h:3038
void update_gtids_impl_end(THD *thd, bool more_trx)
Handle the final part of update_gtids_impl.
Definition: rpl_gtid_state.cc:946
int save(THD *thd)
Save gtid owned by the thd into executed_gtids variable and gtid_executed table.
Definition: rpl_gtid_state.cc:667
bool update_gtids_impl_begin(THD *thd)
This is a sub task of update_gtids_impl responsible only to evaluate if the thread is committing in t...
Definition: rpl_gtid_state.cc:781
void broadcast_sidno(rpl_sidno sidno)
Broadcasts updates for the given SIDNO.
Definition: rpl_gtid.h:3266
enum_return_status generate_automatic_gtid(THD *thd, rpl_sidno specified_sidno=0, rpl_gno specified_gno=0)
Generates the GTID (or ANONYMOUS, if GTID_MODE = OFF or OFF_PERMISSIVE) for the THD,...
Definition: rpl_gtid_state.cc:499
void release_anonymous_ownership()
Release anonymous ownership.
Definition: rpl_gtid.h:3023
void begin_gtid_wait()
Increase the global counter when starting a call to WAIT_FOR_EXECUTED_GTID_SET.
Definition: rpl_gtid.h:3144
void increase_gtid_automatic_tagged_count()
Increments atomic_automatic_tagged_gtid_session_count.
Definition: rpl_gtid.h:3403
void update_gtids_impl(THD *thd, bool is_commit)
Remove the GTID owned by thread from owned GTIDs.
Definition: rpl_gtid_state.cc:220
Malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: malloc_allocator.h:63
Represents a growable array where each element contains a mutex and a condition variable.
Definition: rpl_gtid.h:948
Prealloced_array< Mutex_cond *, 8 > m_array
Definition: rpl_gtid.h:1071
bool is_thd_killed(const THD *thd) const
Return true if the given THD is killed.
Definition: rpl_gtid_mutex_cond_array.cc:96
void enter_cond(THD *thd, int n, PSI_stage_info *stage, PSI_stage_info *old_stage) const
Execute THD::enter_cond for the n'th condition variable.
Definition: rpl_gtid_mutex_cond_array.cc:66
Checkable_rwlock * global_lock
Read-write lock that protects updates to the number of elements.
Definition: rpl_gtid.h:1070
bool wait(const THD *thd, int sidno, struct timespec *abstime) const
Wait for signal on the n'th condition variable.
Definition: rpl_gtid.h:1010
Mutex_cond_array(Checkable_rwlock *global_lock)
Create a new Mutex_cond_array.
Definition: rpl_gtid_mutex_cond_array.cc:42
void broadcast(int n) const
Broadcast the n'th condition.
Definition: rpl_gtid.h:970
void assert_not_owner(int n) const
Assert that this thread does not own the n'th mutex.
Definition: rpl_gtid.h:986
~Mutex_cond_array()
Destroy this object.
Definition: rpl_gtid_mutex_cond_array.cc:48
void assert_owner(int n) const
Assert that this thread owns the n'th mutex.
Definition: rpl_gtid.h:977
void unlock(int n) const
Unlock the n'th mutex.
Definition: rpl_gtid.h:965
void lock(int n) const
Lock the n'th mutex.
Definition: rpl_gtid.h:960
Mutex_cond * get_mutex_cond(int n) const
Return the Nth Mutex_cond object.
Definition: rpl_gtid.h:1062
Iterator over all gtids in a Owned_gtids set.
Definition: rpl_gtid.h:2779
rpl_sidno max_sidno
Max SIDNO of the current iterator.
Definition: rpl_gtid.h:2834
Node * node
Current node on current SIDNO hash.
Definition: rpl_gtid.h:2841
malloc_unordered_multimap< rpl_gno, unique_ptr_my_free< Node > >::const_iterator node_it
Current node iterator on current SIDNO hash.
Definition: rpl_gtid.h:2839
const Owned_gtids * owned_gtids
The Owned_gtids set we iterate over.
Definition: rpl_gtid.h:2830
Node * get_node() const
Return the current GTID Node, or NULL if we reached the end.
Definition: rpl_gtid.h:2826
Gtid_iterator(const Owned_gtids *og)
Definition: rpl_gtid.h:2781
Gtid get() const
Return next GTID, or {0,0} if we reached the end.
Definition: rpl_gtid.h:2817
void next()
Advance to next GTID.
Definition: rpl_gtid.h:2791
rpl_sidno sidno
The SIDNO of the current element, or 1 in the initial iteration.
Definition: rpl_gtid.h:2832
malloc_unordered_multimap< rpl_gno, unique_ptr_my_free< Node > > * hash
Current SIDNO hash.
Definition: rpl_gtid.h:2836
Represents the set of GTIDs that are owned by some thread.
Definition: rpl_gtid.h:2587
size_t get_max_string_length() const
Return an upper bound on the length of the string representation of this Owned_gtids.
Definition: rpl_gtid.h:2683
Checkable_rwlock * tsid_lock
Read-write lock that protects updates to the number of TSIDs.
Definition: rpl_gtid.h:2756
char * to_string() const
Debug only: return a newly allocated string representation of this Owned_gtids.
Definition: rpl_gtid.h:2715
bool thread_owns_anything(my_thread_id thd_id) const
Return true if the given thread is the owner of any gtids.
Definition: rpl_gtid.h:2699
enum_return_status add_gtid_owner(const Gtid >id, my_thread_id owner)
Add a GTID to this Owned_gtids.
Definition: rpl_gtid_owned.cc:70
bool is_intersection_nonempty(const Gtid_set *other) const
Returns true if there is a least one element of this Owned_gtids set in the other Gtid_set.
Definition: rpl_gtid_owned.cc:104
bool is_owned_by(const Gtid >id, const my_thread_id thd_id) const
If thd_id==0, returns true when gtid is not owned by any thread.
Definition: rpl_gtid_owned.cc:138
bool is_empty() const
Returns true if this Owned_gtids is empty.
Definition: rpl_gtid.h:2639
int to_string(char *out) const
Write a string representation of this Owned_gtids to the given buffer.
Definition: rpl_gtid.h:2657
rpl_sidno get_max_sidno() const
Returns the maximal sidno that this Owned_gtids currently has space for.
Definition: rpl_gtid.h:2644
malloc_unordered_multimap< rpl_gno, unique_ptr_my_free< Node > > * get_hash(rpl_sidno sidno) const
Returns the hash for the given SIDNO.
Definition: rpl_gtid.h:2758
Prealloced_array< malloc_unordered_multimap< rpl_gno, unique_ptr_my_free< Node > > *, 8 > sidno_to_hash
Growable array of hashes.
Definition: rpl_gtid.h:2772
Owned_gtids(Checkable_rwlock *tsid_lock)
Constructs a new, empty Owned_gtids object.
Definition: rpl_gtid_owned.cc:39
void dbug_print(const char *text="") const
Print this Owned_gtids to the trace file if debug is enabled; no-op otherwise.
Definition: rpl_gtid.h:2733
void get_gtids(Gtid_set >id_set) const
Definition: rpl_gtid_owned.cc:117
bool contains_gtid(const Gtid >id) const
Return true iff this Owned_gtids object contains the given gtid.
Definition: rpl_gtid_owned.cc:131
~Owned_gtids()
Destroys this Owned_gtids.
Definition: rpl_gtid_owned.cc:43
void print() const
Debug only: print this Owned_gtids to stdout.
Definition: rpl_gtid.h:2723
enum_return_status ensure_sidno(rpl_sidno sidno)
Ensures that this Owned_gtids object can accommodate SIDNOs up to the given SIDNO.
Definition: rpl_gtid_owned.cc:56
void remove_gtid(const Gtid >id, const my_thread_id owner)
Removes the given GTID.
Definition: rpl_gtid_owned.cc:89
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Represents a bidirectional map between TSID and SIDNO.
Definition: rpl_gtid.h:750
rpl_sidno add_tsid(const Tsid &tsid)
Add the given TSID to this map if it does not already exist.
Definition: rpl_gtid_tsid_map.cc:61
enum_return_status copy(Tsid_map *dest)
Deep copy this Tsid_map to dest.
Definition: rpl_gtid_tsid_map.cc:145
Tsid_to_sidno_map::const_iterator Tsid_to_sidno_it
Definition: rpl_gtid.h:774
~Tsid_map()
Destroy this Tsid_map.
Definition: rpl_gtid_tsid_map.cc:51
Tsid_map(Checkable_rwlock *tsid_lock)
Create this Tsid_map.
Definition: rpl_gtid_tsid_map.cc:46
rpl_sidno get_max_sidno() const
Return the biggest sidno in this Tsid_map.
Definition: rpl_gtid.h:867
Checkable_rwlock * get_tsid_lock() const
Return the tsid_lock.
Definition: rpl_gtid.h:873
Tsid_to_sidno_umap _tsid_to_sidno
Hash that maps TSID to SIDNO.
Definition: rpl_gtid.h:916
rpl_sidno tsid_to_sidno(const Tsid &tsid) const
Get the SIDNO for a given TSID.
Definition: rpl_gtid.h:802
Tsid_to_sidno_map _sorted
Data structure that maps numbers in the interval [0, get_max_sidno()-1] to SIDNOs,...
Definition: rpl_gtid.h:923
Sidno_to_tsid_cont _sidno_to_tsid
Array that maps SIDNO to TSID; the element at index N points to a Node with SIDNO N-1.
Definition: rpl_gtid.h:910
enum_return_status clear()
Clears this Tsid_map (for RESET REPLICA)
Definition: rpl_gtid_tsid_map.cc:53
const rpl_sidno & get_sidno(const Tsid_to_sidno_it &it) const
Definition: rpl_gtid.h:851
Checkable_rwlock * tsid_lock
Read-write lock that protects updates to the number of SIDNOs.
Definition: rpl_gtid.h:904
const Tsid & get_tsid(const Tsid_to_sidno_it &it) const
Definition: rpl_gtid.h:856
const Tsid & sidno_to_tsid(rpl_sidno sidno, bool need_lock=false) const
Get the TSID for a given SIDNO.
Definition: rpl_gtid.h:828
std::vector< Tsid_ref, Malloc_allocator< Tsid_ref > > Sidno_to_tsid_cont
Definition: rpl_gtid.h:776
std::reference_wrapper< const Tsid > Tsid_ref
Definition: rpl_gtid.h:775
enum_return_status add_node(rpl_sidno sidno, const Tsid &tsid)
Create a Node from the given SIDNO and a TSID and add it to _sidno_to_tsid, _tsid_to_sidno,...
Definition: rpl_gtid_tsid_map.cc:101
Map_myalloc< Tsid, rpl_sidno > Tsid_to_sidno_map
Definition: rpl_gtid.h:773