Added more diagnostic output.
This commit is contained in:
@ -21,7 +21,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <router.h>
|
#include <router.h>
|
||||||
#include <schemarouter.h>
|
#include <schemarouter.h>
|
||||||
#include <secrets.h>
|
#include <secrets.h>
|
||||||
@ -187,10 +186,6 @@ static bool route_session_write(
|
|||||||
unsigned char packet_type,
|
unsigned char packet_type,
|
||||||
skygw_query_type_t qtype);
|
skygw_query_type_t qtype);
|
||||||
|
|
||||||
static void refreshInstance(
|
|
||||||
ROUTER_INSTANCE* router,
|
|
||||||
CONFIG_PARAMETER* param);
|
|
||||||
|
|
||||||
static void bref_clear_state(backend_ref_t* bref, bref_state_t state);
|
static void bref_clear_state(backend_ref_t* bref, bref_state_t state);
|
||||||
static void bref_set_state(backend_ref_t* bref, bref_state_t state);
|
static void bref_set_state(backend_ref_t* bref, bref_state_t state);
|
||||||
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);
|
||||||
@ -542,6 +537,12 @@ bool check_shard_status(ROUTER_INSTANCE* router, char* shard)
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn a string into an array of strings. The last element in the list is a NULL
|
||||||
|
* pointer.
|
||||||
|
* @param str String to tokenize
|
||||||
|
* @return Pointer to an array of strings.
|
||||||
|
*/
|
||||||
char** tokenize_string(char* str)
|
char** tokenize_string(char* str)
|
||||||
{
|
{
|
||||||
char *tok;
|
char *tok;
|
||||||
@ -579,6 +580,11 @@ char** tokenize_string(char* str)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A fake DCB read function used to forward queued queries.
|
||||||
|
* @param dcb Internal DCB used by the router session
|
||||||
|
* @return Always 1
|
||||||
|
*/
|
||||||
int internalRoute(DCB* dcb)
|
int internalRoute(DCB* dcb)
|
||||||
{
|
{
|
||||||
if(dcb->dcb_readqueue)
|
if(dcb->dcb_readqueue)
|
||||||
@ -593,6 +599,11 @@ int internalRoute(DCB* dcb)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A fake DCB read function used to forward replies to the client.
|
||||||
|
* @param dcb Internal DCB used by the router session
|
||||||
|
* @return Always 1
|
||||||
|
*/
|
||||||
int internalReply(DCB* dcb)
|
int internalReply(DCB* dcb)
|
||||||
{
|
{
|
||||||
if(dcb->dcb_readqueue)
|
if(dcb->dcb_readqueue)
|
||||||
@ -624,7 +635,7 @@ ModuleInit()
|
|||||||
{
|
{
|
||||||
LOGIF(LM, (skygw_log_write_flush(
|
LOGIF(LM, (skygw_log_write_flush(
|
||||||
LOGFILE_MESSAGE,
|
LOGFILE_MESSAGE,
|
||||||
"Initializing Database Sharding router module.")));
|
"Initializing Schema Sharding Router.")));
|
||||||
spinlock_init(&instlock);
|
spinlock_init(&instlock);
|
||||||
instances = NULL;
|
instances = NULL;
|
||||||
}
|
}
|
||||||
@ -642,49 +653,6 @@ ROUTER_OBJECT* GetModuleObject()
|
|||||||
return &MyObject;
|
return &MyObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void refreshInstance(
|
|
||||||
ROUTER_INSTANCE* router,
|
|
||||||
CONFIG_PARAMETER* singleparam)
|
|
||||||
{
|
|
||||||
CONFIG_PARAMETER* param;
|
|
||||||
bool refresh_single;
|
|
||||||
config_param_type_t paramtype;
|
|
||||||
|
|
||||||
if (singleparam != NULL)
|
|
||||||
{
|
|
||||||
param = singleparam;
|
|
||||||
refresh_single = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
param = router->service->svc_config_param;
|
|
||||||
refresh_single = false;
|
|
||||||
}
|
|
||||||
paramtype = config_get_paramtype(param);
|
|
||||||
|
|
||||||
while (param != NULL)
|
|
||||||
{
|
|
||||||
/** Catch unused parameter types */
|
|
||||||
ss_dassert(paramtype == COUNT_TYPE ||
|
|
||||||
paramtype == PERCENT_TYPE ||
|
|
||||||
paramtype == SQLVAR_TARGET_TYPE ||
|
|
||||||
paramtype == STRING_TYPE);
|
|
||||||
|
|
||||||
if (paramtype == COUNT_TYPE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (paramtype == PERCENT_TYPE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
if (refresh_single)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
param = param->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of schemarouter router within the MaxScale.
|
* Create an instance of schemarouter router within the MaxScale.
|
||||||
*
|
*
|
||||||
@ -767,26 +735,12 @@ createInstance(SERVICE *service, char **options)
|
|||||||
router->bitmask = 0;
|
router->bitmask = 0;
|
||||||
router->bitvalue = 0;
|
router->bitvalue = 0;
|
||||||
|
|
||||||
|
|
||||||
conf = config_get_param(service->svc_config_param,"ignore_databases");
|
|
||||||
|
|
||||||
if(conf)
|
|
||||||
{
|
|
||||||
refreshInstance(router, conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read config version number from service to inform what configuration
|
* Read config version number from service to inform what configuration
|
||||||
* is used if any.
|
* is used if any.
|
||||||
*/
|
*/
|
||||||
router->schemarouter_version = service->svc_config_version;
|
router->schemarouter_version = service->svc_config_version;
|
||||||
|
|
||||||
/** refreshInstance(router, NULL); */
|
|
||||||
/**
|
|
||||||
* Get hashtable which includes dbname,backend pairs
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We have completed the creation of the router data, so now
|
* We have completed the creation of the router data, so now
|
||||||
* insert this router into the linked list of routers
|
* insert this router into the linked list of routers
|
||||||
@ -1291,7 +1245,7 @@ static route_target_t get_shard_route_target (
|
|||||||
* @param type The type of the query resolved so far
|
* @param type The type of the query resolved so far
|
||||||
*/
|
*/
|
||||||
void check_drop_tmp_table(
|
void check_drop_tmp_table(
|
||||||
ROUTER* instance,
|
ROUTER* instance,
|
||||||
void* router_session,
|
void* router_session,
|
||||||
GWBUF* querybuf,
|
GWBUF* querybuf,
|
||||||
skygw_query_type_t type)
|
skygw_query_type_t type)
|
||||||
@ -1347,7 +1301,7 @@ void check_drop_tmp_table(
|
|||||||
* @return The type of the query
|
* @return The type of the query
|
||||||
*/
|
*/
|
||||||
skygw_query_type_t is_read_tmp_table(
|
skygw_query_type_t is_read_tmp_table(
|
||||||
ROUTER* instance,
|
ROUTER* instance,
|
||||||
void* router_session,
|
void* router_session,
|
||||||
GWBUF* querybuf,
|
GWBUF* querybuf,
|
||||||
skygw_query_type_t type)
|
skygw_query_type_t type)
|
||||||
@ -2204,6 +2158,10 @@ char *weightby;
|
|||||||
}
|
}
|
||||||
spinlock_release(&router->lock);
|
spinlock_release(&router->lock);
|
||||||
|
|
||||||
|
dcb_printf(dcb,"|%-32s-%-32s|","","");
|
||||||
|
dcb_printf(dcb,"|%-32s|%-32s|","Server","Queries");
|
||||||
|
dcb_printf(dcb,"|%-32s-%-32s|","","");
|
||||||
|
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\tNumber of router sessions: %d\n",
|
"\tNumber of router sessions: %d\n",
|
||||||
router->stats.n_sessions);
|
router->stats.n_sessions);
|
||||||
@ -2609,7 +2567,7 @@ lock_failed:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compare nunmber of connections from this router in backend servers */
|
/** Compare number of connections from this router in backend servers */
|
||||||
int bref_cmp_router_conn(
|
int bref_cmp_router_conn(
|
||||||
const void* bref1,
|
const void* bref1,
|
||||||
const void* bref2)
|
const void* bref2)
|
||||||
@ -2621,7 +2579,7 @@ int bref_cmp_router_conn(
|
|||||||
- ((1000 * b2->backend_conn_count) / b2->weight);
|
- ((1000 * b2->backend_conn_count) / b2->weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compare nunmber of global connections in backend servers */
|
/** Compare number of global connections in backend servers */
|
||||||
int bref_cmp_global_conn(
|
int bref_cmp_global_conn(
|
||||||
const void* bref1,
|
const void* bref1,
|
||||||
const void* bref2)
|
const void* bref2)
|
||||||
@ -2634,7 +2592,7 @@ int bref_cmp_global_conn(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Compare relication lag between backend servers */
|
/** Compare replication lag between backend servers */
|
||||||
int bref_cmp_behind_master(
|
int bref_cmp_behind_master(
|
||||||
const void* bref1,
|
const void* bref1,
|
||||||
const void* bref2)
|
const void* bref2)
|
||||||
@ -2646,7 +2604,7 @@ int bref_cmp_behind_master(
|
|||||||
((b1->backend_server->rlag > b2->backend_server->rlag) ? 1 : 0));
|
((b1->backend_server->rlag > b2->backend_server->rlag) ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compare nunmber of current operations in backend servers */
|
/** Compare number of current operations in backend servers */
|
||||||
int bref_cmp_current_load(
|
int bref_cmp_current_load(
|
||||||
const void* bref1,
|
const void* bref1,
|
||||||
const void* bref2)
|
const void* bref2)
|
||||||
@ -3853,6 +3811,12 @@ static void handle_error_reply_client(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a router session has servers in use
|
||||||
|
* @param rses Router client session
|
||||||
|
* @return True if session has a single backend server in use that is running.
|
||||||
|
* False if no backends are in use or running.
|
||||||
|
*/
|
||||||
bool have_servers(ROUTER_CLIENT_SES* rses)
|
bool have_servers(ROUTER_CLIENT_SES* rses)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -3990,8 +3954,11 @@ return_succp:
|
|||||||
return succp;
|
return succp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the number of servers.
|
||||||
|
* @param inst Router instance
|
||||||
|
* @return Number of servers
|
||||||
|
*/
|
||||||
static int router_get_servercount(
|
static int router_get_servercount(
|
||||||
ROUTER_INSTANCE* inst)
|
ROUTER_INSTANCE* inst)
|
||||||
{
|
{
|
||||||
@ -4042,6 +4009,10 @@ static backend_ref_t* get_bref_from_dcb(
|
|||||||
/**
|
/**
|
||||||
* Calls hang-up function for DCB if it is not both running and in
|
* 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.
|
* 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
|
static int
|
||||||
router_handle_state_switch(
|
router_handle_state_switch(
|
||||||
@ -4101,7 +4072,7 @@ static sescmd_cursor_t* backend_ref_get_sescmd_cursor (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read new database nbame from MYSQL_COM_INIT_DB packet, check that it exists
|
* Read new database name from MYSQL_COM_INIT_DB packet, check that it exists
|
||||||
* in the hashtable and copy its name to MYSQL_session.
|
* in the hashtable and copy its name to MYSQL_session.
|
||||||
*
|
*
|
||||||
* @param inst Router instance
|
* @param inst Router instance
|
||||||
|
Reference in New Issue
Block a user