From 830e7481a09b9b80f79bed709153e8e5fa00b643 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 7 Aug 2014 22:22:11 +1000 Subject: [PATCH 1/2] ckdb - determin reload sharesummary settings if all are complete --- src/ckdb.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index b5201345..211f4d6b 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -139,6 +139,8 @@ static char *restorefrom; * RAM shares: oldest DB sharesummary firstshare where complete='n' * All shares before this have been summarised to the DB with * complete='a' (or 'y') and were deleted from RAM + * If there are none with complete='n' but are others in the DB, + * then the newest firstshare is used * RAM shareerrors: as above * DB+RAM sharesummary: created from shares, so as above * Some shares after this may have been summarised to other @@ -213,6 +215,8 @@ static char *restorefrom; typedef struct loadstatus { tv_t oldest_sharesummary_firstshare_n; + tv_t newest_sharesummary_firstshare; + tv_t sharesummary_firstshare; // whichever of above 2 used tv_t newest_createdate_workinfo; tv_t newest_createdate_auths; tv_t newest_createdate_poolstats; @@ -3935,11 +3939,12 @@ static bool sharesummary_fill(PGconn *conn) workerstatus_update(NULL, NULL, NULL, row); - if (tolower(row->complete[0]) == SUMMARY_NEW && - (dbstatus.oldest_sharesummary_firstshare_n.tv_sec == 0 || - !tv_newer(&(dbstatus.oldest_sharesummary_firstshare_n), &(row->firstshare)))) { - copy_tv(&(dbstatus.oldest_sharesummary_firstshare_n), &(row->firstshare)); - } + if (tolower(row->complete[0]) == SUMMARY_NEW) { + if (dbstatus.oldest_sharesummary_firstshare_n.tv_sec == 0 || + !tv_newer(&(dbstatus.oldest_sharesummary_firstshare_n), &(row->firstshare))) + copy_tv(&(dbstatus.oldest_sharesummary_firstshare_n), &(row->firstshare)); + } else if (tv_newer(&(dbstatus.newest_sharesummary_firstshare), &(row->firstshare))) + copy_tv(&(dbstatus.newest_sharesummary_firstshare), &(row->firstshare)); } if (!ok) k_add_head(sharesummary_free, item); @@ -5336,6 +5341,8 @@ static bool reload() tv_to_buf(&(dbstatus.oldest_sharesummary_firstshare_n), buf, sizeof(buf)); LOGWARNING("%s(): %s oldest DB incomplete sharesummary", __func__, buf); + tv_to_buf(&(dbstatus.newest_sharesummary_firstshare), buf, sizeof(buf)); + LOGWARNING("%s(): %s newest DB sharesummary", __func__, buf); tv_to_buf(&(dbstatus.newest_createdate_workinfo), buf, sizeof(buf)); LOGWARNING("%s(): %s newest DB workinfo", __func__, buf); tv_to_buf(&(dbstatus.newest_createdate_auths), buf, sizeof(buf)); @@ -5347,7 +5354,12 @@ static bool reload() tv_to_buf(&(dbstatus.newest_createdate_blocks), buf, sizeof(buf)); LOGWARNING("%s(): %s newest DB blocks (ignored)", __func__, buf); - copy_tv(&start, &(dbstatus.oldest_sharesummary_firstshare_n)); + if (dbstatus.oldest_sharesummary_firstshare_n.tv_sec) + copy_tv(&(dbstatus.sharesummary_firstshare), &(dbstatus.oldest_sharesummary_firstshare_n)); + else + copy_tv(&(dbstatus.sharesummary_firstshare), &(dbstatus.newest_sharesummary_firstshare)); + + copy_tv(&start, &(dbstatus.sharesummary_firstshare)); reason = "sharesummary"; if (!tv_newer(&start, &(dbstatus.newest_createdate_workinfo))) { copy_tv(&start, &(dbstatus.newest_createdate_workinfo)); @@ -6324,7 +6336,7 @@ static char *cmd_sharelog(char *cmd, char *id, __maybe_unused tv_t *notnow, // This just excludes the shares we certainly don't need if (reloading) { - if (tv_newer(cd, &(dbstatus.oldest_sharesummary_firstshare_n))) + if (tv_newer(cd, &(dbstatus.sharesummary_firstshare))) return NULL; } @@ -6394,7 +6406,7 @@ static char *cmd_sharelog(char *cmd, char *id, __maybe_unused tv_t *notnow, // This just excludes the shareerrors we certainly don't need if (reloading) { - if (tv_newer(cd, &(dbstatus.oldest_sharesummary_firstshare_n))) + if (tv_newer(cd, &(dbstatus.sharesummary_firstshare))) return NULL; } @@ -6446,7 +6458,7 @@ static char *cmd_sharelog(char *cmd, char *id, __maybe_unused tv_t *notnow, bool ok; if (reloading) { - if (tv_newer(cd, &(dbstatus.oldest_sharesummary_firstshare_n))) + if (tv_newer(cd, &(dbstatus.sharesummary_firstshare))) return NULL; } From 52fe152eed70ef33d0c984e513046b124a838b21 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 7 Aug 2014 22:25:36 +1000 Subject: [PATCH 2/2] sql - update reloadstatus.sql for sharesummary --- sql/reloadstatus.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/reloadstatus.sql b/sql/reloadstatus.sql index 7becd9fb..2432090c 100644 --- a/sql/reloadstatus.sql +++ b/sql/reloadstatus.sql @@ -1,4 +1,5 @@ select 'sharesummary' as "sharesummary",min(firstshare) as "min incomplete firstshare" from sharesummary where complete = 'n'; +select 'sharesummary' as "sharesummary",max(firstshare) as "max complete firstshare" from sharesummary where complete != 'n'; select 'workinfo' as "workinfo",max(createdate) as "max createdate" from workinfo; select 'auths' as "auths",max(createdate) as "max createdate" from auths; select 'poolstats' as "poolstats",max(createdate) as "max createdate" from poolstats;