diff options
author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2025-10-09 15:48:28 +0100 |
---|---|---|
committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2025-10-09 15:48:28 +0100 |
commit | 1a9440ec3c1669c5e49825dde70b9cbede3f0de0 (patch) | |
tree | 20269be529b17fb578fa305d7603cc3badf7c003 /src/ingestor.hpp | |
parent | a7a082d8d471bc38f9aa1160b0e9f8daf3d35ba3 (diff) | |
download | webstat-1a9440ec3c1669c5e49825dde70b9cbede3f0de0.tar.bz2 webstat-1a9440ec3c1669c5e49825dde70b9cbede3f0de0.tar.xz webstat-1a9440ec3c1669c5e49825dde70b9cbede3f0de0.zip |
Fix premature remembering of saved entity idswebstat-0.2.1
Don't persist entity ids saved to the DB until the transaction is
committed. Prevents the issue where a later DB operation fails, the
transaction is rolled back, but we still think the entity has been
saved.
Diffstat (limited to 'src/ingestor.hpp')
-rw-r--r-- | src/ingestor.hpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ingestor.hpp b/src/ingestor.hpp index a20071e..8be7360 100644 --- a/src/ingestor.hpp +++ b/src/ingestor.hpp @@ -60,13 +60,15 @@ namespace WebStat { size_t linesParsed = 0; size_t linesDiscarded = 0; size_t linesParked = 0; + mutable std::flat_set<Crc32Value> existingEntities; using JobLastRunTime = std::chrono::system_clock::time_point; JobLastRunTime lastRunIngestParkedLines; private: static constexpr size_t MAX_NEW_ENTITIES = 6; - void storeEntities(DB::Connection *, std::span<const std::optional<Entity>>) const; + using NewEntityIds = std::array<std::optional<Crc32Value>, MAX_NEW_ENTITIES>; + NewEntityIds storeEntities(DB::Connection *, std::span<const std::optional<Entity>>) const; using NewEntities = std::array<std::optional<Entity>, MAX_NEW_ENTITIES>; template<typename... T> NewEntities newEntities(const std::tuple<T...> &) const; void handleCurlOperations(); @@ -75,7 +77,6 @@ namespace WebStat { void jobIngestParkedLine(const std::filesystem::path &, uintmax_t size); using CurlOperations = std::map<CURL *, std::unique_ptr<CurlOperation>>; - mutable std::flat_set<Crc32Value> existingEntities; uint32_t hostnameId; CurlMultiPtr curl; mutable CurlOperations curlOperations; |