log info when flow ctrol waiting time > 0 gracefully
parent
d006954ceb
commit
1abf7402ca
|
|
@ -392,12 +392,12 @@ static void *binlog_writer_func(void *arg)
|
|||
if (fc_queue_empty(&thread->queue)) {
|
||||
current_timestamp = 0;
|
||||
}
|
||||
if (current_timestamp == 0 || current_timestamp > last_timestamp) {
|
||||
if (current_timestamp != last_timestamp) {
|
||||
last_timestamp = current_timestamp;
|
||||
FC_ATOMIC_SET(thread->flow_ctrol.last_timestamp,
|
||||
current_timestamp);
|
||||
}
|
||||
if ((current_timestamp == 0 && last_timestamp != 0) ||
|
||||
(current_timestamp > last_timestamp))
|
||||
{
|
||||
last_timestamp = current_timestamp;
|
||||
FC_ATOMIC_SET(thread->flow_ctrol.last_timestamp,
|
||||
current_timestamp);
|
||||
|
||||
PTHREAD_MUTEX_LOCK(&thread->flow_ctrol.lcp.lock);
|
||||
if (thread->flow_ctrol.waiting_count > 0) {
|
||||
|
|
|
|||
|
|
@ -338,7 +338,9 @@ static inline void sf_push_to_binlog_write_queue(SFBinlogWriterInfo *writer,
|
|||
writer->thread->flow_ctrol.max_delay)
|
||||
{
|
||||
time_t start_time;
|
||||
time_t last_log_timestamp;
|
||||
int time_used;
|
||||
int log_level;
|
||||
|
||||
start_time = g_current_time;
|
||||
PTHREAD_MUTEX_LOCK(&writer->thread->flow_ctrol.lcp.lock);
|
||||
|
|
@ -358,10 +360,23 @@ static inline void sf_push_to_binlog_write_queue(SFBinlogWriterInfo *writer,
|
|||
|
||||
time_used = g_current_time - start_time;
|
||||
if (time_used > 0) {
|
||||
logWarning("file: "__FILE__", line: %d, "
|
||||
"subdir_name: %s, max_delay: %d s, flow ctrol waiting "
|
||||
"time: %d s", __LINE__, writer->fw.cfg.subdir_name,
|
||||
writer->thread->flow_ctrol.max_delay, time_used);
|
||||
last_log_timestamp = FC_ATOMIC_GET(
|
||||
LAST_BINLOG_WRITER_LOG_TIMESTAMP);
|
||||
if (g_current_time != last_log_timestamp &&
|
||||
__sync_bool_compare_and_swap(
|
||||
&LAST_BINLOG_WRITER_LOG_TIMESTAMP,
|
||||
last_log_timestamp, g_current_time))
|
||||
{
|
||||
if (time_used <= writer->thread->flow_ctrol.max_delay) {
|
||||
log_level = LOG_DEBUG;
|
||||
} else {
|
||||
log_level = LOG_WARNING;
|
||||
}
|
||||
log_it_ex(&g_log_context, log_level, "file: "__FILE__", line: %d, "
|
||||
"subdir_name: %s, max_delay: %d s, flow ctrol waiting "
|
||||
"time: %d s", __LINE__, writer->fw.cfg.subdir_name,
|
||||
writer->thread->flow_ctrol.max_delay, time_used);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ typedef struct sf_global_variables {
|
|||
SFConnectionStat connection_stat;
|
||||
sf_error_handler_callback error_handler;
|
||||
string_t empty;
|
||||
volatile time_t last_binlog_writer_log_timestamp;
|
||||
} SFGlobalVariables;
|
||||
|
||||
typedef struct sf_context_ini_config {
|
||||
|
|
@ -98,6 +99,8 @@ extern SFContext g_sf_context;
|
|||
|
||||
#define SF_G_ERROR_HANDLER g_sf_global_vars.error_handler
|
||||
#define SF_G_EMPTY_STRING g_sf_global_vars.empty
|
||||
#define LAST_BINLOG_WRITER_LOG_TIMESTAMP g_sf_global_vars. \
|
||||
last_binlog_writer_log_timestamp
|
||||
|
||||
#define SF_G_EPOLL_EDGE_TRIGGER g_sf_global_vars.epoll_edge_trigger
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue