Browse Source

ckdb - stat report every 10s during logger shutdown - if it's slow

master
kanoi 10 years ago
parent
commit
21c1aa10fc
  1. 18
      src/ckdb.c
  2. 2
      src/ckdb.h

18
src/ckdb.c

@ -2016,7 +2016,8 @@ static void *logger(__maybe_unused void *arg)
K_ITEM *lq_item; K_ITEM *lq_item;
LOGQUEUE *lq; LOGQUEUE *lq;
char buf[128]; char buf[128];
tv_t now; tv_t now, then;
int count;
pthread_detach(pthread_self()); pthread_detach(pthread_self());
@ -2051,18 +2052,26 @@ static void *logger(__maybe_unused void *arg)
} }
K_WLOCK(logqueue_free); K_WLOCK(logqueue_free);
count = logqueue_store->count;
setnow(&now); setnow(&now);
snprintf(buf, sizeof(buf), "logstopping.%d.%ld,%ld", snprintf(buf, sizeof(buf), "logstopping.%d.%ld,%ld",
logqueue_store->count, count, now.tv_sec, now.tv_usec);
now.tv_sec, now.tv_usec);
LOGFILE(buf); LOGFILE(buf);
if (logqueue_store->count) if (count)
LOGERR("%s", buf); LOGERR("%s", buf);
lq_item = logqueue_store->head; lq_item = logqueue_store->head;
copy_tv(&then, &now);
while (lq_item) { while (lq_item) {
DATA_LOGQUEUE(lq, lq_item); DATA_LOGQUEUE(lq, lq_item);
LOGFILE(lq->msg); LOGFILE(lq->msg);
free(lq->msg); free(lq->msg);
count--;
setnow(&now);
if ((now.tv_sec - then.tv_sec) > 10) {
snprintf(buf, sizeof(buf), "logging ... %d", count);
LOGERR("%s", buf);
copy_tv(&then, &now);
}
lq_item = lq_item->next; lq_item = lq_item->next;
} }
K_WUNLOCK(logqueue_free); K_WUNLOCK(logqueue_free);
@ -2073,6 +2082,7 @@ static void *logger(__maybe_unused void *arg)
snprintf(buf, sizeof(buf), "logstop.%ld,%ld", snprintf(buf, sizeof(buf), "logstop.%ld,%ld",
now.tv_sec, now.tv_usec); now.tv_sec, now.tv_usec);
LOGFILE(buf); LOGFILE(buf);
LOGWARNING("%s", buf);
return NULL; return NULL;
} }

2
src/ckdb.h

@ -52,7 +52,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "0.9.6" #define DB_VERSION "0.9.6"
#define CKDB_VERSION DB_VERSION"-0.665" #define CKDB_VERSION DB_VERSION"-0.666"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__

Loading…
Cancel
Save