Binlog Server doesn't ask for any maxwell query if the option is not set

If ‘maxwell-compatibility’ option is not set, no SET/SELECT are sent to
master during slave registration phase
This commit is contained in:
MassimilianoPinto
2017-03-14 09:28:04 +01:00
parent 147a1f88eb
commit 573615889b
2 changed files with 74 additions and 35 deletions

View File

@ -703,14 +703,15 @@ typedef struct binlog_pos_fix
#define BLRM_SERVER_VARS 0x0016 #define BLRM_SERVER_VARS 0x0016
#define BLRM_BINLOG_VARS 0x0017 #define BLRM_BINLOG_VARS 0x0017
#define BLRM_LOWER_CASE_TABLES 0x0018 #define BLRM_LOWER_CASE_TABLES 0x0018
#define BLRM_REGISTER 0x0019 #define BLRM_REGISTER_READY 0x0019
#define BLRM_CHECK_SEMISYNC 0x001A #define BLRM_REGISTER 0x001A
#define BLRM_REQUEST_SEMISYNC 0x001B #define BLRM_CHECK_SEMISYNC 0x001B
#define BLRM_REQUEST_BINLOGDUMP 0x001C #define BLRM_REQUEST_SEMISYNC 0x001C
#define BLRM_BINLOGDUMP 0x001D #define BLRM_REQUEST_BINLOGDUMP 0x001D
#define BLRM_SLAVE_STOPPED 0x001E #define BLRM_BINLOGDUMP 0x001E
#define BLRM_SLAVE_STOPPED 0x001F
#define BLRM_MAXSTATE 0x001E #define BLRM_MAXSTATE 0x001F
static char *blrm_states[] = static char *blrm_states[] =
{ {
@ -739,6 +740,7 @@ static char *blrm_states[] =
"Query server variables", "Query server variables",
"Query binlog variables", "Query binlog variables",
"Query @@lower_case_table_names", "Query @@lower_case_table_names",
"Ready to Register",
"Register slave", "Register slave",
"Semi-Sync Support retrivial", "Semi-Sync Support retrivial",
"Request Semi-Sync Replication", "Request Semi-Sync Replication",

View File

@ -722,43 +722,80 @@ blr_master_response(ROUTER_INSTANCE *router, GWBUF *buf)
router->saved_master.map = buf; router->saved_master.map = buf;
blr_cache_response(router, "map", buf); blr_cache_response(router, "map", buf);
// Query for Server Variables if (router->maxwell_compat)
buf = blr_make_query(router->master, MYSQL_CONNECTOR_SERVER_VARS_QUERY); {
router->master_state = BLRM_SERVER_VARS; // Query for Server Variables
router->master->func.write(router->master, buf); buf = blr_make_query(router->master, MYSQL_CONNECTOR_SERVER_VARS_QUERY);
break; router->master_state = BLRM_SERVER_VARS;
router->master->func.write(router->master, buf);
break;
}
else
{
// Continue: ready for the registration, nothing to write/read
router->master_state = BLRM_REGISTER_READY;
}
case BLRM_SERVER_VARS: case BLRM_SERVER_VARS:
if (router->saved_master.server_vars) /**
* This branch could be reached as fallthrough from BLRM_MAP
* with new state BLRM_REGISTER_READY
* Go ahead if maxwell_compat is not set
*/
if (router->maxwell_compat)
{ {
GWBUF_CONSUME_ALL(router->saved_master.server_vars); if (router->saved_master.server_vars)
} {
router->saved_master.server_vars = buf; GWBUF_CONSUME_ALL(router->saved_master.server_vars);
blr_cache_response(router, "server_vars", buf); }
router->saved_master.server_vars = buf;
blr_cache_response(router, "server_vars", buf);
buf = blr_make_query(router->master, "SELECT IF(@@global.log_bin, 'ON', 'OFF'), @@global.binlog_format, @@global.binlog_row_image"); buf = blr_make_query(router->master,
router->master_state = BLRM_BINLOG_VARS; "SELECT IF(@@global.log_bin, 'ON', 'OFF'), "
router->master->func.write(router->master, buf); "@@global.binlog_format, @@global.binlog_row_image");
break; router->master_state = BLRM_BINLOG_VARS;
router->master->func.write(router->master, buf);
break;
}
case BLRM_BINLOG_VARS: case BLRM_BINLOG_VARS:
if (router->saved_master.binlog_vars) /**
* This branch could be reached as fallthrough from BLRM_MAP
* with new state BLRM_REGISTER_READY.
* Go ahead if maxwell_compat is not set
*/
if (router->maxwell_compat)
{ {
GWBUF_CONSUME_ALL(router->saved_master.binlog_vars); if (router->saved_master.binlog_vars)
} {
router->saved_master.binlog_vars = buf; GWBUF_CONSUME_ALL(router->saved_master.binlog_vars);
blr_cache_response(router, "binlog_vars", buf); }
router->saved_master.binlog_vars = buf;
blr_cache_response(router, "binlog_vars", buf);
buf = blr_make_query(router->master, "select @@lower_case_table_names"); buf = blr_make_query(router->master, "select @@lower_case_table_names");
router->master_state = BLRM_LOWER_CASE_TABLES; router->master_state = BLRM_LOWER_CASE_TABLES;
router->master->func.write(router->master, buf); router->master->func.write(router->master, buf);
break; break;
}
case BLRM_LOWER_CASE_TABLES: case BLRM_LOWER_CASE_TABLES:
if (router->saved_master.lower_case_tables) /**
* This branch could be reached as fallthrough from BLRM_MAP
* with new state BLRM_REGISTER_READY.
* Go ahead if maxwell_compat is not set
*/
if (router->maxwell_compat)
{ {
GWBUF_CONSUME_ALL(router->saved_master.lower_case_tables); if (router->saved_master.lower_case_tables)
{
GWBUF_CONSUME_ALL(router->saved_master.lower_case_tables);
}
router->saved_master.lower_case_tables = buf;
blr_cache_response(router, "lower_case_tables", buf);
router->master_state = BLRM_REGISTER_READY;
// Continue: ready for the registration, nothing to write/read
} }
router->saved_master.lower_case_tables = buf; case BLRM_REGISTER_READY:
blr_cache_response(router, "lower_case_tables", buf); // Prepare registration
buf = blr_make_registration(router); buf = blr_make_registration(router);
router->master_state = BLRM_REGISTER; router->master_state = BLRM_REGISTER;
router->master->func.write(router->master, buf); router->master->func.write(router->master, buf);