From 21c1aa10fcfdbc49860a49fe3cde7f51d324c547 Mon Sep 17 00:00:00 2001 From: kanoi Date: Fri, 28 Nov 2014 13:36:25 +1100 Subject: [PATCH] ckdb - stat report every 10s during logger shutdown - if it's slow --- src/ckdb.c | 18 ++++++++++++++---- src/ckdb.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 71e5eed3..98a2fd91 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -2016,7 +2016,8 @@ static void *logger(__maybe_unused void *arg) K_ITEM *lq_item; LOGQUEUE *lq; char buf[128]; - tv_t now; + tv_t now, then; + int count; pthread_detach(pthread_self()); @@ -2051,18 +2052,26 @@ static void *logger(__maybe_unused void *arg) } K_WLOCK(logqueue_free); + count = logqueue_store->count; setnow(&now); snprintf(buf, sizeof(buf), "logstopping.%d.%ld,%ld", - logqueue_store->count, - now.tv_sec, now.tv_usec); + count, now.tv_sec, now.tv_usec); LOGFILE(buf); - if (logqueue_store->count) + if (count) LOGERR("%s", buf); lq_item = logqueue_store->head; + copy_tv(&then, &now); while (lq_item) { DATA_LOGQUEUE(lq, lq_item); LOGFILE(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; } K_WUNLOCK(logqueue_free); @@ -2073,6 +2082,7 @@ static void *logger(__maybe_unused void *arg) snprintf(buf, sizeof(buf), "logstop.%ld,%ld", now.tv_sec, now.tv_usec); LOGFILE(buf); + LOGWARNING("%s", buf); return NULL; } diff --git a/src/ckdb.h b/src/ckdb.h index 9ed96f68..39a26dc7 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #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_HERE __FILE__, __func__, __LINE__