mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 13:32:13 +00:00
Merge pull request #23086 from azat/memory-blocking
Block all memory tracking limits in dtors/SCOPE_EXIT_*SAFE/tryLogCurrentException
This commit is contained in:
commit
69eac517b6
@ -12,7 +12,8 @@
|
|||||||
///
|
///
|
||||||
/// NOTE: it should be used with caution.
|
/// NOTE: it should be used with caution.
|
||||||
#define SCOPE_EXIT_MEMORY(...) SCOPE_EXIT( \
|
#define SCOPE_EXIT_MEMORY(...) SCOPE_EXIT( \
|
||||||
MemoryTracker::LockExceptionInThread lock_memory_tracker; \
|
MemoryTracker::LockExceptionInThread \
|
||||||
|
lock_memory_tracker(VariableContext::Global); \
|
||||||
__VA_ARGS__; \
|
__VA_ARGS__; \
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,7 +57,8 @@
|
|||||||
#define SCOPE_EXIT_MEMORY_SAFE(...) SCOPE_EXIT( \
|
#define SCOPE_EXIT_MEMORY_SAFE(...) SCOPE_EXIT( \
|
||||||
try \
|
try \
|
||||||
{ \
|
{ \
|
||||||
MemoryTracker::LockExceptionInThread lock_memory_tracker; \
|
MemoryTracker::LockExceptionInThread \
|
||||||
|
lock_memory_tracker(VariableContext::Global); \
|
||||||
__VA_ARGS__; \
|
__VA_ARGS__; \
|
||||||
} \
|
} \
|
||||||
catch (...) \
|
catch (...) \
|
||||||
|
@ -150,7 +150,7 @@ void tryLogCurrentException(Poco::Logger * logger, const std::string & start_of_
|
|||||||
///
|
///
|
||||||
/// And in this case the exception will not be logged, so let's block the
|
/// And in this case the exception will not be logged, so let's block the
|
||||||
/// MemoryTracker until the exception will be logged.
|
/// MemoryTracker until the exception will be logged.
|
||||||
MemoryTracker::LockExceptionInThread lock_memory_tracker;
|
MemoryTracker::LockExceptionInThread lock_memory_tracker(VariableContext::Global);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -24,8 +24,8 @@ namespace
|
|||||||
///
|
///
|
||||||
/// - when it is explicitly blocked with LockExceptionInThread
|
/// - when it is explicitly blocked with LockExceptionInThread
|
||||||
///
|
///
|
||||||
/// - to avoid std::terminate(), when stack unwinding is currently in progress
|
/// - when there are uncaught exceptions objects in the current thread
|
||||||
/// in this thread.
|
/// (to avoid std::terminate())
|
||||||
///
|
///
|
||||||
/// NOTE: that since C++11 destructor marked with noexcept by default, and
|
/// NOTE: that since C++11 destructor marked with noexcept by default, and
|
||||||
/// this means that any throw from destructor (that is not marked with
|
/// this means that any throw from destructor (that is not marked with
|
||||||
|
@ -50,7 +50,7 @@ BrotliWriteBuffer::BrotliWriteBuffer(std::unique_ptr<WriteBuffer> out_, int comp
|
|||||||
BrotliWriteBuffer::~BrotliWriteBuffer()
|
BrotliWriteBuffer::~BrotliWriteBuffer()
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ LZMADeflatingWriteBuffer::LZMADeflatingWriteBuffer(
|
|||||||
LZMADeflatingWriteBuffer::~LZMADeflatingWriteBuffer()
|
LZMADeflatingWriteBuffer::~LZMADeflatingWriteBuffer()
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
lzma_end(&lstr);
|
lzma_end(&lstr);
|
||||||
|
@ -79,7 +79,7 @@ WriteBufferFromFile::~WriteBufferFromFile()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
|
|
||||||
next();
|
next();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ WriteBufferFromFileDescriptor::~WriteBufferFromFileDescriptor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ WriteBufferFromOStream::WriteBufferFromOStream(
|
|||||||
WriteBufferFromOStream::~WriteBufferFromOStream()
|
WriteBufferFromOStream::~WriteBufferFromOStream()
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ WriteBufferFromPocoSocket::WriteBufferFromPocoSocket(Poco::Net::Socket & socket_
|
|||||||
WriteBufferFromPocoSocket::~WriteBufferFromPocoSocket()
|
WriteBufferFromPocoSocket::~WriteBufferFromPocoSocket()
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ void WriteBufferFromS3::allocateBuffer()
|
|||||||
void WriteBufferFromS3::finalize()
|
void WriteBufferFromS3::finalize()
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
finalizeImpl();
|
finalizeImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public:
|
|||||||
~WriteBufferFromVector() override
|
~WriteBufferFromVector() override
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
finalize();
|
finalize();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -138,7 +138,7 @@ void WriteBufferValidUTF8::finish()
|
|||||||
WriteBufferValidUTF8::~WriteBufferValidUTF8()
|
WriteBufferValidUTF8::~WriteBufferValidUTF8()
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ ZlibDeflatingWriteBuffer::ZlibDeflatingWriteBuffer(
|
|||||||
ZlibDeflatingWriteBuffer::~ZlibDeflatingWriteBuffer()
|
ZlibDeflatingWriteBuffer::~ZlibDeflatingWriteBuffer()
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ ZstdDeflatingWriteBuffer::ZstdDeflatingWriteBuffer(
|
|||||||
ZstdDeflatingWriteBuffer::~ZstdDeflatingWriteBuffer()
|
ZstdDeflatingWriteBuffer::~ZstdDeflatingWriteBuffer()
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ void ThreadStatus::finalizeQueryProfiler()
|
|||||||
|
|
||||||
void ThreadStatus::detachQuery(bool exit_if_already_detached, bool thread_exits)
|
void ThreadStatus::detachQuery(bool exit_if_already_detached, bool thread_exits)
|
||||||
{
|
{
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
|
|
||||||
if (exit_if_already_detached && thread_state == ThreadState::DetachedFromQuery)
|
if (exit_if_already_detached && thread_state == ThreadState::DetachedFromQuery)
|
||||||
{
|
{
|
||||||
|
@ -196,7 +196,7 @@ void WriteBufferFromHTTPServerResponse::finalize()
|
|||||||
WriteBufferFromHTTPServerResponse::~WriteBufferFromHTTPServerResponse()
|
WriteBufferFromHTTPServerResponse::~WriteBufferFromHTTPServerResponse()
|
||||||
{
|
{
|
||||||
/// FIXME move final flush into the caller
|
/// FIXME move final flush into the caller
|
||||||
MemoryTracker::LockExceptionInThread lock;
|
MemoryTracker::LockExceptionInThread lock(VariableContext::Global);
|
||||||
finalize();
|
finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user