From 3e99d080b2a3a9b6eae85ae9e3224534744ad7b9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 30 Sep 2025 00:50:29 +0100 Subject: Write log lines to files on error We call this parking, later we can reattempt ingestion after whatever caused the failure has been fixed. --- src/ingestor.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/ingestor.cpp') 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 #include +#include #include #include #include @@ -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 Ingestor::NewEntities Ingestor::newEntities(const std::tuple & values) const -- cgit v1.2.3