diff options
| author | Dan Engelbrecht <[email protected]> | 2023-04-27 14:18:18 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-27 14:18:18 +0200 |
| commit | e6a82b1438dce4e62f605ee74cf8e1d6c932d59c (patch) | |
| tree | 60be84d99f1fe4eec94d13c73f0c1a25119c312a | |
| parent | v0.2.7 (diff) | |
| download | zen-e6a82b1438dce4e62f605ee74cf8e1d6c932d59c.tar.xz zen-e6a82b1438dce4e62f605ee74cf8e1d6c932d59c.zip | |
bugfixes (#261)
* Don't try to GC if now blocks to GC was found, regardless if we have locations in memory
* Don't let exception leak from scope guard as throw in destructor will abort application
* changelog
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | zencore/include/zencore/scopeguard.h | 12 | ||||
| -rw-r--r-- | zenstore/blockstore.cpp | 5 |
3 files changed, 20 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 985248c77..e8da122a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ ## +- Bugfix: Verify that there are blocks to GC for block store garbage collect (void division by zero) +- Bugfix: Log ERROR in scope guard if function throws exception, throwing exception causes application abort + +## 0.2.7 - Bugfix: Safely handle missing blocks when doing garbage collection in block store data - Bugfix: Only strip uri accept type suffix if it can be parsed to a known type - Bugfix: Keep system error code on Windows when file mapping fails and propagate to log/exception diff --git a/zencore/include/zencore/scopeguard.h b/zencore/include/zencore/scopeguard.h index 13fed4ac5..d04c8ed9c 100644 --- a/zencore/include/zencore/scopeguard.h +++ b/zencore/include/zencore/scopeguard.h @@ -3,6 +3,7 @@ #pragma once #include <type_traits> +#include "logging.h" #include "zencore.h" namespace zen { @@ -15,7 +16,16 @@ public: ~ScopeGuardImpl() { if (!m_dismissed) - m_guardFunc(); + { + try + { + m_guardFunc(); + } + catch (std::exception& Ex) + { + ZEN_ERROR("scope guard threw exception: '{}'", Ex.what()); + } + } } void Dismiss() { m_dismissed = true; } diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp index 2894244fe..9738df729 100644 --- a/zenstore/blockstore.cpp +++ b/zenstore/blockstore.cpp @@ -353,6 +353,11 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot, }); size_t BlockCount = Snapshot.BlockCount; + if (BlockCount == 0) + { + ZEN_DEBUG("garbage collect for '{}' SKIPPED, no blocks to process", m_BlocksBasePath); + return; + } std::unordered_set<size_t> KeepChunkMap; KeepChunkMap.reserve(KeepChunkIndexes.size()); |