MXS-1266: cosmetic changes
MXS-1266: cosmetic changes
This commit is contained in:
@ -91,10 +91,15 @@
|
|||||||
/* The router entry points */
|
/* The router entry points */
|
||||||
static MXS_ROUTER *createInstance(SERVICE *service, char **options);
|
static MXS_ROUTER *createInstance(SERVICE *service, char **options);
|
||||||
static void free_instance(ROUTER_INSTANCE *instance);
|
static void free_instance(ROUTER_INSTANCE *instance);
|
||||||
static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session);
|
static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance,
|
||||||
static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
|
MXS_SESSION *session);
|
||||||
static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session);
|
static void closeSession(MXS_ROUTER *instance,
|
||||||
static int routeQuery(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session, GWBUF *queue);
|
MXS_ROUTER_SESSION *router_session);
|
||||||
|
static void freeSession(MXS_ROUTER *instance,
|
||||||
|
MXS_ROUTER_SESSION *router_session);
|
||||||
|
static int routeQuery(MXS_ROUTER *instance,
|
||||||
|
MXS_ROUTER_SESSION *router_session,
|
||||||
|
GWBUF *queue);
|
||||||
static void diagnostics(MXS_ROUTER *instance, DCB *dcb);
|
static void diagnostics(MXS_ROUTER *instance, DCB *dcb);
|
||||||
static json_t* diagnostics_json(const MXS_ROUTER *instance);
|
static json_t* diagnostics_json(const MXS_ROUTER *instance);
|
||||||
static void clientReply(MXS_ROUTER *instance,
|
static void clientReply(MXS_ROUTER *instance,
|
||||||
@ -109,14 +114,21 @@ static void errorReply(MXS_ROUTER *instance,
|
|||||||
bool *succp);
|
bool *succp);
|
||||||
|
|
||||||
static uint64_t getCapabilities(MXS_ROUTER* instance);
|
static uint64_t getCapabilities(MXS_ROUTER* instance);
|
||||||
static int blr_handler_config(void *userdata, const char *section, const char *name, const char *value);
|
static int blr_handler_config(void *userdata,
|
||||||
static int blr_handle_config_item(const char *name, const char *value, ROUTER_INSTANCE *inst);
|
const char *section,
|
||||||
|
const char *name,
|
||||||
|
const char *value);
|
||||||
|
static int blr_handle_config_item(const char *name,
|
||||||
|
const char *value,
|
||||||
|
ROUTER_INSTANCE *inst);
|
||||||
static int blr_load_dbusers(const ROUTER_INSTANCE *router);
|
static int blr_load_dbusers(const ROUTER_INSTANCE *router);
|
||||||
static int blr_check_binlog(ROUTER_INSTANCE *router);
|
static int blr_check_binlog(ROUTER_INSTANCE *router);
|
||||||
void blr_master_close(ROUTER_INSTANCE *);
|
void blr_master_close(ROUTER_INSTANCE *);
|
||||||
void blr_free_ssl_data(ROUTER_INSTANCE *inst);
|
void blr_free_ssl_data(ROUTER_INSTANCE *inst);
|
||||||
static void destroyInstance(MXS_ROUTER *instance);
|
static void destroyInstance(MXS_ROUTER *instance);
|
||||||
bool blr_extract_key(const char *linebuf, int nline, ROUTER_INSTANCE *router);
|
bool blr_extract_key(const char *linebuf,
|
||||||
|
int nline,
|
||||||
|
ROUTER_INSTANCE *router);
|
||||||
bool blr_get_encryption_key(ROUTER_INSTANCE *router);
|
bool blr_get_encryption_key(ROUTER_INSTANCE *router);
|
||||||
int blr_parse_key_file(ROUTER_INSTANCE *router);
|
int blr_parse_key_file(ROUTER_INSTANCE *router);
|
||||||
static bool blr_open_gtid_maps_storage(ROUTER_INSTANCE *inst);
|
static bool blr_open_gtid_maps_storage(ROUTER_INSTANCE *inst);
|
||||||
@ -125,7 +137,8 @@ static void stats_func(void *);
|
|||||||
|
|
||||||
static bool rses_begin_locked_router_action(ROUTER_SLAVE *);
|
static bool rses_begin_locked_router_action(ROUTER_SLAVE *);
|
||||||
static void rses_end_locked_router_action(ROUTER_SLAVE *);
|
static void rses_end_locked_router_action(ROUTER_SLAVE *);
|
||||||
GWBUF *blr_cache_read_response(ROUTER_INSTANCE *router, char *response);
|
GWBUF *blr_cache_read_response(ROUTER_INSTANCE *router,
|
||||||
|
char *response);
|
||||||
extern bool blr_load_last_mariadb_gtid(ROUTER_INSTANCE *router,
|
extern bool blr_load_last_mariadb_gtid(ROUTER_INSTANCE *router,
|
||||||
MARIADB_GTID_INFO *result);
|
MARIADB_GTID_INFO *result);
|
||||||
|
|
||||||
@ -205,11 +218,13 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
{"transaction_safety", MXS_MODULE_PARAM_BOOL, "false"},
|
{"transaction_safety", MXS_MODULE_PARAM_BOOL, "false"},
|
||||||
{"semisync", MXS_MODULE_PARAM_BOOL, "false"},
|
{"semisync", MXS_MODULE_PARAM_BOOL, "false"},
|
||||||
{"encrypt_binlog", MXS_MODULE_PARAM_BOOL, "false"},
|
{"encrypt_binlog", MXS_MODULE_PARAM_BOOL, "false"},
|
||||||
{"encryption_algorithm", MXS_MODULE_PARAM_ENUM, "aes_cbc", MXS_MODULE_OPT_NONE, enc_algo_values},
|
{"encryption_algorithm", MXS_MODULE_PARAM_ENUM, "aes_cbc",
|
||||||
|
MXS_MODULE_OPT_NONE, enc_algo_values},
|
||||||
{"encryption_key_file", MXS_MODULE_PARAM_PATH, NULL, MXS_MODULE_OPT_PATH_R_OK},
|
{"encryption_key_file", MXS_MODULE_PARAM_PATH, NULL, MXS_MODULE_OPT_PATH_R_OK},
|
||||||
{"mariadb10_slave_gtid", MXS_MODULE_PARAM_BOOL, "false"},
|
{"mariadb10_slave_gtid", MXS_MODULE_PARAM_BOOL, "false"},
|
||||||
{"mariadb10_master_gtid", MXS_MODULE_PARAM_BOOL, "false"},
|
{"mariadb10_master_gtid", MXS_MODULE_PARAM_BOOL, "false"},
|
||||||
{"binlog_structure", MXS_MODULE_PARAM_ENUM, "flat", MXS_MODULE_OPT_NONE, binlog_storage_values},
|
{"binlog_structure", MXS_MODULE_PARAM_ENUM, "flat",
|
||||||
|
MXS_MODULE_OPT_NONE, binlog_storage_values},
|
||||||
{"shortburst", MXS_MODULE_PARAM_COUNT, DEF_SHORT_BURST},
|
{"shortburst", MXS_MODULE_PARAM_COUNT, DEF_SHORT_BURST},
|
||||||
{"longburst", MXS_MODULE_PARAM_COUNT, DEF_LONG_BURST},
|
{"longburst", MXS_MODULE_PARAM_COUNT, DEF_LONG_BURST},
|
||||||
{"burstsize", MXS_MODULE_PARAM_SIZE, DEF_BURST_SIZE},
|
{"burstsize", MXS_MODULE_PARAM_SIZE, DEF_BURST_SIZE},
|
||||||
@ -383,8 +398,11 @@ createInstance(SERVICE *service, char **options)
|
|||||||
|
|
||||||
/* Binlog encryption */
|
/* Binlog encryption */
|
||||||
inst->encryption.enabled = config_get_bool(params, "encrypt_binlog");
|
inst->encryption.enabled = config_get_bool(params, "encrypt_binlog");
|
||||||
inst->encryption.encryption_algorithm = config_get_enum(params, "encryption_algorithm", enc_algo_values);
|
inst->encryption.encryption_algorithm = config_get_enum(params,
|
||||||
inst->encryption.key_management_filename = config_copy_string(params, "encryption_key_file");
|
"encryption_algorithm",
|
||||||
|
enc_algo_values);
|
||||||
|
inst->encryption.key_management_filename = config_copy_string(params,
|
||||||
|
"encryption_key_file");
|
||||||
|
|
||||||
/* Encryption CTX */
|
/* Encryption CTX */
|
||||||
inst->encryption_ctx = NULL;
|
inst->encryption_ctx = NULL;
|
||||||
@ -668,7 +686,8 @@ createInstance(SERVICE *service, char **options)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_ERROR("%s: Error: No router options supplied for binlogrouter", service->name);
|
MXS_ERROR("%s: Error: No router options supplied for binlogrouter",
|
||||||
|
service->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
inst->orig_masterid = 0;
|
inst->orig_masterid = 0;
|
||||||
@ -678,9 +697,11 @@ createInstance(SERVICE *service, char **options)
|
|||||||
inst->set_master_server_id = true;
|
inst->set_master_server_id = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((inst->binlogdir == NULL) || (inst->binlogdir != NULL && !strlen(inst->binlogdir)))
|
if ((inst->binlogdir == NULL) ||
|
||||||
|
(inst->binlogdir != NULL && !strlen(inst->binlogdir)))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Service %s, binlog directory is not specified", service->name);
|
MXS_ERROR("Service %s, binlog directory is not specified",
|
||||||
|
service->name);
|
||||||
free_instance(inst);
|
free_instance(inst);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -688,7 +709,8 @@ createInstance(SERVICE *service, char **options)
|
|||||||
if (inst->serverid <= 0)
|
if (inst->serverid <= 0)
|
||||||
{
|
{
|
||||||
MXS_ERROR("Service %s, server-id is not configured. "
|
MXS_ERROR("Service %s, server-id is not configured. "
|
||||||
"Please configure it with a unique positive integer value (1..2^32-1)",
|
"Please configure it with a unique positive "
|
||||||
|
"integer value (1..2^32-1)",
|
||||||
service->name);
|
service->name);
|
||||||
free_instance(inst);
|
free_instance(inst);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -788,8 +810,11 @@ createInstance(SERVICE *service, char **options)
|
|||||||
{
|
{
|
||||||
SERVER *server;
|
SERVER *server;
|
||||||
SSL_LISTENER *ssl_cfg;
|
SSL_LISTENER *ssl_cfg;
|
||||||
server = server_alloc("binlog_router_master_host", "_none_", 3306,
|
server = server_alloc("binlog_router_master_host",
|
||||||
"MySQLBackend", "MySQLBackendAuth", NULL);
|
"_none_", 3306,
|
||||||
|
"MySQLBackend",
|
||||||
|
"MySQLBackendAuth",
|
||||||
|
NULL);
|
||||||
if (server == NULL)
|
if (server == NULL)
|
||||||
{
|
{
|
||||||
MXS_ERROR("%s: Error for server_alloc in createInstance",
|
MXS_ERROR("%s: Error for server_alloc in createInstance",
|
||||||
@ -887,12 +912,15 @@ createInstance(SERVICE *service, char **options)
|
|||||||
|
|
||||||
if (inst->ssl_enabled)
|
if (inst->ssl_enabled)
|
||||||
{
|
{
|
||||||
if (service->dbref && service->dbref->server && service->dbref->server->server_ssl)
|
if (service->dbref &&
|
||||||
|
service->dbref->server &&
|
||||||
|
service->dbref->server->server_ssl)
|
||||||
{
|
{
|
||||||
/* Initialise SSL: exit on error */
|
/* Initialise SSL: exit on error */
|
||||||
if (listener_init_SSL(service->dbref->server->server_ssl) != 0)
|
if (listener_init_SSL(service->dbref->server->server_ssl) != 0)
|
||||||
{
|
{
|
||||||
MXS_ERROR("%s: Unable to initialize SSL with backend server", service->name);
|
MXS_ERROR("%s: Unable to initialize SSL with backend server",
|
||||||
|
service->name);
|
||||||
/* Free SSL struct */
|
/* Free SSL struct */
|
||||||
/* Note: SSL struct in server should be freed by server_free() */
|
/* Note: SSL struct in server should be freed by server_free() */
|
||||||
blr_free_ssl_data(inst);
|
blr_free_ssl_data(inst);
|
||||||
@ -1087,7 +1115,7 @@ createInstance(SERVICE *service, char **options)
|
|||||||
inst->m_errno = BINLOG_FATAL_ERROR_READING;
|
inst->m_errno = BINLOG_FATAL_ERROR_READING;
|
||||||
inst->m_errmsg = MXS_STRDUP_A("HY000 Binlog encryption is Off"
|
inst->m_errmsg = MXS_STRDUP_A("HY000 Binlog encryption is Off"
|
||||||
" but current binlog file has"
|
" but current binlog file has"
|
||||||
" the START_ENCRYPTION_EVENT");
|
" the START_ENCRYPTION_EVENT");
|
||||||
|
|
||||||
return (MXS_ROUTER *)inst;
|
return (MXS_ROUTER *)inst;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,8 @@ typedef enum
|
|||||||
#define BLR_NSTATS_MINUTES 30
|
#define BLR_NSTATS_MINUTES 30
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* High and Low water marks for the slave dcb. These values can be overriden
|
* High and Low water marks for the slave dcb.
|
||||||
|
* These values can be overriden
|
||||||
* by the router options highwater and lowwater.
|
* by the router options highwater and lowwater.
|
||||||
*/
|
*/
|
||||||
#define DEF_LOW_WATER "1000"
|
#define DEF_LOW_WATER "1000"
|
||||||
@ -279,8 +280,29 @@ typedef enum
|
|||||||
#define MARIADB_FL_STANDALONE 1
|
#define MARIADB_FL_STANDALONE 1
|
||||||
|
|
||||||
/* Maxwell-related SQL queries */
|
/* Maxwell-related SQL queries */
|
||||||
#define MYSQL_CONNECTOR_SERVER_VARS_QUERY "SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS tx_isolation, @@wait_timeout AS wait_timeout"
|
#define MYSQL_CONNECTOR_SERVER_VARS_QUERY "SELECT " \
|
||||||
#define MYSQL_CONNECTOR_SQL_MODE_QUERY "SET sql_mode='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'"
|
"@@session.auto_increment_increment AS auto_increment_increment, " \
|
||||||
|
"@@character_set_client AS character_set_client, " \
|
||||||
|
"@@character_set_connection AS character_set_connection, " \
|
||||||
|
"@@character_set_results AS character_set_results, " \
|
||||||
|
"@@character_set_server AS character_set_server, " \
|
||||||
|
"@@init_connect AS init_connect, " \
|
||||||
|
"@@interactive_timeout AS interactive_timeout, " \
|
||||||
|
"@@license AS license, " \
|
||||||
|
"@@lower_case_table_names AS lower_case_table_names, " \
|
||||||
|
"@@max_allowed_packet AS max_allowed_packet, " \
|
||||||
|
"@@net_buffer_length AS net_buffer_length, " \
|
||||||
|
"@@net_write_timeout AS net_write_timeout, " \
|
||||||
|
"@@query_cache_size AS query_cache_size, " \
|
||||||
|
"@@query_cache_type AS query_cache_type, " \
|
||||||
|
"@@sql_mode AS sql_mode, " \
|
||||||
|
"@@system_time_zone AS system_time_zone, " \
|
||||||
|
"@@time_zone AS time_zone, " \
|
||||||
|
"@@tx_isolation AS tx_isolation, " \
|
||||||
|
"@@wait_timeout AS wait_timeout"
|
||||||
|
|
||||||
|
#define MYSQL_CONNECTOR_SQL_MODE_QUERY "SET sql_mode=" \
|
||||||
|
"'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'"
|
||||||
|
|
||||||
/* Saved credential file name's tail */
|
/* Saved credential file name's tail */
|
||||||
static const char BLR_DBUSERS_DIR[] = "cache/users";
|
static const char BLR_DBUSERS_DIR[] = "cache/users";
|
||||||
@ -301,7 +323,7 @@ enum blr_event_state
|
|||||||
{
|
{
|
||||||
BLR_EVENT_STARTED, /*< The first packet of an event has been received */
|
BLR_EVENT_STARTED, /*< The first packet of an event has been received */
|
||||||
BLR_EVENT_ONGOING, /*< Other packets of a multi-packet event are being processed */
|
BLR_EVENT_ONGOING, /*< Other packets of a multi-packet event are being processed */
|
||||||
BLR_EVENT_DONE, /*< The complete event was received */
|
BLR_EVENT_DONE, /*< The complete event was received */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** MariaDB GTID elements */
|
/** MariaDB GTID elements */
|
||||||
@ -399,13 +421,14 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct blfile
|
typedef struct blfile
|
||||||
{
|
{
|
||||||
char binlogname[BINLOG_FNAMELEN + 1]; /*< Name of the binlog file */
|
char binlogname[BINLOG_FNAMELEN + 1];
|
||||||
int fd; /*< Actual file descriptor */
|
/*< Name of the binlog file */
|
||||||
int refcnt; /*< Reference count for file */
|
int fd; /*< Actual file descriptor */
|
||||||
BLCACHE *cache; /*< Record cache for this file */
|
int refcnt; /*< Reference count for file */
|
||||||
SPINLOCK lock; /*< The file lock */
|
BLCACHE *cache; /*< Record cache for this file */
|
||||||
MARIADB_GTID_ELEMS info; /*< Elements for file prefix */
|
SPINLOCK lock; /*< The file lock */
|
||||||
struct blfile *next; /*< Next file in list */
|
MARIADB_GTID_ELEMS info; /*< Elements for file prefix */
|
||||||
|
struct blfile *next; /*< Next file in list */
|
||||||
} BLFILE;
|
} BLFILE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -454,49 +477,56 @@ typedef struct router_slave
|
|||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
skygw_chk_t rses_chk_top;
|
skygw_chk_t rses_chk_top;
|
||||||
#endif
|
#endif
|
||||||
DCB *dcb; /*< The slave server DCB */
|
DCB *dcb; /*< The slave server DCB */
|
||||||
int state; /*< The state of this slave */
|
int state; /*< The state of this slave */
|
||||||
uint32_t binlog_pos; /*< Binlog position for this slave */
|
uint32_t binlog_pos; /*< Binlog position for this slave */
|
||||||
char binlogfile[BINLOG_FNAMELEN + 1];
|
char binlogfile[BINLOG_FNAMELEN + 1];
|
||||||
/*< Current binlog file for this slave */
|
/*< Current binlog file for this slave */
|
||||||
char *uuid; /*< Slave UUID */
|
char *uuid; /*< Slave UUID */
|
||||||
#ifdef BLFILE_IN_SLAVE
|
#ifdef BLFILE_IN_SLAVE
|
||||||
BLFILE *file; /*< Currently open binlog file */
|
BLFILE *file; /*< Currently open binlog file */
|
||||||
#endif
|
#endif
|
||||||
int serverid; /*< Server-id of the slave */
|
int serverid; /*< Server-id of the slave */
|
||||||
char *hostname; /*< Hostname of the slave, if known */
|
char *hostname; /*< Hostname of the slave, if known */
|
||||||
char *user; /*< Username if given */
|
char *user; /*< Username if given */
|
||||||
char *passwd; /*< Password if given */
|
char *passwd; /*< Password if given */
|
||||||
short port; /*< MySQL port */
|
short port; /*< MySQL port */
|
||||||
int nocrc; /*< Disable CRC */
|
int nocrc; /*< Disable CRC */
|
||||||
int overrun;
|
int overrun;
|
||||||
uint32_t rank; /*< Replication rank */
|
uint32_t rank; /*< Replication rank */
|
||||||
uint8_t seqno; /*< Replication dump sequence no */
|
uint8_t seqno; /*< Replication dump sequence no */
|
||||||
uint32_t lastEventTimestamp;/*< Last event timestamp sent */
|
uint32_t lastEventTimestamp;
|
||||||
SPINLOCK catch_lock; /*< Event catchup lock */
|
/*< Last event timestamp sent */
|
||||||
unsigned int cstate; /*< Catch up state */
|
SPINLOCK catch_lock; /*< Event catchup lock */
|
||||||
|
unsigned int cstate; /*< Catch up state */
|
||||||
bool mariadb10_compat;/*< MariaDB 10.0 compatibility */
|
bool mariadb10_compat;/*< MariaDB 10.0 compatibility */
|
||||||
SPINLOCK rses_lock; /*< Protects rses_deleted */
|
SPINLOCK rses_lock; /*< Protects rses_deleted */
|
||||||
pthread_t pthread;
|
pthread_t pthread;
|
||||||
struct router_instance
|
struct router_instance *router; /*< Pointer to the owning router */
|
||||||
*router; /*< Pointer to the owning router */
|
|
||||||
struct router_slave *next;
|
struct router_slave *next;
|
||||||
SLAVE_STATS stats; /*< Slave statistics */
|
SLAVE_STATS stats; /*< Slave statistics */
|
||||||
time_t connect_time; /*< Connect time of slave */
|
time_t connect_time; /*< Connect time of slave */
|
||||||
char *warning_msg; /*< Warning message */
|
char *warning_msg; /*< Warning message */
|
||||||
int heartbeat; /*< Heartbeat in seconds */
|
int heartbeat; /*< Heartbeat in seconds */
|
||||||
uint8_t lastEventReceived; /*< Last event received */
|
uint8_t lastEventReceived;
|
||||||
time_t lastReply; /*< Last event sent */
|
/*< Last event received */
|
||||||
// lsi: Last Sent Information
|
time_t lastReply; /*< Last event sent */
|
||||||
blr_thread_role_t lsi_sender_role; /*< Master or slave code sent */
|
/*< lsi: Last Sent Information */
|
||||||
THREAD lsi_sender_tid; /*< Who sent */
|
blr_thread_role_t lsi_sender_role;
|
||||||
char lsi_binlog_name[BINLOG_FNAMELEN + 1]; /*< Which binlog file */
|
/*< Master or slave code sent */
|
||||||
uint32_t lsi_binlog_pos; /*< What position */
|
THREAD lsi_sender_tid;
|
||||||
void *encryption_ctx; /*< Encryption context */
|
/*< Who sent */
|
||||||
bool gtid_strict_mode;/*< MariaDB 10 Slave sets gtid_strict_mode */
|
char lsi_binlog_name[BINLOG_FNAMELEN + 1];
|
||||||
char *mariadb_gtid; /*< MariaDB 10 Slave connects with GTID */
|
/*< Which binlog file */
|
||||||
sqlite3 *gtid_maps; /*< GTID storage client handle, read only*/
|
uint32_t lsi_binlog_pos;
|
||||||
MARIADB_GTID_INFO f_info; /*< GTID info for file name prefix */
|
/*< What position */
|
||||||
|
void *encryption_ctx;
|
||||||
|
/*< Encryption context */
|
||||||
|
bool gtid_strict_mode;
|
||||||
|
/*< MariaDB 10 Slave sets gtid_strict_mode */
|
||||||
|
char *mariadb_gtid; /*< MariaDB 10 Slave connects with GTID */
|
||||||
|
sqlite3 *gtid_maps; /*< GTID storage client handle, read only*/
|
||||||
|
MARIADB_GTID_INFO f_info; /*< GTID info for file name prefix */
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
skygw_chk_t rses_chk_tail;
|
skygw_chk_t rses_chk_tail;
|
||||||
#endif
|
#endif
|
||||||
@ -552,7 +582,10 @@ typedef struct
|
|||||||
GWBUF *map; /*< select @@max_allowed_packet */
|
GWBUF *map; /*< select @@max_allowed_packet */
|
||||||
GWBUF *mariadb10; /*< set @mariadb_slave_capability */
|
GWBUF *mariadb10; /*< set @mariadb_slave_capability */
|
||||||
GWBUF *server_vars; /*< MySQL Connector master server variables */
|
GWBUF *server_vars; /*< MySQL Connector master server variables */
|
||||||
GWBUF *binlog_vars; /*< SELECT @@global.log_bin, @@global.binlog_format, @@global.binlog_row_image; */
|
GWBUF *binlog_vars; /*< SELECT @@global.log_bin,
|
||||||
|
* @@global.binlog_format,
|
||||||
|
* @@global.binlog_row_image;
|
||||||
|
*/
|
||||||
GWBUF *lower_case_tables; /*< select @@lower_case_table_names */
|
GWBUF *lower_case_tables; /*< select @@lower_case_table_names */
|
||||||
} MASTER_RESPONSES;
|
} MASTER_RESPONSES;
|
||||||
|
|
||||||
@ -582,13 +615,14 @@ typedef enum
|
|||||||
/** Transaction Details */
|
/** Transaction Details */
|
||||||
typedef struct pending_transaction
|
typedef struct pending_transaction
|
||||||
{
|
{
|
||||||
char gtid[GTID_MAX_LEN + 1]; /** MariaDB 10.x GTID */
|
char gtid[GTID_MAX_LEN + 1]; /*< MariaDB 10.x GTID */
|
||||||
master_transaction_t state; /** Transaction state */
|
master_transaction_t state; /*< Transaction state */
|
||||||
uint64_t start_pos; /** The BEGIN pos */
|
uint64_t start_pos; /*< The BEGIN pos */
|
||||||
uint64_t end_pos; /** The next_pos in COMMIT event */
|
uint64_t end_pos; /*< The next_pos in COMMIT event */
|
||||||
MARIADB_GTID_ELEMS gtid_elms; /** MariaDB 10.x GTID components */
|
MARIADB_GTID_ELEMS gtid_elms; /*< MariaDB 10.x GTID components */
|
||||||
bool standalone; /** Standalone event, such as DDL
|
bool standalone; /*< Standalone event, such as DDL
|
||||||
* no terminating COMMIT */
|
* no terminating COMMIT
|
||||||
|
*/
|
||||||
} PENDING_TRANSACTION;
|
} PENDING_TRANSACTION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -608,7 +642,8 @@ typedef struct router_instance
|
|||||||
char *password; /*< Password to use with master */
|
char *password; /*< Password to use with master */
|
||||||
char *fileroot; /*< Root of binlog filename */
|
char *fileroot; /*< Root of binlog filename */
|
||||||
bool master_chksum; /*< Does the master provide checksums */
|
bool master_chksum; /*< Does the master provide checksums */
|
||||||
bool mariadb10_compat; /*< MariaDB 10.0 compatibility */
|
bool mariadb10_compat;
|
||||||
|
/*< MariaDB 10.0 compatibility */
|
||||||
bool maxwell_compat; /*< Zendesk's Maxwell compatibility */
|
bool maxwell_compat; /*< Zendesk's Maxwell compatibility */
|
||||||
char *master_uuid; /*< Set UUID of the master, sent to slaves */
|
char *master_uuid; /*< Set UUID of the master, sent to slaves */
|
||||||
DCB *master; /*< DCB for master connection */
|
DCB *master; /*< DCB for master connection */
|
||||||
@ -621,49 +656,51 @@ typedef struct router_instance
|
|||||||
char *binlogdir; /*< The directory with the binlog files */
|
char *binlogdir; /*< The directory with the binlog files */
|
||||||
SPINLOCK binlog_lock; /*< Lock to control update of the binlog position */
|
SPINLOCK binlog_lock; /*< Lock to control update of the binlog position */
|
||||||
int trx_safe; /*< Detect and handle partial transactions */
|
int trx_safe; /*< Detect and handle partial transactions */
|
||||||
PENDING_TRANSACTION pending_transaction; /*< Pending transaction */
|
PENDING_TRANSACTION pending_transaction;
|
||||||
enum blr_event_state master_event_state; /*< Packet read state */
|
/*< Pending transaction */
|
||||||
REP_HEADER stored_header; /*< Relication header of the event the master is sending */
|
enum blr_event_state master_event_state;
|
||||||
GWBUF *stored_event; /*< Buffer where partial events are stored */
|
/*< Packet read state */
|
||||||
uint64_t last_safe_pos; /* last committed transaction */
|
REP_HEADER stored_header;
|
||||||
|
/*< Relication header of the event the master is sending */
|
||||||
|
GWBUF *stored_event; /*< Buffer where partial events are stored */
|
||||||
|
uint64_t last_safe_pos; /* last committed transaction */
|
||||||
char binlog_name[BINLOG_FNAMELEN + 1];
|
char binlog_name[BINLOG_FNAMELEN + 1];
|
||||||
/*< Name of the current binlog file */
|
/*< Name of the current binlog file */
|
||||||
uint64_t binlog_position;
|
uint64_t binlog_position;/*< last committed transaction position */
|
||||||
/*< last committed transaction position */
|
uint64_t current_pos; /*< Current binlog position */
|
||||||
uint64_t current_pos;
|
|
||||||
/*< Current binlog position */
|
|
||||||
int binlog_fd; /*< File descriptor of the binlog
|
int binlog_fd; /*< File descriptor of the binlog
|
||||||
* file being written
|
* file being written
|
||||||
*/
|
*/
|
||||||
uint64_t last_written; /*< Position of the last write operation */
|
uint64_t last_written; /*< Position of the last write operation */
|
||||||
uint64_t last_event_pos; /*< Position of last event written */
|
uint64_t last_event_pos; /*< Position of last event written */
|
||||||
uint64_t current_safe_event;
|
uint64_t current_safe_event;
|
||||||
/*< Position of the latest safe event being sent to slaves */
|
/*< Position of the latest safe event being sent to slaves */
|
||||||
char prevbinlog[BINLOG_FNAMELEN + 1];
|
char prevbinlog[BINLOG_FNAMELEN + 1];
|
||||||
int rotating; /*< Rotation in progress flag */
|
int rotating; /*< Rotation in progress flag */
|
||||||
BLFILE *files; /*< Files used by the slaves */
|
BLFILE *files; /*< Files used by the slaves */
|
||||||
SPINLOCK fileslock; /*< Lock for the files queue above */
|
SPINLOCK fileslock; /*< Lock for the files queue above */
|
||||||
unsigned int short_burst; /*< Short burst for slave catchup */
|
unsigned int short_burst; /*< Short burst for slave catchup */
|
||||||
unsigned int long_burst; /*< Long burst for slave catchup */
|
unsigned int long_burst; /*< Long burst for slave catchup */
|
||||||
unsigned long burst_size; /*< Maximum size of burst to send */
|
unsigned long burst_size; /*< Maximum size of burst to send */
|
||||||
unsigned long heartbeat; /*< Configured heartbeat value */
|
unsigned long heartbeat; /*< Configured heartbeat value */
|
||||||
ROUTER_STATS stats; /*< Statistics for this router */
|
ROUTER_STATS stats; /*< Statistics for this router */
|
||||||
int active_logs;
|
int active_logs;
|
||||||
int reconnect_pending;
|
int reconnect_pending;
|
||||||
int retry_backoff;
|
int retry_backoff;
|
||||||
time_t connect_time;
|
time_t connect_time;
|
||||||
int handling_threads;
|
int handling_threads;
|
||||||
unsigned long m_errno; /*< master response mysql errno */
|
unsigned long m_errno; /*< master response mysql errno */
|
||||||
char *m_errmsg; /*< master response mysql error message */
|
char *m_errmsg; /*< master response mysql error message */
|
||||||
char *set_master_version; /*< Send custom Version to slaves */
|
char *set_master_version; /*< Send custom Version to slaves */
|
||||||
char *set_master_hostname; /*< Send custom Hostname to slaves */
|
char *set_master_hostname; /*< Send custom Hostname to slaves */
|
||||||
bool set_master_uuid; /*< Send custom Master UUID to slaves */
|
bool set_master_uuid; /*< Send custom Master UUID to slaves */
|
||||||
bool set_master_server_id; /*< Send custom Master server_id to slaves */
|
bool set_master_server_id; /*< Send custom Master server_id to slaves */
|
||||||
int send_slave_heartbeat; /*< Enable sending heartbeat to slaves */
|
int send_slave_heartbeat; /*< Enable sending heartbeat to slaves */
|
||||||
bool ssl_enabled; /*< Use SSL connection to master */
|
bool ssl_enabled; /*< Use SSL connection to master */
|
||||||
int ssl_cert_verification_depth; /*< The maximum length of the certificate
|
int ssl_cert_verification_depth;
|
||||||
* authority chain that will be accepted.
|
/*< The maximum length of the certificate
|
||||||
*/
|
* authority chain that will be accepted.
|
||||||
|
*/
|
||||||
char *ssl_key; /*< config Certificate Key for Master SSL connection */
|
char *ssl_key; /*< config Certificate Key for Master SSL connection */
|
||||||
char *ssl_ca; /*< config CA Certificate for Master SSL connection */
|
char *ssl_ca; /*< config CA Certificate for Master SSL connection */
|
||||||
char *ssl_cert; /*< config Certificate for Master SSL connection */
|
char *ssl_cert; /*< config Certificate for Master SSL connection */
|
||||||
@ -672,11 +709,12 @@ typedef struct router_instance
|
|||||||
int master_semi_sync; /*< Semi-Sync replication status of master server */
|
int master_semi_sync; /*< Semi-Sync replication status of master server */
|
||||||
BINLOG_ENCRYPTION_SETUP encryption; /*< Binlog encryption setup */
|
BINLOG_ENCRYPTION_SETUP encryption; /*< Binlog encryption setup */
|
||||||
void *encryption_ctx; /*< Encryption context */
|
void *encryption_ctx; /*< Encryption context */
|
||||||
char last_mariadb_gtid[GTID_MAX_LEN + 1]; /*< Last seen MariaDB 10 GTID */
|
char last_mariadb_gtid[GTID_MAX_LEN + 1];
|
||||||
bool mariadb10_gtid; /*< Save received MariaDB GTIDs into repo.
|
/*< Last seen MariaDB 10 GTID */
|
||||||
* This allows MariaDB 10 slave servers
|
bool mariadb10_gtid; /*< Save received MariaDB GTIDs into repo.
|
||||||
* connecting with GTID
|
* This allows MariaDB 10 slave servers
|
||||||
*/
|
* connecting with GTID
|
||||||
|
*/
|
||||||
bool mariadb10_master_gtid;/*< Enables MariaDB 10 GTID registration
|
bool mariadb10_master_gtid;/*< Enables MariaDB 10 GTID registration
|
||||||
* to MariaDB 10.0/10.1 Master
|
* to MariaDB 10.0/10.1 Master
|
||||||
*/
|
*/
|
||||||
@ -695,12 +733,12 @@ typedef struct slave_encryption_ctx
|
|||||||
uint8_t binlog_crypto_scheme; /**< Encryption scheme */
|
uint8_t binlog_crypto_scheme; /**< Encryption scheme */
|
||||||
uint32_t binlog_key_version; /**< Encryption key version */
|
uint32_t binlog_key_version; /**< Encryption key version */
|
||||||
uint8_t nonce[AES_BLOCK_SIZE]; /**< nonce (random bytes) of current binlog.
|
uint8_t nonce[AES_BLOCK_SIZE]; /**< nonce (random bytes) of current binlog.
|
||||||
* These bytes + the binlog event current pos
|
* These bytes + the binlog event current pos
|
||||||
* form the encrryption IV for the event */
|
* form the encrryption IV for the event */
|
||||||
char *log_file; /**< The log file the client has requested */
|
char *log_file; /**< The log file the client has requested */
|
||||||
uint32_t first_enc_event_pos; /**< The position of first encrypted event
|
uint32_t first_enc_event_pos; /**< The position of first encrypted event
|
||||||
* It's the first event afte Start_encryption_event
|
* It's the first event afte Start_encryption_event
|
||||||
* Which is after FDE */
|
* Which is after FDE */
|
||||||
} SLAVE_ENCRYPTION_CTX;
|
} SLAVE_ENCRYPTION_CTX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -712,8 +750,8 @@ typedef struct binlog_encryption_ctx
|
|||||||
uint8_t binlog_crypto_scheme; /**< Encryption scheme */
|
uint8_t binlog_crypto_scheme; /**< Encryption scheme */
|
||||||
uint32_t binlog_key_version; /**< Encryption key version */
|
uint32_t binlog_key_version; /**< Encryption key version */
|
||||||
uint8_t nonce[AES_BLOCK_SIZE]; /**< nonce (random bytes) of current binlog.
|
uint8_t nonce[AES_BLOCK_SIZE]; /**< nonce (random bytes) of current binlog.
|
||||||
* These bytes + the binlog event current pos
|
* These bytes + the binlog event current pos
|
||||||
* form the encrryption IV for the event */
|
* form the encrryption IV for the event */
|
||||||
char *binlog_file; /**< Current binlog file being encrypted */
|
char *binlog_file; /**< Current binlog file being encrypted */
|
||||||
} BINLOG_ENCRYPTION_CTX;
|
} BINLOG_ENCRYPTION_CTX;
|
||||||
|
|
||||||
@ -729,15 +767,18 @@ typedef struct binlog_pos_fix
|
|||||||
{
|
{
|
||||||
bool fix; /**< Truncate file to last safe pos */
|
bool fix; /**< Truncate file to last safe pos */
|
||||||
uint64_t pos; /**< Position of the event to be replaced
|
uint64_t pos; /**< Position of the event to be replaced
|
||||||
* by an Ignorable Event */
|
* by an Ignorable Event
|
||||||
|
*/
|
||||||
bool replace_trx; /**< Replace all events belonging to
|
bool replace_trx; /**< Replace all events belonging to
|
||||||
* a transaction starting at pos */
|
* a transaction starting at pos
|
||||||
|
*/
|
||||||
} BINLOG_FILE_FIX;
|
} BINLOG_FILE_FIX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines and offsets for binlog encryption
|
* Defines and offsets for binlog encryption
|
||||||
*
|
*
|
||||||
* BLRM_FDE_EVENT_TYPES_OFFSET is the offset in FDE event content that points to
|
* BLRM_FDE_EVENT_TYPES_OFFSET is the offset
|
||||||
|
* in FDE event content that points to
|
||||||
* the number of events the master server supports.
|
* the number of events the master server supports.
|
||||||
*/
|
*/
|
||||||
#define BLR_FDE_EVENT_BINLOG_VERSION 2
|
#define BLR_FDE_EVENT_BINLOG_VERSION 2
|
||||||
@ -846,7 +887,11 @@ static char *blrm_states[] =
|
|||||||
|
|
||||||
static char *blrs_states[] =
|
static char *blrs_states[] =
|
||||||
{
|
{
|
||||||
"Created", "Unregistered", "Registered", "Sending binlogs", "Errored"
|
"Created",
|
||||||
|
"Unregistered",
|
||||||
|
"Registered",
|
||||||
|
"Sending binlogs",
|
||||||
|
"Errored"
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -860,12 +905,12 @@ static char *blrs_states[] =
|
|||||||
/**
|
/**
|
||||||
* MySQL protocol OpCodes needed for replication
|
* MySQL protocol OpCodes needed for replication
|
||||||
*/
|
*/
|
||||||
#define COM_QUIT 0x01
|
#define COM_QUIT 0x01
|
||||||
#define COM_QUERY 0x03
|
#define COM_QUERY 0x03
|
||||||
#define COM_STATISTICS 0x09
|
#define COM_STATISTIC 0x09
|
||||||
#define COM_PING 0x0e
|
#define COM_PING 0x0e
|
||||||
#define COM_REGISTER_SLAVE 0x15
|
#define COM_REGISTER_SLAVE 0x15
|
||||||
#define COM_BINLOG_DUMP 0x12
|
#define COM_BINLOG_DUMP 0x12
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macros to extract common fields
|
* Macros to extract common fields
|
||||||
@ -895,25 +940,43 @@ extern void blr_master_response(ROUTER_INSTANCE *, GWBUF *);
|
|||||||
extern void blr_master_reconnect(ROUTER_INSTANCE *);
|
extern void blr_master_reconnect(ROUTER_INSTANCE *);
|
||||||
extern int blr_master_connected(ROUTER_INSTANCE *);
|
extern int blr_master_connected(ROUTER_INSTANCE *);
|
||||||
|
|
||||||
extern int blr_slave_request(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);
|
extern int blr_slave_request(ROUTER_INSTANCE *,
|
||||||
extern void blr_slave_rotate(ROUTER_INSTANCE *, ROUTER_SLAVE *, uint8_t *);
|
ROUTER_SLAVE *,
|
||||||
extern int blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large);
|
GWBUF *);
|
||||||
|
extern void blr_slave_rotate(ROUTER_INSTANCE *,
|
||||||
|
ROUTER_SLAVE *,
|
||||||
|
uint8_t *);
|
||||||
|
extern int blr_slave_catchup(ROUTER_INSTANCE *router,
|
||||||
|
ROUTER_SLAVE *slave,
|
||||||
|
bool large);
|
||||||
extern void blr_init_cache(ROUTER_INSTANCE *);
|
extern void blr_init_cache(ROUTER_INSTANCE *);
|
||||||
|
|
||||||
extern int blr_file_init(ROUTER_INSTANCE *);
|
extern int blr_file_init(ROUTER_INSTANCE *);
|
||||||
extern int blr_write_binlog_record(ROUTER_INSTANCE *, REP_HEADER *, uint32_t pos, uint8_t *);
|
extern int blr_write_binlog_record(ROUTER_INSTANCE *,
|
||||||
extern int blr_file_rotate(ROUTER_INSTANCE *, char *, uint64_t);
|
REP_HEADER *,
|
||||||
|
uint32_t pos,
|
||||||
|
uint8_t *);
|
||||||
|
extern int blr_file_rotate(ROUTER_INSTANCE *,
|
||||||
|
char *,
|
||||||
|
uint64_t);
|
||||||
extern void blr_file_flush(ROUTER_INSTANCE *);
|
extern void blr_file_flush(ROUTER_INSTANCE *);
|
||||||
extern BLFILE *blr_open_binlog(ROUTER_INSTANCE *,
|
extern BLFILE *blr_open_binlog(ROUTER_INSTANCE *,
|
||||||
const char *,
|
const char *,
|
||||||
const MARIADB_GTID_INFO *);
|
const MARIADB_GTID_INFO *);
|
||||||
extern GWBUF *blr_read_binlog(ROUTER_INSTANCE *, BLFILE *, unsigned long, REP_HEADER *, char *,
|
extern GWBUF *blr_read_binlog(ROUTER_INSTANCE *, BLFILE *,
|
||||||
|
unsigned long, REP_HEADER *,
|
||||||
|
char *,
|
||||||
const SLAVE_ENCRYPTION_CTX *);
|
const SLAVE_ENCRYPTION_CTX *);
|
||||||
extern void blr_close_binlog(ROUTER_INSTANCE *, BLFILE *);
|
extern void blr_close_binlog(ROUTER_INSTANCE *, BLFILE *);
|
||||||
extern unsigned long blr_file_size(BLFILE *);
|
extern unsigned long blr_file_size(BLFILE *);
|
||||||
extern int blr_statistics(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);
|
extern int blr_statistics(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);
|
||||||
extern int blr_ping(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);
|
extern int blr_ping(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);
|
||||||
extern int blr_send_custom_error(DCB *, int, int, char *, char *, unsigned int);
|
extern int blr_send_custom_error(DCB *,
|
||||||
|
int,
|
||||||
|
int,
|
||||||
|
char *,
|
||||||
|
char *,
|
||||||
|
unsigned int);
|
||||||
extern int blr_file_next_exists(ROUTER_INSTANCE *,
|
extern int blr_file_next_exists(ROUTER_INSTANCE *,
|
||||||
ROUTER_SLAVE *,
|
ROUTER_SLAVE *,
|
||||||
char *next_file);
|
char *next_file);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -477,10 +477,13 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
|||||||
rv = 1;
|
rv = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
blr_send_custom_error(slave->dcb, 1, 0,
|
blr_send_custom_error(slave->dcb,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
"You have an error in your SQL syntax; Check the "
|
"You have an error in your SQL syntax; Check the "
|
||||||
"syntax the MaxScale binlog router accepts.",
|
"syntax the MaxScale binlog router accepts.",
|
||||||
"42000", 1064);
|
"42000",
|
||||||
|
1064);
|
||||||
MXS_ERROR("Unexpected MySQL Command (%d) received from slave",
|
MXS_ERROR("Unexpected MySQL Command (%d) received from slave",
|
||||||
MYSQL_COMMAND(queue));
|
MYSQL_COMMAND(queue));
|
||||||
break;
|
break;
|
||||||
@ -633,7 +636,8 @@ blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MXS_INFO("Execute statement (truncated, it contains password)"
|
MXS_INFO("Execute statement (truncated, it contains password)"
|
||||||
" from the slave '%s'", new_text);
|
" from the slave '%s'",
|
||||||
|
new_text);
|
||||||
MXS_FREE(new_text);
|
MXS_FREE(new_text);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -722,7 +726,7 @@ blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
|||||||
if (blr_handle_admin_stmt(router,
|
if (blr_handle_admin_stmt(router,
|
||||||
slave,
|
slave,
|
||||||
word,
|
word,
|
||||||
brkb))
|
brkb))
|
||||||
{
|
{
|
||||||
MXS_FREE(query_text);
|
MXS_FREE(query_text);
|
||||||
return 1;
|
return 1;
|
||||||
@ -744,7 +748,9 @@ blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_INFO("Unexpected query from '%s'@'%s', possibly a 10.1 slave: %s",
|
MXS_INFO("Unexpected query from '%s'@'%s', possibly a 10.1 slave: %s",
|
||||||
slave->dcb->user, slave->dcb->remote, query_text);
|
slave->dcb->user,
|
||||||
|
slave->dcb->remote,
|
||||||
|
query_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_FREE(query_text);
|
MXS_FREE(query_text);
|
||||||
@ -1087,21 +1093,61 @@ blr_slave_send_master_status(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
|||||||
*/
|
*/
|
||||||
static char *slave_status_columns[] =
|
static char *slave_status_columns[] =
|
||||||
{
|
{
|
||||||
"Slave_IO_State", "Master_Host", "Master_User", "Master_Port", "Connect_Retry",
|
"Slave_IO_State",
|
||||||
"Master_Log_File", "Read_Master_Log_Pos", "Relay_Log_File", "Relay_Log_Pos",
|
"Master_Host",
|
||||||
"Relay_Master_Log_File", "Slave_IO_Running", "Slave_SQL_Running", "Replicate_Do_DB",
|
"Master_User",
|
||||||
"Replicate_Ignore_DB", "Replicate_Do_Table",
|
"Master_Port",
|
||||||
"Replicate_Ignore_Table", "Replicate_Wild_Do_Table", "Replicate_Wild_Ignore_Table",
|
"Connect_Retry",
|
||||||
"Last_Errno", "Last_Error", "Skip_Counter", "Exec_Master_Log_Pos", "Relay_Log_Space",
|
"Master_Log_File",
|
||||||
"Until_Condition", "Until_Log_File", "Until_Log_Pos", "Master_SSL_Allowed",
|
"Read_Master_Log_Pos",
|
||||||
"Master_SSL_CA_File", "Master_SSL_CA_Path", "Master_SSL_Cert", "Master_SSL_Cipher",
|
"Relay_Log_File",
|
||||||
"Master_SSL_Key", "Seconds_Behind_Master",
|
"Relay_Log_Pos",
|
||||||
"Master_SSL_Verify_Server_Cert", "Last_IO_Errno", "Last_IO_Error", "Last_SQL_Errno",
|
"Relay_Master_Log_File",
|
||||||
"Last_SQL_Error", "Replicate_Ignore_Server_Ids", "Master_Server_Id", "Master_UUID",
|
"Slave_IO_Running",
|
||||||
"Master_Info_File", "SQL_Delay", "SQL_Remaining_Delay", "Slave_SQL_Running_State",
|
"Slave_SQL_Running",
|
||||||
"Master_Retry_Count", "Master_Bind", "Last_IO_Error_TimeStamp",
|
"Replicate_Do_DB",
|
||||||
"Last_SQL_Error_Timestamp", "Master_SSL_Crl", "Master_SSL_Crlpath",
|
"Replicate_Ignore_DB",
|
||||||
"Retrieved_Gtid_Set", "Executed_Gtid_Set", "Auto_Position", NULL
|
"Replicate_Do_Table",
|
||||||
|
"Replicate_Ignore_Table",
|
||||||
|
"Replicate_Wild_Do_Table",
|
||||||
|
"Replicate_Wild_Ignore_Table",
|
||||||
|
"Last_Errno",
|
||||||
|
"Last_Error",
|
||||||
|
"Skip_Counter",
|
||||||
|
"Exec_Master_Log_Pos",
|
||||||
|
"Relay_Log_Space",
|
||||||
|
"Until_Condition",
|
||||||
|
"Until_Log_File",
|
||||||
|
"Until_Log_Pos",
|
||||||
|
"Master_SSL_Allowed",
|
||||||
|
"Master_SSL_CA_File",
|
||||||
|
"Master_SSL_CA_Path",
|
||||||
|
"Master_SSL_Cert",
|
||||||
|
"Master_SSL_Cipher",
|
||||||
|
"Master_SSL_Key",
|
||||||
|
"Seconds_Behind_Master",
|
||||||
|
"Master_SSL_Verify_Server_Cert",
|
||||||
|
"Last_IO_Errno",
|
||||||
|
"Last_IO_Error",
|
||||||
|
"Last_SQL_Errno",
|
||||||
|
"Last_SQL_Error",
|
||||||
|
"Replicate_Ignore_Server_Ids",
|
||||||
|
"Master_Server_Id",
|
||||||
|
"Master_UUID",
|
||||||
|
"Master_Info_File",
|
||||||
|
"SQL_Delay",
|
||||||
|
"SQL_Remaining_Delay",
|
||||||
|
"Slave_SQL_Running_State",
|
||||||
|
"Master_Retry_Count",
|
||||||
|
"Master_Bind",
|
||||||
|
"Last_IO_Error_TimeStamp",
|
||||||
|
"Last_SQL_Error_Timestamp",
|
||||||
|
"Master_SSL_Crl",
|
||||||
|
"Master_SSL_Crlpath",
|
||||||
|
"Retrieved_Gtid_Set",
|
||||||
|
"Executed_Gtid_Set",
|
||||||
|
"Auto_Position",
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1206,8 +1252,12 @@ blr_slave_send_slave_status(ROUTER_INSTANCE *router,
|
|||||||
ptr += col_len;
|
ptr += col_len;
|
||||||
|
|
||||||
// Master_Host
|
// Master_Host
|
||||||
snprintf(column, max_column_size, "%s",
|
snprintf(column,
|
||||||
router->service->dbref->server->name ? router->service->dbref->server->name : "");
|
max_column_size,
|
||||||
|
"%s",
|
||||||
|
router->service->dbref->server->name ?
|
||||||
|
router->service->dbref->server->name :
|
||||||
|
"");
|
||||||
col_len = strlen(column);
|
col_len = strlen(column);
|
||||||
*ptr++ = col_len; // Length of result string
|
*ptr++ = col_len; // Length of result string
|
||||||
memcpy((char *)ptr, column, col_len); // Result string
|
memcpy((char *)ptr, column, col_len); // Result string
|
||||||
@ -1961,7 +2011,8 @@ blr_slave_binlog_dump(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue
|
|||||||
router->service->name, slave->dcb->remote,
|
router->service->name, slave->dcb->remote,
|
||||||
dcb_get_port(slave->dcb),
|
dcb_get_port(slave->dcb),
|
||||||
slave->serverid,
|
slave->serverid,
|
||||||
slave->binlogfile, (unsigned long)slave->binlog_pos);
|
slave->binlogfile,
|
||||||
|
(unsigned long)slave->binlog_pos);
|
||||||
|
|
||||||
/* Force the slave to call catchup routine */
|
/* Force the slave to call catchup routine */
|
||||||
poll_fake_write_event(slave->dcb);
|
poll_fake_write_event(slave->dcb);
|
||||||
@ -2313,7 +2364,8 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
|
|||||||
#endif
|
#endif
|
||||||
if (hkheartbeat - beat1 > 1)
|
if (hkheartbeat - beat1 > 1)
|
||||||
{
|
{
|
||||||
MXS_ERROR("blr_open_binlog took %lu beats", hkheartbeat - beat1);
|
MXS_ERROR("blr_open_binlog took %lu beats",
|
||||||
|
hkheartbeat - beat1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2518,8 +2570,10 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
|
|||||||
slave->dcb->remote,
|
slave->dcb->remote,
|
||||||
dcb_get_port(slave->dcb),
|
dcb_get_port(slave->dcb),
|
||||||
slave->serverid,
|
slave->serverid,
|
||||||
slave->binlogfile, (unsigned long)slave->binlog_pos,
|
slave->binlogfile,
|
||||||
router->binlog_name, router->binlog_position);
|
(unsigned long)slave->binlog_pos,
|
||||||
|
router->binlog_name,
|
||||||
|
router->binlog_position);
|
||||||
|
|
||||||
/* Reset encryption context */
|
/* Reset encryption context */
|
||||||
MXS_FREE(slave->encryption_ctx);
|
MXS_FREE(slave->encryption_ctx);
|
||||||
@ -2527,9 +2581,15 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
|
|||||||
|
|
||||||
/* Now pass the next_file to blr_slave_fake_rotate() */
|
/* Now pass the next_file to blr_slave_fake_rotate() */
|
||||||
#ifdef BLFILE_IN_SLAVE
|
#ifdef BLFILE_IN_SLAVE
|
||||||
if (blr_slave_fake_rotate(router, slave, &slave->file, next_file))
|
if (blr_slave_fake_rotate(router,
|
||||||
|
slave,
|
||||||
|
&slave->file,
|
||||||
|
next_file))
|
||||||
#else
|
#else
|
||||||
if (blr_slave_fake_rotate(router, slave, &file, next_file))
|
if (blr_slave_fake_rotate(router,
|
||||||
|
slave,
|
||||||
|
&file,
|
||||||
|
next_file))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
spinlock_acquire(&slave->catch_lock);
|
spinlock_acquire(&slave->catch_lock);
|
||||||
@ -2739,7 +2799,12 @@ blr_slave_read_fde(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* FDE is not encrypted, so we can pass NULL to last parameter */
|
/* FDE is not encrypted, so we can pass NULL to last parameter */
|
||||||
if ((record = blr_read_binlog(router, file, 4, &hdr, err_msg, NULL)) == NULL)
|
if ((record = blr_read_binlog(router,
|
||||||
|
file,
|
||||||
|
4,
|
||||||
|
&hdr,
|
||||||
|
err_msg,
|
||||||
|
NULL)) == NULL)
|
||||||
{
|
{
|
||||||
if (hdr.ok != SLAVE_POS_READ_OK)
|
if (hdr.ok != SLAVE_POS_READ_OK)
|
||||||
{
|
{
|
||||||
@ -3196,10 +3261,10 @@ blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a MySQL OK packet to the slave backend
|
* Send a MySQL OK packet to the connected client
|
||||||
*
|
*
|
||||||
* @param router The binlog router instance
|
* @param router The binlog router instance
|
||||||
* @param slave The slave server to which we are sending the response
|
* @param slave The slave server to which we are sending data
|
||||||
*
|
*
|
||||||
* @return Result of a write call, non-zero if successful
|
* @return Result of a write call, non-zero if successful
|
||||||
*/
|
*/
|
||||||
@ -3227,11 +3292,11 @@ blr_slave_send_ok(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a MySQL OK packet with a message to the slave backend
|
* Send a MySQL OK packet with a message to the client
|
||||||
*
|
*
|
||||||
* @param router The binlog router instance
|
* @param router The binlog router instance
|
||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
* @param slave The slave server to which we are sending the response
|
* @param slave The slave server to which we are sending data
|
||||||
*
|
*
|
||||||
* @return The write call result: non-zero on success
|
* @return The write call result: non-zero on success
|
||||||
*/
|
*/
|
||||||
@ -5289,7 +5354,9 @@ blr_slave_show_warnings(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
|||||||
msg_ptr = strchr(slave->warning_msg, ':');
|
msg_ptr = strchr(slave->warning_msg, ':');
|
||||||
if (msg_ptr)
|
if (msg_ptr)
|
||||||
{
|
{
|
||||||
size_t len = (msg_ptr - slave->warning_msg > 16) ? 16 : (msg_ptr - slave->warning_msg);
|
size_t len = (msg_ptr - slave->warning_msg > 16) ?
|
||||||
|
16 :
|
||||||
|
(msg_ptr - slave->warning_msg);
|
||||||
memcpy(err_code, slave->warning_msg, len);
|
memcpy(err_code, slave->warning_msg, len);
|
||||||
err_code[len] = 0;
|
err_code[len] = 0;
|
||||||
code_len = strlen(err_code);
|
code_len = strlen(err_code);
|
||||||
@ -7457,7 +7524,8 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE *router,
|
|||||||
blr_slave_send_error_packet(slave,
|
blr_slave_send_error_packet(slave,
|
||||||
"This operation cannot be performed "
|
"This operation cannot be performed "
|
||||||
"with a running slave; run STOP SLAVE first",
|
"with a running slave; run STOP SLAVE first",
|
||||||
(unsigned int)1198, NULL);
|
(unsigned int)1198,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -7508,7 +7576,8 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE *router,
|
|||||||
blr_slave_send_error_packet(slave,
|
blr_slave_send_error_packet(slave,
|
||||||
"Cannot change master with a running slave; "
|
"Cannot change master with a running slave; "
|
||||||
"run STOP SLAVE first",
|
"run STOP SLAVE first",
|
||||||
(unsigned int)1198, NULL);
|
(unsigned int)1198,
|
||||||
|
NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user