Merge remote-tracking branch 'origin/develop' into MXS-329-develop-20151111

# Conflicts:
#	server/core/CMakeLists.txt
#	server/core/buffer.c
#	server/core/service.c
#	server/modules/filter/tee.c
#	server/modules/monitor/mysql_mon.c
#	server/modules/routing/binlog/blr.c
#	server/modules/routing/binlog/blr_slave.c
#	server/modules/routing/debugcmd.c
#	server/modules/routing/readwritesplit/readwritesplit.c
#	utils/skygw_utils.cc

- resolved.
This commit is contained in:
counterpoint
2015-11-11 11:08:02 +00:00
436 changed files with 289135 additions and 8102 deletions

File diff suppressed because it is too large Load Diff

View File

@ -25,18 +25,15 @@
#define STRERROR_BUFLEN 512
#endif
typedef struct filewriter_st filewriter_t;
typedef struct logfile_st logfile_t;
typedef struct fnames_conf_st fnames_conf_t;
typedef struct logmanager_st logmanager_t;
typedef enum {
BB_READY = 0x00,
BB_FULL,
BB_CLEARED
typedef enum
{
BB_READY = 0x00,
BB_FULL,
BB_CLEARED
} blockbuf_state_t;
typedef enum {
typedef enum
{
LOGFILE_ERROR = 1,
LOGFILE_FIRST = LOGFILE_ERROR,
LOGFILE_MESSAGE = 2,
@ -46,16 +43,20 @@ typedef enum {
} logfile_id_t;
typedef enum { FILEWRITER_INIT, FILEWRITER_RUN, FILEWRITER_DONE }
filewriter_state_t;
typedef enum
{
FILEWRITER_INIT,
FILEWRITER_RUN,
FILEWRITER_DONE
} filewriter_state_t;
/**
* Thread-specific logging information.
*/
typedef struct log_info_st
typedef struct log_info
{
size_t li_sesid;
int li_enabled_logs;
size_t li_sesid;
int li_enabled_logs;
} log_info_t;
#define LE LOGFILE_ERROR
@ -67,36 +68,36 @@ typedef struct log_info_st
* Check if specified log type is enabled in general or if it is enabled
* for the current session.
*/
#define LOG_IS_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
(log_ses_count[id] > 0 && \
tls_log_info.li_enabled_logs & id)) ? true : false)
#define LOG_IS_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
(log_ses_count[id] > 0 && \
tls_log_info.li_enabled_logs & id)) ? true : false)
#define LOG_MAY_BE_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
log_ses_count[id] > 0) ? true : false)
#define LOG_MAY_BE_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
log_ses_count[id] > 0) ? true : false)
/**
* Execute the given command if specified log is enabled in general or
* if there is at least one session for whom the log is enabled.
*/
#define LOGIF_MAYBE(id,cmd) if (LOG_MAY_BE_ENABLED(id)) \
{ \
cmd; \
}
#define LOGIF_MAYBE(id,cmd) if (LOG_MAY_BE_ENABLED(id)) \
{ \
cmd; \
}
/**
* Execute the given command if specified log is enabled in general or
* if the log is enabled for the current session.
*/
#define LOGIF(id,cmd) if (LOG_IS_ENABLED(id)) \
{ \
cmd; \
}
#define LOGIF(id,cmd) if (LOG_IS_ENABLED(id)) \
{ \
cmd; \
}
#if !defined(LOGIF)
#define LOGIF(id,cmd) if (lm_enabled_logfiles_bitmask & id) \
{ \
cmd; \
}
{ \
cmd; \
}
#endif
/**
@ -106,7 +107,13 @@ typedef struct log_info_st
* RUN Struct is valid for run-time checking.
* DONE means that possible memory allocations have been released.
*/
typedef enum { UNINIT = 0, INIT, RUN, DONE } flat_obj_state_t;
typedef enum
{
UNINIT = 0,
INIT,
RUN,
DONE
} flat_obj_state_t;
/**
* LOG_AUGMENT_WITH_FUNCTION Each logged line is suffixed with [function-name].
@ -117,9 +124,28 @@ typedef enum
LOG_AUGMENTATION_MASK = (LOG_AUGMENT_WITH_FUNCTION)
} log_augmentation_t;
/**
* LOG_FLUSH_NO Do not flush after writing.
* LOG_FLUSH_YES Flush after writing.
*/
enum log_flush
{
LOG_FLUSH_NO = 0,
LOG_FLUSH_YES = 1
};
EXTERN_C_BLOCK_BEGIN
bool skygw_logmanager_init(int argc, char* argv[]);
extern int lm_enabled_logfiles_bitmask;
extern ssize_t log_ses_count[];
extern __thread log_info_t tls_log_info;
int mxs_log_flush();
int mxs_log_rotate();
int mxs_log_enable_priority(int priority);
int mxs_log_disable_priority(int priority);
bool skygw_logmanager_init(const char* logdir, int argc, char* argv[]);
void skygw_logmanager_done(void);
void skygw_logmanager_exit(void);
@ -128,14 +154,12 @@ void skygw_logmanager_exit(void);
*/
void skygw_log_done(void);
int skygw_log_write_context(logfile_id_t id,
enum log_flush flush,
const char* file, int line, const char* function,
const char* format, ...);
int skygw_log_flush(logfile_id_t id);
void skygw_log_sync_all(void);
int skygw_log_rotate(logfile_id_t id);
int skygw_log_write_context_flush(logfile_id_t id,
const char* file, int line, const char* function,
const char* format, ...);
int skygw_log_enable(logfile_id_t id);
int skygw_log_disable(logfile_id_t id);
void skygw_log_sync_all(void);
@ -144,10 +168,10 @@ void logmanager_enable_syslog(int);
void logmanager_enable_maxscalelog(int);
#define skygw_log_write(id, format, ...)\
skygw_log_write_context(id, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
skygw_log_write_context(id, LOG_FLUSH_NO, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
#define skygw_log_write_flush(id, format, ...)\
skygw_log_write_context_flush(id, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
skygw_log_write_context(id, LOG_FLUSH_YES, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
/**
* What augmentation if any should a logged message be augmented with.
@ -159,12 +183,30 @@ int skygw_log_get_augmentation();
EXTERN_C_BLOCK_END
const char* get_trace_prefix_default(void);
const char* get_trace_suffix_default(void);
const char* get_msg_prefix_default(void);
const char* get_msg_suffix_default(void);
const char* get_err_prefix_default(void);
const char* get_err_suffix_default(void);
const char* get_logpath_default(void);
/**
* Helper, not to be called directly.
*/
#define MXS_MESSAGE_FLUSH(id, format, ...)\
do { if (LOG_IS_ENABLED(id)) { skygw_log_write_flush(id, format, ##__VA_ARGS__); } } while (false)
/**
* Helper, not to be called directly.
*/
#define MXS_MESSAGE(id, format, ...)\
do { if (LOG_IS_ENABLED(id)) { skygw_log_write(id, format, ##__VA_ARGS__); } } while (false)
/**
* Log an error, warning, notice, info, or debug message.
*
* @param format The printf format of the message.
* @param ... Arguments, depending on the format.
*/
#define MXS_ERROR(format, ...) MXS_MESSAGE_FLUSH(LOGFILE_ERROR, format, ##__VA_ARGS__)
#define MXS_WARNING(format, ...) MXS_MESSAGE(LOGFILE_ERROR, format, ##__VA_ARGS__)
#define MXS_NOTICE(format, ...) MXS_MESSAGE(LOGFILE_MESSAGE, format, ##__VA_ARGS__)
#define MXS_INFO(format, ...) MXS_MESSAGE(LOGFILE_TRACE, format, ##__VA_ARGS__)
#define MXS_DEBUG(format, ...) MXS_MESSAGE(LOGFILE_DEBUG, format, ##__VA_ARGS__)
#endif /** LOG_MANAGER_H */

File diff suppressed because it is too large Load Diff

View File

@ -25,90 +25,99 @@
int main(int argc, char** argv)
{
int iterations = 0, i, interval = 10;
int block_size;
int succp, err = 0;
char cwd[1024];
char tmp[2048];
char *message;
char** optstr;
long msg_index = 1;
struct timespec ts1;
ts1.tv_sec = 0;
memset(cwd,0,1024);
if( argc <4){
fprintf(stderr,
"Log Manager Log Order Test\n"
"Writes an ascending number into the error log to determine if log writes are in order.\n"
"Usage:\t testorder <iterations> <frequency of log flushes> <size of message in bytes>\n");
return 1;
}
block_size = atoi(argv[3]);
if(block_size < 1 || block_size > 1024){
fprintf(stderr,"Message size too small or large, must be at least 1 byte long and must not exceed 1024 bytes.");
return 1;
}
int iterations = 0, i, interval = 10;
int block_size;
int succp, err = 0;
char cwd[1024];
char tmp[2048];
char *message;
char** optstr;
long msg_index = 1;
struct timespec ts1;
ts1.tv_sec = 0;
if(getcwd(cwd,sizeof(cwd)) == NULL ||
(optstr = (char**)malloc(sizeof(char*)*4)) == NULL ||
(message = (char*)malloc(sizeof(char)*block_size))== NULL){
fprintf(stderr,"Fatal Error, exiting...");
return 1;
}
memset(tmp,0,1024);
sprintf(tmp,"%s",cwd);
optstr[0] = strdup("log_manager");
optstr[1] = strdup("-j");
optstr[2] = strdup(tmp);
optstr[3] = NULL;
iterations = atoi(argv[1]);
interval = atoi(argv[2]);
succp = skygw_logmanager_init( 3, optstr);
if(!succp)
fprintf(stderr,"Error, log manager initialization failed.\n");
ss_dassert(succp);
skygw_log_disable(LOGFILE_TRACE);
skygw_log_disable(LOGFILE_MESSAGE);
skygw_log_disable(LOGFILE_DEBUG);
for(i = 0;i<iterations;i++){
sprintf(message,"message|%ld",msg_index++);
int msgsize = block_size - strlen(message);
if(msgsize < 0 || msgsize > 8192){
fprintf(stderr,"Error: Message too long");
break;
}
memset(message + strlen(message), ' ', msgsize);
memset(message + block_size - 1,'\0',1);
if(interval > 0 && i % interval == 0){
err = skygw_log_write_flush(LOGFILE_ERROR, message);
}else{
err = skygw_log_write(LOGFILE_ERROR, message);
memset(cwd, 0, 1024);
if (argc < 4)
{
fprintf(stderr,
"Log Manager Log Order Test\n"
"Writes an ascending number into the error log to determine if log writes are in order.\n"
"Usage:\t testorder <iterations> <frequency of log flushes> <size of message in bytes>\n");
return 1;
}
if(err){
fprintf(stderr,"Error: log_manager returned %d",err);
break;
}
ts1.tv_nsec = 100*1000000;
nanosleep(&ts1, NULL);
}
skygw_log_flush(LOGFILE_ERROR);
skygw_logmanager_done();
free(message);
free(optstr[0]);
free(optstr[1]);
free(optstr[2]);
free(optstr[3]);
free(optstr);
return 0;
block_size = atoi(argv[3]);
if (block_size < 1 || block_size > 1024)
{
fprintf(stderr,"Message size too small or large, must be at least 1 byte long and "
"must not exceed 1024 bytes.");
return 1;
}
if (getcwd(cwd, sizeof(cwd)) == NULL ||
(optstr = (char**)malloc(sizeof(char*) * 4)) == NULL ||
(message = (char*)malloc(sizeof(char) * block_size)) == NULL)
{
fprintf(stderr,"Fatal Error, exiting...");
return 1;
}
memset(tmp, 0, 1024);
sprintf(tmp, "%s", cwd);
optstr[0] = strdup("log_manager");
optstr[1] = NULL;
iterations = atoi(argv[1]);
interval = atoi(argv[2]);
succp = skygw_logmanager_init(tmp, 1, optstr);
if (!succp)
{
fprintf(stderr,"Error, log manager initialization failed.\n");
}
ss_dassert(succp);
skygw_log_disable(LOGFILE_TRACE);
skygw_log_disable(LOGFILE_MESSAGE);
skygw_log_disable(LOGFILE_DEBUG);
for (i = 0; i < iterations; i++)
{
sprintf(message, "message|%ld", msg_index++);
int msgsize = block_size - strlen(message);
if (msgsize < 0 || msgsize > 8192)
{
fprintf(stderr,"Error: Message too long");
break;
}
memset(message + strlen(message), ' ', msgsize);
memset(message + block_size - 1, '\0', 1);
if (interval > 0 && i % interval == 0)
{
err = skygw_log_write_flush(LOGFILE_ERROR, message);
}
else
{
err = skygw_log_write(LOGFILE_ERROR, message);
}
if (err)
{
fprintf(stderr,"Error: log_manager returned %d",err);
break;
}
ts1.tv_nsec = 100 * 1000000;
nanosleep(&ts1, NULL);
}
skygw_log_flush(LOGFILE_ERROR);
skygw_logmanager_done();
free(message);
free(optstr[0]);
free(optstr[1]);
free(optstr[2]);
free(optstr[3]);
free(optstr);
return 0;
}