Merge branch 'develop' into 1.2.1-binlog_router_trx

This commit is contained in:
MassimilianoPinto 2015-09-11 15:22:17 +02:00
commit 3fe317f69b
7 changed files with 66 additions and 22 deletions

View File

@ -124,6 +124,18 @@ log_debug=1
To disable the log use the value 0 and to enable it use the value 1.
#### `log_augmentation`
Enable or disable the augmentation of messages. If this is enabled, then each logged message is appended with the name of the function where the message was logged. This is primarily for development purposes and hence is disabled by default.
```
# Valid options are:
# log_augmentation=<0|1>
log_augmentation=1
```
To disable the augmentation use the value 0 and to enable it use the value 1.
#### `logdir`
Set the directory where the logfiles are stored. The folder needs to be both readable and writable by the user running MaxScale.

View File

@ -43,6 +43,7 @@ Switch|Long Option|Description
`-U USER`|`--user=USER`|run MaxScale as another user. The user ID and group ID of this user are used to run MaxScale.
`-s [yes no]`|`--syslog=[yes no]`|log messages to syslog (default:yes)
`-S [yes no]`|`--maxscalelog=[yes no]`|log messages to MaxScale log (default: yes)
`-G [0 1]`|`--log_augmentation=[0 1]`|augment messages with the name of the function where the message was logged (default: 0). Primarily for development purposes.
`-v`|`--version`|print version info and exit
`-V`|`--version-full`|print version info and the commit ID the binary was built from
`-?`|`--help`|show this help

View File

@ -106,7 +106,7 @@ static bool flushall_done_flag;
/**
* Default augmentation.
*/
static int default_log_augmentation = LOG_AUGMENT_WITH_FUNCTION;
static int default_log_augmentation = 0;
static int log_augmentation = default_log_augmentation;
/** Writer thread structure */

View File

@ -108,7 +108,7 @@ static inline void dcb_write_fake_code(DCB *dcb);
static inline void dcb_write_when_already_queued(DCB *dcb, GWBUF *queue);
static void dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno);
static inline void dcb_write_tidy_up(DCB *dcb, bool below_water);
static int dcb_write_SSL_error_report (DCB *dcb, int ret);
static void dcb_write_SSL_error_report (DCB *dcb, int ret, int ssl_errno);
size_t dcb_get_session_id(
DCB *dcb)
@ -1453,23 +1453,31 @@ dcb_write_SSL(DCB *dcb, GWBUF *queue)
#if defined(FAKE_CODE)
dcb_write_fake_code(dcb);
#endif /* FAKE_CODE */
do
{
w = gw_write_SSL(dcb->ssl, GWBUF_DATA(queue), GWBUF_LENGTH(queue));
dcb->stats.n_writes++;
do
{
w = gw_write_SSL (dcb->ssl, GWBUF_DATA (queue), GWBUF_LENGTH (queue));
dcb->stats.n_writes++;
if (w <= 0)
{
int ssl_errno = dcb_write_SSL_error_report (dcb, w);
if(ssl_errno != SSL_ERROR_WANT_WRITE)
if (w <= 0)
{
int ssl_errno = SSL_get_error (dcb->ssl, w);
dcb_write_SSL_error_report (dcb, w, ssl_errno);
if (ssl_errno != SSL_ERROR_WANT_WRITE)
{
atomic_add(&dcb->writeqlen, gwbuf_length(queue));
atomic_add (&dcb->writeqlen, gwbuf_length (queue));
dcb->stats.n_buffered++;
dcb_write_tidy_up(dcb, below_water);
dcb_write_tidy_up (dcb, below_water);
return 1;
}
#ifdef SS_DEBUG
else
{
skygw_log_write (LD, "SSL error: SSL_ERROR_WANT_WRITE, retrying SSL_write...");
}
#endif
}
} while(w <= 0);
}
while(w <= 0);
/** Remove written bytes from the queue */
queue = gwbuf_consume(queue, w);
@ -1501,14 +1509,12 @@ dcb_write_SSL(DCB *dcb, GWBUF *queue)
*
* @param dcb The DCB of the client
* @param ret The SSL operation return code
* @return The final SSL error number
* @param ssl_errno The SSL error code
*/
static int
dcb_write_SSL_error_report (DCB *dcb, int ret)
static void
dcb_write_SSL_error_report (DCB *dcb, int ret, int ssl_errno)
{
int ssl_errno;
char errbuf[STRERROR_BUFLEN];
ssl_errno = SSL_get_error(dcb->ssl,ret);
if (LOG_IS_ENABLED(LOGFILE_DEBUG))
{
@ -1587,7 +1593,6 @@ dcb_write_SSL_error_report (DCB *dcb, int ret)
} while((ssl_errno = ERR_get_error()) != 0);
}
}
return SSL_ERROR_NONE;
}
/**

View File

@ -181,6 +181,7 @@ static struct option long_options[] = {
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, '?'},
{"version-full", no_argument, 0, 'V'},
{"log_augmentation", required_argument, 0, 'G'},
{0, 0, 0, 0}
};
static int cnf_preparser(void* data, const char* section, const char* name, const char* value);
@ -197,6 +198,7 @@ static int ntfw_cb(const char*, const struct stat*, int, struct FTW*);
static bool file_is_readable(char* absolute_pathname);
static bool file_is_writable(char* absolute_pathname);
bool handle_path_arg(char** dest, char* path, char* arg, bool rd, bool wr);
static void set_log_augmentation(const char* value);
static void usage(void);
static char* get_expanded_pathname(
char** abs_path,
@ -1128,7 +1130,7 @@ int main(int argc, char **argv)
}
}
while ((opt = getopt_long(argc, argv, "dc:f:l:vVs:S:?L:D:C:B:U:A:P:",
while ((opt = getopt_long(argc, argv, "dc:f:l:vVs:S:?L:D:C:B:U:A:P:G:",
long_options, &option_index)) != -1)
{
bool succp = true;
@ -1291,6 +1293,9 @@ int main(int argc, char **argv)
succp = false;
}
break;
case 'G':
set_log_augmentation(optarg);
break;
case '?':
usage();
rc = EXIT_SUCCESS;
@ -2312,6 +2317,21 @@ bool handle_path_arg(char** dest, char* path, char* arg, bool rd, bool wr)
return rval;
}
void set_log_augmentation(const char* value)
{
// Command line arguments are handled first, thus command line argument
// has priority.
static bool augmentation_set = false;
if (!augmentation_set)
{
skygw_log_set_augmentation(atoi(value));
augmentation_set = true;
}
}
/**
* Pre-parse the MaxScale.cnf for config, log and module directories.
* @param data Parameter passed by inih
@ -2423,6 +2443,10 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
{
cnf->maxlog = config_truth_value((char*)value);
}
else if(strcmp(name, "log_augmentation") == 0)
{
set_log_augmentation(value);
}
}
return 1;

View File

@ -5,7 +5,7 @@ install(TARGETS binlogrouter DESTINATION ${MAXSCALE_LIBDIR})
add_executable(maxbinlogcheck maxbinlogcheck.c blr_file.c blr_cache.c blr_master.c blr_slave.c blr.c ${CMAKE_SOURCE_DIR}/server/core/service.c ${CMAKE_SOURCE_DIR}/server/core/spinlock.c ${CMAKE_SOURCE_DIR}/server/core/buffer.c ${CMAKE_SOURCE_DIR}/server/core/atomic.c ${CMAKE_SOURCE_DIR}/server/core/hint.c ${CMAKE_SOURCE_DIR}/server/core/gwdirs.c ${CMAKE_SOURCE_DIR}/server/core/server.c ${CMAKE_SOURCE_DIR}/server/core/dcb.c ${CMAKE_SOURCE_DIR}/server/core/users.c ${CMAKE_SOURCE_DIR}/server/core/dbusers.c ${CMAKE_SOURCE_DIR}/server/core/utils.c ${CMAKE_SOURCE_DIR}/server/core/hashtable.c ${CMAKE_SOURCE_DIR}/server/core/poll.c ${CMAKE_SOURCE_DIR}/server/core/gwbitmask.c ${CMAKE_SOURCE_DIR}/server/core/config.c ${CMAKE_SOURCE_DIR}/server/core/session.c ${CMAKE_SOURCE_DIR}/server/core/housekeeper.c ${CMAKE_SOURCE_DIR}/server/core/filter.c ${CMAKE_SOURCE_DIR}/server/core/resultset.c ${CMAKE_SOURCE_DIR}/server/core/load_utils.c ${CMAKE_SOURCE_DIR}/server/core/monitor.c ${CMAKE_SOURCE_DIR}/server/core/gw_utils.c ${CMAKE_SOURCE_DIR}/server/core/thread.c ${CMAKE_SOURCE_DIR}/server/core/secrets.c)
target_link_libraries(maxbinlogcheck utils ssl pthread log_manager ${PCRE_LINK_FLAGS} aio rt crypt dl crypto inih z m stdc++ ${EMBEDDED_LIB} ${CURL_LIBRARIES})
target_link_libraries(maxbinlogcheck utils ssl pthread log_manager ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} aio rt crypt dl crypto inih z m stdc++ ${CURL_LIBRARIES})
install(TARGETS maxbinlogcheck DESTINATION bin)

View File

@ -45,6 +45,8 @@ MODULE_INFO info = {
# include <mysql_client_server_protocol.h>
#endif
#define RWSPLIT_TRACE_MSG_LEN 1000
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
@ -2247,7 +2249,7 @@ static bool route_single_stmt(
size_t len = MIN(GWBUF_LENGTH(querybuf),
MYSQL_GET_PACKET_LEN((unsigned char *)querybuf->start)-1);
char* data = (char*)&packet[5];
char* contentstr = strndup(data, len);
char* contentstr = strndup(data, MIN(len, RWSPLIT_TRACE_MSG_LEN));
char* qtypestr = skygw_get_qtype_str(qtype);
skygw_log_write(