aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/IO/WriteBuffer.cpp
diff options
context:
space:
mode:
authorvitalyisaev <vitalyisaev@ydb.tech>2023-11-14 09:58:56 +0300
committervitalyisaev <vitalyisaev@ydb.tech>2023-11-14 10:20:20 +0300
commitc2b2dfd9827a400a8495e172a56343462e3ceb82 (patch)
treecd4e4f597d01bede4c82dffeb2d780d0a9046bd0 /contrib/clickhouse/src/IO/WriteBuffer.cpp
parentd4ae8f119e67808cb0cf776ba6e0cf95296f2df7 (diff)
downloadydb-c2b2dfd9827a400a8495e172a56343462e3ceb82.tar.gz
YQ Connector: move tests from yql to ydb (OSS)
Перенос папки с тестами на Коннектор из папки yql в папку ydb (синхронизируется с github).
Diffstat (limited to 'contrib/clickhouse/src/IO/WriteBuffer.cpp')
-rw-r--r--contrib/clickhouse/src/IO/WriteBuffer.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/IO/WriteBuffer.cpp b/contrib/clickhouse/src/IO/WriteBuffer.cpp
new file mode 100644
index 0000000000..61fdd31e16
--- /dev/null
+++ b/contrib/clickhouse/src/IO/WriteBuffer.cpp
@@ -0,0 +1,33 @@
+#include "WriteBuffer.h"
+
+#include <Common/logger_useful.h>
+
+namespace DB
+{
+
+/// Calling finalize() in the destructor of derived classes is a bad practice.
+/// This causes objects to be left on the remote FS when a write operation is rolled back.
+/// Do call finalize() explicitly, before this call you have no guarantee that the file has been written
+WriteBuffer::~WriteBuffer()
+{
+ // That destructor could be call with finalized=false in case of exceptions
+ if (count() > 0 && !finalized)
+ {
+ /// It is totally OK to destroy instance without finalization when an exception occurs
+ /// However it is suspicious to destroy instance without finalization at the green path
+ if (!std::uncaught_exceptions() && std::current_exception() == nullptr)
+ {
+ Poco::Logger * log = &Poco::Logger::get("WriteBuffer");
+ LOG_ERROR(
+ log,
+ "WriteBuffer is not finalized when destructor is called. "
+ "No exceptions in flight are detected. "
+ "The file might not be written at all or might be truncated. "
+ "Stack trace: {}",
+ StackTrace().toString());
+ chassert(false && "WriteBuffer is not finalized in destructor.");
+ }
+ }
+}
+
+}