]> granicus.if.org Git - vnstat/commitdiff
continue daemon process execution with data caching if database writes fail due to...
authorTeemu Toivola <git@humdi.net>
Sun, 19 May 2019 14:57:33 +0000 (17:57 +0300)
committerTeemu Toivola <git@humdi.net>
Sun, 19 May 2019 14:57:33 +0000 (17:57 +0300)
CHANGES
src/daemon.c
src/dbsql.c
src/dbsql.h

diff --git a/CHANGES b/CHANGES
index 42be9d7193efb977bf264e20721a8d1866b0f9bf..712291ea16f924efc9435e83b732104bb878dcf3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -19,6 +19,8 @@
    - Show warning in log if writing cached data to database is slow
    - Try database query for up to 5 seconds when database is busy or locked
      instead of giving up immediately
+   - Continue daemon process execution with data caching if database writes
+     fail due to disk being full
 
 
 2.2 / 28-Apr-2018
index 4d6876642ce156f096ee1dcf584d873b1727d3a1..e2042b65ae1a1fe05ad5bc369cf60e352c9bfd14 100644 (file)
@@ -705,11 +705,16 @@ void handledatabaseerror(DSTATE *s)
                printe(PT_Error);
                errorexitdaemon(s, 1);
        } else {
-               s->dbretrycount++;
-               if (s->dbretrycount >= DBRETRYLIMIT) {
-                       snprintf(errorstring, 1024, "Database error retry limit %d reached, exiting.", DBRETRYLIMIT);
+               if (db_isdiskfull(db_errcode)) {
+                       snprintf(errorstring, 1024, "Disk is full, continuing with data caching.");
                        printe(PT_Error);
-                       errorexitdaemon(s, 1);
+               } else {
+                       s->dbretrycount++;
+                       if (s->dbretrycount >= DBRETRYLIMIT) {
+                               snprintf(errorstring, 1024, "Database error retry limit %d reached, exiting.", DBRETRYLIMIT);
+                               printe(PT_Error);
+                               errorexitdaemon(s, 1);
+                       }
                }
        }
 }
index fcb892311a942603efbafed997b77ded815eef1e..0e3e979d319c1a390f7f01dc60ceee2860555804 100644 (file)
@@ -1075,6 +1075,15 @@ int db_iserrcodefatal(int errcode)
        }
 }
 
+int db_isdiskfull(int errcode)
+{
+       if (errcode == SQLITE_FULL) {
+               return 1;
+       } else {
+               return 0;
+       }
+}
+
 #if HAVE_DECL_SQLITE_CHECKPOINT_RESTART
 void db_walcheckpoint(void)
 {
index 03d138872a285e5af9a8cd7abcafda6fdb48d618..0c6df85223643d60cea2a581ca3e40ad7f71a37a 100644 (file)
@@ -64,6 +64,7 @@ int db_begintransaction(void);
 int db_committransaction(void);
 int db_rollbacktransaction(void);
 int db_iserrcodefatal(int errcode);
+int db_isdiskfull(int errcode);
 #if HAVE_DECL_SQLITE_CHECKPOINT_RESTART
 void db_walcheckpoint(void);
 #endif