aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-05-05 14:37:48 +0200
committerGitHub Enterprise <[email protected]>2025-05-05 14:37:48 +0200
commitf74d56510a19d693f9febb1a1686c2382a924dfb (patch)
treef1d116e65a8a9a0008c5ee5a54030944631a25c1 /src
parentiterate chunks crash fix (#376) (diff)
downloadzen-f74d56510a19d693f9febb1a1686c2382a924dfb.tar.xz
zen-f74d56510a19d693f9febb1a1686c2382a924dfb.zip
silence Out Of Disk errors to sentry (#378)
* block writing GC state/info if disk is full * fix if/else on error while writing gc state
Diffstat (limited to 'src')
-rw-r--r--src/zenstore/gc.cpp104
1 files changed, 56 insertions, 48 deletions
diff --git a/src/zenstore/gc.cpp b/src/zenstore/gc.cpp
index ac4dda83f..56d0e8db6 100644
--- a/src/zenstore/gc.cpp
+++ b/src/zenstore/gc.cpp
@@ -2538,7 +2538,11 @@ GcScheduler::CollectGarbage(const GcClock::TimePoint& CacheExpireTime,
ZEN_INFO("GCV2: {}", SB.ToView());
- AppendGCLog(GcId, GcStartTime, Settings, Result);
+ CheckDiskSpace();
+ if (!m_AreDiskWritesBlocked.load())
+ {
+ AppendGCLog(GcId, GcStartTime, Settings, Result);
+ }
if (SkipCid)
{
@@ -2580,65 +2584,69 @@ GcScheduler::CollectGarbage(const GcClock::TimePoint& CacheExpireTime,
m_LastFullGCDiff = Diff;
}
- for (uint32_t RetryCount = 0; RetryCount < 3; RetryCount++)
+ CheckDiskSpace();
+ if (!m_AreDiskWritesBlocked.load())
{
- if (RetryCount > 0)
+ for (uint32_t RetryCount = 0; RetryCount < 3; RetryCount++)
{
- ZEN_INFO("Writing GC state failed {} time(s), pausing and trying again", RetryCount);
- Sleep(250);
- }
- try
- {
- const fs::path Path = m_Config.RootDirectory / "gc_state";
- ZEN_DEBUG("saving scheduler state to '{}'", Path);
- CbObjectWriter SchedulerState;
- SchedulerState << "LastGcTime"sv << static_cast<int64_t>(m_LastGcTime.time_since_epoch().count());
- SchedulerState << "LastGcExpireTime"sv << static_cast<int64_t>(m_LastGcExpireTime.time_since_epoch().count());
- SchedulerState << "AttachmentPassIndex"sv << m_AttachmentPassIndex;
-
- SaveCompactBinaryObject(Path, SchedulerState.Save());
if (RetryCount > 0)
{
- ZEN_INFO("Writing GC state succeeded after {} attempts", RetryCount + 1);
- }
- break;
- }
- catch (const std::system_error& SystemError)
- {
- if (IsOOM(SystemError.code()))
- {
- ZEN_WARN("writing gc scheduler state ran out of memory: '{}'", SystemError.what());
+ ZEN_INFO("Writing GC state failed {} time(s), pausing and trying again", RetryCount);
+ Sleep(250);
}
- else if (IsOOD(SystemError.code()))
+ try
{
- ZEN_WARN("writing gc scheduler state ran out of disk space: '{}'", SystemError.what());
+ const fs::path Path = m_Config.RootDirectory / "gc_state";
+ ZEN_DEBUG("saving scheduler state to '{}'", Path);
+ CbObjectWriter SchedulerState;
+ SchedulerState << "LastGcTime"sv << static_cast<int64_t>(m_LastGcTime.time_since_epoch().count());
+ SchedulerState << "LastGcExpireTime"sv << static_cast<int64_t>(m_LastGcExpireTime.time_since_epoch().count());
+ SchedulerState << "AttachmentPassIndex"sv << m_AttachmentPassIndex;
+
+ SaveCompactBinaryObject(Path, SchedulerState.Save());
+ if (RetryCount > 0)
+ {
+ ZEN_INFO("Writing GC state succeeded after {} attempts", RetryCount + 1);
+ }
+ break;
}
- if (RetryCount == 0)
+ catch (const std::system_error& SystemError)
{
- ZEN_ERROR("writing gc scheduler state failed with system error exception: '{}' ({})",
- SystemError.what(),
- SystemError.code().value());
- }
- else
- {
- ZEN_WARN("writing gc scheduler state failed with system error exception: '{}' ({})",
- SystemError.what(),
- SystemError.code().value());
+ if (IsOOM(SystemError.code()))
+ {
+ ZEN_WARN("writing gc scheduler state ran out of memory: '{}'", SystemError.what());
+ }
+ else if (IsOOD(SystemError.code()))
+ {
+ ZEN_WARN("writing gc scheduler state ran out of disk space: '{}'", SystemError.what());
+ }
+ else if (RetryCount == 0)
+ {
+ ZEN_ERROR("writing gc scheduler state failed with system error exception: '{}' ({})",
+ SystemError.what(),
+ SystemError.code().value());
+ }
+ else
+ {
+ ZEN_WARN("writing gc scheduler state failed with system error exception: '{}' ({})",
+ SystemError.what(),
+ SystemError.code().value());
+ }
}
- }
- catch (const std::bad_alloc& BadAlloc)
- {
- ZEN_WARN("writing gc scheduler state ran out of memory: '{}'", BadAlloc.what());
- }
- catch (const std::exception& Ex)
- {
- if (RetryCount == 0)
+ catch (const std::bad_alloc& BadAlloc)
{
- ZEN_ERROR("writing gc scheduler state failed with: '{}'", Ex.what());
+ ZEN_WARN("writing gc scheduler state ran out of memory: '{}'", BadAlloc.what());
}
- else
+ catch (const std::exception& Ex)
{
- ZEN_WARN("writing gc scheduler state failed with: '{}'", Ex.what());
+ if (RetryCount == 0)
+ {
+ ZEN_ERROR("writing gc scheduler state failed with: '{}'", Ex.what());
+ }
+ else
+ {
+ ZEN_WARN("writing gc scheduler state failed with: '{}'", Ex.what());
+ }
}
}
}