Merge pull request #23086 from azat/memory-blocking

Block all memory tracking limits in dtors/SCOPE_EXIT_*SAFE/tryLogCurrentException
This commit is contained in:
alexey-milovidov 2021-04-15 14:36:10 +03:00 committed by GitHub
commit 69eac517b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 20 additions and 18 deletions

View File

@ -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 (...) \

View File

@ -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
{ {

View File

@ -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

View File

@ -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();
} }

View File

@ -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);

View File

@ -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();

View File

@ -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();
} }

View File

@ -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();
} }

View File

@ -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();
} }

View File

@ -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();
} }

View File

@ -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();
} }
}; };

View File

@ -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();
} }

View File

@ -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();

View File

@ -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();

View File

@ -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)
{ {

View File

@ -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();
} }