Skip to content

Commit 22c27ae

Browse files
committed
WL#8202: Group Replication: Server Interfaces (2nd push)
This worklog works as an umbrella to MySQL Group Replication 2nd milestone into 5.7. Children worklogs: WL#6826: GCS Replication: Interfaces for COMMIT Validation WL#6834: GCS Replication: Extract PKE for certification purposes WL#6839: GCS Replication: P_S table to show DBSM stats WL#6841: GCS Replication: P_S table to show GCS kernel stats WL#7206: GCS: Make the MTR rpl suite to work with GCS replication WL#7988: GCS: Pre-conditions verification WL#8250: GCS Replication: Transaction Applier Module [SERVER CHANGES] WL#8251: GCS Replication: Online distributed recovery [SERVER CHANGES] WL#8252: GCS Replication: Plugin [SERVER CHANGES]
1 parent 7532dbf commit 22c27ae

File tree

613 files changed

+9334
-1825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

613 files changed

+9334
-1825
lines changed

include/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ SET(HEADERS_ABI
3131
mysql/plugin_audit.h
3232
mysql/plugin_ftparser.h
3333
mysql/plugin_validate_password.h
34+
mysql/plugin_group_replication.h
3435
)
3536

3637
SET(HEADERS
+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software Foundation,
14+
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15+
16+
#ifndef GROUP_REPLICATION_PRIV_INCLUDE
17+
#define GROUP_REPLICATION_PRIV_INCLUDE
18+
19+
#ifndef MYSQL_SERVER
20+
#define MYSQL_SERVER
21+
#endif
22+
23+
#ifndef HAVE_REPLICATION
24+
#define HAVE_REPLICATION
25+
#endif
26+
27+
#include <my_global.h>
28+
#include <my_thread.h>
29+
#include <my_sys.h>
30+
31+
#include <debug_sync.h>
32+
#include <log_event.h>
33+
#include <replication.h>
34+
#include <rpl_channel_service_interface.h>
35+
#include <rpl_gtid.h>
36+
37+
38+
/**
39+
Server side initializations and cleanup.
40+
*/
41+
int group_replication_init(const char* plugin_name);
42+
int group_replication_cleanup();
43+
int group_replication_start();
44+
int group_replication_stop();
45+
46+
47+
/**
48+
Returns the server connection attribute
49+
50+
@Note This method implementation is on sql_class.cc
51+
52+
@return the pthread for the connection attribute.
53+
*/
54+
my_thread_attr_t *get_connection_attrib();
55+
56+
57+
/**
58+
Returns the server hostname, port and uuid.
59+
60+
@param[out] hostname
61+
@param[out] port
62+
@param[out] uuid
63+
*/
64+
void get_server_host_port_uuid(char **hostname, uint *port, char** uuid);
65+
66+
67+
/**
68+
Returns a struct containing all server startup information needed to evaluate
69+
if one has conditions to proceed executing master-master replication.
70+
71+
@param[out] requirements
72+
*/
73+
void get_server_startup_prerequirements(Trans_context_info& requirements);
74+
75+
76+
/**
77+
Returns if the server engine initialization as ended or not.
78+
79+
@return is the server ready
80+
@retval false not ready
81+
@retval true ready
82+
*/
83+
bool is_server_engine_ready();
84+
85+
86+
/**
87+
Returns the server GTID_EXECUTED encoded as a binary string.
88+
89+
@note Memory allocated to encoded_gtid_executed must be release by caller.
90+
91+
@param[out] encoded_gtid_executed binary string
92+
@param[out] length binary string length
93+
*/
94+
bool get_server_encoded_gtid_executed(uchar **encoded_gtid_executed,
95+
uint *length);
96+
97+
#if !defined(DBUG_OFF)
98+
/**
99+
Returns a text representation of a encoded GTID set.
100+
101+
@note Memory allocated to returned pointer must be release by caller.
102+
103+
@param[in] encoded_gtid_set binary string
104+
@param[in] length binary string length
105+
106+
@return a pointer to text representation of the encoded set
107+
*/
108+
char* encoded_gtid_set_to_string(uchar *encoded_gtid_set, uint length);
109+
#endif
110+
111+
112+
/**
113+
Return last gno for a given sidno, see
114+
Gtid_state::get_last_executed_gno() for details.
115+
*/
116+
rpl_gno get_last_executed_gno(rpl_sidno sidno);
117+
118+
119+
/**
120+
Return sidno for a given sid, see Sid_map::add_sid() for details.
121+
*/
122+
rpl_sidno get_sidno_from_global_sid_map(rpl_sid sid);
123+
124+
125+
/**
126+
Set slave thread default options.
127+
128+
@param[in] thd The thread
129+
*/
130+
void set_slave_thread_options(THD* thd);
131+
132+
133+
/**
134+
Add thread to Global_THD_manager singleton.
135+
136+
@param[in] thd The thread
137+
*/
138+
void global_thd_manager_add_thd(THD *thd);
139+
140+
141+
/**
142+
Remove thread from Global_THD_manager singleton.
143+
144+
@param[in] thd The thread
145+
*/
146+
void global_thd_manager_remove_thd(THD *thd);
147+
148+
149+
#endif /* GROUP_REPLICATION_PRIV_INCLUDE */
150+

include/mysql/plugin.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ typedef struct st_mysql_xid MYSQL_XID;
9191
#define MYSQL_VALIDATE_PASSWORD_PLUGIN 8 /* validate password plugin type */
9292
#define MYSQL_REWRITE_PRE_PARSE_PLUGIN 9 /* Pre-parse query rewrite. */
9393
#define MYSQL_REWRITE_POST_PARSE_PLUGIN 10 /* Post-parse query rewrite. */
94-
#define MYSQL_MAX_PLUGIN_TYPE_NUM 11 /* The number of plugin types */
94+
#define MYSQL_GROUP_REPLICATION_PLUGIN 11 /* The Group Replication plugin */
95+
#define MYSQL_MAX_PLUGIN_TYPE_NUM 12 /* The number of plugin types */
9596

9697
/* We use the following strings to define licenses for plugins */
9798
#define PLUGIN_LICENSE_PROPRIETARY 0

include/mysql/plugin_audit.h.pp

+27
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,33 @@
191191
void mysql_parser_free_string(MYSQL_LEX_STRING string);
192192
MYSQL_LEX_STRING mysql_parser_get_query(void* thd);
193193
MYSQL_LEX_STRING mysql_parser_get_normalized_query(void* thd);
194+
#include <mysql/service_rpl_transaction_ctx.h>
195+
struct st_transaction_termination_ctx
196+
{
197+
unsigned long m_thread_id;
198+
unsigned int m_flags;
199+
char m_rollback_transaction;
200+
char m_generated_gtid;
201+
int m_sidno;
202+
long long int m_gno;
203+
};
204+
typedef struct st_transaction_termination_ctx Transaction_termination_ctx;
205+
extern struct rpl_transaction_ctx_service_st {
206+
int (*set_transaction_ctx)(Transaction_termination_ctx transaction_termination_ctx);
207+
} *rpl_transaction_ctx_service;
208+
int set_transaction_ctx(Transaction_termination_ctx transaction_termination_ctx);
209+
#include <mysql/service_rpl_transaction_write_set.h>
210+
struct st_trans_write_set
211+
{
212+
unsigned int m_flags;
213+
unsigned long write_set_size;
214+
unsigned long* write_set;
215+
};
216+
typedef struct st_trans_write_set Transaction_write_set;
217+
extern struct transaction_write_set_service_st {
218+
Transaction_write_set* (*get_transaction_write_set)(unsigned long m_thread_id);
219+
} *transaction_write_set_service;
220+
Transaction_write_set* get_transaction_write_set(unsigned long m_thread_id);
194221
struct st_mysql_xid {
195222
long formatID;
196223
long gtrid_length;

include/mysql/plugin_auth.h.pp

+27
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,33 @@
191191
void mysql_parser_free_string(MYSQL_LEX_STRING string);
192192
MYSQL_LEX_STRING mysql_parser_get_query(void* thd);
193193
MYSQL_LEX_STRING mysql_parser_get_normalized_query(void* thd);
194+
#include <mysql/service_rpl_transaction_ctx.h>
195+
struct st_transaction_termination_ctx
196+
{
197+
unsigned long m_thread_id;
198+
unsigned int m_flags;
199+
char m_rollback_transaction;
200+
char m_generated_gtid;
201+
int m_sidno;
202+
long long int m_gno;
203+
};
204+
typedef struct st_transaction_termination_ctx Transaction_termination_ctx;
205+
extern struct rpl_transaction_ctx_service_st {
206+
int (*set_transaction_ctx)(Transaction_termination_ctx transaction_termination_ctx);
207+
} *rpl_transaction_ctx_service;
208+
int set_transaction_ctx(Transaction_termination_ctx transaction_termination_ctx);
209+
#include <mysql/service_rpl_transaction_write_set.h>
210+
struct st_trans_write_set
211+
{
212+
unsigned int m_flags;
213+
unsigned long write_set_size;
214+
unsigned long* write_set;
215+
};
216+
typedef struct st_trans_write_set Transaction_write_set;
217+
extern struct transaction_write_set_service_st {
218+
Transaction_write_set* (*get_transaction_write_set)(unsigned long m_thread_id);
219+
} *transaction_write_set_service;
220+
Transaction_write_set* get_transaction_write_set(unsigned long m_thread_id);
194221
struct st_mysql_xid {
195222
long formatID;
196223
long gtrid_length;

include/mysql/plugin_ftparser.h.pp

+27
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,33 @@
191191
void mysql_parser_free_string(MYSQL_LEX_STRING string);
192192
MYSQL_LEX_STRING mysql_parser_get_query(void* thd);
193193
MYSQL_LEX_STRING mysql_parser_get_normalized_query(void* thd);
194+
#include <mysql/service_rpl_transaction_ctx.h>
195+
struct st_transaction_termination_ctx
196+
{
197+
unsigned long m_thread_id;
198+
unsigned int m_flags;
199+
char m_rollback_transaction;
200+
char m_generated_gtid;
201+
int m_sidno;
202+
long long int m_gno;
203+
};
204+
typedef struct st_transaction_termination_ctx Transaction_termination_ctx;
205+
extern struct rpl_transaction_ctx_service_st {
206+
int (*set_transaction_ctx)(Transaction_termination_ctx transaction_termination_ctx);
207+
} *rpl_transaction_ctx_service;
208+
int set_transaction_ctx(Transaction_termination_ctx transaction_termination_ctx);
209+
#include <mysql/service_rpl_transaction_write_set.h>
210+
struct st_trans_write_set
211+
{
212+
unsigned int m_flags;
213+
unsigned long write_set_size;
214+
unsigned long* write_set;
215+
};
216+
typedef struct st_trans_write_set Transaction_write_set;
217+
extern struct transaction_write_set_service_st {
218+
Transaction_write_set* (*get_transaction_write_set)(unsigned long m_thread_id);
219+
} *transaction_write_set_service;
220+
Transaction_write_set* get_transaction_write_set(unsigned long m_thread_id);
194221
struct st_mysql_xid {
195222
long formatID;
196223
long gtrid_length;
+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software Foundation,
14+
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15+
16+
#ifndef MYSQL_PLUGIN_GROUP_REPLICATION_INCLUDED
17+
#define MYSQL_PLUGIN_GROUP_REPLICATION_INCLUDED
18+
19+
/* API for Group Peplication plugin. (MYSQL_GROUP_REPLICATION_PLUGIN) */
20+
21+
#include <mysql/plugin.h>
22+
#define MYSQL_GROUP_REPLICATION_INTERFACE_VERSION 0x0100
23+
24+
enum enum_member_state {
25+
MEMBER_STATE_ONLINE= 1,
26+
MEMBER_STATE_OFFLINE,
27+
MEMBER_STATE_RECOVERING
28+
};
29+
30+
enum enum_applier_status {
31+
APPLIER_STATE_RUNNING= 1,
32+
APPLIER_STATE_STOP,
33+
APPLIER_STATE_ERROR
34+
};
35+
36+
typedef struct st_group_replication_connection_status_info
37+
{
38+
char* channel_name;
39+
char* group_name;
40+
bool service_state;
41+
} GROUP_REPLICATION_CONNECTION_STATUS_INFO;
42+
43+
typedef struct st_group_replication_group_members_info
44+
{
45+
char* channel_name;
46+
char* member_id;
47+
char* member_address;
48+
enum enum_member_state member_state;
49+
} GROUP_REPLICATION_GROUP_MEMBERS_INFO;
50+
51+
typedef struct st_group_replication_member_stats_info
52+
{
53+
char* channel_name;
54+
char* view_id;
55+
char* member_id;
56+
unsigned long long int transaction_in_queue;
57+
unsigned long long int transaction_certified;
58+
unsigned long long int transaction_conflicts_detected;
59+
unsigned long long int transactions_in_validation;
60+
char* committed_transactions;
61+
char* last_conflict_free_transaction;
62+
} GROUP_REPLICATION_GROUP_MEMBER_STATS_INFO;
63+
64+
struct st_mysql_group_replication
65+
{
66+
int interface_version;
67+
68+
/*
69+
This function is used to start the group replication.
70+
*/
71+
int (*start)();
72+
/*
73+
This function is used to stop the group replication.
74+
*/
75+
int (*stop)();
76+
/*
77+
This function is used to get the current group replication running status.
78+
*/
79+
bool (*is_running)();
80+
/*
81+
This function initializes conflict checking module with info received
82+
from group on this member.
83+
84+
@param info View_change_log_event with conflict checking info.
85+
*/
86+
int (*set_retrieved_certification_info)(void* info);
87+
88+
/*
89+
This function is used to fetch information for group replication kernel stats.
90+
*/
91+
bool (*get_connection_status_info)(GROUP_REPLICATION_CONNECTION_STATUS_INFO *info);
92+
93+
/*
94+
This function is used to fetch information for group replication members.
95+
*/
96+
bool (*get_group_members_info)(uint index, GROUP_REPLICATION_GROUP_MEMBERS_INFO *info);
97+
98+
/*
99+
This function is used to fetch information for group replication members statistics.
100+
*/
101+
bool (*get_group_member_stats_info)(GROUP_REPLICATION_GROUP_MEMBER_STATS_INFO* info);
102+
103+
/*
104+
Get number of group replication members.
105+
*/
106+
uint (*get_members_number_info)();
107+
};
108+
109+
#endif
110+

0 commit comments

Comments
 (0)