From 579c2ee279fc768571519b58db458dc714e2c43a Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 21 Jul 2016 00:40:08 +1000 Subject: [PATCH] ckdb - report an error if keysummary != sharesummary total --- src/ckdb.h | 2 +- src/ckdb_dbio.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ckdb.h b/src/ckdb.h index 291675f2..f83de0dc 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.7" -#define CKDB_VERSION DB_VERSION"-2.203" +#define CKDB_VERSION DB_VERSION"-2.204" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index db591025..242074c6 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -4492,7 +4492,7 @@ bool sharesummaries_to_markersummaries(PGconn *conn, WORKMARKERS *workmarkers, K_ITEM *ks_item, ks_look; bool ok = false, conned = false; int64_t diffacc = 0, shareacc = 0; - int64_t kdiffacc= 0, kshareacc = 0; + int64_t kdiffacc = 0, kshareacc = 0; char *reason = NULL; int ss_count, kss_count, ms_count, ks_count; char *st = NULL; @@ -4974,6 +4974,12 @@ flail: tvdiff(&kdb_fin, &kdb_stt), tvdiff(&lck_got, &lck_stt), tvdiff(&lck_fin, &lck_got)); + + // This should never happen + if (kshareacc != (shareacc << 1) || kdiffacc != (diffacc << 1)) { + LOGERR("%s() CODE BUG: keysummary share/diff counts " + "are wrong!", shortname); + } } free_ktree(ms_root, NULL); free_ktree(ks_root, NULL);