aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/logger
diff options
context:
space:
mode:
authorsrx64 <srx64@yandex-team.com>2023-03-28 12:46:21 +0300
committersrx64 <srx64@yandex-team.com>2023-03-28 12:46:21 +0300
commit3f83d0726c21640812b2c9db148af82ba9cba75a (patch)
treecee525b88caef044819ff0ae0b5395d7c5e44ca6 /library/cpp/logger
parentc270c8ce912c36e9639202e4cafa1fa5261c9925 (diff)
downloadydb-3f83d0726c21640812b2c9db148af82ba9cba75a.tar.gz
Fix memory leakage in TSyncPageCacheFileLogBackend
Memleak occurred when the storage was running out of space and a TFileError exception was thrown. In this case, the buffer was not cleared after writing.
Diffstat (limited to 'library/cpp/logger')
-rw-r--r--library/cpp/logger/sync_page_cache_file.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/library/cpp/logger/sync_page_cache_file.cpp b/library/cpp/logger/sync_page_cache_file.cpp
index 86cf0fff88..1424159af7 100644
--- a/library/cpp/logger/sync_page_cache_file.cpp
+++ b/library/cpp/logger/sync_page_cache_file.cpp
@@ -2,6 +2,7 @@
#include "record.h"
#include <util/generic/buffer.h>
+#include <util/generic/yexception.h>
#include <util/system/file.h>
#include <util/system/info.h>
#include <util/system/mutex.h>
@@ -74,10 +75,15 @@ private:
}
void Write() {
- File_.Write(Buffer_.Data(), Buffer_.Size());
- WrittenPtr_ += Buffer_.Size();
- PageAlignedWrittenPtr_ = AlignDown(WrittenPtr_, GetPageSize());
- Buffer_.Clear();
+ try {
+ File_.Write(Buffer_.Data(), Buffer_.Size());
+ WrittenPtr_ += Buffer_.Size();
+ PageAlignedWrittenPtr_ = AlignDown(WrittenPtr_, GetPageSize());
+ Buffer_.Clear();
+ } catch (TFileError&) {
+ Buffer_.Clear();
+ throw;
+ }
}
void FlushAsync(const i64 from, const i64 to) {