MySQL 8.4.2
Source Code Documentation
|
Represents the set of GTIDs that are owned by some thread. More...
#include <rpl_gtid.h>
Classes | |
class | Gtid_iterator |
Iterator over all gtids in a Owned_gtids set. More... | |
struct | Node |
Represents one owned GTID. More... | |
Public Member Functions | |
Owned_gtids (Checkable_rwlock *tsid_lock) | |
Constructs a new, empty Owned_gtids object. More... | |
~Owned_gtids () | |
Destroys this Owned_gtids. More... | |
enum_return_status | add_gtid_owner (const Gtid >id, my_thread_id owner) |
Add a GTID to this Owned_gtids. More... | |
void | get_gtids (Gtid_set >id_set) const |
void | remove_gtid (const Gtid >id, const my_thread_id owner) |
Removes the given GTID. More... | |
enum_return_status | ensure_sidno (rpl_sidno sidno) |
Ensures that this Owned_gtids object can accommodate SIDNOs up to the given SIDNO. More... | |
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. More... | |
bool | is_empty () const |
Returns true if this Owned_gtids is empty. More... | |
rpl_sidno | get_max_sidno () const |
Returns the maximal sidno that this Owned_gtids currently has space for. More... | |
int | to_string (char *out) const |
Write a string representation of this Owned_gtids to the given buffer. More... | |
size_t | get_max_string_length () const |
Return an upper bound on the length of the string representation of this Owned_gtids. More... | |
bool | thread_owns_anything (my_thread_id thd_id) const |
Return true if the given thread is the owner of any gtids. More... | |
char * | to_string () const |
Debug only: return a newly allocated string representation of this Owned_gtids. More... | |
void | print () const |
Debug only: print this Owned_gtids to stdout. More... | |
void | dbug_print (const char *text="") const |
Print this Owned_gtids to the trace file if debug is enabled; no-op otherwise. More... | |
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. More... | |
Private Member Functions | |
malloc_unordered_multimap< rpl_gno, unique_ptr_my_free< Node > > * | get_hash (rpl_sidno sidno) const |
Returns the hash for the given SIDNO. More... | |
bool | contains_gtid (const Gtid >id) const |
Return true iff this Owned_gtids object contains the given gtid. More... | |
Private Attributes | |
Checkable_rwlock * | tsid_lock |
Read-write lock that protects updates to the number of TSIDs. More... | |
Prealloced_array< malloc_unordered_multimap< rpl_gno, unique_ptr_my_free< Node > > *, 8 > | sidno_to_hash |
Growable array of hashes. More... | |
Represents the set of GTIDs that are owned by some thread.
This data structure has a read-write lock that protects the number of SIDNOs. The lock is provided by the invoker of the constructor and it is generally the caller's responsibility to acquire the read lock. Access methods assert that the caller already holds the read (or write) lock. If a method of this class grows the number of SIDNOs, then the method temporarily upgrades this lock to a write lock and then degrades it to a read lock again; there will be a short period when the lock is not held at all.
The internal representation is a multi-valued map from GTIDs to threads, mapping GTIDs to one or more threads that owns it.
In Group Replication multiple threads can own a GTID whereas if GR is disabeld there is at most one owner per GTID.
Owned_gtids::Owned_gtids | ( | Checkable_rwlock * | tsid_lock | ) |
Constructs a new, empty Owned_gtids object.
tsid_lock | Read-write lock that protects updates to the number of TSIDs. |
Owned_gtids::~Owned_gtids | ( | ) |
Destroys this Owned_gtids.
enum_return_status Owned_gtids::add_gtid_owner | ( | const Gtid & | gtid, |
my_thread_id | owner | ||
) |
Add a GTID to this Owned_gtids.
gtid | The Gtid to add. |
owner | The my_thread_id of the gtid to add. |
|
private |
Return true iff this Owned_gtids object contains the given gtid.
|
inline |
Print this Owned_gtids to the trace file if debug is enabled; no-op otherwise.
enum_return_status Owned_gtids::ensure_sidno | ( | rpl_sidno | sidno | ) |
Ensures that this Owned_gtids object can accommodate SIDNOs up to the given SIDNO.
If this Owned_gtids object needs to be resized, then the lock will be temporarily upgraded to a write lock and then degraded to a read lock again; there will be a short period when the lock is not held at all.
sidno | The SIDNO. |
void Owned_gtids::get_gtids | ( | Gtid_set & | gtid_set | ) | const |
|
inlineprivate |
Returns the hash for the given SIDNO.
|
inline |
Returns the maximal sidno that this Owned_gtids currently has space for.
|
inline |
Return an upper bound on the length of the string representation of this Owned_gtids.
The actual length may be smaller. This includes the trailing '\0'.
|
inline |
Returns true if this Owned_gtids is empty.
bool Owned_gtids::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.
bool Owned_gtids::is_owned_by | ( | const Gtid & | gtid, |
const my_thread_id | thd_id | ||
) | const |
If thd_id==0, returns true when gtid is not owned by any thread.
If thd_id!=0, returns true when gtid is owned by that thread.
|
inline |
Debug only: print this Owned_gtids to stdout.
void Owned_gtids::remove_gtid | ( | const Gtid & | gtid, |
const my_thread_id | owner | ||
) |
Removes the given GTID.
If the gtid does not exist in this Owned_gtids object, does nothing.
gtid | The Gtid. |
owner | thread_id of the owner thread |
|
inline |
Return true if the given thread is the owner of any gtids.
|
inline |
Debug only: return a newly allocated string representation of this Owned_gtids.
|
inline |
Write a string representation of this Owned_gtids to the given buffer.
out | Buffer to write to. |
|
private |
Growable array of hashes.
|
mutableprivate |
Read-write lock that protects updates to the number of TSIDs.