1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-26: Global transaction commit. Intermediate commit.

Now slave records GTID in mysql.rpl_slave_state when applying XID log event.
This commit is contained in:
unknown
2012-11-05 15:01:49 +01:00
parent ab8e8f4b27
commit 03f28863e8
10 changed files with 569 additions and 31 deletions

View File

@@ -2953,19 +2953,93 @@ struct rpl_gtid
};
struct rpl_state
{
HASH hash;
/*
Replication slave state.
rpl_state();
~rpl_state();
For every independent replication stream (identified by domain_id), this
remembers the last gtid applied on the slave within this domain.
Since events are always committed in-order within a single domain, this is
sufficient to maintain the state of the replication slave.
*/
struct rpl_slave_state
{
/* Elements in the list of GTIDs kept for each domain_id. */
struct list_element
{
struct list_element *next;
uint64 sub_id;
uint64 seq_no;
uint32 server_id;
};
/* Elements in the HASH that hold the state for one domain_id. */
struct element
{
struct list_element *list;
uint64 last_sub_id;
uint32 domain_id;
list_element *grab_list() { list_element *l= list; list= NULL; return l; }
void add (list_element *l)
{
l->next= list;
list= l;
if (last_sub_id < l->sub_id)
last_sub_id= l->sub_id;
}
};
/* Mapping from domain_id to its element. */
HASH hash;
/* Mutex protecting access to the state. */
mysql_mutex_t LOCK_slave_state;
bool inited;
bool loaded;
rpl_slave_state();
~rpl_slave_state();
void init();
void deinit();
ulong count() const { return hash.records; }
int update(uint32 domain_id, uint32 server_id, uint64 sub_id, uint64 seq_no);
int record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id,
bool in_transaction);
uint64 next_subid(uint32 domain_id);
void lock() { DBUG_ASSERT(inited); mysql_mutex_lock(&LOCK_slave_state); }
void unlock() { DBUG_ASSERT(inited); mysql_mutex_unlock(&LOCK_slave_state); }
element *get_element(uint32 domain_id);
};
/*
Binlog state.
This keeps the last GTID written to the binlog for every distinct
(domain_id, server_id) pair.
This will be logged at the start of the next binlog file as a
Gtid_list_log_event; this way, it is easy to find the binlog file
containing a gigen GTID, by simply scanning backwards from the newest
one until a lower seq_no is found in the Gtid_list_log_event at the
start of a binlog for the given domain_id and server_id.
*/
struct rpl_binlog_state
{
/* Mapping from (domain_id,server_id) to its GTID. */
HASH hash;
/* Mutex protecting access to the state. */
mysql_mutex_t LOCK_binlog_state;
rpl_binlog_state();
~rpl_binlog_state();
ulong count() const { return hash.records; }
int update(const struct rpl_gtid *gtid);
};
extern rpl_state global_rpl_gtid_state;
/**
@class Gtid_log_event
@@ -3129,7 +3203,7 @@ public:
static const uint element_size= 4+4+8;
#ifdef MYSQL_SERVER
Gtid_list_log_event(rpl_state *gtid_set);
Gtid_list_log_event(rpl_binlog_state *gtid_set);
#ifdef HAVE_REPLICATION
void pack_info(THD *thd, Protocol *protocol);
#endif