From 7bc6768762be23c1a568827152dc16f6ad6fe404 Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 4 Apr 2015 14:43:08 +1100 Subject: [PATCH] ckdb - don't show OoO messages during reload, just once at the end --- src/ckdb.c | 13 ++++++++----- src/ckdb.h | 3 ++- src/ckdb_dbio.c | 45 +++++++++++++++++++++++++++------------------ 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 13b42c8b..7dd3f9af 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -3348,6 +3348,7 @@ static void *listener(void *arg) K_ITEM *wq_item; time_t now; int wqcount, wqgot; + char ooo_buf[256]; tv_t wq_stt, wq_fin; double min, sec; int left; @@ -3381,6 +3382,8 @@ static void *listener(void *arg) wqcount = workqueue_store->count; K_RUNLOCK(workqueue_store); + LOGWARNING("reload shares OoO %s", ooo_status(ooo_buf, sizeof(ooo_buf))); + LOGWARNING("%s(): ckdb ready, queue %d", __func__, wqcount); /* Until startup_complete, the values should be ignored @@ -3395,14 +3398,14 @@ static void *listener(void *arg) ck_wunlock(&last_lock); startup_complete = true; - } - setnow(&wq_stt); + setnow(&wq_stt); + conn = dbconnect(); + now = time(NULL); + wqgot = 0; + } // Process queued work - conn = dbconnect(); - now = time(NULL); - wqgot = 0; while (!everyone_die) { K_WLOCK(workqueue_store); wq_item = k_unlink_head(workqueue_store); diff --git a/src/ckdb.h b/src/ckdb.h index c36698af..d3ffab10 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.0" -#define CKDB_VERSION DB_VERSION"-1.050" +#define CKDB_VERSION DB_VERSION"-1.051" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -2011,6 +2011,7 @@ extern bool shareerrors_add(PGconn *conn, char *workinfoid, char *username, extern bool sharesummaries_to_markersummaries(PGconn *conn, WORKMARKERS *workmarkers, char *by, char *code, char *inet, tv_t *cd, K_TREE *trf_root); +extern char *ooo_status(char *buf, size_t siz); #define sharesummary_update(_conn, _s_row, _e_row, _ss_item, _by, _code, _inet, _cd) \ _sharesummary_update(_conn, _s_row, _e_row, _ss_item, _by, _code, _inet, _cd, \ WHERE_FFL_HERE) diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index a91d27c3..ddf152f1 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -3683,6 +3683,18 @@ flail: static int64_t ooof0, ooof, oool0, oool; #define OOOLIMIT -2.0 +/* This isn't locked so it is possible - but very unlikely - + * to get an invalid set of numbers if any ooo variables change + * during the snprintf, but that will simply display a wrong number */ +char *ooo_status(char *buf, size_t siz) +{ + snprintf(buf, siz, + "F%"PRId64":%"PRId64"/L%"PRId64":%"PRId64"/%.1f/T%"PRId64, + ooof, ooof0, oool, oool0, OOOLIMIT, + ooof + ooof0 + oool + oool0); + return buf; +} + bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row, K_ITEM *ss_item, char *by, char *code, char *inet, tv_t *cd, WHERE_FFL_ARGS) { @@ -3701,6 +3713,7 @@ bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row, K_ITE bool must_update = false, conned = false; double diff = 0; char *st = NULL, *db = NULL; + char ooo_buf[256]; LOGDEBUG("%s(): update", __func__); @@ -3812,22 +3825,20 @@ bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row, K_ITE // don't LOG '=' in case shares come from ckpool with the same timestamp if (td < 0.0) { char *tmp1, *tmp2; - int level; - // DEBUG only for shares out of order up to OOOLIMIT seconds + int level = LOG_DEBUG; + // WARNING for shares exceeding the OOOLIMIT but not during startup if (td < OOOLIMIT) { - level = LOG_WARNING; ooof++; - } else { - level = LOG_DEBUG; + if (startup_complete) + level = LOG_WARNING; + } else ooof0++; - } LOGMSG(level, "%s(): OoO %s createdate (%s) is < summary" - " firstshare (%s) (F%"PRId64":%"PRId64 - "/L%"PRId64":%"PRId64"/%.1f)", + " firstshare (%s) (%s)", __func__, s_row ? "shares" : "shareerrors", (tmp1 = ctv_to_buf(sharecreatedate, NULL, 0)), (tmp2 = ctv_to_buf(&(row->firstshare), NULL, 0)), - ooof, ooof0, oool, oool0, OOOLIMIT); + ooo_status(ooo_buf, sizeof(ooo_buf))); free(tmp2); free(tmp1); row->firstshare.tv_sec = sharecreatedate->tv_sec; @@ -3842,22 +3853,20 @@ bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row, K_ITE row->lastdiffacc = diff; } else { char *tmp1, *tmp2; - int level; - // DEBUG only for shares out of order up to OOOLIMIT seconds + int level = LOG_DEBUG; + // WARNING for shares exceeding the OOOLIMIT but not during startup if (td < OOOLIMIT) { - level = LOG_WARNING; oool++; - } else { - level = LOG_DEBUG; + if (startup_complete) + level = LOG_WARNING; + } else oool0++; - } LOGMSG(level, "%s(): OoO %s createdate (%s) is < summary" - " lastshare (%s) (F%"PRId64":%"PRId64 - "/L%"PRId64":%"PRId64"/%.1f)", + " lastshare (%s) (%s)", __func__, s_row ? "shares" : "shareerrors", (tmp1 = ctv_to_buf(sharecreatedate, NULL, 0)), (tmp2 = ctv_to_buf(&(row->lastshare), NULL, 0)), - ooof, ooof0, oool, oool0, OOOLIMIT); + ooo_status(ooo_buf, sizeof(ooo_buf))); free(tmp2); free(tmp1); }