Remove unused code from readwritesplit
There was a lot of extra debug logging behind unused defines. These were never enabled and some of the code never worked.
This commit is contained in:
@ -307,8 +307,7 @@ static void *newSession(ROUTER *router_inst, SESSION *session)
|
|||||||
|
|
||||||
if (client_rses == NULL)
|
if (client_rses == NULL)
|
||||||
{
|
{
|
||||||
ss_dassert(false);
|
return NULL;
|
||||||
goto return_rses;
|
|
||||||
}
|
}
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
client_rses->rses_chk_top = CHK_NUM_ROUTER_SES;
|
client_rses->rses_chk_top = CHK_NUM_ROUTER_SES;
|
||||||
@ -348,7 +347,8 @@ static void *newSession(ROUTER *router_inst, SESSION *session)
|
|||||||
|
|
||||||
if (!have_enough_servers(&client_rses, min_nservers, router_nservers, router))
|
if (!have_enough_servers(&client_rses, min_nservers, router_nservers, router))
|
||||||
{
|
{
|
||||||
goto return_rses;
|
MXS_FREE(client_rses);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create backend reference objects for this session.
|
* Create backend reference objects for this session.
|
||||||
@ -359,9 +359,7 @@ static void *newSession(ROUTER *router_inst, SESSION *session)
|
|||||||
{
|
{
|
||||||
/** log this */
|
/** log this */
|
||||||
MXS_FREE(client_rses);
|
MXS_FREE(client_rses);
|
||||||
MXS_FREE(backend_ref);
|
return NULL;
|
||||||
client_rses = NULL;
|
|
||||||
goto return_rses;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Initialize backend references with BACKEND ptr.
|
* Initialize backend references with BACKEND ptr.
|
||||||
@ -413,8 +411,7 @@ static void *newSession(ROUTER *router_inst, SESSION *session)
|
|||||||
{
|
{
|
||||||
MXS_FREE(client_rses->rses_backend_ref);
|
MXS_FREE(client_rses->rses_backend_ref);
|
||||||
MXS_FREE(client_rses);
|
MXS_FREE(client_rses);
|
||||||
client_rses = NULL;
|
return NULL;
|
||||||
goto return_rses;
|
|
||||||
}
|
}
|
||||||
succp = select_connect_backend_servers(&master_ref, backend_ref, router_nservers,
|
succp = select_connect_backend_servers(&master_ref, backend_ref, router_nservers,
|
||||||
max_nslaves, max_slave_rlag,
|
max_nslaves, max_slave_rlag,
|
||||||
@ -432,8 +429,7 @@ static void *newSession(ROUTER *router_inst, SESSION *session)
|
|||||||
{
|
{
|
||||||
MXS_FREE(client_rses->rses_backend_ref);
|
MXS_FREE(client_rses->rses_backend_ref);
|
||||||
MXS_FREE(client_rses);
|
MXS_FREE(client_rses);
|
||||||
client_rses = NULL;
|
return NULL;
|
||||||
goto return_rses;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy backend pointers to router session. */
|
/** Copy backend pointers to router session. */
|
||||||
@ -458,13 +454,6 @@ static void *newSession(ROUTER *router_inst, SESSION *session)
|
|||||||
router->connections = client_rses;
|
router->connections = client_rses;
|
||||||
spinlock_release(&router->lock);
|
spinlock_release(&router->lock);
|
||||||
|
|
||||||
return_rses:
|
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
if (client_rses != NULL)
|
|
||||||
{
|
|
||||||
CHK_CLIENT_RSES(client_rses);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return (void *)client_rses;
|
return (void *)client_rses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,16 +509,8 @@ static void closeSession(ROUTER *instance, void *router_session)
|
|||||||
if (BREF_IS_IN_USE(bref))
|
if (BREF_IS_IN_USE(bref))
|
||||||
{
|
{
|
||||||
CHK_DCB(dcb);
|
CHK_DCB(dcb);
|
||||||
#if defined(SS_DEBUG)
|
ss_dassert(dcb->session->state == SESSION_STATE_STOPPING);
|
||||||
/**
|
|
||||||
* session must be moved to SESSION_STATE_STOPPING state before
|
|
||||||
* router session is closed.
|
|
||||||
*/
|
|
||||||
if (dcb->session != NULL)
|
|
||||||
{
|
|
||||||
ss_dassert(dcb->session->state == SESSION_STATE_STOPPING);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/** Clean operation counter in bref and in SERVER */
|
/** Clean operation counter in bref and in SERVER */
|
||||||
if (BREF_IS_WAITING_RESULT(bref))
|
if (BREF_IS_WAITING_RESULT(bref))
|
||||||
{
|
{
|
||||||
@ -764,7 +745,7 @@ static void clientReply(ROUTER *instance, void *router_session, GWBUF *writebuf,
|
|||||||
*/
|
*/
|
||||||
if (!rses_begin_locked_router_action(router_cli_ses))
|
if (!rses_begin_locked_router_action(router_cli_ses))
|
||||||
{
|
{
|
||||||
print_error_packet(router_cli_ses, writebuf, backend_dcb);
|
gwbuf_free(writebuf);
|
||||||
goto lock_failed;
|
goto lock_failed;
|
||||||
}
|
}
|
||||||
/** Holding lock ensures that router session remains open */
|
/** Holding lock ensures that router session remains open */
|
||||||
@ -1795,57 +1776,6 @@ static bool have_enough_servers(ROUTER_CLIENT_SES **p_rses, const int min_nsrv,
|
|||||||
return succp;
|
return succp;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PREP_STMT_CACHING)
|
|
||||||
#define MAX_STMT_LEN 1024
|
|
||||||
|
|
||||||
static prep_stmt_t *prep_stmt_init(prep_stmt_type_t type, void *id)
|
|
||||||
{
|
|
||||||
prep_stmt_t *pstmt;
|
|
||||||
|
|
||||||
pstmt = (prep_stmt_t *)MXS_CALLOC(1, sizeof(prep_stmt_t));
|
|
||||||
|
|
||||||
if (pstmt != NULL)
|
|
||||||
{
|
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
pstmt->pstmt_chk_top = CHK_NUM_PREP_STMT;
|
|
||||||
pstmt->pstmt_chk_tail = CHK_NUM_PREP_STMT;
|
|
||||||
#endif
|
|
||||||
pstmt->pstmt_state = PREP_STMT_ALLOC;
|
|
||||||
pstmt->pstmt_type = type;
|
|
||||||
|
|
||||||
if (type == PREP_STMT_NAME)
|
|
||||||
{
|
|
||||||
pstmt->pstmt_id.name = strndup((char *)id, MAX_STMT_LEN);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pstmt->pstmt_id.seq = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CHK_PREP_STMT(pstmt);
|
|
||||||
return pstmt;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void prep_stmt_done(prep_stmt_t *pstmt)
|
|
||||||
{
|
|
||||||
CHK_PREP_STMT(pstmt);
|
|
||||||
|
|
||||||
if (pstmt->pstmt_type == PREP_STMT_NAME)
|
|
||||||
{
|
|
||||||
MXS_FREE(pstmt->pstmt_id.name);
|
|
||||||
}
|
|
||||||
MXS_FREE(pstmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool prep_stmt_drop(prep_stmt_t *pstmt)
|
|
||||||
{
|
|
||||||
CHK_PREP_STMT(pstmt);
|
|
||||||
|
|
||||||
pstmt->pstmt_state = PREP_STMT_DROPPED;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif /*< PREP_STMT_CACHING */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Refresh the instance by the given parameter value.
|
* @brief Refresh the instance by the given parameter value.
|
||||||
*
|
*
|
||||||
@ -1950,44 +1880,6 @@ static void refreshInstance(ROUTER_INSTANCE *router,
|
|||||||
}
|
}
|
||||||
param = param->next;
|
param = param->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(NOT_USED) /*< can't read monitor config parameters */
|
|
||||||
if ((*router->servers)->backend_server->rlag == -2)
|
|
||||||
{
|
|
||||||
rlag_enabled = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rlag_enabled = true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* If replication lag detection is not enabled the measure can't be
|
|
||||||
* used in slave selection.
|
|
||||||
*/
|
|
||||||
if (!rlag_enabled)
|
|
||||||
{
|
|
||||||
if (rlag_limited)
|
|
||||||
{
|
|
||||||
MXS_WARNING("Configuration Failed, max_slave_replication_lag "
|
|
||||||
"is set to %d,\n\t\t but detect_replication_lag "
|
|
||||||
"is not enabled. Replication lag will not be checked.",
|
|
||||||
router->rwsplit_config.rw_max_slave_replication_lag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (router->rwsplit_config.rw_slave_select_criteria ==
|
|
||||||
LEAST_BEHIND_MASTER)
|
|
||||||
{
|
|
||||||
MXS_WARNING("Configuration Failed, router option "
|
|
||||||
"\n\t\t slave_selection_criteria=LEAST_BEHIND_MASTER "
|
|
||||||
"is specified, but detect_replication_lag "
|
|
||||||
"is not enabled.\n\t\t "
|
|
||||||
"slave_selection_criteria=%s will be used instead.",
|
|
||||||
STRCRITERIA(DEFAULT_CRITERIA));
|
|
||||||
|
|
||||||
router->rwsplit_config.rw_slave_select_criteria = DEFAULT_CRITERIA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /*< NOT_USED */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -32,26 +32,6 @@
|
|||||||
|
|
||||||
MXS_BEGIN_DECLS
|
MXS_BEGIN_DECLS
|
||||||
|
|
||||||
#undef PREP_STMT_CACHING
|
|
||||||
|
|
||||||
#if defined(PREP_STMT_CACHING)
|
|
||||||
|
|
||||||
typedef enum prep_stmt_type
|
|
||||||
{
|
|
||||||
PREP_STMT_NAME,
|
|
||||||
PREP_STMT_ID
|
|
||||||
} prep_stmt_type_t;
|
|
||||||
|
|
||||||
typedef enum prep_stmt_state
|
|
||||||
{
|
|
||||||
PREP_STMT_ALLOC,
|
|
||||||
PREP_STMT_SENT,
|
|
||||||
PREP_STMT_RECV,
|
|
||||||
PREP_STMT_DROPPED
|
|
||||||
} prep_stmt_state_t;
|
|
||||||
|
|
||||||
#endif /*< PREP_STMT_CACHING */
|
|
||||||
|
|
||||||
typedef enum bref_state
|
typedef enum bref_state
|
||||||
{
|
{
|
||||||
BREF_IN_USE = 0x01,
|
BREF_IN_USE = 0x01,
|
||||||
|
@ -366,66 +366,6 @@ void live_session_reply(GWBUF **querybuf, ROUTER_CLIENT_SES *rses)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Uses MySQL specific mechanisms
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @brief Write an error message to the log for session lock failure
|
|
||||||
*
|
|
||||||
* This happens when processing a client reply and the session cannot be
|
|
||||||
* locked.
|
|
||||||
*
|
|
||||||
* @param rses Router session
|
|
||||||
* @param buf Query buffer containing reply data
|
|
||||||
* @param dcb The backend DCB that sent the reply
|
|
||||||
*/
|
|
||||||
void print_error_packet(ROUTER_CLIENT_SES *rses, GWBUF *buf, DCB *dcb)
|
|
||||||
{
|
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
if (GWBUF_IS_TYPE_MYSQL(buf))
|
|
||||||
{
|
|
||||||
while (gwbuf_length(buf) > 0)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* This works with MySQL protocol only !
|
|
||||||
* Protocol specific packet print functions would be nice.
|
|
||||||
*/
|
|
||||||
uint8_t *ptr = GWBUF_DATA(buf);
|
|
||||||
size_t len = MYSQL_GET_PACKET_LEN(ptr);
|
|
||||||
|
|
||||||
if (MYSQL_GET_COMMAND(ptr) == 0xff)
|
|
||||||
{
|
|
||||||
SERVER *srv = NULL;
|
|
||||||
backend_ref_t *bref = rses->rses_backend_ref;
|
|
||||||
int i;
|
|
||||||
char *bufstr;
|
|
||||||
|
|
||||||
for (i = 0; i < rses->rses_nbackends; i++)
|
|
||||||
{
|
|
||||||
if (bref[i].bref_dcb == dcb)
|
|
||||||
{
|
|
||||||
srv = bref[i].ref->server;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ss_dassert(srv != NULL);
|
|
||||||
char *str = (char *)&ptr[7];
|
|
||||||
bufstr = strndup(str, len - 3);
|
|
||||||
|
|
||||||
MXS_ERROR("Backend server %s:%d responded with "
|
|
||||||
"error : %s",
|
|
||||||
srv->name, srv->port, bufstr);
|
|
||||||
MXS_FREE(bufstr);
|
|
||||||
}
|
|
||||||
buf = gwbuf_consume(buf, len + 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gwbuf_free(buf);
|
|
||||||
}
|
|
||||||
#endif /*< SS_DEBUG */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Uses MySQL specific mechanisms
|
* Uses MySQL specific mechanisms
|
||||||
*/
|
*/
|
||||||
|
@ -891,9 +891,6 @@ route_target_t get_route_target(ROUTER_CLIENT_SES *rses,
|
|||||||
hint = hint->next;
|
hint = hint->next;
|
||||||
} /*< while (hint != NULL) */
|
} /*< while (hint != NULL) */
|
||||||
|
|
||||||
#if defined(SS_EXTRA_DEBUG)
|
|
||||||
MXS_INFO("Selected target \"%s\"", STRTARGET(target));
|
|
||||||
#endif
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1098,9 +1095,6 @@ bool handle_slave_is_target(ROUTER_INSTANCE *inst, ROUTER_CLIENT_SES *rses,
|
|||||||
*/
|
*/
|
||||||
if (rwsplit_get_dcb(target_dcb, rses, BE_SLAVE, NULL, rlag_max))
|
if (rwsplit_get_dcb(target_dcb, rses, BE_SLAVE, NULL, rlag_max))
|
||||||
{
|
{
|
||||||
#if defined(SS_EXTRA_DEBUG)
|
|
||||||
MXS_INFO("Found DCB for slave.");
|
|
||||||
#endif
|
|
||||||
atomic_add(&inst->stats.n_slave, 1);
|
atomic_add(&inst->stats.n_slave, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user