diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index 0ade2e54a..3e19bcd6b 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -729,10 +729,10 @@ static int logmanager_write_log( /** Length of session id */ int sesid_str_len; - /** 2 braces and 2 spaces */ + /** 2 braces, 2 spaces and terminating char */ if (id == LOGFILE_TRACE && tls_log_info.li_sesid != 0) { - sesid_str_len = 2+2+get_decimal_len(tls_log_info.li_sesid); + sesid_str_len = 2+2+get_decimal_len(tls_log_info.li_sesid)+1; } else { @@ -741,13 +741,13 @@ static int logmanager_write_log( timestamp_len = get_timestamp_len(); /** Find out how much can be safely written with current block size */ - if (timestamp_len-1+sesid_str_len+str_len > lf->lf_buf_size) + if (timestamp_len-1+sesid_str_len-1+str_len > lf->lf_buf_size) { safe_str_len = lf->lf_buf_size; } else { - safe_str_len = timestamp_len-1+sesid_str_len+str_len; + safe_str_len = timestamp_len-1+sesid_str_len-1+str_len; } /** * Seek write position and register to block buffer. @@ -810,6 +810,11 @@ static int logmanager_write_log( "[%lu] ", tls_log_info.li_sesid); } + + if (sesid_str_len != 0) + { + sesid_str_len -= 1; /*< don't calculate terminating char anymore */ + } /** * Write next string to overwrite terminating null character * of the timestamp string. diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index b86db4dde..fbe38bc37 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -1473,6 +1473,12 @@ static route_target_t get_route_target ( QUERY_IS_TYPE(qtype, QUERY_TYPE_UNKNOWN))); target = TARGET_MASTER; } +#if defined(SS_DEBUG) + LOGIF(LT, (skygw_log_write( + LOGFILE_TRACE, + "Selected target \"%s\"", + STRTARGET(target)))); +#endif return target; } diff --git a/utils/skygw_debug.h b/utils/skygw_debug.h index 7294a7ba6..1ade113a3 100644 --- a/utils/skygw_debug.h +++ b/utils/skygw_debug.h @@ -262,6 +262,12 @@ typedef enum skygw_chk_t { (SERVER_IS_RELAY_SERVER(s) ? "RUNNING RELAY" : \ (SERVER_IS_RUNNING(s) ? "RUNNING (only)" : "NO STATUS"))))))) +#define STRTARGET(t) (t == TARGET_ALL ? "TARGET_ALL" : \ + (t == TARGET_MASTER ? "TARGET_MASTER" : \ + (t == TARGET_SLAVE ? "TARGET_SLAVE" : \ + (t == TARGET_UNDEFINED ? "TARGET_UNDEFINED" : \ + "Unknown target value")))) + #define BREFSRV(b) (b->bref_backend->backend_server)