diff options
| author | Dan Engelbrecht <[email protected]> | 2023-10-02 12:00:00 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-02 12:00:00 +0200 |
| commit | 0abf7994e8913c19360a0f0b8527495c0f99de87 (patch) | |
| tree | a9a0338d69a95a6f20d9634a2a0e9f5b1595b639 /src/zencore/except.cpp | |
| parent | Limit size of memory cache layer (#423) (diff) | |
| download | zen-0abf7994e8913c19360a0f0b8527495c0f99de87.tar.xz zen-0abf7994e8913c19360a0f0b8527495c0f99de87.zip | |
Handle OOM and OOD more gracefully to not spam Sentry with error reports (#434)
- Improvement: Catch Out Of Memory and Out Of Disk exceptions and report back to reqeuster without reporting an error to Sentry
- Improvement: If creating bucket fails when storing and item in the structured cache, log a warning and propagate error to requester without reporting an error to Sentry
- Improvement: Make an explicit flush of the active block written to in blockstore flush
- Improvement: Make sure cache and cas MakeIndexSnapshot does not throw exception on failure which would cause and abnormal termniation at exit
Diffstat (limited to 'src/zencore/except.cpp')
| -rw-r--r-- | src/zencore/except.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/zencore/except.cpp b/src/zencore/except.cpp index 65f5ebc62..f98743ea9 100644 --- a/src/zencore/except.cpp +++ b/src/zencore/except.cpp @@ -110,4 +110,62 @@ ThrowOutOfMemory(std::string_view Message) } #endif +#if ZEN_PLATFORM_WINDOWS +bool +IsOOM(const std::system_error& SystemError) +{ + switch (SystemError.code().value()) + { + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_OUTOFMEMORY: + case ERROR_PAGEFILE_QUOTA_EXCEEDED: + case ERROR_NONPAGED_SYSTEM_RESOURCES: + case ERROR_PAGED_SYSTEM_RESOURCES: + case ERROR_PAGEFILE_QUOTA: + case ERROR_COMMITMENT_LIMIT: + return true; + default: + return false; + } +} +bool +IsOOD(const std::system_error& SystemError) +{ + switch (SystemError.code().value()) + { + case ERROR_HANDLE_DISK_FULL: + case ERROR_DISK_FULL: + case ERROR_DISK_RESOURCES_EXHAUSTED: + case ERROR_DISK_QUOTA_EXCEEDED: + return true; + default: + return false; + } +} +#else +bool +IsOOM(const std::system_error& SystemError) +{ + switch (SystemError.code().value()) + { + case ENOMEM: + return true; + default: + return false; + } +} +bool +IsOOD(const std::system_error& SystemError) +{ + switch (SystemError.code().value()) + { + case ENOSPC: + case EDQUOT: + return true; + default: + return false; + } +} +#endif + } // namespace zen |