From 659aad0f9b5a94e3780e41c0120d8a974ed45c87 Mon Sep 17 00:00:00 2001 From: Teemu Toivola Date: Tue, 13 Aug 2019 23:51:39 +0300 Subject: [PATCH] improve database error retry error message, increase retry count from 3 to 5, clarify behaviour in comment, update changelog --- CHANGES | 4 ++++ src/common.h | 6 ++++-- src/daemon.c | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index cc249d1..1ef2391 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ 2.4 / - Fixed + - Daemon didn't correctly wait when acquiring database lock for data write + which could result in unnecessary errors and even process exit if an + external database read operation had exactly the same timing as the + daemon write operation - Daemon didn't fork() even when requested to with --daemon when started by PID 1 (issue seen at least in Docker containers) - Move vnstatd man page from section 1 to section 8 diff --git a/src/common.h b/src/common.h index a2dce02..2f411c8 100644 --- a/src/common.h +++ b/src/common.h @@ -257,8 +257,10 @@ and most can be changed later from the config file. #define CTX "606060" #define CTXD "-" -/* number of retries for non-fatal database errors */ -#define DBRETRYLIMIT 3 +/* number of retries after non-fatal database errors, */ +/* will result in given number + 1 tries in total before exit, */ +/* a full disk (as reported by sqlite) will no cause retries or exit */ +#define DBRETRYLIMIT 5 /* internal config structure */ typedef struct { diff --git a/src/daemon.c b/src/daemon.c index 3f79b04..3e27db9 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -697,8 +697,8 @@ void handledatabaseerror(DSTATE *s) printe(PT_Error); } else { s->dbretrycount++; - if (s->dbretrycount >= DBRETRYLIMIT) { - snprintf(errorstring, 1024, "Database error retry limit %d reached, exiting.", DBRETRYLIMIT); + if (s->dbretrycount > DBRETRYLIMIT) { + snprintf(errorstring, 1024, "Database error retry limit of %d reached, exiting.", DBRETRYLIMIT); printe(PT_Error); errorexitdaemon(s, 1); } -- 2.40.0