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:
@ -19,6 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define __USE_UNIX98 1
|
||||
#include <pthread.h>
|
||||
@ -120,16 +121,19 @@ typedef enum skygw_chk_t {
|
||||
} skygw_chk_t;
|
||||
|
||||
# define STRBOOL(b) ((b) ? "true" : "false")
|
||||
|
||||
# define STRQTYPE(t) ((t) == QUERY_TYPE_WRITE ? "QUERY_TYPE_WRITE" : \
|
||||
((t) == QUERY_TYPE_READ ? "QUERY_TYPE_READ" : \
|
||||
((t) == QUERY_TYPE_SESSION_WRITE ? "QUERY_TYPE_SESSION_WRITE" : \
|
||||
((t) == QUERY_TYPE_UNKNOWN ? "QUERY_TYPE_UNKNWON" : \
|
||||
((t) == QUERY_TYPE_LOCAL_READ ? "QUERY_TYPE_LOCAL_READ" : \
|
||||
"Unknown query type")))))
|
||||
|
||||
#define STRLOGID(i) ((i) == LOGFILE_TRACE ? "LOGFILE_TRACE" : \
|
||||
((i) == LOGFILE_MESSAGE ? "LOGFILE_MESSAGE" : \
|
||||
((i) == LOGFILE_ERROR ? "LOGFILE_ERROR" : \
|
||||
"Unknown logfile type")))
|
||||
((i) == LOGFILE_MESSAGE ? "LOGFILE_MESSAGE" : \
|
||||
((i) == LOGFILE_ERROR ? "LOGFILE_ERROR" : \
|
||||
((i) == LOGFILE_DEBUG ? "LOGFILE_DEBUG" : \
|
||||
"Unknown logfile type"))))
|
||||
|
||||
#define STRPACKETTYPE(p) ((p) == COM_INIT_DB ? "COM_INIT_DB" : \
|
||||
((p) == COM_CREATE_DB ? "COM_CREATE_DB" : \
|
||||
@ -285,11 +289,11 @@ typedef enum skygw_chk_t {
|
||||
ss_info_dassert((n->slnode_chk_top == CHK_NUM_SLIST_NODE && \
|
||||
n->slnode_chk_tail == CHK_NUM_SLIST_NODE), \
|
||||
"Single-linked list node under- or overflow"); \
|
||||
}
|
||||
}
|
||||
|
||||
#define CHK_SLIST_CURSOR(c) { \
|
||||
ss_info_dassert(c->slcursor_chk_top == CHK_NUM_SLIST_CURSOR && \
|
||||
c->slcursor_chk_tail == CHK_NUM_SLIST_CURSOR, \
|
||||
ss_info_dassert(c->slcursor_chk_top == CHK_NUM_SLIST_CURSOR && \
|
||||
c->slcursor_chk_tail == CHK_NUM_SLIST_CURSOR, \
|
||||
"List cursor under- or overflow"); \
|
||||
ss_info_dassert(c->slcursor_list != NULL, \
|
||||
"List cursor doesn't have list"); \
|
||||
@ -297,34 +301,35 @@ typedef enum skygw_chk_t {
|
||||
(c->slcursor_pos == NULL && \
|
||||
c->slcursor_list->slist_head == NULL), \
|
||||
"List cursor doesn't have position"); \
|
||||
}
|
||||
}
|
||||
|
||||
#define CHK_QUERY_TEST(q) { \
|
||||
ss_info_dassert(q->qt_chk_top == CHK_NUM_QUERY_TEST && \
|
||||
q->qt_chk_tail == CHK_NUM_QUERY_TEST, \
|
||||
"Query test under- or overflow."); \
|
||||
}
|
||||
#define CHK_QUERY_TEST(q) { \
|
||||
ss_info_dassert(q->qt_chk_top == CHK_NUM_QUERY_TEST && \
|
||||
q->qt_chk_tail == CHK_NUM_QUERY_TEST, \
|
||||
"Query test under- or overflow."); \
|
||||
}
|
||||
|
||||
#define CHK_LOGFILE(lf) { \
|
||||
ss_info_dassert(lf->lf_chk_top == CHK_NUM_LOGFILE && \
|
||||
ss_info_dassert(lf->lf_chk_top == CHK_NUM_LOGFILE && \
|
||||
lf->lf_chk_tail == CHK_NUM_LOGFILE, \
|
||||
"Logfile struct under- or overflow"); \
|
||||
ss_info_dassert(lf->lf_logpath != NULL && \
|
||||
lf->lf_name_prefix != NULL && \
|
||||
lf->lf_name_suffix != NULL && \
|
||||
lf->lf_full_name != NULL, \
|
||||
"NULL in name variable\n"); \
|
||||
ss_info_dassert(lf->lf_filepath != NULL && \
|
||||
lf->lf_name_prefix != NULL && \
|
||||
lf->lf_name_suffix != NULL && \
|
||||
lf->lf_full_file_name != NULL, \
|
||||
"NULL in name variable\n"); \
|
||||
ss_info_dassert(lf->lf_id >= LOGFILE_FIRST && \
|
||||
lf->lf_id <= LOGFILE_LAST, \
|
||||
"Invalid logfile id\n"); \
|
||||
lf->lf_id <= LOGFILE_LAST, \
|
||||
"Invalid logfile id\n"); \
|
||||
ss_debug( \
|
||||
(lf->lf_chk_top != CHK_NUM_LOGFILE || \
|
||||
lf->lf_chk_tail != CHK_NUM_LOGFILE ? \
|
||||
false : \
|
||||
(lf->lf_logpath == NULL || \
|
||||
(lf->lf_filepath == NULL || \
|
||||
lf->lf_name_prefix == NULL || \
|
||||
lf->lf_name_suffix == NULL || \
|
||||
lf->lf_full_name == NULL ? false : true)); \
|
||||
}
|
||||
lf->lf_full_file_name == NULL ? false : true));) \
|
||||
}
|
||||
|
||||
#define CHK_FILEWRITER(fwr) { \
|
||||
ss_info_dassert(fwr->fwr_chk_top == CHK_NUM_FILEWRITER && \
|
||||
|
||||
@ -279,8 +279,9 @@ mlist_node_t* mlist_detach_nodes(
|
||||
* @return Address of mlist_t struct.
|
||||
*
|
||||
*
|
||||
* @details Cursor must protect its reads with read lock, and after acquiring
|
||||
* read lock reader must check whether the list is deleted (mlist_deleted).
|
||||
* @details Cursor must protect its reads with read lock, and after
|
||||
* acquiring read lock reader must check whether the list is deleted
|
||||
* (mlist_deleted).
|
||||
*
|
||||
*/
|
||||
mlist_t* mlist_init(
|
||||
@ -1240,8 +1241,10 @@ simple_mutex_t* simple_mutex_init(
|
||||
sm = (simple_mutex_t *)calloc(1, sizeof(simple_mutex_t));
|
||||
}
|
||||
ss_dassert(sm != NULL);
|
||||
#if defined(SS_DEBUG)
|
||||
sm->sm_chk_top = CHK_NUM_SIMPLE_MUTEX;
|
||||
sm->sm_chk_tail = CHK_NUM_SIMPLE_MUTEX;
|
||||
#endif
|
||||
sm->sm_name = name;
|
||||
|
||||
/** Create pthread mutex */
|
||||
@ -1746,8 +1749,8 @@ return_succp:
|
||||
}
|
||||
|
||||
skygw_file_t* skygw_file_init(
|
||||
char* fname)
|
||||
|
||||
char* fname,
|
||||
char* symlinkname)
|
||||
{
|
||||
skygw_file_t* file;
|
||||
|
||||
@ -1780,16 +1783,46 @@ skygw_file_t* skygw_file_init(
|
||||
setvbuf(file->sf_file, NULL, _IONBF, 0);
|
||||
|
||||
if (!file_write_header(file)) {
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
fprintf(stderr,
|
||||
"* Writing header of log file %s failed.\n",
|
||||
file->sf_fname);
|
||||
perror("SkyGW file open\n");
|
||||
"* Writing header of log file %s failed due %d, %s.\n",
|
||||
file->sf_fname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
free(file);
|
||||
file = NULL;
|
||||
goto return_file;
|
||||
}
|
||||
CHK_FILE(file);
|
||||
ss_dfprintf(stderr, "Opened %s\n", file->sf_fname);
|
||||
ss_dfprintf(stderr, "Opened %s\n", file->sf_fname);
|
||||
|
||||
/**
|
||||
* Create symlink to newly created file if name was provided.
|
||||
*/
|
||||
if (symlinkname != NULL)
|
||||
{
|
||||
int rc;
|
||||
|
||||
unlink(symlinkname);
|
||||
rc = symlink(fname, symlinkname);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
fprintf(stderr,
|
||||
"failed to create symlink %s -> "
|
||||
"%s due %d, %s. Exiting.",
|
||||
fname,
|
||||
symlinkname,
|
||||
eno,
|
||||
strerror(eno));
|
||||
free(file);
|
||||
file = NULL;
|
||||
goto return_file;
|
||||
}
|
||||
}
|
||||
|
||||
return_file:
|
||||
return file;
|
||||
|
||||
@ -145,7 +145,7 @@ EXTERN_C_BLOCK_END
|
||||
/** Skygw thread routines */
|
||||
|
||||
/** Skygw file routines */
|
||||
skygw_file_t* skygw_file_init(char* fname);
|
||||
skygw_file_t* skygw_file_init(char* fname, char* symlinkname);
|
||||
void skygw_file_done(skygw_file_t* file);
|
||||
bool skygw_file_write(
|
||||
skygw_file_t* file,
|
||||
|
||||
Reference in New Issue
Block a user