summaryrefslogtreecommitdiff
path: root/src/ingestor.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-09-30 00:50:29 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-09-30 00:50:29 +0100
commit3e99d080b2a3a9b6eae85ae9e3224534744ad7b9 (patch)
treea978222aed2f4e6f80d8fb934f993e7b5c895091 /src/ingestor.cpp
parent897546d596d8d7213cff60146123bb8f97d4d1cc (diff)
downloadwebstat-3e99d080b2a3a9b6eae85ae9e3224534744ad7b9.tar.bz2
webstat-3e99d080b2a3a9b6eae85ae9e3224534744ad7b9.tar.xz
webstat-3e99d080b2a3a9b6eae85ae9e3224534744ad7b9.zip
Write log lines to files on error
We call this parking, later we can reattempt ingestion after whatever caused the failure has been fixed.
Diffstat (limited to 'src/ingestor.cpp')
-rw-r--r--src/ingestor.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ingestor.cpp b/src/ingestor.cpp
index db11799..639eed0 100644
--- a/src/ingestor.cpp
+++ b/src/ingestor.cpp
@@ -4,6 +4,7 @@
#include "util.hpp"
#include <connection.h>
#include <dbTypes.h>
+#include <fstream>
#include <modifycommand.h>
#include <ranges>
#include <scn/scan.h>
@@ -148,7 +149,12 @@ namespace WebStat {
void
Ingestor::ingestLogLine(const std::string_view line)
{
- ingestLogLine(dbpool->get().get(), line);
+ try {
+ ingestLogLine(dbpool->get().get(), line);
+ }
+ catch (const std::exception &) {
+ parkLogLine(line);
+ }
}
void
@@ -171,6 +177,13 @@ namespace WebStat {
}
}
+ void
+ Ingestor::parkLogLine(std::string_view line)
+ {
+ std::ofstream {settings.fallbackDir / std::format("parked-{}.log", crc32(line))} << line;
+ linesParked++;
+ }
+
template<typename... T>
Ingestor::NewEntities
Ingestor::newEntities(const std::tuple<T...> & values) const