log_manager.cc
Added new argument '-s' which takes additional argument composed of list of logfile identifiers. Logfiles listed with '-s' will be written on main memory instead of disk. In practice, the log file in question will be written in /dev/shm but corresponding symlink is added to log directory. In the case of name conflicts with log files and links, a differentiating sequence number is included in hte name of the file. This, however, is done only when existing file is not writable or is of different type (symlink <> file). Added new logfile LOGFILE_DEBUG whose contents will be largerly what was included up to date in trace log. Disabled feature which spreads writes to log files to others because of bug (#338) in the way block buffers are managed. Changed log manager parameters to match with the current implementation. List of arguments: "-h - help\n" "-a <debug prefix> ............(\"skygw_debug\")\n" "-b <debug suffix> ............(\".log\")\n" "-c <trace prefix> ............(\"skygw_trace\")\n" "-d <trace suffix> ............(\".log\")\n" "-e <message prefix> ............(\"skygw_msg\")\n" "-f <message suffix> ............(\".log\")\n" "-g <error prefix> ............(\"skygw_err\")\n" "-i <error suffix> ............(\".log\")\n" "-j <log path> ............(\"/tmp\")\n" "-s <shmem log file ids> ........(no default)\n"; dcb.c dcb_add_to_zombieslist, add dcb to the front of zombies list instead of inserting to the end of it. gateway.c Renamed shutdown_gateway to shutdown_server (Bug #131) Call skygw_logmanager_init so that trace and debug logs are written to shared memory. poll.c dcb.h Removed some dead code and references to unneeded mutexes. debugcmd.c Added enable/disable log command for debug log. skygw_utils.cc skygw_file_init now takes optional symlink name as a second argument. Symlink is created to point to the file being created.
This commit is contained in:
@ -253,7 +253,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
backend_protocol->state = MYSQL_IDLE;
|
||||
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_read_backend_event] "
|
||||
"gw_receive_backend_auth succeed. "
|
||||
"dcb %p fd %d, user %s.",
|
||||
@ -265,7 +265,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
default:
|
||||
ss_dassert(receive_rc == 0);
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_read_backend_event] "
|
||||
"gw_receive_backend_auth read "
|
||||
"successfully "
|
||||
@ -436,7 +436,7 @@ static int gw_write_backend_event(DCB *dcb) {
|
||||
"Writing to backend failed due invalid Maxscale "
|
||||
"state.");
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_write_backend_event] Write to backend "
|
||||
"dcb %p fd %d "
|
||||
"failed due invalid state %s.",
|
||||
@ -454,7 +454,7 @@ static int gw_write_backend_event(DCB *dcb) {
|
||||
rc = 0;
|
||||
} else {
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_write_backend_event] Dcb %p in state %s "
|
||||
"but there's nothing to write either.",
|
||||
pthread_self(),
|
||||
@ -474,7 +474,7 @@ static int gw_write_backend_event(DCB *dcb) {
|
||||
rc = 1;
|
||||
return_rc:
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_write_backend_event] "
|
||||
"wrote to dcb %p fd %d, return %d",
|
||||
pthread_self(),
|
||||
@ -508,7 +508,7 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
||||
gwbuf_consume(queue, GWBUF_LENGTH(queue));
|
||||
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_MySQLWrite_backend] Write to backend failed. "
|
||||
"Backend dcb %p fd %d is %s.",
|
||||
pthread_self(),
|
||||
@ -602,7 +602,7 @@ static int gw_error_backend_event(DCB *dcb) {
|
||||
* rsession should never be NULL here.
|
||||
*/
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_error_backend_event] "
|
||||
"Call closeSession for backend "
|
||||
"session.",
|
||||
@ -641,7 +641,7 @@ static int gw_create_backend_connection(
|
||||
|
||||
if (protocol == NULL) {
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_create_backend_connection] Failed to create "
|
||||
"protocol object for backend connection.",
|
||||
pthread_self());
|
||||
@ -664,7 +664,7 @@ static int gw_create_backend_connection(
|
||||
protocol->fd = fd;
|
||||
protocol->state = MYSQL_CONNECTED;
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_create_backend_connection] Established "
|
||||
"connection to %s:%i, protocol fd %d client "
|
||||
"fd %d.",
|
||||
@ -680,7 +680,7 @@ static int gw_create_backend_connection(
|
||||
protocol->state = MYSQL_PENDING_CONNECT;
|
||||
protocol->fd = fd;
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_create_backend_connection] Connection "
|
||||
"pending to %s:%i, protocol fd %d client fd %d.",
|
||||
pthread_self(),
|
||||
@ -694,7 +694,7 @@ static int gw_create_backend_connection(
|
||||
ss_dassert(fd == -1);
|
||||
ss_dassert(protocol->state == MYSQL_ALLOC);
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_create_backend_connection] Connection "
|
||||
"failed to %s:%i, protocol fd %d client fd %d.",
|
||||
pthread_self(),
|
||||
|
||||
@ -977,7 +977,7 @@ int gw_MySQLAccept(DCB *listener)
|
||||
listener->stats.n_accepts++;
|
||||
#if defined(SS_DEBUG)
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_MySQLAccept] Accepted fd %d.",
|
||||
pthread_self(),
|
||||
c_sock);
|
||||
@ -1046,7 +1046,7 @@ int gw_MySQLAccept(DCB *listener)
|
||||
else
|
||||
{
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_MySQLAccept] Added dcb %p for fd "
|
||||
"%d to epoll set.",
|
||||
pthread_self(),
|
||||
|
||||
@ -328,7 +328,7 @@ int gw_receive_backend_auth(
|
||||
(uint8_t *)calloc(1, GWBUF_LENGTH(head)+1);
|
||||
memcpy(tmpbuf, ptr, GWBUF_LENGTH(head));
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_receive_backend_auth] Invalid "
|
||||
"authentication message from backend dcb %p "
|
||||
"fd %d, ptr[4] = %p, msg %s.",
|
||||
@ -358,7 +358,7 @@ int gw_receive_backend_auth(
|
||||
*/
|
||||
rc = 0;
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_receive_backend_auth] Read zero bytes from "
|
||||
"backend dcb %p fd %d in state %s. n %d, head %p, len %d",
|
||||
pthread_self(),
|
||||
@ -374,7 +374,7 @@ int gw_receive_backend_auth(
|
||||
ss_dassert(n < 0 && head == NULL);
|
||||
rc = -1;
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_receive_backend_auth] Reading from backend dcb %p "
|
||||
"fd %d in state %s failed. n %d, head %p, len %d",
|
||||
pthread_self(),
|
||||
@ -672,7 +672,7 @@ int gw_do_connect_to_backend(
|
||||
}
|
||||
*fd = so;
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_do_connect_to_backend] Connected to backend server "
|
||||
"%s:%d, fd %d.",
|
||||
pthread_self(),
|
||||
|
||||
@ -114,7 +114,7 @@ struct subcommand showoptions[] = {
|
||||
{0, 0, 0} }
|
||||
};
|
||||
|
||||
extern void shutdown_gateway();
|
||||
extern void shutdown_maxscale();
|
||||
static void shutdown_service(DCB *dcb, SERVICE *service);
|
||||
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
||||
|
||||
@ -122,16 +122,37 @@ static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
||||
* The subcommands of the shutdown command
|
||||
*/
|
||||
struct subcommand shutdownoptions[] = {
|
||||
{ "maxscale", 0, shutdown_gateway, "Shutdown the MaxScale gateway",
|
||||
{0, 0, 0} },
|
||||
{ "monitor", 1, shutdown_monitor, "Shutdown a monitor, e.g. shutdown monitor 0x48381e0",
|
||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||
{ "service", 1, shutdown_service, "Shutdown a service, e.g. shutdown service 0x4838320",
|
||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||
{ NULL, 0, NULL, NULL,
|
||||
{0, 0, 0} }
|
||||
{ "maxscale",
|
||||
0,
|
||||
shutdown_maxscale,
|
||||
"Shutdown MaxScale",
|
||||
|
||||
{0, 0, 0}
|
||||
},
|
||||
{
|
||||
"monitor",
|
||||
1,
|
||||
shutdown_monitor,
|
||||
"Shutdown a monitor, e.g. shutdown monitor 0x48381e0",
|
||||
{ARG_TYPE_ADDRESS, 0, 0}
|
||||
},
|
||||
{
|
||||
"service",
|
||||
1,
|
||||
shutdown_service,
|
||||
"Shutdown a service, e.g. shutdown service 0x4838320",
|
||||
{ARG_TYPE_ADDRESS, 0, 0}
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
{0, 0, 0}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static void restart_service(DCB *dcb, SERVICE *service);
|
||||
static void restart_monitor(DCB *dcb, MONITOR *monitor);
|
||||
/**
|
||||
@ -216,8 +237,8 @@ struct subcommand disableoptions[] = {
|
||||
"log",
|
||||
1,
|
||||
disable_log_action,
|
||||
"Disable Log for MaxScale, Options: trace | error | message E.g. "
|
||||
"disable log trace",
|
||||
"Disable Log for MaxScale, Options: debug | trace | error | message "
|
||||
"E.g. disable log debug",
|
||||
{ARG_TYPE_STRING, 0, 0}
|
||||
},
|
||||
{
|
||||
@ -726,7 +747,9 @@ static void enable_log_action(DCB *dcb, char *arg1) {
|
||||
logfile_id_t type;
|
||||
int max_len = strlen("message");
|
||||
|
||||
if (strncmp(arg1, "trace", max_len) == 0) {
|
||||
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||
type = LOGFILE_DEBUG;
|
||||
} else if (strncmp(arg1, "trace", max_len) == 0) {
|
||||
type = LOGFILE_TRACE;
|
||||
} else if (strncmp(arg1, "error", max_len) == 0) {
|
||||
type = LOGFILE_ERROR;
|
||||
@ -748,7 +771,9 @@ static void disable_log_action(DCB *dcb, char *arg1) {
|
||||
logfile_id_t type;
|
||||
int max_len = strlen("message");
|
||||
|
||||
if (strncmp(arg1, "trace", max_len) == 0) {
|
||||
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||
type = LOGFILE_DEBUG;
|
||||
} else if (strncmp(arg1, "trace", max_len) == 0) {
|
||||
type = LOGFILE_TRACE;
|
||||
} else if (strncmp(arg1, "error", max_len) == 0) {
|
||||
type = LOGFILE_ERROR;
|
||||
|
||||
@ -282,7 +282,7 @@ BACKEND *candidate = NULL;
|
||||
int i;
|
||||
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [newSession] new router session with session "
|
||||
"%p, and inst %p.",
|
||||
pthread_self(),
|
||||
@ -322,7 +322,7 @@ int i;
|
||||
for (i = 0; inst->servers[i]; i++) {
|
||||
if(inst->servers[i]) {
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [newSession] Examine server in port %d with "
|
||||
"%d connections. Status is %d, "
|
||||
"inst->bitvalue is %d",
|
||||
@ -383,7 +383,7 @@ int i;
|
||||
atomic_add(&candidate->current_connection_count, 1);
|
||||
client_rses->backend = candidate;
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [newSession] Selected server in port %d. "
|
||||
"Connections : %d\n",
|
||||
pthread_self(),
|
||||
@ -465,7 +465,7 @@ static void freeSession(
|
||||
spinlock_release(&router->lock);
|
||||
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [freeSession] Unlinked router_client_session %p from "
|
||||
"router %p and from server on port %d. Connections : %d. ",
|
||||
pthread_self(),
|
||||
|
||||
@ -547,14 +547,16 @@ static int routeQuery(
|
||||
"%s.",
|
||||
STRPACKETTYPE(packet_type),
|
||||
STRQTYPE(qtype),
|
||||
querystr,
|
||||
(querystr == NULL ? "(empty)" : querystr),
|
||||
(rses_is_closed ? "Router was closed" :
|
||||
"Router has no backend servers where to route to"));
|
||||
|
||||
goto return_ret;
|
||||
}
|
||||
|
||||
skygw_log_write(LOGFILE_TRACE, "String\t\"%s\"", querystr);
|
||||
skygw_log_write(LOGFILE_TRACE,
|
||||
"String\t\"%s\"",
|
||||
querystr == NULL ? "(empty)" : querystr);
|
||||
skygw_log_write(LOGFILE_TRACE,
|
||||
"Packet type\t%s",
|
||||
STRPACKETTYPE(packet_type));
|
||||
@ -590,7 +592,7 @@ static int routeQuery(
|
||||
case QUERY_TYPE_SESSION_WRITE:
|
||||
skygw_log_write(LOGFILE_TRACE,
|
||||
"%lu [routeQuery:rwsplit] Query type\t%s, "
|
||||
"routing to All servers.",
|
||||
"routing to all servers.",
|
||||
pthread_self(),
|
||||
STRQTYPE(qtype));
|
||||
/**
|
||||
@ -865,8 +867,8 @@ static bool search_backend_servers(
|
||||
if (be != NULL) {
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"%lu [search_backend_servers] Examine server %s:%d "
|
||||
"with %d connections. Status is %d, "
|
||||
"%lu [search_backend_servers] Examine server "
|
||||
"%s:%d with %d connections. Status is %d, "
|
||||
"router->bitvalue is %d",
|
||||
pthread_self(),
|
||||
be->backend_server->name,
|
||||
@ -931,7 +933,8 @@ static bool search_backend_servers(
|
||||
succp = false;
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Couldn't find suitable Slave from %d candidates.",
|
||||
"Error : Couldn't find suitable Slave from %d "
|
||||
"candidates.",
|
||||
i);
|
||||
}
|
||||
|
||||
@ -939,7 +942,8 @@ static bool search_backend_servers(
|
||||
succp = false;
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Couldn't find suitable Master from %d candidates.",
|
||||
"Error : Couldn't find suitable Master from %d "
|
||||
"candidates.",
|
||||
i);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user