]> granicus.if.org Git - vnstat/commitdiff
log warning also when Write-Ahead Logging checkpoint is slow
authorTeemu Toivola <git@humdi.net>
Mon, 13 May 2019 20:55:47 +0000 (23:55 +0300)
committerTeemu Toivola <git@humdi.net>
Mon, 13 May 2019 20:55:47 +0000 (23:55 +0300)
src/common.h
src/daemon.c
src/dbsql.c

index 15abcc8c5284565676d06001e7a1da878b483cb5..1948c43b98f133a0d3ec394a6cf8d28a9847fb77 100644 (file)
@@ -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 */
index d02de15ff6d6edb0d6fef2119cf202c5538f62f0..63e49a8629e6093248a9b1f1bc2cf803333c919e 100644 (file)
@@ -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);
        }
index 584ccf07d02302b0d1cb2a71cdb719e07e3be5e7..90a36e093d7757a17154bbebe992de7b6a44ae1b 100644 (file)
@@ -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