Remove unused DCB callback code

The highwater and lowwater callbacks were never registered for the client
DCBs in the binlogrouter.

The DCB hangup callbacks were never called by the core and were replaced
with fake hangup events in an earlier version.
This commit is contained in:
Markus Mäkelä
2017-02-21 10:25:01 +02:00
parent c3cc46ae04
commit 68f99ae305
7 changed files with 0 additions and 161 deletions

View File

@ -192,8 +192,6 @@ MXS_MODULE* MXS_CREATE_MODULE()
{"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},
{"lowwater", MXS_MODULE_PARAM_COUNT, DEF_LOW_WATER},
{"highwater", MXS_MODULE_PARAM_COUNT, DEF_HIGH_WATER},
{"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},
@ -321,8 +319,6 @@ createInstance(SERVICE *service, char **options)
MXS_CONFIG_PARAMETER *params = service->svc_config_param; MXS_CONFIG_PARAMETER *params = service->svc_config_param;
inst->low_water = config_get_integer(params, "lowwater");
inst->high_water = config_get_integer(params, "highwater");
inst->initbinlog = config_get_integer(params, "file"); inst->initbinlog = config_get_integer(params, "file");
inst->short_burst = config_get_integer(params, "shortburst"); inst->short_burst = config_get_integer(params, "shortburst");
@ -394,8 +390,6 @@ createInstance(SERVICE *service, char **options)
* password= * password=
* master-id= * master-id=
* filestem= * filestem=
* lowwater=
* highwater=
*/ */
if (options) if (options)
{ {
@ -535,14 +529,6 @@ createInstance(SERVICE *service, char **options)
MXS_FREE(inst->encryption.key_management_filename); MXS_FREE(inst->encryption.key_management_filename);
inst->encryption.key_management_filename = MXS_STRDUP_A(value); inst->encryption.key_management_filename = MXS_STRDUP_A(value);
} }
else if (strcmp(options[i], "lowwater") == 0)
{
inst->low_water = atoi(value);
}
else if (strcmp(options[i], "highwater") == 0)
{
inst->high_water = atoi(value);
}
else if (strcmp(options[i], "shortburst") == 0) else if (strcmp(options[i], "shortburst") == 0)
{ {
inst->short_burst = atoi(value); inst->short_burst = atoi(value);

View File

@ -574,8 +574,6 @@ typedef struct router_instance
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 low_water; /*< Low water mark for client DCB */
unsigned int high_water; /*< High water mark for client DCB */
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 */

View File

@ -2289,9 +2289,6 @@ blr_slave_binlog_dump(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue
blr_slave_read_ste(router, slave, fde_end_pos); blr_slave_read_ste(router, slave, fde_end_pos);
} }
slave->dcb->low_water = router->low_water;
slave->dcb->high_water = router->high_water;
dcb_add_callback(slave->dcb, DCB_REASON_DRAINED, blr_slave_callback, slave); dcb_add_callback(slave->dcb, DCB_REASON_DRAINED, blr_slave_callback, slave);
slave->state = BLRS_DUMPING; slave->state = BLRS_DUMPING;

View File

@ -423,11 +423,6 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
atomic_add(&candidate->connections, 1); atomic_add(&candidate->connections, 1);
// TODO: Remove this as it is never called
dcb_add_callback(client_rses->backend_dcb,
DCB_REASON_NOT_RESPONDING,
&handle_state_switch,
client_rses);
inst->stats.n_sessions++; inst->stats.n_sessions++;
CHK_CLIENT_RSES(client_rses); CHK_CLIENT_RSES(client_rses);

View File

@ -1159,73 +1159,6 @@ backend_ref_t *get_bref_from_dcb(ROUTER_CLIENT_SES *rses, DCB *dcb)
return bref; return bref;
} }
/**
* @brief Call hang up function
*
* Calls hang-up function for DCB if it is not both running and in
* master/slave/joined/ndb role. Called by DCB's callback routine.
*
* @param dcb DCB relating to a backend server
* @param reason The reason for the state change
* @param data Data is a backend reference structure belonging to this router
*
* @return 1 for success, 0 for failure
*/
int router_handle_state_switch(DCB *dcb, DCB_REASON reason, void *data)
{
backend_ref_t *bref;
int rc = 1;
SERVER *srv;
CHK_DCB(dcb);
if (NULL == dcb->session->router_session)
{
/*
* The following processing will fail if there is no router session,
* because the "data" parameter will not contain meaningful data,
* so we have no choice but to stop here.
*/
return 0;
}
bref = (backend_ref_t *)data;
CHK_BACKEND_REF(bref);
srv = bref->ref->server;
if (SERVER_IS_RUNNING(srv) && SERVER_IS_IN_CLUSTER(srv))
{
goto return_rc;
}
MXS_DEBUG("%lu [router_handle_state_switch] %s %s:%d in state %s",
pthread_self(), STRDCBREASON(reason), srv->name, srv->port,
STRSRVSTATUS(srv));
CHK_SESSION(((MXS_SESSION *)dcb->session));
if (dcb->session->router_session)
{
CHK_CLIENT_RSES(((ROUTER_CLIENT_SES *)dcb->session->router_session));
}
switch (reason)
{
case DCB_REASON_NOT_RESPONDING:
dcb->func.hangup(dcb);
break;
default:
break;
}
return_rc:
return rc;
}
/*
* The end of the functions used here and elsewhere in the router; start of
* functions that are purely internal to this module, i.e. are called directly
* or indirectly by the API functions and not used elsewhere.
*/
/** /**
* @brief Process router options * @brief Process router options
* *

View File

@ -433,9 +433,6 @@ static bool connect_server(backend_ref_t *bref, MXS_SESSION *session, bool execu
if (!execute_history || execute_sescmd_history(bref)) if (!execute_history || execute_sescmd_history(bref))
{ {
/** Add a callback for unresponsive server */
dcb_add_callback(bref->bref_dcb, DCB_REASON_NOT_RESPONDING,
&router_handle_state_switch, (void *) bref);
bref->bref_state = 0; bref->bref_state = 0;
bref_set_state(bref, BREF_IN_USE); bref_set_state(bref, BREF_IN_USE);
atomic_add(&bref->ref->connections, 1); atomic_add(&bref->ref->connections, 1);

View File

@ -2772,11 +2772,6 @@ static bool connect_backend_servers(backend_ref_t* backend_ref,
* of dcb_close. * of dcb_close.
*/ */
atomic_add(&b->connections, 1); atomic_add(&b->connections, 1);
dcb_add_callback(backend_ref[i].bref_dcb,
DCB_REASON_NOT_RESPONDING,
&router_handle_state_switch,
(void *)&backend_ref[i]);
} }
else else
{ {
@ -3750,15 +3745,6 @@ static bool handle_error_new_connection(ROUTER_INSTANCE* inst,
succp = true; succp = true;
goto return_succp; goto return_succp;
} }
/**
* Remove callback because this DCB won't be used
* unless it is reconnected later, and then the callback
* is set again.
*/
dcb_remove_callback(backend_dcb,
DCB_REASON_NOT_RESPONDING,
&router_handle_state_switch,
(void *)bref);
/** /**
* Try to get replacement slave or at least the minimum * Try to get replacement slave or at least the minimum
@ -3815,59 +3801,6 @@ static backend_ref_t* get_bref_from_dcb(ROUTER_CLIENT_SES* rses,
return bref; return bref;
} }
/**
* Calls hang-up function for DCB if it is not both running and in
* master/slave/joined/ndb role. Called by DCB's callback routine.
* @param dcb Backend server DCB
* @param reason The reason this DCB callback was called
* @param data Data pointer assigned in the add_callback function call
* @return Always 1
*/
static int router_handle_state_switch(DCB* dcb,
DCB_REASON reason,
void* data)
{
backend_ref_t* bref;
int rc = 1;
SERVER* srv;
CHK_DCB(dcb);
if (NULL == dcb->session->router_session)
{
/*
* The following processing will fail if there is no router session,
* because the "data" parameter will not contain meaningful data,
* so we have no choice but to stop here.
*/
return 0;
}
bref = (backend_ref_t *) data;
CHK_BACKEND_REF(bref);
srv = bref->bref_backend->server;
if (SERVER_IS_RUNNING(srv))
{
goto return_rc;
}
switch (reason)
{
case DCB_REASON_NOT_RESPONDING:
atomic_add(&bref->bref_backend->connections, -1);
MXS_INFO("server %s not responding", srv->unique_name);
dcb->func.hangup(dcb);
break;
default:
break;
}
return_rc:
return rc;
}
static sescmd_cursor_t* backend_ref_get_sescmd_cursor(backend_ref_t* bref) static sescmd_cursor_t* backend_ref_get_sescmd_cursor(backend_ref_t* bref)
{ {
sescmd_cursor_t* scur; sescmd_cursor_t* scur;