diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 9d44a095b..f69ec3e3b 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -372,9 +372,7 @@ version() void ModuleInit() { - LOGIF(LM, (skygw_log_write_flush( - LOGFILE_MESSAGE, - "Initializing statemend-based read/write split router module."))); + MXS_NOTICE("Initializing statemend-based read/write split router module."); spinlock_init(&instlock); instances = NULL; } @@ -518,25 +516,21 @@ static void refreshInstance( { if (rlag_limited) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Warning : Configuration Failed, max_slave_replication_lag " + 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))); + router->rwsplit_config.rw_max_slave_replication_lag); } if (router->rwsplit_config.rw_slave_select_criteria == LEAST_BEHIND_MASTER) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Warning : Configuration Failed, router option " + 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)))); + STRCRITERIA(DEFAULT_CRITERIA)); router->rwsplit_config.rw_slave_select_criteria = DEFAULT_CRITERIA; @@ -645,11 +639,10 @@ createInstance(SERVICE *service, char **options) } if (total == 0) { - LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, - "WARNING: Weighting Parameter for service '%s' " + MXS_WARNING("Weighting Parameter for service '%s' " "will be ignored as no servers have values " "for the parameter '%s'.\n", - service->name, weightby))); + service->name, weightby); } else { @@ -670,14 +663,12 @@ createInstance(SERVICE *service, char **options) if (perc == 0) { - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Server '%s' has no value " - "for weighting parameter '%s', " - "no queries will be routed to " - "this server.\n", - router->servers[n]->backend_server->unique_name, - weightby))); + MXS_ERROR("Server '%s' has no value " + "for weighting parameter '%s', " + "no queries will be routed to " + "this server.\n", + router->servers[n]->backend_server->unique_name, + weightby); } } } @@ -964,9 +955,7 @@ static void closeSession( ROUTER_CLIENT_SES* router_cli_ses; backend_ref_t* backend_ref; - LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, - "%lu [RWSplit:closeSession]", - pthread_self()))); + MXS_DEBUG("%lu [RWSplit:closeSession]", pthread_self()); /** * router session can be NULL if newSession failed and it is discarding @@ -1144,8 +1133,7 @@ static bool get_dcb( master_host = get_root_master(backend_ref, rses->rses_nbackends); if (master_bref->bref_backend != master_host) { - LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, - "Master has changed."))); + MXS_INFO("Master has changed."); } #endif if (name != NULL) /*< Choose backend by name from a hint */ @@ -1269,13 +1257,11 @@ static bool get_dcb( } else { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Server %s:%d is too much behind the " - "master, %d s. and can't be chosen.", - b->backend_server->name, - b->backend_server->port, - b->backend_server->rlag))); + MXS_INFO("Server %s:%d is too much behind the " + "master, %d s. and can't be chosen.", + b->backend_server->name, + b->backend_server->port, + b->backend_server->rlag); } } } /*< for */ @@ -1303,13 +1289,11 @@ static bool get_dcb( } else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Server at %s:%d should be master but " - "is %s instead and can't be chosen to master.", - master_bref->bref_backend->backend_server->name, - master_bref->bref_backend->backend_server->port, - STRSRVSTATUS(master_bref->bref_backend->backend_server)))); + MXS_ERROR("Server at %s:%d should be master but " + "is %s instead and can't be chosen to master.", + master_bref->bref_backend->backend_server->name, + master_bref->bref_backend->backend_server->port, + STRSRVSTATUS(master_bref->bref_backend->backend_server)); succp = false; } } @@ -1406,15 +1390,13 @@ static route_target_t get_route_target ( !( QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_STMT) || QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_NAMED_STMT))) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Warning : The query can't be routed to all " + MXS_WARNING("The query can't be routed to all " "backend servers because it includes SELECT and " "SQL variable modifications which is not supported. " "Set use_sql_variables_in=master or split the " "query to two, where SQL variable modifications " "are done in the first and the SELECT in the " - "second one."))); + "second one."); target = TARGET_MASTER; } @@ -1463,10 +1445,8 @@ static route_target_t get_route_target ( if (hint->type == HINT_ROUTE_TO_MASTER) { target = TARGET_MASTER; /*< override */ - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [get_route_target] Hint: route to master.", - pthread_self()))); + MXS_DEBUG("%lu [get_route_target] Hint: route to master.", + pthread_self()); break; } else if (hint->type == HINT_ROUTE_TO_NAMED_SERVER) @@ -1476,11 +1456,9 @@ static route_target_t get_route_target ( * found, the oroginal target is chosen. */ target |= TARGET_NAMED_SERVER; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [get_route_target] Hint: route to " - "named server : ", - pthread_self()))); + MXS_DEBUG("%lu [get_route_target] Hint: route to " + "named server : ", + pthread_self()); } else if (hint->type == HINT_ROUTE_TO_UPTODATE_SERVER) { @@ -1501,28 +1479,18 @@ static route_target_t get_route_target ( } else { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Error : Unknown hint parameter " - "'%s' when 'max_slave_replication_lag' " - "was expected.", - (char *)hint->data))); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Unknown hint parameter " - "'%s' when 'max_slave_replication_lag' " - "was expected.", - (char *)hint->data))); + MXS_ERROR("Unknown hint parameter " + "'%s' when 'max_slave_replication_lag' " + "was expected.", + (char *)hint->data); } } else if (hint->type == HINT_ROUTE_TO_SLAVE) { target = TARGET_SLAVE; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [get_route_target] Hint: route to " - "slave.", - pthread_self()))); + MXS_DEBUG("%lu [get_route_target] Hint: route to " + "slave.", + pthread_self()); } hint = hint->next; } /*< while (hint != NULL) */ @@ -1559,10 +1527,7 @@ static route_target_t get_route_target ( target = TARGET_MASTER; } #if defined(SS_EXTRA_DEBUG) - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Selected target \"%s\"", - STRTARGET(target)))); + MXS_INFO("Selected target \"%s\"", STRTARGET(target)); #endif return target; } @@ -1643,8 +1608,7 @@ void check_drop_tmp_table( if (hashtable_delete(rses_prop_tmp->rses_prop_data.temp_tables, (void *)hkey)) { - LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, - "Temporary table dropped: %s",hkey))); + MXS_INFO("Temporary table dropped: %s",hkey); } } free(tbl[i]); @@ -1738,10 +1702,8 @@ static skygw_query_type_t is_read_tmp_table( (bool)hashtable_fetch(rses_prop_tmp->rses_prop_data.temp_tables,(void *)hkey))) { /**Query target is a temporary table*/ - qtype = QUERY_TYPE_READ_TMP_TABLE; - LOGIF(LT, - (skygw_log_write(LOGFILE_TRACE, - "Query targets a temporary table: %s",hkey))); + qtype = QUERY_TYPE_READ_TMP_TABLE; + MXS_INFO("Query targets a temporary table: %s",hkey); } } } @@ -1857,7 +1819,7 @@ static void check_create_tmp_table( } else { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error : Call to malloc() failed."))); + MXS_ERROR("Call to malloc() failed."); } } if(rses_prop_tmp){ @@ -1869,7 +1831,7 @@ static void check_create_tmp_table( { rses_prop_tmp->rses_prop_data.temp_tables = h; }else{ - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error : Failed to allocate a new hashtable."))); + MXS_ERROR("Failed to allocate a new hashtable."); } } @@ -1879,10 +1841,7 @@ static void check_create_tmp_table( (void *)hkey, (void *)is_temp) == 0) /*< Conflict in hash table */ { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Temporary table conflict in hashtable: %s", - hkey))); + MXS_INFO("Temporary table conflict in hashtable: %s", hkey); } #if defined(SS_DEBUG) { @@ -1892,10 +1851,7 @@ static void check_create_tmp_table( hkey); if (retkey) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Temporary table added: %s", - hkey))); + MXS_INFO("Temporary table added: %s", hkey); } } #endif @@ -2015,12 +1971,10 @@ static int routeQuery( { char* query_str = modutil_get_query(querybuf); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Can't route %s:\"%s\" to " - "backend server. Router is closed.", - STRPACKETTYPE(packet_type), - (query_str == NULL ? "(empty)" : query_str)))); + MXS_ERROR("Can't route %s:\"%s\" to " + "backend server. Router is closed.", + STRPACKETTYPE(packet_type), + (query_str == NULL ? "(empty)" : query_str)); free(query_str); } } @@ -2049,12 +2003,10 @@ static int routeQuery( { char* query_str = modutil_get_query(querybuf); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Can't route %s:\"%s\" to " - "backend server. Router is closed.", - STRPACKETTYPE(packet_type), - (query_str == NULL ? "(empty)" : query_str)))); + MXS_ERROR("Can't route %s:\"%s\" to " + "backend server. Router is closed.", + STRPACKETTYPE(packet_type), + (query_str == NULL ? "(empty)" : query_str)); free(query_str); } } @@ -2076,11 +2028,8 @@ retblock: if (canonical_query_str != NULL) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Canonical version: %s", - canonical_query_str))); - free(canonical_query_str); + MXS_INFO("Canonical version: %s", canonical_query_str); + free(canonical_query_str); } } #endif @@ -2129,14 +2078,12 @@ static bool route_single_stmt( { char* query_str = modutil_get_query(querybuf); CHK_DCB(master_dcb); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Can't route %s:%s:\"%s\" to " - "backend server. Session doesn't have a Master " - "node", - STRPACKETTYPE(packet_type), - STRQTYPE(qtype), - (query_str == NULL ? "(empty)" : query_str)))); + MXS_ERROR("Can't route %s:%s:\"%s\" to " + "backend server. Session doesn't have a Master " + "node", + STRPACKETTYPE(packet_type), + STRQTYPE(qtype), + (query_str == NULL ? "(empty)" : query_str)); free(query_str); succp = false; goto retblock; @@ -2271,7 +2218,7 @@ static bool route_single_stmt( rses->rses_transaction_active = false; } - if (LOG_IS_ENABLED(LOGFILE_TRACE)) + if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO)) { if (!rses->rses_load_active) { @@ -2337,21 +2284,18 @@ static bool route_single_stmt( char* query_str = modutil_get_query(querybuf); char* qtype_str = skygw_get_qtype_str(qtype); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Can't route %s:%s:\"%s\". SELECT with " - "session data modification is not supported " - "if configuration parameter " - "use_sql_variables_in=all .", - STRPACKETTYPE(packet_type), - qtype_str, - (query_str == NULL ? "(empty)" : query_str)))); + MXS_ERROR("Can't route %s:%s:\"%s\". SELECT with " + "session data modification is not supported " + "if configuration parameter " + "use_sql_variables_in=all .", + STRPACKETTYPE(packet_type), + qtype_str, + (query_str == NULL ? "(empty)" : query_str)); - LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, - "Unable to route the query " - "without losing session data " - "modification from other " - "servers. <"))); + MXS_INFO("Unable to route the query " + "without losing session data " + "modification from other " + "servers. <"); while (bref != NULL && !BREF_IS_IN_USE(bref)) { @@ -2375,12 +2319,10 @@ static bool route_single_stmt( * If there were no available backend references * available return false - session will be closed */ - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Sending error message to client " - "failed. Router doesn't have any " - "available backends. Session will be " - "closed."))); + MXS_ERROR("Sending error message to client " + "failed. Router doesn't have any " + "available backends. Session will be " + "closed."); succp = false; } if (query_str) free (query_str); @@ -2413,13 +2355,11 @@ static bool route_single_stmt( { char* query_str = modutil_get_query(querybuf); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Can't route %s:%s:\"%s\" to " - "backend server. Router is closed.", - STRPACKETTYPE(packet_type), - STRQTYPE(qtype), - (query_str == NULL ? "(empty)" : query_str)))); + MXS_ERROR("Can't route %s:%s:\"%s\" to " + "backend server. Router is closed.", + STRPACKETTYPE(packet_type), + STRQTYPE(qtype), + (query_str == NULL ? "(empty)" : query_str)); free(query_str); } succp = false; @@ -2447,11 +2387,9 @@ static bool route_single_stmt( * backend server. */ named_server = hint->data; - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Hint: route to server " - "'%s'", - named_server))); + MXS_INFO("Hint: route to server " + "'%s'", + named_server); } else if (hint->type == HINT_PARAMETER && (strncasecmp((char *)hint->data, @@ -2469,11 +2407,9 @@ static bool route_single_stmt( * value for backend srv */ rlag_max = val; - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Hint: " - "max_slave_replication_lag=%d", - rlag_max))); + MXS_INFO("Hint: " + "max_slave_replication_lag=%d", + rlag_max); } } hint = hint->next; @@ -2494,21 +2430,17 @@ static bool route_single_stmt( { if (TARGET_IS_NAMED_SERVER(route_target)) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Was supposed to route to named server " - "%s but couldn't find the server in a " - "suitable state.", - named_server))); + MXS_INFO("Was supposed to route to named server " + "%s but couldn't find the server in a " + "suitable state.", + named_server); } else if (TARGET_IS_RLAG_MAX(route_target)) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Was supposed to route to server with " - "replication lag at most %d but couldn't " - "find such a slave.", - rlag_max))); + MXS_INFO("Was supposed to route to server with " + "replication lag at most %d but couldn't " + "find such a slave.", + rlag_max); } } } @@ -2528,8 +2460,7 @@ static bool route_single_stmt( if (succp) { #if defined(SS_EXTRA_DEBUG) - LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, - "Found DCB for slave."))); + MXS_INFO("Found DCB for slave."); #endif ss_dassert(get_root_master_bref(rses) == rses->rses_master_ref); @@ -2537,10 +2468,9 @@ static bool route_single_stmt( } else { - LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, - "Was supposed to route to slave" - "but finding suitable one " - "failed."))); + MXS_INFO("Was supposed to route to slave" + "but finding suitable one " + "failed."); } } else if (TARGET_IS_MASTER(route_target)) @@ -2562,20 +2492,14 @@ static bool route_single_stmt( { if (succp && master_dcb != curr_master_dcb) { - LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, - "Was supposed to " - "route to master " - "but master has " - "changed."))); + MXS_INFO("Was supposed to route to master " + "but master has changed."); } else { - LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, - "Was supposed to " - "route to master " - "but couldn't find " - "master in a " - "suitable state."))); + MXS_INFO("Was supposed to route to master " + "but couldn't find master in a " + "suitable state."); } /** * Master has changed. Return with error indicator. @@ -2596,13 +2520,11 @@ static bool route_single_stmt( ss_dassert(target_dcb != NULL); - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Route query to %s \t%s:%d <", - (SERVER_IS_MASTER(bref->bref_backend->backend_server) ? - "master" : "slave"), - bref->bref_backend->backend_server->name, - bref->bref_backend->backend_server->port))); + MXS_INFO("Route query to %s \t%s:%d <", + (SERVER_IS_MASTER(bref->bref_backend->backend_server) ? + "master" : "slave"), + bref->bref_backend->backend_server->name, + bref->bref_backend->backend_server->port); /** * Store current stmt if execution of previous session command * haven't completed yet. @@ -2640,9 +2562,7 @@ static bool route_single_stmt( } else { - LOGIF((LE|LT), (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Routing query failed."))); + MXS_ERROR("Routing query failed."); succp = false; } } @@ -2657,10 +2577,7 @@ retblock: if (canonical_query_str != NULL) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Canonical version: %s", - canonical_query_str))); + MXS_INFO("Canonical version: %s", canonical_query_str); free(canonical_query_str); } } @@ -2909,14 +2826,12 @@ static void clientReply ( ss_dassert(len+4 == GWBUF_LENGTH(scur->scmd_cur_cmd->my_sescmd_buf)); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Failed to execute %s in %s:%d. %s %s", - cmdstr, - bref->bref_backend->backend_server->name, - bref->bref_backend->backend_server->port, - err, - replystr))); + MXS_ERROR("Failed to execute %s in %s:%d. %s %s", + cmdstr, + bref->bref_backend->backend_server->name, + bref->bref_backend->backend_server->port, + err, + replystr); free(cmdstr); free(err); @@ -2986,22 +2901,18 @@ static void clientReply ( { bool succp; - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Backend %s:%d processed reply and starts to execute " - "active cursor.", - bref->bref_backend->backend_server->name, - bref->bref_backend->backend_server->port))); + MXS_INFO("Backend %s:%d processed reply and starts to execute " + "active cursor.", + bref->bref_backend->backend_server->name, + bref->bref_backend->backend_server->port); succp = execute_sescmd_in_backend(bref); ss_dassert(succp); if(!succp) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Backend %s:%d failed to execute session command.", - bref->bref_backend->backend_server->name, - bref->bref_backend->backend_server->port))); + MXS_INFO("Backend %s:%d failed to execute session command.", + bref->bref_backend->backend_server->name, + bref->bref_backend->backend_server->port); } } else if (bref->bref_pending_cmd != NULL) /*< non-sescmd is waiting to be routed */ @@ -3028,16 +2939,12 @@ static void clientReply ( if (sql) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Routing query \"%s\" failed.", sql))); + MXS_ERROR("Routing query \"%s\" failed.", sql); free(sql); } else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Failed to route query."))); + MXS_ERROR("Failed to route query."); } } gwbuf_free(bref->bref_pending_cmd); @@ -3299,20 +3206,19 @@ static bool select_connect_backend_servers( } #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; ibackend_server->name, - b->backend_server->port, - b->backend_conn_count))); + MXS_INFO("master bref %p bref %p %d %s %d:%d", + *p_master_ref, + &backend_ref[i], + backend_ref[i].bref_state, + b->backend_server->name, + b->backend_server->port, + b->backend_conn_count); } #endif /** @@ -3322,17 +3228,16 @@ static bool select_connect_backend_servers( */ qsort(backend_ref, (size_t)router_nservers, sizeof(backend_ref_t), p); - if (LOG_IS_ENABLED(LOGFILE_TRACE)) + if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO)) { if (select_criteria == LEAST_GLOBAL_CONNECTIONS || select_criteria == LEAST_ROUTER_CONNECTIONS || select_criteria == LEAST_BEHIND_MASTER || select_criteria == LEAST_CURRENT_OPERATIONS) { - LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, - "Servers and %s connection counts:", - select_criteria == LEAST_GLOBAL_CONNECTIONS ? - "all MaxScale" : "router"))); + MXS_INFO("Servers and %s connection counts:", + select_criteria == LEAST_GLOBAL_CONNECTIONS ? + "all MaxScale" : "router"); for (i=0; ibackend_server->stats.n_current, - b->backend_server->name, - b->backend_server->port, - STRSRVSTATUS(b->backend_server)))); + MXS_INFO("MaxScale connections : %d in \t%s:%d %s", + b->backend_server->stats.n_current, + b->backend_server->name, + b->backend_server->port, + STRSRVSTATUS(b->backend_server)); break; case LEAST_ROUTER_CONNECTIONS: - LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE, - "RWSplit connections : %d in \t%s:%d %s", - b->backend_conn_count, - b->backend_server->name, - b->backend_server->port, - STRSRVSTATUS(b->backend_server)))); + MXS_INFO("RWSplit connections : %d in \t%s:%d %s", + b->backend_conn_count, + b->backend_server->name, + b->backend_server->port, + STRSRVSTATUS(b->backend_server)); break; case LEAST_CURRENT_OPERATIONS: - LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE, - "current operations : %d in \t%s:%d %s", - b->backend_server->stats.n_current_ops, - b->backend_server->name, - b->backend_server->port, - STRSRVSTATUS(b->backend_server)))); + MXS_INFO("current operations : %d in \t%s:%d %s", + b->backend_server->stats.n_current_ops, + b->backend_server->name, + b->backend_server->port, + STRSRVSTATUS(b->backend_server)); break; case LEAST_BEHIND_MASTER: - LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE, - "replication lag : %d in \t%s:%d %s", - b->backend_server->rlag, - b->backend_server->name, - b->backend_server->port, - STRSRVSTATUS(b->backend_server)))); + MXS_INFO("replication lag : %d in \t%s:%d %s", + b->backend_server->rlag, + b->backend_server->name, + b->backend_server->port, + STRSRVSTATUS(b->backend_server)); default: break; } @@ -3463,12 +3364,10 @@ static bool select_connect_backend_servers( } else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Unable to establish " - "connection with slave %s:%d", - b->backend_server->name, - b->backend_server->port))); + MXS_ERROR("Unable to establish " + "connection with slave %s:%d", + b->backend_server->name, + b->backend_server->port); /* handle connect error */ } } @@ -3518,12 +3417,10 @@ static bool select_connect_backend_servers( else { succp = false; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Unable to establish " - "connection with master %s:%d", - b->backend_server->name, - b->backend_server->port))); + MXS_ERROR("Unable to establish " + "connection with master %s:%d", + b->backend_server->name, + b->backend_server->port); /** handle connect error */ } } @@ -3531,20 +3428,19 @@ static bool select_connect_backend_servers( } /*< for */ #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; ibackend_server->name, - b->backend_server->port, - b->backend_conn_count))); + MXS_INFO("master bref %p bref %p %d %s %d:%d", + *p_master_ref, + &backend_ref[i], + backend_ref[i].bref_state, + b->backend_server->name, + b->backend_server->port, + b->backend_conn_count); } /* assert with master_host */ ss_dassert(!master_connected || @@ -3564,16 +3460,7 @@ static bool select_connect_backend_servers( if (slaves_connected == 0 && slaves_found > 0) { #if defined(SS_EXTRA_DEBUG) - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Warning : Couldn't connect to any of the %d " - "slaves. Routing to %s only.", - slaves_found, - (is_synced_master ? "Galera nodes" : "Master")))); - - LOGIF(LM, (skygw_log_write( - LOGFILE_MESSAGE, - "* Warning : Couldn't connect to any of the %d " + MXS_WARNING("Couldn't connect to any of the %d " "slaves. Routing to %s only.", slaves_found, (is_synced_master ? "Galera nodes" : "Master")))); @@ -3582,30 +3469,19 @@ static bool select_connect_backend_servers( else if (slaves_found == 0) { #if defined(SS_EXTRA_DEBUG) - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Warning : Couldn't find any slaves from existing " + MXS_WARNING("Couldn't find any slaves from existing " "%d servers. Routing to %s only.", router_nservers, - (is_synced_master ? "Galera nodes" : "Master")))); - - LOGIF(LM, (skygw_log_write( - LOGFILE_MESSAGE, - "* Warning : Couldn't find any slaves from existing " - "%d servers. Routing to %s only.", - router_nservers, - (is_synced_master ? "Galera nodes" : "Master")))); + (is_synced_master ? "Galera nodes" : "Master")); #endif } else if (slaves_connected < max_nslaves) { - LOGIF(LT, (skygw_log_write_flush( - LOGFILE_TRACE, - "Note : Couldn't connect to maximum number of " - "slaves. Connected successfully to %d slaves " - "of %d of them.", - slaves_connected, - slaves_found))); + MXS_INFO("Couldn't connect to maximum number of " + "slaves. Connected successfully to %d slaves " + "of %d of them.", + slaves_connected, + slaves_found); } if (LOG_IS_ENABLED(LT)) @@ -3616,12 +3492,10 @@ static bool select_connect_backend_servers( if (BREF_IS_IN_USE((&backend_ref[i]))) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Selected %s in \t%s:%d", - STRSRVSTATUS(b->backend_server), - b->backend_server->name, - b->backend_server->port))); + MXS_INFO("Selected %s in \t%s:%d", + STRSRVSTATUS(b->backend_server), + b->backend_server->name, + b->backend_server->port); } } /* for */ } @@ -3635,65 +3509,24 @@ static bool select_connect_backend_servers( if (!master_found) { - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Error : Couldn't find suitable %s from %d " - "candidates.", - (is_synced_master ? "Galera node" : "Master"), - router_nservers))); - - LOGIF(LM, (skygw_log_write( - LOGFILE_MESSAGE, - "Error : Couldn't find suitable %s from %d " - "candidates.", - (is_synced_master ? "Galera node" : "Master"), - router_nservers))); - - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Error : Couldn't find suitable %s from %d " - "candidates.", - (is_synced_master ? "Galera node" : "Master"), - router_nservers))); + MXS_ERROR("Couldn't find suitable %s from %d " + "candidates.", + (is_synced_master ? "Galera node" : "Master"), + router_nservers); } else if (!master_connected) { - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Error : Couldn't connect to any %s although " - "there exists at least one %s node in the " - "cluster.", - (is_synced_master ? "Galera node" : "Master"), - (is_synced_master ? "Galera node" : "Master")))); - - LOGIF(LM, (skygw_log_write( - LOGFILE_MESSAGE, - "Error : Couldn't connect to any %s although " - "there exists at least one %s node in the " - "cluster.", - (is_synced_master ? "Galera node" : "Master"), - (is_synced_master ? "Galera node" : "Master")))); - - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Error : Couldn't connect to any %s although " - "there exists at least one %s node in the " - "cluster.", - (is_synced_master ? "Galera node" : "Master"), - (is_synced_master ? "Galera node" : "Master")))); + MXS_ERROR("Couldn't connect to any %s although " + "there exists at least one %s node in the " + "cluster.", + (is_synced_master ? "Galera node" : "Master"), + (is_synced_master ? "Galera node" : "Master")); } if (slaves_connected < min_nslaves) { - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Error : Couldn't establish required amount of " - "slave connections for router session."))); - - LOGIF(LM, (skygw_log_write( - LOGFILE_MESSAGE, - "Error : Couldn't establish required amount of " - "slave connections for router session."))); + MXS_ERROR("Couldn't establish required amount of " + "slave connections for router session."); } /** Clean up connections */ @@ -3764,13 +3597,11 @@ static void rses_property_done( break; default: - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [rses_property_done] Unknown property type %d " - "in property %p", - pthread_self(), - prop->rses_prop_type, - prop))); + MXS_DEBUG("%lu [rses_property_done] Unknown property type %d " + "in property %p", + pthread_self(), + prop->rses_prop_type, + prop); ss_dassert(false); break; @@ -4229,9 +4060,7 @@ static bool execute_sescmd_in_backend( if (sescmd_cursor_get_command(scur) == NULL) { succp = false; - LOGIF(LT, (skygw_log_write_flush( - LOGFILE_TRACE, - "Cursor had no pending session commands."))); + MXS_INFO("Cursor had no pending session commands."); goto return_succp; } @@ -4417,17 +4246,15 @@ static void tracelog_routed_query( querystr = (char *)malloc(len); memcpy(querystr, startpos, len-1); querystr[len-1] = '\0'; - LOGIF(LD, (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [%s] %d bytes long buf, \"%s\" -> %s:%d %s dcb %p", - pthread_self(), - funcname, - (int)buflen, - querystr, - b->backend_server->name, - b->backend_server->port, - STRBETYPE(be_type), - dcb))); + MXS_DEBUG("%lu [%s] %d bytes long buf, \"%s\" -> %s:%d %s dcb %p", + pthread_self(), + funcname, + (int)buflen, + querystr, + b->backend_server->name, + b->backend_server->port, + STRBETYPE(be_type), + dcb); free(querystr); } else if (packet_type == '\x22' || @@ -4439,18 +4266,16 @@ static void tracelog_routed_query( querystr = (char *)malloc(len); memcpy(querystr, startpos, len-1); querystr[len-1] = '\0'; - LOGIF(LD, (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [%s] %d bytes long buf, \"%s\" -> %s:%d %s dcb %p", - pthread_self(), - funcname, - (int)buflen, - querystr, - b->backend_server->name, - b->backend_server->port, - STRBETYPE(be_type), - dcb))); - free(querystr); + MXS_DEBUG("%lu [%s] %d bytes long buf, \"%s\" -> %s:%d %s dcb %p", + pthread_self(), + funcname, + (int)buflen, + querystr, + b->backend_server->name, + b->backend_server->port, + STRBETYPE(be_type), + dcb); + free(querystr); } } gwbuf_free(buf); @@ -4500,9 +4325,7 @@ static bool route_session_write( int nbackends; int nsucc; - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Session write, routing to all servers."))); + MXS_INFO("Session write, routing to all servers."); /** Maximum number of slaves in this router client session */ max_nslaves = rses_get_max_slavecount(router_cli_ses, router_cli_ses->rses_nbackends); @@ -4532,16 +4355,15 @@ static bool route_session_write( { DCB* dcb = backend_ref[i].bref_dcb; - if (LOG_IS_ENABLED(LOGFILE_TRACE) && BREF_IS_IN_USE((&backend_ref[i]))) + if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO) && + BREF_IS_IN_USE((&backend_ref[i]))) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Route query to %s \t%s:%d%s", - (SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ? - "master" : "slave"), - backend_ref[i].bref_backend->backend_server->name, - backend_ref[i].bref_backend->backend_server->port, - (i+1==router_cli_ses->rses_nbackends ? " <" : " ")))); + MXS_INFO("Route query to %s \t%s:%d%s", + (SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ? + "master" : "slave"), + backend_ref[i].bref_backend->backend_server->name, + backend_ref[i].bref_backend->backend_server->port, + (i+1==router_cli_ses->rses_nbackends ? " <" : " ")); } if (BREF_IS_IN_USE((&backend_ref[i]))) @@ -4565,10 +4387,8 @@ static bool route_session_write( if (router_cli_ses->rses_nbackends <= 0) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Router session doesn't have any backends in use. " - "Routing failed. <"))); + MXS_INFO("Router session doesn't have any backends in use. " + "Routing failed. <"); goto return_succp; } @@ -4649,16 +4469,14 @@ static bool route_session_write( nbackends += 1; - if (LOG_IS_ENABLED(LOGFILE_TRACE)) + if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO)) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Route query to %s \t%s:%d%s", - (SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ? - "master" : "slave"), - backend_ref[i].bref_backend->backend_server->name, - backend_ref[i].bref_backend->backend_server->port, - (i+1==router_cli_ses->rses_nbackends ? " <" : " ")))); + MXS_INFO("Route query to %s \t%s:%d%s", + (SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ? + "master" : "slave"), + backend_ref[i].bref_backend->backend_server->name, + backend_ref[i].bref_backend->backend_server->port, + (i+1==router_cli_ses->rses_nbackends ? " <" : " ")); } scur = backend_ref_get_sescmd_cursor(&backend_ref[i]); @@ -4677,11 +4495,9 @@ static bool route_session_write( if (sescmd_cursor_is_active(scur)) { nsucc += 1; - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Backend %s:%d already executing sescmd.", - backend_ref[i].bref_backend->backend_server->name, - backend_ref[i].bref_backend->backend_server->port))); + MXS_INFO("Backend %s:%d already executing sescmd.", + backend_ref[i].bref_backend->backend_server->name, + backend_ref[i].bref_backend->backend_server->port); } else { @@ -4691,12 +4507,10 @@ static bool route_session_write( } else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Failed to execute session " - "command in %s:%d", - backend_ref[i].bref_backend->backend_server->name, - backend_ref[i].bref_backend->backend_server->port))); + MXS_ERROR("Failed to execute session " + "command in %s:%d", + backend_ref[i].bref_backend->backend_server->name, + backend_ref[i].bref_backend->backend_server->port); } } } @@ -4770,11 +4584,9 @@ static void rwsplit_process_router_options( { if ((value = strchr(options[i], '=')) == NULL) { - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, "Warning : Unsupported " - "router option \"%s\" for " - "readwritesplit router.", - options[i]))); + MXS_ERROR("router option \"%s\" for " + "readwritesplit router.", + options[i]); } else { @@ -4792,14 +4604,13 @@ static void rwsplit_process_router_options( if (c == UNDEFINED_CRITERIA) { - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, "Warning : Unknown " + MXS_WARNING("Unknown " "slave selection criteria \"%s\". " "Allowed values are LEAST_GLOBAL_CONNECTIONS, " "LEAST_ROUTER_CONNECTIONS, " "LEAST_BEHIND_MASTER," "and LEAST_CURRENT_OPERATIONS.", - STRCRITERIA(router->rwsplit_config.rw_slave_select_criteria)))); + STRCRITERIA(router->rwsplit_config.rw_slave_select_criteria)); } else { @@ -4905,25 +4716,21 @@ static void handleError ( } else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : server %s:%d lost the " - "master status but could not locate the " - "corresponding backend ref.", - srv->name, - srv->port))); + MXS_ERROR("server %s:%d lost the " + "master status but could not locate the " + "corresponding backend ref.", + srv->name, + srv->port); dcb_close(backend_dcb); } if (!srv->master_err_is_logged) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : server %s:%d lost the " - "master status. Readwritesplit " - "service can't locate the master. " - "Client sessions will be closed.", - srv->name, - srv->port))); + MXS_ERROR("server %s:%d lost the " + "master status. Readwritesplit " + "service can't locate the master. " + "Client sessions will be closed.", + srv->name, + srv->port); srv->master_err_is_logged = true; } *succp = false; @@ -5137,13 +4944,11 @@ static void print_error_packet( char* str = (char*)&ptr[7]; bufstr = strndup(str, len-3); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Backend server %s:%d responded with " - "error : %s", - srv->name, - srv->port, - bufstr))); + MXS_ERROR("Backend server %s:%d responded with " + "error : %s", + srv->name, + srv->port, + bufstr); free(bufstr); } buf = gwbuf_consume(buf, len+4); @@ -5183,14 +4988,12 @@ static bool have_enough_servers( { if (router_nsrv < min_nsrv) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Unable to start %s service. There are " - "too few backend servers available. Found %d " - "when %d is required.", - router->service->name, - router_nsrv, - min_nsrv))); + MXS_ERROR("Unable to start %s service. There are " + "too few backend servers available. Found %d " + "when %d is required.", + router->service->name, + router_nsrv, + min_nsrv); } else { @@ -5199,27 +5002,23 @@ static bool have_enough_servers( if ((*p_rses)->rses_config.rw_max_slave_conn_count < min_nsrv) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Unable to start %s service. There are " - "too few backend servers configured in " - "MaxScale.cnf. Found %d when %d is required.", - router->service->name, - (*p_rses)->rses_config.rw_max_slave_conn_count, - min_nsrv))); + MXS_ERROR("Unable to start %s service. There are " + "too few backend servers configured in " + "MaxScale.cnf. Found %d when %d is required.", + router->service->name, + (*p_rses)->rses_config.rw_max_slave_conn_count, + min_nsrv); } if (nservers < min_nsrv) { double dbgpct = ((double)min_nsrv/(double)router_nsrv)*100.0; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Unable to start %s service. There are " - "too few backend servers configured in " - "MaxScale.cnf. Found %d%% when at least %.0f%% " - "would be required.", - router->service->name, - (*p_rses)->rses_config.rw_max_slave_conn_percent, - dbgpct))); + MXS_ERROR("Unable to start %s service. There are " + "too few backend servers configured in " + "MaxScale.cnf. Found %d%% when at least %.0f%% " + "would be required.", + router->service->name, + (*p_rses)->rses_config.rw_max_slave_conn_percent, + dbgpct); } } free(*p_rses); @@ -5350,13 +5149,12 @@ static int router_handle_state_switch( goto return_rc; } - LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, - "%lu [router_handle_state_switch] %s %s:%d in state %s", - pthread_self(), - STRDCBREASON(reason), - srv->name, - srv->port, - STRSRVSTATUS(srv)))); + 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(((SESSION*)dcb->session)); if (dcb->session->router_session) { @@ -5530,11 +5328,9 @@ static backend_ref_t* get_root_master_bref( } if (candidate_bref == NULL) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Could not find master among the backend " - "servers. Previous master's state : %s", - STRSRVSTATUS(BREFSRV(rses->rses_master_ref))))); + MXS_ERROR("Could not find master among the backend " + "servers. Previous master's state : %s", + STRSRVSTATUS(BREFSRV(rses->rses_master_ref))); } return candidate_bref; }