24#ifndef CONSISTENCY_MANAGER_INCLUDED
25#define CONSISTENCY_MANAGER_INCLUDED
27#define CONSISTENCY_INFO_OUTCOME_OK 0
28#define CONSISTENCY_INFO_OUTCOME_ERROR 1
29#define CONSISTENCY_INFO_OUTCOME_COMMIT 2
47 std::unique_ptr<Transaction_consistency_info>;
69 void *
operator new(
size_t size,
const std::nothrow_t &)
noexcept {
86 void operator delete(
void *ptr,
const std::nothrow_t &)
noexcept {
99 void *
operator new(
size_t size)
noexcept {
113 void operator delete(
void *ptr)
noexcept {
my_free(ptr); }
134 Members_list *members_that_must_prepare_the_transaction);
239 const std::vector<Gcs_member_identifier> &leaving_members);
266 std::unique_ptr<Checkable_rwlock>
277typedef std::pair<Pipeline_event *, Transaction_consistency_manager_key>
281 std::less<Transaction_consistency_manager_key>,
320 std::unique_ptr<Transaction_consistency_info> transaction_info);
371 const std::vector<Gcs_member_identifier> &leaving_members);
409 ulong gr_consistency_level, ulong
timeout,
411 const THD *thd)
override;
524 const THD *thd)
const;
564 std::list<my_thread_id, Malloc_allocator<my_thread_id>>
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:325
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:40
Group_member_status
Definition: member_info.h:173
Listener for transaction life cycle events.
Definition: group_transaction_observation_manager.h:33
enum_transaction_origin
Enum for transaction origins.
Definition: group_transaction_observation_manager.h:36
Class that contains the logic to hold transactions when group_replication_consistency is set to BEFOR...
Definition: hold_transactions.h:36
Malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: malloc_allocator.h:63
A wrapper for log events/packets.
Definition: pipeline_interfaces.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
The consistency information of a transaction, including its configuration and state.
Definition: consistency_manager.h:55
gr::Gtid_tsid m_tsid
Definition: consistency_manager.h:261
const uint64_t m_begin_timestamp
Definition: consistency_manager.h:270
Transaction_consistency_info(my_thread_id thread_id, bool local_transaction, const gr::Gtid_tsid &tsid, bool is_tsid_specified, rpl_sidno sidno, rpl_gno gno, enum_group_replication_consistency_level consistency_level, Members_list *members_that_must_prepare_the_transaction)
Constructor.
Definition: consistency_manager.cc:35
my_thread_id m_thread_id
Definition: consistency_manager.h:258
bool m_transaction_prepared_locally
Definition: consistency_manager.h:268
bool is_transaction_prepared_locally()
Is the transaction prepared locally?
Definition: consistency_manager.cc:85
const bool m_local_transaction
Definition: consistency_manager.h:259
std::string get_tsid_string() const
Return the string representation of UUID and tag.
Definition: consistency_manager.cc:255
const rpl_sidno m_sidno
Definition: consistency_manager.h:262
int handle_member_leave(const std::vector< Gcs_member_identifier > &leaving_members)
Call action after members leave the group.
Definition: consistency_manager.cc:225
const enum_group_replication_consistency_level m_consistency_level
Definition: consistency_manager.h:264
int handle_remote_prepare(const Gcs_member_identifier &gcs_member_id)
Call action after this transaction being prepared by other member.
Definition: consistency_manager.cc:179
const rpl_gno m_gno
Definition: consistency_manager.h:263
int after_applier_prepare(my_thread_id thread_id, Group_member_info::Group_member_status member_status)
Call action after this transaction being prepared on this member applier.
Definition: consistency_manager.cc:111
virtual ~Transaction_consistency_info()
Definition: consistency_manager.cc:73
std::unique_ptr< Checkable_rwlock > m_members_that_must_prepare_the_transaction_lock
Definition: consistency_manager.h:267
bool m_transaction_prepared_remotely
Definition: consistency_manager.h:269
enum_group_replication_consistency_level get_consistency_level()
Get the transaction consistency.
Definition: consistency_manager.cc:94
const bool m_tsid_specified
Definition: consistency_manager.h:260
bool is_the_transaction_prepared_remotely()
Did all other ONLINE members already prepared the transaction?
Definition: consistency_manager.cc:104
rpl_gno get_gno()
Get the transaction gno.
Definition: consistency_manager.cc:91
my_thread_id get_thread_id()
Get the thread id that is executing the transaction.
Definition: consistency_manager.cc:77
rpl_sidno get_sidno()
Get the transaction sidno.
Definition: consistency_manager.cc:89
bool is_a_single_member_group()
Is this transaction running on a single member group?
Definition: consistency_manager.cc:98
bool is_local_transaction()
Is the transaction from this server?
Definition: consistency_manager.cc:81
uint64_t get_begin_timestamp() const
Return the time at which the wait for the transaction prepare acknowledge from others members did sta...
Definition: consistency_manager.cc:251
Members_list * m_members_that_must_prepare_the_transaction
Definition: consistency_manager.h:265
The consistency information of all ongoing transactions which have consistency GROUP_REPLICATION_CONS...
Definition: consistency_manager.h:294
Hold_transactions m_hold_transactions
Hold transaction mechanism.
Definition: consistency_manager.h:575
int after_applier_prepare(rpl_sidno sidno, rpl_gno gno, my_thread_id thread_id, Group_member_info::Group_member_status member_status)
Call action after a transaction being prepared on this member applier.
Definition: consistency_manager.cc:388
int after_certification(std::unique_ptr< Transaction_consistency_info > transaction_info)
Call action after a transaction is certified.
Definition: consistency_manager.cc:316
int before_transaction_begin(my_thread_id thread_id, ulong gr_consistency_level, ulong timeout, enum_rpl_channel_type rpl_channel_type, const THD *thd) override
Call action before a transaction starts.
Definition: consistency_manager.cc:636
int transaction_begin_sync_prepared_transactions(my_thread_id thread_id, ulong timeout)
Help method called by transaction begin action that, if there are precedent prepared transactions wit...
Definition: consistency_manager.cc:787
Checkable_rwlock * m_prepared_transactions_on_my_applier_lock
Definition: consistency_manager.h:559
bool has_local_prepared_transactions()
Are there local prepared transactions waiting for prepare acknowledge from other members?
Definition: consistency_manager.cc:853
Transaction_consistency_manager_map m_map
Definition: consistency_manager.h:557
int transaction_begin_sync_before_execution(my_thread_id thread_id, enum_group_replication_consistency_level consistency_level, ulong timeout, const THD *thd) const
Help method called by transaction begin action that, for transactions with consistency GROUP_REPLICAT...
Definition: consistency_manager.cc:688
void disable_primary_election_checks()
Tells the consistency manager that a primary election ended so it shall disable primary election chec...
Definition: consistency_manager.cc:955
int handle_sync_before_execution_message(my_thread_id thread_id, const Gcs_member_identifier &gcs_member_id) const
Call action once a Sync_before_execution_message is received, this will allow fetch the group transac...
Definition: consistency_manager.cc:768
int handle_member_leave(const std::vector< Gcs_member_identifier > &leaving_members)
Call action after members leave the group.
Definition: consistency_manager.cc:592
void register_transaction_observer()
Register an observer for transactions.
Definition: consistency_manager.cc:942
int remove_prepared_transaction(Transaction_consistency_manager_key key)
Help method that cleans prepared transactions and releases transactions waiting on them.
Definition: consistency_manager.cc:887
~Transaction_consistency_manager() override
Definition: consistency_manager.cc:288
void plugin_is_stopping()
Inform that plugin is stopping.
Definition: consistency_manager.cc:938
std::list< Transaction_consistency_manager_pevent_pair, Malloc_allocator< Transaction_consistency_manager_pevent_pair > > m_delayed_view_change_events
Definition: consistency_manager.h:568
std::list< my_thread_id, Malloc_allocator< my_thread_id > > m_new_transactions_waiting
Definition: consistency_manager.h:565
std::list< Transaction_consistency_manager_key, Malloc_allocator< Transaction_consistency_manager_key > > m_prepared_transactions_on_my_applier
Definition: consistency_manager.h:563
Transaction_consistency_manager_key m_last_local_transaction
Definition: consistency_manager.h:569
void unregister_transaction_observer()
Unregister the observer for transactions.
Definition: consistency_manager.cc:946
int after_rollback(my_thread_id thread_id) override
Executed after rollback.
Definition: consistency_manager.cc:974
void clear()
Clear all information.
Definition: consistency_manager.cc:297
int handle_remote_prepare(const gr::Gtid_tsid &tsid, bool is_tsid_specified, rpl_gno gno, const Gcs_member_identifier &gcs_member_id)
Call action after a transaction being prepared by other member.
Definition: consistency_manager.cc:476
int before_rollback(my_thread_id thread_id, Group_transaction_listener::enum_transaction_origin origin) override
Executed before rollback.
Definition: consistency_manager.cc:969
std::atomic< bool > m_plugin_stopping
Definition: consistency_manager.h:571
int after_commit(my_thread_id thread_id, rpl_sidno sidno, rpl_gno gno) override
Call action after commit a transaction on this member.
Definition: consistency_manager.cc:617
Checkable_rwlock * m_map_lock
Definition: consistency_manager.h:556
std::atomic< bool > m_primary_election_active
Definition: consistency_manager.h:572
int schedule_view_change_event(Pipeline_event *pevent)
Schedule a View_change_log_event log into the relay to after the local prepared transactions are comp...
Definition: consistency_manager.cc:874
Transaction_consistency_manager()
Constructor.
Definition: consistency_manager.cc:260
void enable_primary_election_checks()
Tells the consistency manager that a primary election is running so it shall enable primary election ...
Definition: consistency_manager.cc:950
int before_commit(my_thread_id thread_id, Group_transaction_listener::enum_transaction_origin origin) override
Executed before commit.
Definition: consistency_manager.cc:964
void plugin_started()
Inform that plugin did start.
Definition: consistency_manager.cc:934
Represents Transaction Source Identifier which is composed of source UUID and transaction tag.
Definition: tsid.h:44
std::pair< Pipeline_event *, Transaction_consistency_manager_key > Transaction_consistency_manager_pevent_pair
Definition: consistency_manager.h:278
std::pair< rpl_sidno, rpl_gno > Transaction_consistency_manager_key
Definition: consistency_manager.h:273
std::map< Transaction_consistency_manager_key, Transaction_consistency_info_uptr, std::less< Transaction_consistency_manager_key >, Malloc_allocator< std::pair< const Transaction_consistency_manager_key, Transaction_consistency_info_uptr > > > Transaction_consistency_manager_map
Definition: consistency_manager.h:284
std::unique_ptr< Transaction_consistency_info > Transaction_consistency_info_uptr
Definition: consistency_manager.h:47
std::pair< Transaction_consistency_manager_key, Transaction_consistency_info_uptr > Transaction_consistency_manager_pair
Definition: consistency_manager.h:276
#define MY_WME
Definition: my_sys.h:130
#define MYF(v)
Definition: my_inttypes.h:97
void * my_malloc(PSI_memory_key key, size_t size, int flags)
Allocates size bytes of memory.
Definition: my_memory.cc:57
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
static my_thread_id thread_id
Definition: my_thr_init.cc:63
uint32 my_thread_id
Definition: my_thread_local.h:34
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:498
size_t size(const char *const c)
Definition: base64.h:46
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2894
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2880
std::list< Gcs_member_identifier, Malloc_allocator< Gcs_member_identifier > > Members_list
Definition: pipeline_interfaces.h:40
API for Group Replication plugin.
enum_group_replication_consistency_level
Definition: plugin_group_replication.h:35
PSI_memory_key key_consistent_transactions
Definition: plugin_psi.h:247
required string key
Definition: replication_asynchronous_connection_failover.proto:60
enum_rpl_channel_type
Type of replication channel thread/transaction might be associated to.
Definition: rpl_context.h:50
mysql::gtid::gno_t rpl_gno
GNO, the second (numeric) component of a GTID, is an alias of mysql::gtid::gno_t.
Definition: rpl_gtid.h:113
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:109