LOGIFs removed from schemarouters.

This commit is contained in:
Johan Wikman
2015-11-17 13:41:30 +02:00
parent 069297f47e
commit 0413c957f8
3 changed files with 332 additions and 451 deletions

View File

@ -372,7 +372,7 @@ showdb_response_t parse_showdb_response(ROUTER_CLIENT_SES* rses, backend_ref_t*
if (PTR_IS_ERR(ptr)) if (PTR_IS_ERR(ptr))
{ {
skygw_log_write(LOGFILE_TRACE, "schemarouter: SHOW DATABASES returned an error."); MXS_INFO("schemarouter: SHOW DATABASES returned an error.");
gwbuf_free(buf); gwbuf_free(buf);
return SHOWDB_FATAL_ERROR; return SHOWDB_FATAL_ERROR;
} }
@ -387,7 +387,7 @@ showdb_response_t parse_showdb_response(ROUTER_CLIENT_SES* rses, backend_ref_t*
if (ptr >= (unsigned char*) buf->end) if (ptr >= (unsigned char*) buf->end)
{ {
skygw_log_write(LOGFILE_TRACE, "schemarouter: Malformed packet for SHOW DATABASES."); MXS_INFO("schemarouter: Malformed packet for SHOW DATABASES.");
*buffer = gwbuf_append(buf, *buffer); *buffer = gwbuf_append(buf, *buffer);
return SHOWDB_FATAL_ERROR; return SHOWDB_FATAL_ERROR;
} }
@ -408,7 +408,7 @@ showdb_response_t parse_showdb_response(ROUTER_CLIENT_SES* rses, backend_ref_t*
{ {
if (hashtable_add(rses->shardmap->hash, data, target)) if (hashtable_add(rses->shardmap->hash, data, target))
{ {
skygw_log_write(LOGFILE_TRACE, "schemarouter: <%s, %s>", target, data); MXS_INFO("schemarouter: <%s, %s>", target, data);
} }
else else
{ {
@ -419,7 +419,7 @@ showdb_response_t parse_showdb_response(ROUTER_CLIENT_SES* rses, backend_ref_t*
rses->router->ignore_match_data, NULL) >= 0))) rses->router->ignore_match_data, NULL) >= 0)))
{ {
duplicate_found = true; duplicate_found = true;
skygw_log_write(LE, "Error: Database '%s' found on servers '%s' and '%s' for user %s@%s.", MXS_ERROR("Database '%s' found on servers '%s' and '%s' for user %s@%s.",
data, target, data, target,
(char*)hashtable_fetch(rses->shardmap->hash, data), (char*)hashtable_fetch(rses->shardmap->hash, data),
rses->rses_client_dcb->user, rses->rses_client_dcb->user,
@ -436,12 +436,12 @@ showdb_response_t parse_showdb_response(ROUTER_CLIENT_SES* rses, backend_ref_t*
bref->n_mapping_eof == 1) bref->n_mapping_eof == 1)
{ {
atomic_add(&bref->n_mapping_eof, 1); atomic_add(&bref->n_mapping_eof, 1);
skygw_log_write(LOGFILE_TRACE, "schemarouter: SHOW DATABASES fully received from %s.", MXS_INFO("schemarouter: SHOW DATABASES fully received from %s.",
bref->bref_backend->backend_server->unique_name); bref->bref_backend->backend_server->unique_name);
} }
else else
{ {
skygw_log_write(LOGFILE_TRACE, "schemarouter: SHOW DATABASES partially received from %s.", MXS_INFO("schemarouter: SHOW DATABASES partially received from %s.",
bref->bref_backend->backend_server->unique_name); bref->bref_backend->backend_server->unique_name);
} }
@ -498,7 +498,7 @@ int gen_databaselist(ROUTER_INSTANCE* inst, ROUTER_CLIENT_SES* session)
clone = gwbuf_clone(buffer); clone = gwbuf_clone(buffer);
dcb = session->rses_backend_ref[i].bref_dcb; dcb = session->rses_backend_ref[i].bref_dcb;
rval |= !dcb->func.write(dcb,clone); rval |= !dcb->func.write(dcb,clone);
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Wrote SHOW DATABASES to %s for session %p: returned %d", MXS_DEBUG("schemarouter: Wrote SHOW DATABASES to %s for session %p: returned %d",
session->rses_backend_ref[i].bref_backend->backend_server->unique_name, session->rses_backend_ref[i].bref_backend->backend_server->unique_name,
session->rses_client_dcb->session, session->rses_client_dcb->session,
rval); rval);
@ -544,7 +544,7 @@ char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client,
/** Warn about improper usage of the router */ /** Warn about improper usage of the router */
if(rval && strcmp(name,rval) != 0) if(rval && strcmp(name,rval) != 0)
{ {
skygw_log_write(LOGFILE_ERROR,"Error : Schemarouter: Query targets databases on servers '%s' and '%s'. " MXS_ERROR("Schemarouter: Query targets databases on servers '%s' and '%s'. "
"Cross database queries across servers are not supported." "Cross database queries across servers are not supported."
,rval,name); ,rval,name);
} }
@ -552,7 +552,7 @@ char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client,
{ {
rval = name; rval = name;
has_dbs = true; has_dbs = true;
skygw_log_write(LOGFILE_TRACE,"schemarouter: Query targets database '%s' on server '%s'",dbnms[i],rval); MXS_INFO("schemarouter: Query targets database '%s' on server '%s'",dbnms[i],rval);
} }
} }
} }
@ -575,14 +575,14 @@ char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client,
tmp = (char*) hashtable_fetch(ht, tok); tmp = (char*) hashtable_fetch(ht, tok);
if(tmp) if(tmp)
skygw_log_write(LOGFILE_TRACE,"schemarouter: SHOW TABLES with specific database '%s' on server '%s'", tok, tmp); MXS_INFO("schemarouter: SHOW TABLES with specific database '%s' on server '%s'", tok, tmp);
} }
free(query); free(query);
if(tmp == NULL) if(tmp == NULL)
{ {
rval = (char*) hashtable_fetch(ht, client->current_db); rval = (char*) hashtable_fetch(ht, client->current_db);
skygw_log_write(LOGFILE_TRACE,"schemarouter: SHOW TABLES query, current database '%s' on server '%s'", MXS_INFO("schemarouter: SHOW TABLES query, current database '%s' on server '%s'",
client->current_db,rval); client->current_db,rval);
} }
else else
@ -602,7 +602,7 @@ char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client,
if(strcmp(srvnm,buffer->hint->data) == 0) if(strcmp(srvnm,buffer->hint->data) == 0)
{ {
rval = srvnm; rval = srvnm;
skygw_log_write(LOGFILE_TRACE,"schemarouter: Routing hint found (%s)",srvnm); MXS_INFO("schemarouter: Routing hint found (%s)",srvnm);
} }
} }
@ -618,7 +618,7 @@ char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client,
rval = (char*) hashtable_fetch(ht, client->current_db); rval = (char*) hashtable_fetch(ht, client->current_db);
if(rval) if(rval)
{ {
skygw_log_write(LOGFILE_TRACE,"schemarouter: Using active database '%s'",client->current_db); MXS_INFO("schemarouter: Using active database '%s'",client->current_db);
} }
} }
} }
@ -679,10 +679,8 @@ char** tokenize_string(char* str)
if(tmp == NULL) if(tmp == NULL)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("realloc returned NULL: %s.",
LOGFILE_ERROR, strerror_r(errno, errbuf, sizeof(errbuf)));
"Error : realloc returned NULL: %s.",
strerror_r(errno, errbuf, sizeof(errbuf)))));
free(list); free(list);
return NULL; return NULL;
} }
@ -750,9 +748,7 @@ version()
void void
ModuleInit() ModuleInit()
{ {
LOGIF(LM, (skygw_log_write_flush( MXS_NOTICE("Initializing Schema Sharding Router.");
LOGFILE_MESSAGE,
"Initializing Schema Sharding Router.")));
spinlock_init(&instlock); spinlock_init(&instlock);
instances = NULL; instances = NULL;
} }
@ -794,7 +790,7 @@ createInstance(SERVICE *service, char **options)
} }
if((router->ignored_dbs = hashtable_alloc(SCHEMAROUTER_HASHSIZE, hashkeyfun, hashcmpfun)) == NULL) if((router->ignored_dbs = hashtable_alloc(SCHEMAROUTER_HASHSIZE, hashkeyfun, hashcmpfun)) == NULL)
{ {
skygw_log_write(LE,"Error: Memory allocation failed when allocating schemarouter database ignore list."); MXS_ERROR("Memory allocation failed when allocating schemarouter database ignore list.");
free(router); free(router);
return NULL; return NULL;
} }
@ -805,7 +801,7 @@ createInstance(SERVICE *service, char **options)
if ((router->shard_maps = hashtable_alloc(SCHEMAROUTER_USERHASH_SIZE, hashkeyfun, hashcmpfun)) == NULL) if ((router->shard_maps = hashtable_alloc(SCHEMAROUTER_USERHASH_SIZE, hashkeyfun, hashcmpfun)) == NULL)
{ {
skygw_log_write(LE, "Error: Memory allocation failed when allocating schemarouter database ignore list."); MXS_ERROR("Memory allocation failed when allocating schemarouter database ignore list.");
hashtable_free(router->ignored_dbs); hashtable_free(router->ignored_dbs);
free(router); free(router);
return NULL; return NULL;
@ -838,7 +834,7 @@ createInstance(SERVICE *service, char **options)
conf = service->svc_config_param; conf = service->svc_config_param;
if((config_get_param(conf,"auth_all_servers")) == NULL) if((config_get_param(conf,"auth_all_servers")) == NULL)
{ {
skygw_log_write(LOGFILE_MESSAGE,"Schemarouter: Authentication data is fetched from all servers. To disable this " MXS_NOTICE("Schemarouter: Authentication data is fetched from all servers. To disable this "
"add 'auth_all_servers=0' to the service."); "add 'auth_all_servers=0' to the service.");
service->users_from_all = true; service->users_from_all = true;
} }
@ -854,7 +850,7 @@ createInstance(SERVICE *service, char **options)
{ {
PCRE2_UCHAR errbuf[512]; PCRE2_UCHAR errbuf[512];
pcre2_get_error_message(errcode, errbuf, sizeof(errbuf)); pcre2_get_error_message(errcode, errbuf, sizeof(errbuf));
skygw_log_write(LE, "Error: Regex compilation failed at %d for regex '%s': %s", MXS_ERROR("Regex compilation failed at %d for regex '%s': %s",
(int)erroffset, param->value, errbuf); (int)erroffset, param->value, errbuf);
hashtable_free(router->ignored_dbs); hashtable_free(router->ignored_dbs);
free(router); free(router);
@ -865,7 +861,7 @@ createInstance(SERVICE *service, char **options)
if (match_data == NULL) if (match_data == NULL)
{ {
skygw_log_write(LE, "Error: PCRE2 match data creation failed. This" MXS_ERROR("PCRE2 match data creation failed. This"
" is most likely caused by a lack of available memory."); " is most likely caused by a lack of available memory.");
pcre2_code_free(re); pcre2_code_free(re);
hashtable_free(router->ignored_dbs); hashtable_free(router->ignored_dbs);
@ -897,7 +893,7 @@ createInstance(SERVICE *service, char **options)
char* value; char* value;
if((value = strchr(options[i],'=')) == NULL) if((value = strchr(options[i],'=')) == NULL)
{ {
skygw_log_write(LOGFILE_ERROR,"Error: Unknown router options for Schemarouter: %s",options[i]); MXS_ERROR("Unknown router options for Schemarouter: %s",options[i]);
failure = true; failure = true;
break; break;
} }
@ -925,7 +921,7 @@ createInstance(SERVICE *service, char **options)
} }
else else
{ {
skygw_log_write(LOGFILE_ERROR,"Error: Unknown router options for Schemarouter: %s",options[i]); MXS_ERROR("Unknown router options for Schemarouter: %s",options[i]);
failure = true; failure = true;
break; break;
} }
@ -1087,13 +1083,13 @@ static void* newSession(
strncpy(db,data->db,MYSQL_DATABASE_MAXLEN); strncpy(db,data->db,MYSQL_DATABASE_MAXLEN);
memset(data->db,0,MYSQL_DATABASE_MAXLEN+1); memset(data->db,0,MYSQL_DATABASE_MAXLEN+1);
using_db = true; using_db = true;
skygw_log_write(LOGFILE_TRACE,"schemarouter: Client logging in directly to a database '%s', " MXS_INFO("schemarouter: Client logging in directly to a database '%s', "
"postponing until databases have been mapped.",db); "postponing until databases have been mapped.",db);
} }
if(!have_db) if(!have_db)
{ {
LOGIF(LT,(skygw_log_write(LT,"schemarouter: Client'%s' connecting with empty database.",data->user))); MXS_INFO("schemarouter: Client'%s' connecting with empty database.",data->user);
} }
spinlock_release(&session->ses_lock); spinlock_release(&session->ses_lock);
@ -1130,7 +1126,7 @@ static void* newSession(
{ {
if ((map = shard_map_alloc()) == NULL) if ((map = shard_map_alloc()) == NULL)
{ {
skygw_log_write(LE, "Error: Failed to allocate enough memory to create" MXS_ERROR("Failed to allocate enough memory to create"
"new shard mapping. Session will be closed."); "new shard mapping. Session will be closed.");
free(client_rses); free(client_rses);
return NULL; return NULL;
@ -1306,9 +1302,7 @@ static void closeSession(
ROUTER_INSTANCE* inst; ROUTER_INSTANCE* inst;
backend_ref_t* backend_ref; backend_ref_t* backend_ref;
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, MXS_DEBUG("%lu [schemarouter:closeSession]", pthread_self());
"%lu [schemarouter:closeSession]",
pthread_self())));
/** /**
* router session can be NULL if newSession failed and it is discarding * router session can be NULL if newSession failed and it is discarding
@ -1560,10 +1554,7 @@ static route_target_t get_shard_route_target (
target = TARGET_ANY; target = TARGET_ANY;
} }
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LT, (skygw_log_write( MXS_INFO("Selected target type \"%s\"", STRTARGET(target));
LOGFILE_TRACE,
"Selected target type \"%s\"",
STRTARGET(target))));
#endif #endif
return target; return target;
} }
@ -1611,8 +1602,7 @@ ROUTER* instance,
if (hashtable_delete(rses_prop_tmp->rses_prop_data.temp_tables, if (hashtable_delete(rses_prop_tmp->rses_prop_data.temp_tables,
(void *)hkey)) (void *)hkey))
{ {
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, MXS_INFO("Temporary table dropped: %s",hkey);
"Temporary table dropped: %s",hkey)));
} }
} }
free(tbl[i]); free(tbl[i]);
@ -1679,9 +1669,7 @@ ROUTER* instance,
{ {
/**Query target is a temporary table*/ /**Query target is a temporary table*/
qtype = QUERY_TYPE_READ_TMP_TABLE; qtype = QUERY_TYPE_READ_TMP_TABLE;
LOGIF(LT, MXS_INFO("Query targets a temporary table: %s",hkey);
(skygw_log_write(LOGFILE_TRACE,
"Query targets a temporary table: %s",hkey)));
} }
} }
@ -1768,7 +1756,7 @@ void check_create_tmp_table(
} }
else else
{ {
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error : Call to malloc() failed."))); MXS_ERROR("Call to malloc() failed.");
} }
} }
if(rses_prop_tmp){ if(rses_prop_tmp){
@ -1780,7 +1768,7 @@ void check_create_tmp_table(
{ {
rses_prop_tmp->rses_prop_data.temp_tables = h; rses_prop_tmp->rses_prop_data.temp_tables = h;
}else{ }else{
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error : Failed to allocate a new hashtable."))); MXS_ERROR("Failed to allocate a new hashtable.");
} }
} }
@ -1790,10 +1778,7 @@ void check_create_tmp_table(
(void *)hkey, (void *)hkey,
(void *)is_temp) == 0) /*< Conflict in hash table */ (void *)is_temp) == 0) /*< Conflict in hash table */
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Temporary table conflict in hashtable: %s", hkey);
LOGFILE_TRACE,
"Temporary table conflict in hashtable: %s",
hkey)));
} }
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
{ {
@ -1803,10 +1788,7 @@ void check_create_tmp_table(
hkey); hkey);
if (retkey) if (retkey)
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Temporary table added: %s", hkey);
LOGFILE_TRACE,
"Temporary table added: %s",
hkey)));
} }
} }
#endif #endif
@ -1958,9 +1940,7 @@ static int routeQuery(
if (!rses_begin_locked_router_action(router_cli_ses)) if (!rses_begin_locked_router_action(router_cli_ses))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Route query aborted! Routing session is closed <");
LOGFILE_TRACE,
"Route query aborted! Routing session is closed <")));
ret = 0; ret = 0;
goto retblock; goto retblock;
} }
@ -1984,7 +1964,7 @@ static int routeQuery(
{ {
int init_rval = 1; int init_rval = 1;
char* querystr = modutil_get_SQL(querybuf); char* querystr = modutil_get_SQL(querybuf);
skygw_log_write(LOGFILE_DEBUG|LOGFILE_TRACE,"schemarouter: Storing query for session %p: %s", MXS_INFO("schemarouter: Storing query for session %p: %s",
router_cli_ses->rses_client_dcb->session, router_cli_ses->rses_client_dcb->session,
querystr); querystr);
free(querystr); free(querystr);
@ -2038,14 +2018,11 @@ static int routeQuery(
{ {
char* query_str = modutil_get_query(querybuf); char* query_str = modutil_get_query(querybuf);
LOGIF(LE, MXS_ERROR("Can't route %s:%s:\"%s\" to "
(skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Can't route %s:%s:\"%s\" to "
"backend server. Router is closed.", "backend server. Router is closed.",
STRPACKETTYPE(packet_type), STRPACKETTYPE(packet_type),
STRQTYPE(qtype), STRQTYPE(qtype),
(query_str == NULL ? "(empty)" : query_str)))); (query_str == NULL ? "(empty)" : query_str));
free(query_str); free(query_str);
} }
ret = 0; ret = 0;
@ -2120,11 +2097,8 @@ static int routeQuery(
char* contentstr = strndup(data, len); char* contentstr = strndup(data, len);
char* qtypestr = skygw_get_qtype_str(qtype); char* qtypestr = skygw_get_qtype_str(qtype);
skygw_log_write( MXS_INFO("> Cmd: %s, type: %s, "
LOGFILE_TRACE,
"> Cmd: %s, type: %s, "
"stmt: %s%s %s", "stmt: %s%s %s",
STRPACKETTYPE(ptype), STRPACKETTYPE(ptype),
(qtypestr==NULL ? "N/A" : qtypestr), (qtypestr==NULL ? "N/A" : qtypestr),
contentstr, contentstr,
@ -2189,9 +2163,7 @@ static int routeQuery(
SCHEMA_ERRSTR_DBNOTFOUND, SCHEMA_ERRSTR_DBNOTFOUND,
errbuf); errbuf);
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Changing database failed.");
LOGFILE_ERROR,
"Error : Changing database failed.")));
ret = 1; ret = 1;
goto retblock; goto retblock;
} }
@ -2222,14 +2194,14 @@ static int routeQuery(
if(tname) if(tname)
{ {
skygw_log_write(LOGFILE_TRACE,"schemarouter: INIT_DB for database '%s' on server '%s'", MXS_INFO("schemarouter: INIT_DB for database '%s' on server '%s'",
router_cli_ses->current_db,tname); router_cli_ses->current_db,tname);
route_target = TARGET_NAMED_SERVER; route_target = TARGET_NAMED_SERVER;
targetserver = strdup(tname); targetserver = strdup(tname);
} }
else else
{ {
skygw_log_write(LOGFILE_TRACE,"schemarouter: INIT_DB with unknown database"); MXS_INFO("schemarouter: INIT_DB with unknown database");
} }
spinlock_release(&router_cli_ses->shardmap->lock); spinlock_release(&router_cli_ses->shardmap->lock);
} }
@ -2252,7 +2224,7 @@ static int routeQuery(
} }
else else
{ {
skygw_log_write(LOGFILE_TRACE,"schemarouter: Backend server '%s' is not in a viable state",tname); MXS_INFO("schemarouter: Backend server '%s' is not in a viable state",tname);
/** /**
* Shard is not a viable target right now so we check * Shard is not a viable target right now so we check
@ -2281,7 +2253,7 @@ static int routeQuery(
*/ */
route_target = TARGET_ANY; route_target = TARGET_ANY;
skygw_log_write(LOGFILE_TRACE,"schemarouter: Routing query to first available backend."); MXS_INFO("schemarouter: Routing query to first available backend.");
} }
else else
@ -2301,7 +2273,7 @@ static int routeQuery(
} }
else else
{ {
skygw_log_write(LOGFILE_ERROR, "Error : Router internal failure (schemarouter)"); MXS_ERROR("Error : Router internal failure (schemarouter)");
/** Something else went wrong, terminate connection */ /** Something else went wrong, terminate connection */
ret = 0; ret = 0;
} }
@ -2337,9 +2309,7 @@ static int routeQuery(
/** Lock router session */ /** Lock router session */
if (!rses_begin_locked_router_action(router_cli_ses)) if (!rses_begin_locked_router_action(router_cli_ses))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Route query aborted! Routing session is closed <");
LOGFILE_TRACE,
"Route query aborted! Routing session is closed <")));
ret = 0; ret = 0;
goto retblock; goto retblock;
} }
@ -2362,9 +2332,8 @@ static int routeQuery(
{ {
/**No valid backends alive*/ /**No valid backends alive*/
skygw_log_write(LOGFILE_TRACE,"schemarouter: No backends are running"); MXS_INFO("schemarouter: No backends are running");
skygw_log_write(LOGFILE_ERROR, MXS_ERROR("Schemarouter: Failed to route query, "
"Error: Schemarouter: Failed to route query, "
"no backends are available."); "no backends are available.");
rses_end_locked_router_action(router_cli_ses); rses_end_locked_router_action(router_cli_ses);
ret = 0; ret = 0;
@ -2387,12 +2356,9 @@ static int routeQuery(
if (!succp) if (!succp)
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Was supposed to route to named server "
LOGFILE_TRACE,
"Was supposed to route to named server "
"%s but couldn't find the server in a " "%s but couldn't find the server in a "
"suitable state.", "suitable state.", targetserver);
targetserver)));
} }
} }
@ -2405,11 +2371,9 @@ static int routeQuery(
bref = get_bref_from_dcb(router_cli_ses, target_dcb); bref = get_bref_from_dcb(router_cli_ses, target_dcb);
scur = &bref->bref_sescmd_cur; scur = &bref->bref_sescmd_cur;
LOGIF(LT, (skygw_log_write( MXS_INFO("Route query to \t%s:%d <",
LOGFILE_TRACE,
"Route query to \t%s:%d <",
bref->bref_backend->backend_server->name, bref->bref_backend->backend_server->name,
bref->bref_backend->backend_server->port))); bref->bref_backend->backend_server->port);
/** /**
* Store current stmt if execution of previous session command * Store current stmt if execution of previous session command
* haven't completed yet. Note that according to MySQL protocol * haven't completed yet. Note that according to MySQL protocol
@ -2442,9 +2406,7 @@ static int routeQuery(
} }
else else
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Routing query failed.");
LOGFILE_ERROR,
"Error : Routing query failed.")));
} }
} }
rses_end_locked_router_action(router_cli_ses); rses_end_locked_router_action(router_cli_ses);
@ -2644,7 +2606,7 @@ static void clientReply(ROUTER* instance,
return; return;
} }
skygw_log_write(LOGFILE_DEBUG, "schemarouter: Reply from [%s] session [%p]" MXS_DEBUG("schemarouter: Reply from [%s] session [%p]"
" mapping [%s] queries queued [%s]", " mapping [%s] queries queued [%s]",
bref->bref_backend->backend_server->unique_name, bref->bref_backend->backend_server->unique_name,
router_cli_ses->rses_client_dcb->session, router_cli_ses->rses_client_dcb->session,
@ -2700,8 +2662,7 @@ static void clientReply(ROUTER* instance,
ss_dassert(router_cli_ses->init == INIT_READY); ss_dassert(router_cli_ses->init == INIT_READY);
route_queued_query(router_cli_ses); route_queued_query(router_cli_ses);
} }
skygw_log_write_flush(LOGFILE_DEBUG, MXS_DEBUG("session [%p] database map finished.",
"session [%p] database map finished.",
router_cli_ses); router_cli_ses);
} }
@ -2716,7 +2677,7 @@ static void clientReply(ROUTER* instance,
if (router_cli_ses->init & INIT_USE_DB) if (router_cli_ses->init & INIT_USE_DB)
{ {
skygw_log_write(LOGFILE_DEBUG, "schemarouter: Reply to USE '%s' received for session %p", MXS_DEBUG("schemarouter: Reply to USE '%s' received for session %p",
router_cli_ses->connect_db, router_cli_ses->connect_db,
router_cli_ses->rses_client_dcb->session); router_cli_ses->rses_client_dcb->session);
router_cli_ses->init &= ~INIT_USE_DB; router_cli_ses->init &= ~INIT_USE_DB;
@ -2767,14 +2728,12 @@ static void clientReply(ROUTER* instance,
ss_dassert(len + 4 == GWBUF_LENGTH(scur->scmd_cur_cmd->my_sescmd_buf)); ss_dassert(len + 4 == GWBUF_LENGTH(scur->scmd_cur_cmd->my_sescmd_buf));
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to execute %s in %s:%d. %s %s",
LOGFILE_ERROR,
"Error : Failed to execute %s in %s:%d. %s %s",
cmdstr, cmdstr,
bref->bref_backend->backend_server->name, bref->bref_backend->backend_server->name,
bref->bref_backend->backend_server->port, bref->bref_backend->backend_server->port,
err, err,
replystr))); replystr);
free(cmdstr); free(cmdstr);
free(err); free(err);
@ -2817,7 +2776,7 @@ static void clientReply(ROUTER* instance,
unsigned char* cmd = (unsigned char*) writebuf->start; unsigned char* cmd = (unsigned char*) writebuf->start;
int state = router_cli_ses->init; int state = router_cli_ses->init;
/** Write reply to client DCB */ /** Write reply to client DCB */
skygw_log_write(LOGFILE_TRACE, "schemarouter: returning reply [%s] " MXS_INFO("schemarouter: returning reply [%s] "
"state [%s] session [%p]", "state [%s] session [%p]",
PTR_IS_ERR(cmd) ? "ERR" : PTR_IS_OK(cmd) ? "OK" : "RSET", PTR_IS_ERR(cmd) ? "ERR" : PTR_IS_OK(cmd) ? "OK" : "RSET",
state & INIT_UNINT ? "UNINIT" : state & INIT_MAPPING ? "MAPPING" : "READY", state & INIT_UNINT ? "UNINIT" : state & INIT_MAPPING ? "MAPPING" : "READY",
@ -2837,12 +2796,10 @@ static void clientReply(ROUTER* instance,
if (sescmd_cursor_is_active(scur)) if (sescmd_cursor_is_active(scur))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Backend %s:%d processed reply and starts to execute "
LOGFILE_TRACE,
"Backend %s:%d processed reply and starts to execute "
"active cursor.", "active cursor.",
bref->bref_backend->backend_server->name, bref->bref_backend->backend_server->name,
bref->bref_backend->backend_server->port))); bref->bref_backend->backend_server->port);
execute_sescmd_in_backend(bref); execute_sescmd_in_backend(bref);
} }
@ -2869,16 +2826,12 @@ static void clientReply(ROUTER* instance,
if (sql) if (sql)
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Routing query \"%s\" failed.", sql);
LOGFILE_ERROR,
"Routing query \"%s\" failed.", sql)));
free(sql); free(sql);
} }
else else
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Routing query failed.");
LOGFILE_ERROR,
"Routing query failed.")));
} }
} }
gwbuf_free(bref->bref_pending_cmd); gwbuf_free(bref->bref_pending_cmd);
@ -2947,7 +2900,7 @@ static void bref_clear_state(
{ {
if(bref == NULL) if(bref == NULL)
{ {
skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); MXS_ERROR("[%s] Error: NULL parameter.",__FUNCTION__);
return; return;
} }
if (state != BREF_WAITING_RESULT) if (state != BREF_WAITING_RESULT)
@ -2973,7 +2926,7 @@ static void bref_clear_state(
ss_dassert(prev2 > 0); ss_dassert(prev2 > 0);
if(prev2 <= 0) if(prev2 <= 0)
{ {
skygw_log_write(LE,"[%s] Error: negative current operation count in backend %s:%u", MXS_ERROR("[%s] Error: negative current operation count in backend %s:%u",
__FUNCTION__, __FUNCTION__,
bref->bref_backend->backend_server->name, bref->bref_backend->backend_server->name,
bref->bref_backend->backend_server->port); bref->bref_backend->backend_server->port);
@ -2988,7 +2941,7 @@ static void bref_set_state(
{ {
if(bref == NULL) if(bref == NULL)
{ {
skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); MXS_ERROR("[%s] Error: NULL parameter.",__FUNCTION__);
return; return;
} }
if (state != BREF_WAITING_RESULT) if (state != BREF_WAITING_RESULT)
@ -3005,7 +2958,7 @@ static void bref_set_state(
ss_dassert(prev1 >= 0); ss_dassert(prev1 >= 0);
if(prev1 < 0) if(prev1 < 0)
{ {
skygw_log_write(LE,"[%s] Error: negative number of connections waiting " MXS_ERROR("[%s] Error: negative number of connections waiting "
"for results in backend %s:%u", "for results in backend %s:%u",
__FUNCTION__, __FUNCTION__,
bref->bref_backend->backend_server->name, bref->bref_backend->backend_server->name,
@ -3017,7 +2970,7 @@ static void bref_set_state(
ss_dassert(prev2 >= 0); ss_dassert(prev2 >= 0);
if(prev2 < 0) if(prev2 < 0)
{ {
skygw_log_write(LE,"[%s] Error: negative current operation count in backend %s:%u", MXS_ERROR("[%s] Error: negative current operation count in backend %s:%u",
__FUNCTION__, __FUNCTION__,
bref->bref_backend->backend_server->name, bref->bref_backend->backend_server->name,
bref->bref_backend->backend_server->port); bref->bref_backend->backend_server->port);
@ -3071,38 +3024,35 @@ static bool connect_backend_servers(
#if defined(EXTRA_SS_DEBUG) #if defined(EXTRA_SS_DEBUG)
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "Servers and conns before ordering:"))); MXS_INFO("Servers and conns before ordering:");
for (i=0; i<router_nservers; i++) for (i=0; i<router_nservers; i++)
{ {
BACKEND* b = backend_ref[i].bref_backend; BACKEND* b = backend_ref[i].bref_backend;
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, MXS_INFO("bref %p %d %s %d:%d",
"bref %p %d %s %d:%d",
&backend_ref[i], &backend_ref[i],
backend_ref[i].bref_state, backend_ref[i].bref_state,
b->backend_server->name, b->backend_server->name,
b->backend_server->port, b->backend_server->port,
b->backend_conn_count))); b->backend_conn_count);
} }
#endif #endif
if (LOG_IS_ENABLED(LOGFILE_TRACE)) if (LOG_IS_ENABLED(LOGFILE_TRACE))
{ {
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, MXS_INFO("Servers and connection counts:");
"Servers and connection counts:")));
for (i=0; i<router_nservers; i++) for (i=0; i<router_nservers; i++)
{ {
BACKEND* b = backend_ref[i].bref_backend; BACKEND* b = backend_ref[i].bref_backend;
LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE, MXS_INFO("MaxScale connections : %d (%d) in \t%s:%d %s",
"MaxScale connections : %d (%d) in \t%s:%d %s",
b->backend_conn_count, b->backend_conn_count,
b->backend_server->stats.n_current, b->backend_server->stats.n_current,
b->backend_server->name, b->backend_server->name,
b->backend_server->port, b->backend_server->port,
STRSRVSTATUS(b->backend_server)))); STRSRVSTATUS(b->backend_server));
} }
} /*< log only */ } /*< log only */
/** /**
@ -3168,12 +3118,10 @@ static bool connect_backend_servers(
else else
{ {
succp = false; succp = false;
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Unable to establish "
LOGFILE_ERROR,
"Error : Unable to establish "
"connection with slave %s:%d", "connection with slave %s:%d",
b->backend_server->name, b->backend_server->name,
b->backend_server->port))); b->backend_server->port);
/* handle connect error */ /* handle connect error */
break; break;
} }
@ -3182,19 +3130,18 @@ static bool connect_backend_servers(
} /*< for */ } /*< for */
#if defined(EXTRA_SS_DEBUG) #if defined(EXTRA_SS_DEBUG)
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "Servers and conns after ordering:"))); MXS_INFO("Servers and conns after ordering:");
for (i=0; i<router_nservers; i++) for (i=0; i<router_nservers; i++)
{ {
BACKEND* b = backend_ref[i].bref_backend; BACKEND* b = backend_ref[i].bref_backend;
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, MXS_INFO("bref %p %d %s %d:%d",
"bref %p %d %s %d:%d",
&backend_ref[i], &backend_ref[i],
backend_ref[i].bref_state, backend_ref[i].bref_state,
b->backend_server->name, b->backend_server->name,
b->backend_server->port, b->backend_server->port,
b->backend_conn_count))); b->backend_conn_count);
} }
#endif #endif
/** /**
@ -3212,12 +3159,10 @@ static bool connect_backend_servers(
if (BREF_IS_IN_USE((&backend_ref[i]))) if (BREF_IS_IN_USE((&backend_ref[i])))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Connected %s in \t%s:%d",
LOGFILE_TRACE,
"Connected %s in \t%s:%d",
STRSRVSTATUS(b->backend_server), STRSRVSTATUS(b->backend_server),
b->backend_server->name, b->backend_server->name,
b->backend_server->port))); b->backend_server->port);
} }
} /* for */ } /* for */
} }
@ -3269,13 +3214,11 @@ static void rses_property_done(
break; break;
default: default:
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [rses_property_done] Unknown property type %d "
LOGFILE_DEBUG,
"%lu [rses_property_done] Unknown property type %d "
"in property %p", "in property %p",
pthread_self(), pthread_self(),
prop->rses_prop_type, prop->rses_prop_type,
prop))); prop);
ss_dassert(false); ss_dassert(false);
break; break;
@ -3610,9 +3553,7 @@ static bool execute_sescmd_in_backend(
if (sescmd_cursor_get_command(scur) == NULL) if (sescmd_cursor_get_command(scur) == NULL)
{ {
succp = false; succp = false;
LOGIF(LT, (skygw_log_write_flush( MXS_INFO("Cursor had no pending session commands.");
LOGFILE_TRACE,
"Cursor had no pending session commands.")));
goto return_succp; goto return_succp;
} }
@ -3623,23 +3564,24 @@ static bool execute_sescmd_in_backend(
sescmd_cursor_set_active(scur, true); sescmd_cursor_set_active(scur, true);
} }
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LT, tracelog_routed_query(scur->scmd_cur_rses, if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
{
tracelog_routed_query(scur->scmd_cur_rses,
"execute_sescmd_in_backend", "execute_sescmd_in_backend",
backend_ref, backend_ref,
sescmd_cursor_clone_querybuf(scur))); sescmd_cursor_clone_querybuf(scur));
}
{ {
GWBUF* tmpbuf = sescmd_cursor_clone_querybuf(scur); GWBUF* tmpbuf = sescmd_cursor_clone_querybuf(scur);
uint8_t* ptr = GWBUF_DATA(tmpbuf); uint8_t* ptr = GWBUF_DATA(tmpbuf);
unsigned char cmd = MYSQL_GET_COMMAND(ptr); unsigned char cmd = MYSQL_GET_COMMAND(ptr);
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [execute_sescmd_in_backend] Just before write, fd "
LOGFILE_DEBUG,
"%lu [execute_sescmd_in_backend] Just before write, fd "
"%d : cmd %s.", "%d : cmd %s.",
pthread_self(), pthread_self(),
dcb->fd, dcb->fd,
STRPACKETTYPE(cmd)))); STRPACKETTYPE(cmd));
gwbuf_free(tmpbuf); gwbuf_free(tmpbuf);
} }
#endif /*< SS_DEBUG */ #endif /*< SS_DEBUG */
@ -3792,9 +3734,7 @@ static void tracelog_routed_query(
querystr = (char *)malloc(len); querystr = (char *)malloc(len);
memcpy(querystr, startpos, len-1); memcpy(querystr, startpos, len-1);
querystr[len-1] = '\0'; querystr[len-1] = '\0';
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [%s] %d bytes long buf, \"%s\" -> %s:%d %s dcb %p",
LOGFILE_DEBUG,
"%lu [%s] %d bytes long buf, \"%s\" -> %s:%d %s dcb %p",
pthread_self(), pthread_self(),
funcname, funcname,
(int)buflen, (int)buflen,
@ -3802,7 +3742,7 @@ static void tracelog_routed_query(
b->backend_server->name, b->backend_server->name,
b->backend_server->port, b->backend_server->port,
STRBETYPE(be_type), STRBETYPE(be_type),
dcb))); dcb);
free(querystr); free(querystr);
} }
else if (packet_type == '\x22' || else if (packet_type == '\x22' ||
@ -3814,9 +3754,7 @@ static void tracelog_routed_query(
querystr = (char *)malloc(len); querystr = (char *)malloc(len);
memcpy(querystr, startpos, len-1); memcpy(querystr, startpos, len-1);
querystr[len-1] = '\0'; querystr[len-1] = '\0';
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [%s] %d bytes long buf, \"%s\" -> %s:%d %s dcb %p",
LOGFILE_DEBUG,
"%lu [%s] %d bytes long buf, \"%s\" -> %s:%d %s dcb %p",
pthread_self(), pthread_self(),
funcname, funcname,
(int)buflen, (int)buflen,
@ -3824,7 +3762,7 @@ static void tracelog_routed_query(
b->backend_server->name, b->backend_server->name,
b->backend_server->port, b->backend_server->port,
STRBETYPE(be_type), STRBETYPE(be_type),
dcb))); dcb);
free(querystr); free(querystr);
} }
} }
@ -3864,9 +3802,7 @@ static bool route_session_write(
backend_ref_t* backend_ref; backend_ref_t* backend_ref;
int i; int i;
LOGIF(LT, (skygw_log_write( MXS_INFO("Session write, routing to all servers.");
LOGFILE_TRACE,
"Session write, routing to all servers.")));
backend_ref = router_cli_ses->rses_backend_ref; backend_ref = router_cli_ses->rses_backend_ref;
@ -3897,14 +3833,12 @@ static bool route_session_write(
if (LOG_IS_ENABLED(LOGFILE_TRACE)) if (LOG_IS_ENABLED(LOGFILE_TRACE))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Route query to %s\t%s:%d%s",
LOGFILE_TRACE,
"Route query to %s\t%s:%d%s",
(SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ? (SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ?
"master" : "slave"), "master" : "slave"),
backend_ref[i].bref_backend->backend_server->name, backend_ref[i].bref_backend->backend_server->name,
backend_ref[i].bref_backend->backend_server->port, backend_ref[i].bref_backend->backend_server->port,
(i+1==router_cli_ses->rses_nbackends ? " <" : "")))); (i+1==router_cli_ses->rses_nbackends ? " <" : ""));
} }
if (BREF_IS_IN_USE((&backend_ref[i]))) if (BREF_IS_IN_USE((&backend_ref[i])))
@ -3937,11 +3871,9 @@ static bool route_session_write(
if(router_cli_ses->rses_config.max_sescmd_hist > 0 && if(router_cli_ses->rses_config.max_sescmd_hist > 0 &&
router_cli_ses->n_sescmd >= router_cli_ses->rses_config.max_sescmd_hist) router_cli_ses->n_sescmd >= router_cli_ses->rses_config.max_sescmd_hist)
{ {
LOGIF(LE, (skygw_log_write( MXS_ERROR("Router session exceeded session command history limit of %d. "
LOGFILE_ERROR|LOGFILE_TRACE,
"Router session exceeded session command history limit of %d. "
"Closing router session.", "Closing router session.",
router_cli_ses->rses_config.max_sescmd_hist))); router_cli_ses->rses_config.max_sescmd_hist);
gwbuf_free(querybuf); gwbuf_free(querybuf);
atomic_add(&router_cli_ses->router->stats.n_hist_exceeded,1); atomic_add(&router_cli_ses->router->stats.n_hist_exceeded,1);
rses_end_locked_router_action(router_cli_ses); rses_end_locked_router_action(router_cli_ses);
@ -4009,14 +3941,12 @@ static bool route_session_write(
if (LOG_IS_ENABLED(LOGFILE_TRACE)) if (LOG_IS_ENABLED(LOGFILE_TRACE))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Route query to %s\t%s:%d%s",
LOGFILE_TRACE,
"Route query to %s\t%s:%d%s",
(SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ? (SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ?
"master" : "slave"), "master" : "slave"),
backend_ref[i].bref_backend->backend_server->name, backend_ref[i].bref_backend->backend_server->name,
backend_ref[i].bref_backend->backend_server->port, backend_ref[i].bref_backend->backend_server->port,
(i+1==router_cli_ses->rses_nbackends ? " <" : "")))); (i+1==router_cli_ses->rses_nbackends ? " <" : ""));
} }
scur = backend_ref_get_sescmd_cursor(&backend_ref[i]); scur = backend_ref_get_sescmd_cursor(&backend_ref[i]);
@ -4036,11 +3966,9 @@ static bool route_session_write(
{ {
succp = true; succp = true;
LOGIF(LT, (skygw_log_write( MXS_INFO("Backend %s:%d already executing sescmd.",
LOGFILE_TRACE,
"Backend %s:%d already executing sescmd.",
backend_ref[i].bref_backend->backend_server->name, backend_ref[i].bref_backend->backend_server->name,
backend_ref[i].bref_backend->backend_server->port))); backend_ref[i].bref_backend->backend_server->port);
} }
else else
{ {
@ -4048,12 +3976,10 @@ static bool route_session_write(
if (!succp) if (!succp)
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to execute session "
LOGFILE_ERROR,
"Error : Failed to execute session "
"command in %s:%d", "command in %s:%d",
backend_ref[i].bref_backend->backend_server->name, backend_ref[i].bref_backend->backend_server->name,
backend_ref[i].bref_backend->backend_server->port))); backend_ref[i].bref_backend->backend_server->port);
} }
else else
{ {
@ -4307,7 +4233,7 @@ static bool handle_error_new_connection(
if(!have_servers(rses)) if(!have_servers(rses))
{ {
skygw_log_write(LOGFILE_ERROR,"Error : No more valid servers, closing session"); MXS_ERROR("No more valid servers, closing session");
succp = false; succp = false;
goto return_succp; goto return_succp;
} }
@ -4410,7 +4336,7 @@ router_handle_state_switch(
{ {
case DCB_REASON_NOT_RESPONDING: case DCB_REASON_NOT_RESPONDING:
atomic_add(&bref->bref_backend->backend_conn_count, -1); atomic_add(&bref->bref_backend->backend_conn_count, -1);
skygw_log_write(LOGFILE_TRACE,"schemarouter: server %s not responding",srv->unique_name); MXS_INFO("schemarouter: server %s not responding",srv->unique_name);
dcb->func.hangup(dcb); dcb->func.hangup(dcb);
break; break;
@ -4447,7 +4373,7 @@ bool detect_show_shards(GWBUF* query)
if(query == NULL) if(query == NULL)
{ {
skygw_log_write(LE,"Fatal Error: NULL value passed at %s:%d",__FILE__,__LINE__); MXS_ERROR("NULL value passed at %s:%d",__FILE__,__LINE__);
return false; return false;
} }
@ -4458,7 +4384,7 @@ bool detect_show_shards(GWBUF* query)
if((querystr = modutil_get_SQL(query)) == NULL) if((querystr = modutil_get_SQL(query)) == NULL)
{ {
skygw_log_write(LE,"Fatal Error: failure to parse SQL at %s:%d",__FILE__,__LINE__); MXS_ERROR("Failure to parse SQL at %s:%d",__FILE__,__LINE__);
return false; return false;
} }
@ -4521,7 +4447,7 @@ int process_show_shards(ROUTER_CLIENT_SES* rses)
sl.rses = rses; sl.rses = rses;
if ((sl.rset = resultset_create(shard_list_cb, &sl)) == NULL) if ((sl.rset = resultset_create(shard_list_cb, &sl)) == NULL)
{ {
skygw_log_write(LE, "[%s] Error: Failed to create resultset.", __FUNCTION__); MXS_ERROR("[%s] Error: Failed to create resultset.", __FUNCTION__);
rval = -1; rval = -1;
} }
else else
@ -4535,7 +4461,7 @@ int process_show_shards(ROUTER_CLIENT_SES* rses)
} }
else else
{ {
skygw_log_write(LE, "Error: hashtable_iterator creation failed. " MXS_ERROR("hashtable_iterator creation failed. "
"This is caused by a memory allocation failure."); "This is caused by a memory allocation failure.");
rval = -1; rval = -1;
} }
@ -4558,12 +4484,12 @@ void write_error_to_client(DCB* dcb, int errnum, const char* mysqlstate, const c
{ {
if (dcb->func.write(dcb, errbuff) != 1) if (dcb->func.write(dcb, errbuff) != 1)
{ {
skygw_log_write(LE, "Error: Failed to write error packet to client."); MXS_ERROR("Failed to write error packet to client.");
} }
} }
else else
{ {
skygw_log_write(LE, "Error: Memory allocation failed when creating error packet."); MXS_ERROR("Memory allocation failed when creating error packet.");
} }
} }
@ -4604,7 +4530,7 @@ bool handle_default_db(ROUTER_CLIENT_SES *router_cli_ses)
if (get_shard_dcb(&dcb, router_cli_ses, target)) if (get_shard_dcb(&dcb, router_cli_ses, target))
{ {
dcb->func.write(dcb, buffer); dcb->func.write(dcb, buffer);
skygw_log_write(LOGFILE_DEBUG, "schemarouter: USE '%s' sent to %s for session %p", MXS_DEBUG("schemarouter: USE '%s' sent to %s for session %p",
router_cli_ses->connect_db, router_cli_ses->connect_db,
target, target,
router_cli_ses->rses_client_dcb->session); router_cli_ses->rses_client_dcb->session);
@ -4612,18 +4538,18 @@ bool handle_default_db(ROUTER_CLIENT_SES *router_cli_ses)
} }
else else
{ {
skygw_log_write_flush(LOGFILE_TRACE, "schemarouter: Couldn't find target DCB for '%s'.", target); MXS_INFO("schemarouter: Couldn't find target DCB for '%s'.", target);
} }
} }
else else
{ {
skygw_log_write_flush(LOGFILE_ERROR, "Error : Buffer allocation failed."); MXS_ERROR("Buffer allocation failed.");
} }
} }
else else
{ {
/** Unknown database, hang up on the client*/ /** Unknown database, hang up on the client*/
skygw_log_write_flush(LOGFILE_TRACE, "schemarouter: Connecting to a non-existent database '%s'", MXS_INFO("schemarouter: Connecting to a non-existent database '%s'",
router_cli_ses->connect_db); router_cli_ses->connect_db);
char errmsg[128 + MYSQL_DATABASE_MAXLEN + 1]; char errmsg[128 + MYSQL_DATABASE_MAXLEN + 1];
sprintf(errmsg, "Unknown database '%s'", router_cli_ses->connect_db); sprintf(errmsg, "Unknown database '%s'", router_cli_ses->connect_db);
@ -4648,7 +4574,7 @@ void route_queued_query(ROUTER_CLIENT_SES *router_cli_ses)
tmp->next = NULL; tmp->next = NULL;
#ifdef SS_DEBUG #ifdef SS_DEBUG
char* querystr = modutil_get_SQL(tmp); char* querystr = modutil_get_SQL(tmp);
skygw_log_write(LOGFILE_DEBUG, "schemarouter: Sending queued buffer for session %p: %s", MXS_DEBUG("schemarouter: Sending queued buffer for session %p: %s",
router_cli_ses->rses_client_dcb->session, router_cli_ses->rses_client_dcb->session,
querystr); querystr);
free(querystr); free(querystr);
@ -4684,7 +4610,7 @@ int inspect_backend_mapping_states(ROUTER_CLIENT_SES *router_cli_ses,
if (rc == SHOWDB_FULL_RESPONSE) if (rc == SHOWDB_FULL_RESPONSE)
{ {
router_cli_ses->rses_backend_ref[i].bref_mapped = true; router_cli_ses->rses_backend_ref[i].bref_mapped = true;
skygw_log_write(LOGFILE_DEBUG, "schemarouter: Received SHOW DATABASES reply from %s for session %p", MXS_DEBUG("schemarouter: Received SHOW DATABASES reply from %s for session %p",
router_cli_ses->rses_backend_ref[i].bref_backend->backend_server->unique_name, router_cli_ses->rses_backend_ref[i].bref_backend->backend_server->unique_name,
router_cli_ses->rses_client_dcb->session); router_cli_ses->rses_client_dcb->session);
} }
@ -4692,7 +4618,7 @@ int inspect_backend_mapping_states(ROUTER_CLIENT_SES *router_cli_ses,
{ {
bref->map_queue = writebuf; bref->map_queue = writebuf;
writebuf = NULL; writebuf = NULL;
skygw_log_write(LOGFILE_DEBUG, "schemarouter: Received partial SHOW DATABASES reply from %s for session %p", MXS_DEBUG("schemarouter: Received partial SHOW DATABASES reply from %s for session %p",
router_cli_ses->rses_backend_ref[i].bref_backend->backend_server->unique_name, router_cli_ses->rses_backend_ref[i].bref_backend->backend_server->unique_name,
router_cli_ses->rses_client_dcb->session); router_cli_ses->rses_client_dcb->session);
} }
@ -4704,11 +4630,11 @@ int inspect_backend_mapping_states(ROUTER_CLIENT_SES *router_cli_ses,
{ {
if (rc == SHOWDB_DUPLICATE_DATABASES) if (rc == SHOWDB_DUPLICATE_DATABASES)
{ {
skygw_log_write(LE, "Error: Duplicate databases found, closing session."); MXS_ERROR("Duplicate databases found, closing session.");
} }
else else
{ {
skygw_log_write(LE, "Error: Fatal error when processing SHOW DATABASES response, closing session."); MXS_ERROR("Fatal error when processing SHOW DATABASES response, closing session.");
} }
client_dcb = router_cli_ses->rses_client_dcb; client_dcb = router_cli_ses->rses_client_dcb;
@ -4731,8 +4657,7 @@ int inspect_backend_mapping_states(ROUTER_CLIENT_SES *router_cli_ses,
} }
else else
{ {
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, MXS_ERROR("Creating buffer for error message failed.");
"Error : Creating buffer for error message failed.")));
} }
} }
} }
@ -4745,7 +4670,7 @@ int inspect_backend_mapping_states(ROUTER_CLIENT_SES *router_cli_ses,
!BREF_IS_MAPPED(&bkrf[i])) !BREF_IS_MAPPED(&bkrf[i]))
{ {
mapped = false; mapped = false;
skygw_log_write(LOGFILE_DEBUG, "schemarouter: Still waiting for reply to SHOW DATABASES from %s for session %p", MXS_DEBUG("schemarouter: Still waiting for reply to SHOW DATABASES from %s for session %p",
bkrf[i].bref_backend->backend_server->unique_name, bkrf[i].bref_backend->backend_server->unique_name,
router_cli_ses->rses_client_dcb->session); router_cli_ses->rses_client_dcb->session);
} }
@ -4800,7 +4725,7 @@ void synchronize_shard_map(ROUTER_CLIENT_SES *client)
} }
else if (map->state != SHMAP_READY) else if (map->state != SHMAP_READY)
{ {
skygw_log_write(LE, "Warning: Shard map state is not ready but" MXS_WARNING("Shard map state is not ready but"
"it is in use. Replacing it with a newer one."); "it is in use. Replacing it with a newer one.");
replace_shard_map(&map, &client->shardmap); replace_shard_map(&map, &client->shardmap);
} }

View File

@ -41,7 +41,7 @@ bool extract_database(GWBUF* buf, char* str)
tok = strtok_r(query," ;",&saved); tok = strtok_r(query," ;",&saved);
if(tok == NULL || strcasecmp(tok,"use") != 0) if(tok == NULL || strcasecmp(tok,"use") != 0)
{ {
skygw_log_write(LOGFILE_ERROR,"extract_database: Malformed chage database packet."); MXS_ERROR("extract_database: Malformed chage database packet.");
succp = false; succp = false;
goto retblock; goto retblock;
} }
@ -49,7 +49,7 @@ bool extract_database(GWBUF* buf, char* str)
tok = strtok_r(NULL," ;",&saved); tok = strtok_r(NULL," ;",&saved);
if(tok == NULL) if(tok == NULL)
{ {
skygw_log_write(LOGFILE_ERROR,"extract_database: Malformed chage database packet."); MXS_ERROR("extract_database: Malformed chage database packet.");
succp = false; succp = false;
goto retblock; goto retblock;
} }
@ -73,16 +73,12 @@ bool extract_database(GWBUF* buf, char* str)
*/ */
void create_error_reply(char* fail_str,DCB* dcb) void create_error_reply(char* fail_str,DCB* dcb)
{ {
skygw_log_write_flush( MXS_INFO("change_current_db: failed to change database: %s", fail_str);
LOGFILE_TRACE,
"change_current_db: failed to change database: %s", fail_str);
GWBUF* errbuf = modutil_create_mysql_err_msg(1, 0, 1049, "42000", fail_str); GWBUF* errbuf = modutil_create_mysql_err_msg(1, 0, 1049, "42000", fail_str);
if (errbuf == NULL) if (errbuf == NULL)
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Creating buffer for error message failed.");
LOGFILE_ERROR,
"Error : Creating buffer for error message failed.")));
return; return;
} }
/** Set flags that help router to identify session commands reply */ /** Set flags that help router to identify session commands reply */
@ -120,8 +116,7 @@ bool change_current_db(char* dest,
succp = false; succp = false;
goto retblock; goto retblock;
} }
skygw_log_write(LOGFILE_TRACE,"change_current_db: INIT_DB with database '%s'", MXS_INFO("change_current_db: INIT_DB with database '%s'", db);
db);
/** /**
* Update the session's active database only if it's in the hashtable. * Update the session's active database only if it's in the hashtable.
* If it isn't found, send a custom error packet to the client. * If it isn't found, send a custom error packet to the client.
@ -135,7 +130,7 @@ bool change_current_db(char* dest,
else else
{ {
strcpy(dest,db); strcpy(dest,db);
skygw_log_write(LOGFILE_TRACE,"change_current_db: database is on server: '%s'.",target); MXS_INFO("change_current_db: database is on server: '%s'.",target);
succp = true; succp = true;
goto retblock; goto retblock;
} }
@ -143,10 +138,8 @@ bool change_current_db(char* dest,
else else
{ {
/** Create error message */ /** Create error message */
skygw_log_write_flush(LOGFILE_ERROR, MXS_ERROR("change_current_db: failed to change database: Query buffer too large");
"change_current_db: failed to change database: Query buffer too large"); MXS_INFO("change_current_db: failed to change database: "
skygw_log_write_flush(LOGFILE_TRACE,
"change_current_db: failed to change database: "
"Query buffer too large [%ld bytes]", GWBUF_LENGTH(buf)); "Query buffer too large [%ld bytes]", GWBUF_LENGTH(buf));
succp = false; succp = false;
goto retblock; goto retblock;

View File

@ -343,7 +343,7 @@ parse_mapping_response(ROUTER_CLIENT_SES* rses, char* target, GWBUF* buf)
{ {
if(hashtable_add(rses->dbhash,data,target)) if(hashtable_add(rses->dbhash,data,target))
{ {
skygw_log_write(LOGFILE_TRACE,"shardrouter: <%s, %s>",target,data); MXS_INFO("shardrouter: <%s, %s>",target,data);
} }
free(data); free(data);
} }
@ -468,7 +468,7 @@ get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client, GWBUF*
} }
else else
{ {
skygw_log_write(LOGFILE_TRACE,"shardrouter: Query targets database '%s' on server '%s",dbnms[i],rval); MXS_INFO("shardrouter: Query targets database '%s' on server '%s",dbnms[i],rval);
has_dbs = true; has_dbs = true;
} }
} }
@ -487,14 +487,14 @@ get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client, GWBUF*
ss_dassert(tok != NULL); ss_dassert(tok != NULL);
tmp = (char*) hashtable_fetch(ht, tok); tmp = (char*) hashtable_fetch(ht, tok);
if(tmp) if(tmp)
skygw_log_write(LOGFILE_TRACE,"shardrouter: SHOW TABLES with specific database '%s' on server '%s'", tok, tmp); MXS_INFO("shardrouter: SHOW TABLES with specific database '%s' on server '%s'", tok, tmp);
} }
free(query); free(query);
if(tmp == NULL) if(tmp == NULL)
{ {
rval = (char*) hashtable_fetch(ht, client->rses_mysql_session->db); rval = (char*) hashtable_fetch(ht, client->rses_mysql_session->db);
skygw_log_write(LOGFILE_TRACE,"shardrouter: SHOW TABLES query, current database '%s' on server '%s'", MXS_INFO("shardrouter: SHOW TABLES query, current database '%s' on server '%s'",
client->rses_mysql_session->db,rval); client->rses_mysql_session->db,rval);
} }
else else
@ -516,7 +516,7 @@ get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client, GWBUF*
if(strcmp(srvrf->server->unique_name,buffer->hint->data) == 0) if(strcmp(srvrf->server->unique_name,buffer->hint->data) == 0)
{ {
rval = srvrf->server->unique_name; rval = srvrf->server->unique_name;
skygw_log_write(LOGFILE_TRACE,"shardrouter: Routing hint found (%s)",rval); MXS_INFO("shardrouter: Routing hint found (%s)",rval);
} }
srvrf = srvrf->next; srvrf = srvrf->next;
@ -535,7 +535,7 @@ get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client, GWBUF*
rval = (char*) hashtable_fetch(ht, client->rses_mysql_session->db); rval = (char*) hashtable_fetch(ht, client->rses_mysql_session->db);
if(rval) if(rval)
{ {
skygw_log_write(LOGFILE_TRACE,"shardrouter: Using active database '%s'",client->rses_mysql_session->db); MXS_INFO("shardrouter: Using active database '%s'",client->rses_mysql_session->db);
} }
} }
@ -564,10 +564,8 @@ tokenize_string(char* str)
if(tmp == NULL) if(tmp == NULL)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("realloc returned NULL: %s.",
LOGFILE_ERROR, strerror_r(errno, errbuf, sizeof(errbuf)));
"Error : realloc returned NULL: %s.",
strerror_r(errno, errbuf, sizeof(errbuf)))));
free(list); free(list);
return NULL; return NULL;
} }
@ -634,7 +632,7 @@ filterReply(FILTER* instance, void *session, GWBUF *reply)
if(!logged) if(!logged)
{ {
/* /*
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Still waiting for reply to SHOW DATABASES from %s for session %p", MXS_DEBUG("schemarouter: Still waiting for reply to SHOW DATABASES from %s for session %p",
bkrf[i].bref_backend->backend_server->unique_name, bkrf[i].bref_backend->backend_server->unique_name,
rses->rses_client_dcb->session); rses->rses_client_dcb->session);
*/ */
@ -660,7 +658,7 @@ filterReply(FILTER* instance, void *session, GWBUF *reply)
if((target = hashtable_fetch(rses->dbhash, if((target = hashtable_fetch(rses->dbhash,
rses->connect_db)) == NULL) rses->connect_db)) == NULL)
{ {
skygw_log_write_flush(LOGFILE_TRACE,"schemarouter: Connecting to a non-existent database '%s'", MXS_INFO("schemarouter: Connecting to a non-existent database '%s'",
rses->connect_db); rses->connect_db);
rses->rses_closed = true; rses->rses_closed = true;
if(rses->queue) if(rses->queue)
@ -682,7 +680,7 @@ filterReply(FILTER* instance, void *session, GWBUF *reply)
buffer = gwbuf_alloc(qlen + 5); buffer = gwbuf_alloc(qlen + 5);
if(buffer == NULL) if(buffer == NULL)
{ {
skygw_log_write_flush(LOGFILE_ERROR,"Error : Buffer allocation failed."); MXS_ERROR("Buffer allocation failed.");
rses->rses_closed = true; rses->rses_closed = true;
if(rses->queue) if(rses->queue)
gwbuf_free(rses->queue); gwbuf_free(rses->queue);
@ -707,15 +705,14 @@ filterReply(FILTER* instance, void *session, GWBUF *reply)
rses->queue = rses->queue->next; rses->queue = rses->queue->next;
tmp->next = NULL; tmp->next = NULL;
char* querystr = modutil_get_SQL(tmp); char* querystr = modutil_get_SQL(tmp);
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Sending queued buffer for session %p: %s", MXS_DEBUG("schemarouter: Sending queued buffer for session %p: %s",
rses->rses_client_dcb->session, rses->rses_client_dcb->session,
querystr); querystr);
poll_add_epollin_event_to_dcb(rses->routedcb,tmp); poll_add_epollin_event_to_dcb(rses->routedcb,tmp);
free(querystr); free(querystr);
} }
skygw_log_write_flush(LOGFILE_DEBUG,"session [%p] database map finished.", MXS_DEBUG("session [%p] database map finished.", rses);
rses);
} }
goto retblock; goto retblock;
@ -727,7 +724,7 @@ filterReply(FILTER* instance, void *session, GWBUF *reply)
rses->queue = rses->queue->next; rses->queue = rses->queue->next;
tmp->next = NULL; tmp->next = NULL;
char* querystr = modutil_get_SQL(tmp); char* querystr = modutil_get_SQL(tmp);
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Sending queued buffer for session %p: %s", MXS_DEBUG("schemarouter: Sending queued buffer for session %p: %s",
rses->rses_client_dcb->session, rses->rses_client_dcb->session,
querystr); querystr);
poll_add_epollin_event_to_dcb(rses->routedcb,tmp); poll_add_epollin_event_to_dcb(rses->routedcb,tmp);
@ -737,7 +734,7 @@ filterReply(FILTER* instance, void *session, GWBUF *reply)
if(rses->init & INIT_USE_DB) if(rses->init & INIT_USE_DB)
{ {
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Reply to USE '%s' received for session %p", MXS_DEBUG("schemarouter: Reply to USE '%s' received for session %p",
rses->connect_db, rses->connect_db,
rses->rses_client_dcb->session); rses->rses_client_dcb->session);
rses->init &= ~INIT_USE_DB; rses->init &= ~INIT_USE_DB;
@ -831,9 +828,7 @@ version()
void void
ModuleInit() ModuleInit()
{ {
LOGIF(LM, (skygw_log_write_flush( MXS_NOTICE("Initializing statemend-based read/write split router module.");
LOGFILE_MESSAGE,
"Initializing statemend-based read/write split router module.")));
spinlock_init(&instlock); spinlock_init(&instlock);
instances = NULL; instances = NULL;
} }
@ -938,7 +933,7 @@ createInstance(SERVICE *service, char **options)
if(conf == NULL) if(conf == NULL)
{ {
skygw_log_write(LOGFILE_ERROR, "Error : no 'subservices' confguration parameter found. " MXS_ERROR("No 'subservices' confguration parameter found. "
" Expected a list of service names."); " Expected a list of service names.");
free(router); free(router);
return NULL; return NULL;
@ -951,7 +946,7 @@ createInstance(SERVICE *service, char **options)
{ {
free(router); free(router);
free(services); free(services);
skygw_log_write(LOGFILE_ERROR,"Error: Memory allocation failed."); MXS_ERROR("Memory allocation failed.");
return NULL; return NULL;
} }
@ -966,10 +961,10 @@ createInstance(SERVICE *service, char **options)
temp = realloc(res_svc, sizeof(SERVICE*)*(sz * 2)); temp = realloc(res_svc, sizeof(SERVICE*)*(sz * 2));
if(temp == NULL) if(temp == NULL)
{ {
skygw_log_write(LOGFILE_ERROR, "Error : Memory reallocation failed."); MXS_ERROR("Memory reallocation failed.");
LOGIF(LD,(skygw_log_write(LOGFILE_DEBUG, "shardrouter.c: realloc returned NULL. " MXS_DEBUG("shardrouter.c: realloc returned NULL. "
"service count[%d] buffer size [%lu] tried to allocate [%lu]", "service count[%d] buffer size [%lu] tried to allocate [%lu]",
sz, sizeof(SERVICE*) * (sz), sizeof(SERVICE*) * (sz * 2)))); sz, sizeof(SERVICE*) * (sz), sizeof(SERVICE*) * (sz * 2));
free(res_svc); free(res_svc);
free(router); free(router);
return NULL; return NULL;
@ -983,7 +978,7 @@ createInstance(SERVICE *service, char **options)
{ {
free(res_svc); free(res_svc);
free(router); free(router);
skygw_log_write(LOGFILE_ERROR, "Error : No service named '%s' found.", options[i]); MXS_ERROR("No service named '%s' found.", options[i]);
return NULL; return NULL;
} }
i++; i++;
@ -998,7 +993,7 @@ createInstance(SERVICE *service, char **options)
if(i < min_nsvc) if(i < min_nsvc)
{ {
skygw_log_write(LOGFILE_ERROR, "Error : Not enough parameters for 'subservice' router option. Shardrouter requires at least %d " MXS_ERROR("Not enough parameters for 'subservice' router option. Shardrouter requires at least %d "
"configured services to work.", min_nsvc); "configured services to work.", min_nsvc);
free(router->services); free(router->services);
free(router); free(router);
@ -1107,7 +1102,7 @@ newSession(
if(subsvc->scur == NULL) if(subsvc->scur == NULL)
{ {
subsvc_set_state(subsvc,SUBSVC_FAILED); subsvc_set_state(subsvc,SUBSVC_FAILED);
skygw_log_write_flush(LOGFILE_ERROR,"Error : Memory allocation failed in shardrouter."); MXS_ERROR("Memory allocation failed in shardrouter.");
continue; continue;
} }
subsvc->scur->scmd_cur_rses = client_rses; subsvc->scur->scmd_cur_rses = client_rses;
@ -1117,7 +1112,7 @@ newSession(
if(subsvc->dcb == NULL){ if(subsvc->dcb == NULL){
subsvc_set_state(subsvc,SUBSVC_FAILED); subsvc_set_state(subsvc,SUBSVC_FAILED);
skygw_log_write_flush(LOGFILE_ERROR,"Error : Failed to clone client DCB in shardrouter."); MXS_ERROR("Failed to clone client DCB in shardrouter.");
continue; continue;
} }
@ -1127,7 +1122,7 @@ newSession(
dcb_close(subsvc->dcb); dcb_close(subsvc->dcb);
subsvc->dcb = NULL; subsvc->dcb = NULL;
subsvc_set_state(subsvc,SUBSVC_FAILED); subsvc_set_state(subsvc,SUBSVC_FAILED);
skygw_log_write_flush(LOGFILE_ERROR,"Error : Failed to create subsession for service %s in shardrouter.",subsvc->service->name); MXS_ERROR("Failed to create subsession for service %s in shardrouter.",subsvc->service->name);
continue; continue;
} }
@ -1136,7 +1131,7 @@ newSession(
if(dummy_filterdef == NULL) if(dummy_filterdef == NULL)
{ {
subsvc_set_state(subsvc,SUBSVC_FAILED); subsvc_set_state(subsvc,SUBSVC_FAILED);
skygw_log_write_flush(LOGFILE_ERROR,"Error : Failed to allocate filter definition in shardrouter."); MXS_ERROR("Failed to allocate filter definition in shardrouter.");
continue; continue;
} }
dummy_filterdef->obj = &dummyObject; dummy_filterdef->obj = &dummyObject;
@ -1146,7 +1141,7 @@ newSession(
if(dummy_upstream == NULL) if(dummy_upstream == NULL)
{ {
subsvc_set_state(subsvc,SUBSVC_FAILED); subsvc_set_state(subsvc,SUBSVC_FAILED);
skygw_log_write_flush(LOGFILE_ERROR,"Error : Failed to set filterUpstream in shardrouter."); MXS_ERROR("Failed to set filterUpstream in shardrouter.");
continue; continue;
} }
@ -1217,9 +1212,7 @@ closeSession(
{ {
ROUTER_CLIENT_SES* router_cli_ses; ROUTER_CLIENT_SES* router_cli_ses;
int i; int i;
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, MXS_DEBUG("%lu [RWSplit:closeSession]", pthread_self());
"%lu [RWSplit:closeSession]",
pthread_self())));
/** /**
* router session can be NULL if newSession failed and it is discarding * router session can be NULL if newSession failed and it is discarding
@ -1351,10 +1344,7 @@ get_shard_route_target(skygw_query_type_t qtype,
target = TARGET_ANY; target = TARGET_ANY;
} }
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LT, (skygw_log_write( MXS_INFO("Selected target \"%s\"", STRTARGET(target));
LOGFILE_TRACE,
"Selected target \"%s\"",
STRTARGET(target))));
#endif #endif
return target; return target;
} }
@ -1551,7 +1541,7 @@ routeQuery(ROUTER* instance,
char db[MYSQL_DATABASE_MAXLEN + 1]; char db[MYSQL_DATABASE_MAXLEN + 1];
char errbuf[26+MYSQL_DATABASE_MAXLEN]; char errbuf[26+MYSQL_DATABASE_MAXLEN];
skygw_log_write_flush(LOGFILE_DEBUG,"shardrouter: routeQuery"); MXS_DEBUG("shardrouter: routeQuery");
CHK_CLIENT_RSES(router_cli_ses); CHK_CLIENT_RSES(router_cli_ses);
/** Dirty read for quick check if router is closed. */ /** Dirty read for quick check if router is closed. */
@ -1564,9 +1554,7 @@ routeQuery(ROUTER* instance,
/** Lock router session */ /** Lock router session */
if(!rses_begin_locked_router_action(router_cli_ses)) if(!rses_begin_locked_router_action(router_cli_ses))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Route query aborted! Routing session is closed <");
LOGFILE_TRACE,
"Route query aborted! Routing session is closed <")));
ret = 0; ret = 0;
goto retblock; goto retblock;
} }
@ -1583,7 +1571,7 @@ routeQuery(ROUTER* instance,
{ {
char* querystr = modutil_get_SQL(querybuf); char* querystr = modutil_get_SQL(querybuf);
skygw_log_write(LOGFILE_DEBUG,"shardrouter: Storing query for session %p: %s", MXS_DEBUG("shardrouter: Storing query for session %p: %s",
router_cli_ses->rses_client_dcb->session, router_cli_ses->rses_client_dcb->session,
querystr); querystr);
free(querystr); free(querystr);
@ -1625,14 +1613,11 @@ routeQuery(ROUTER* instance,
{ {
char* query_str = modutil_get_query(querybuf); char* query_str = modutil_get_query(querybuf);
LOGIF(LE, MXS_ERROR("Can't route %s:%s:\"%s\" to "
(skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Can't route %s:%s:\"%s\" to "
"backend server. Router is closed.", "backend server. Router is closed.",
STRPACKETTYPE(packet_type), STRPACKETTYPE(packet_type),
STRQTYPE(qtype), STRQTYPE(qtype),
(query_str == NULL ? "(empty)" : query_str)))); (query_str == NULL ? "(empty)" : query_str));
free(query_str); free(query_str);
} }
ret = 0; ret = 0;
@ -1699,9 +1684,7 @@ routeQuery(ROUTER* instance,
extract_database(querybuf,db); extract_database(querybuf,db);
snprintf(errbuf,25+MYSQL_DATABASE_MAXLEN,"Unknown database: %s",db); snprintf(errbuf,25+MYSQL_DATABASE_MAXLEN,"Unknown database: %s",db);
create_error_reply(errbuf,router_cli_ses->replydcb); create_error_reply(errbuf,router_cli_ses->replydcb);
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Changing database failed.");
LOGFILE_ERROR,
"Error : Changing database failed.")));
return 1; return 1;
} }
} }
@ -1801,9 +1784,7 @@ routeQuery(ROUTER* instance,
/** Lock router session */ /** Lock router session */
if(!rses_begin_locked_router_action(router_cli_ses)) if(!rses_begin_locked_router_action(router_cli_ses))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Route query aborted! Routing session is closed <");
LOGFILE_TRACE,
"Route query aborted! Routing session is closed <")));
ret = 0; ret = 0;
goto retblock; goto retblock;
} }
@ -1847,12 +1828,10 @@ routeQuery(ROUTER* instance,
if(!succp) if(!succp)
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Was supposed to route to named server "
LOGFILE_TRACE,
"Was supposed to route to named server "
"%s but couldn't find the server in a " "%s but couldn't find the server in a "
"suitable state.", "suitable state.",
tname))); tname);
} }
} }
@ -1888,9 +1867,7 @@ routeQuery(ROUTER* instance,
} }
else else
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Routing query failed.");
LOGFILE_ERROR,
"Error : Routing query failed.")));
ret = 0; ret = 0;
} }
} }
@ -2094,13 +2071,11 @@ rses_property_done(
break; break;
default: default:
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [rses_property_done] Unknown property type %d "
LOGFILE_DEBUG,
"%lu [rses_property_done] Unknown property type %d "
"in property %p", "in property %p",
pthread_self(), pthread_self(),
prop->rses_prop_type, prop->rses_prop_type,
prop))); prop);
ss_dassert(false); ss_dassert(false);
break; break;
@ -2444,9 +2419,7 @@ execute_sescmd_in_backend(SUBSERVICE* subsvc)
if(sescmd_cursor_get_command(scur) == NULL) if(sescmd_cursor_get_command(scur) == NULL)
{ {
succp = false; succp = false;
LOGIF(LT, (skygw_log_write_flush( MXS_INFO("Cursor had no pending session commands.");
LOGFILE_TRACE,
"Cursor had no pending session commands.")));
goto return_succp; goto return_succp;
} }
@ -2601,9 +2574,7 @@ route_session_write(
SUBSERVICE* subsvc; SUBSERVICE* subsvc;
int i; int i;
LOGIF(LT, (skygw_log_write( MXS_INFO("Session write, routing to all servers.");
LOGFILE_TRACE,
"Session write, routing to all servers.")));
/** /**
* These are one-way messages and server doesn't respond to them. * These are one-way messages and server doesn't respond to them.
@ -2632,12 +2603,10 @@ route_session_write(
if(LOG_IS_ENABLED(LOGFILE_TRACE)) if(LOG_IS_ENABLED(LOGFILE_TRACE))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Route query to %s%s%s",
LOGFILE_TRACE,
"Route query to %s%s%s",
i == 0 ? ">":"", i == 0 ? ">":"",
subsvc->service->name, subsvc->service->name,
i+1 >= router_cli_ses->n_subservice ? "<" : ""))); i+1 >= router_cli_ses->n_subservice ? "<" : "");
} }
if(!SUBSVC_IS_CLOSED(subsvc) && SUBSVC_IS_OK(subsvc)) if(!SUBSVC_IS_CLOSED(subsvc) && SUBSVC_IS_OK(subsvc))
@ -2687,12 +2656,10 @@ route_session_write(
if(LOG_IS_ENABLED(LOGFILE_TRACE)) if(LOG_IS_ENABLED(LOGFILE_TRACE))
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Route query to %s%s%s",
LOGFILE_TRACE,
"Route query to %s%s%s",
i == 0 ? ">":"", i == 0 ? ">":"",
subsvc->service->name, subsvc->service->name,
i+1 >= router_cli_ses->n_subservice ? "<" : ""))); i+1 >= router_cli_ses->n_subservice ? "<" : "");
} }
@ -2715,10 +2682,8 @@ route_session_write(
{ {
succp = true; succp = true;
LOGIF(LT, (skygw_log_write( MXS_INFO("Service %s already executing sescmd.",
LOGFILE_TRACE, subsvc->service->name);
"Service %s already executing sescmd.",
subsvc->service->name)));
} }
else else
{ {
@ -2726,11 +2691,9 @@ route_session_write(
if(!succp) if(!succp)
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to execute session "
LOGFILE_ERROR,
"Error : Failed to execute session "
"command in %s", "command in %s",
subsvc->service->name))); subsvc->service->name);
} }
} }
} }