Browse Source

ckdb - don't show OoO messages during reload, just once at the end

master
kanoi 10 years ago
parent
commit
7bc6768762
  1. 9
      src/ckdb.c
  2. 3
      src/ckdb.h
  3. 45
      src/ckdb_dbio.c

9
src/ckdb.c

@ -3348,6 +3348,7 @@ static void *listener(void *arg)
K_ITEM *wq_item; K_ITEM *wq_item;
time_t now; time_t now;
int wqcount, wqgot; int wqcount, wqgot;
char ooo_buf[256];
tv_t wq_stt, wq_fin; tv_t wq_stt, wq_fin;
double min, sec; double min, sec;
int left; int left;
@ -3381,6 +3382,8 @@ static void *listener(void *arg)
wqcount = workqueue_store->count; wqcount = workqueue_store->count;
K_RUNLOCK(workqueue_store); K_RUNLOCK(workqueue_store);
LOGWARNING("reload shares OoO %s", ooo_status(ooo_buf, sizeof(ooo_buf)));
LOGWARNING("%s(): ckdb ready, queue %d", __func__, wqcount); LOGWARNING("%s(): ckdb ready, queue %d", __func__, wqcount);
/* Until startup_complete, the values should be ignored /* Until startup_complete, the values should be ignored
@ -3395,14 +3398,14 @@ static void *listener(void *arg)
ck_wunlock(&last_lock); ck_wunlock(&last_lock);
startup_complete = true; startup_complete = true;
}
setnow(&wq_stt); setnow(&wq_stt);
// Process queued work
conn = dbconnect(); conn = dbconnect();
now = time(NULL); now = time(NULL);
wqgot = 0; wqgot = 0;
}
// Process queued work
while (!everyone_die) { while (!everyone_die) {
K_WLOCK(workqueue_store); K_WLOCK(workqueue_store);
wq_item = k_unlink_head(workqueue_store); wq_item = k_unlink_head(workqueue_store);

3
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.0" #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 " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #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, extern bool sharesummaries_to_markersummaries(PGconn *conn, WORKMARKERS *workmarkers,
char *by, char *code, char *inet, char *by, char *code, char *inet,
tv_t *cd, K_TREE *trf_root); 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) \ #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, \ _sharesummary_update(_conn, _s_row, _e_row, _ss_item, _by, _code, _inet, _cd, \
WHERE_FFL_HERE) WHERE_FFL_HERE)

45
src/ckdb_dbio.c

@ -3683,6 +3683,18 @@ flail:
static int64_t ooof0, ooof, oool0, oool; static int64_t ooof0, ooof, oool0, oool;
#define OOOLIMIT -2.0 #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, 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) 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; bool must_update = false, conned = false;
double diff = 0; double diff = 0;
char *st = NULL, *db = NULL; char *st = NULL, *db = NULL;
char ooo_buf[256];
LOGDEBUG("%s(): update", __func__); 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 // don't LOG '=' in case shares come from ckpool with the same timestamp
if (td < 0.0) { if (td < 0.0) {
char *tmp1, *tmp2; char *tmp1, *tmp2;
int level; int level = LOG_DEBUG;
// DEBUG only for shares out of order up to OOOLIMIT seconds // WARNING for shares exceeding the OOOLIMIT but not during startup
if (td < OOOLIMIT) { if (td < OOOLIMIT) {
level = LOG_WARNING;
ooof++; ooof++;
} else { if (startup_complete)
level = LOG_DEBUG; level = LOG_WARNING;
} else
ooof0++; ooof0++;
}
LOGMSG(level, "%s(): OoO %s createdate (%s) is < summary" LOGMSG(level, "%s(): OoO %s createdate (%s) is < summary"
" firstshare (%s) (F%"PRId64":%"PRId64 " firstshare (%s) (%s)",
"/L%"PRId64":%"PRId64"/%.1f)",
__func__, s_row ? "shares" : "shareerrors", __func__, s_row ? "shares" : "shareerrors",
(tmp1 = ctv_to_buf(sharecreatedate, NULL, 0)), (tmp1 = ctv_to_buf(sharecreatedate, NULL, 0)),
(tmp2 = ctv_to_buf(&(row->firstshare), 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(tmp2);
free(tmp1); free(tmp1);
row->firstshare.tv_sec = sharecreatedate->tv_sec; 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; row->lastdiffacc = diff;
} else { } else {
char *tmp1, *tmp2; char *tmp1, *tmp2;
int level; int level = LOG_DEBUG;
// DEBUG only for shares out of order up to OOOLIMIT seconds // WARNING for shares exceeding the OOOLIMIT but not during startup
if (td < OOOLIMIT) { if (td < OOOLIMIT) {
level = LOG_WARNING;
oool++; oool++;
} else { if (startup_complete)
level = LOG_DEBUG; level = LOG_WARNING;
} else
oool0++; oool0++;
}
LOGMSG(level, "%s(): OoO %s createdate (%s) is < summary" LOGMSG(level, "%s(): OoO %s createdate (%s) is < summary"
" lastshare (%s) (F%"PRId64":%"PRId64 " lastshare (%s) (%s)",
"/L%"PRId64":%"PRId64"/%.1f)",
__func__, s_row ? "shares" : "shareerrors", __func__, s_row ? "shares" : "shareerrors",
(tmp1 = ctv_to_buf(sharecreatedate, NULL, 0)), (tmp1 = ctv_to_buf(sharecreatedate, NULL, 0)),
(tmp2 = ctv_to_buf(&(row->lastshare), 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(tmp2);
free(tmp1); free(tmp1);
} }

Loading…
Cancel
Save