From: Teemu Toivola Date: Mon, 13 May 2019 20:55:47 +0000 (+0300) Subject: log warning also when Write-Ahead Logging checkpoint is slow X-Git-Tag: v2.3~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36acf4b3e7e79bde3ce8cf5ff02051b76e51a1ce;p=vnstat log warning also when Write-Ahead Logging checkpoint is slow --- diff --git a/src/common.h b/src/common.h index 15abcc8..1948c43 100644 --- a/src/common.h +++ b/src/common.h @@ -233,7 +233,7 @@ and most can be changed later from the config file. #define IS64BIT -2 #define WALDB 0 #define WALDBCHECKPOINTINTERVALMINS 240 -#define SLOWDBFLUSHWARNLIMIT 3.0 +#define SLOWDBWARNLIMIT 4.0 // needs to be less than DBREADTIMEOUTSECS #define DBSYNCHRONOUS -1 /* database read timeout */ diff --git a/src/daemon.c b/src/daemon.c index d02de15..63e49a8 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -680,7 +680,7 @@ void flushcachetodisk(DSTATE *s) db_rollbacktransaction(); } used_secs = timeused(__func__, 0); - if (used_secs > SLOWDBFLUSHWARNLIMIT) { + if (used_secs > SLOWDBWARNLIMIT) { snprintf(errorstring, 1024, "Writing cached data to database took %.1f seconds.", used_secs); printe(PT_Warning); } diff --git a/src/dbsql.c b/src/dbsql.c index 584ccf0..90a36e0 100644 --- a/src/dbsql.c +++ b/src/dbsql.c @@ -1077,13 +1077,21 @@ int db_iserrcodefatal(int errcode) #if HAVE_DECL_SQLITE_CHECKPOINT_RESTART void db_walcheckpoint(void) { - timeused_debug(__func__, 1); + double used_secs = 0.0; + + timeused(__func__, 1); #if HAVE_DECL_SQLITE_CHECKPOINT_TRUNCATE sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_TRUNCATE, NULL, NULL); #else sqlite3_wal_checkpoint_v2(db, NULL, SQLITE_CHECKPOINT_RESTART, NULL, NULL); #endif - timeused_debug(__func__, 0); + timeused(__func__, 0); + + used_secs = timeused(__func__, 0); + if (used_secs > SLOWDBWARNLIMIT) { + snprintf(errorstring, 1024, "Write-Ahead Logging checkpoint took %.1f seconds.", used_secs); + printe(PT_Warning); + } } #endif