Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Common/MemoryTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace
///
/// - when it is explicitly blocked with LockExceptionInThread
///
/// - to avoid std::terminate(), when stack unwinding is current in progress in
/// this thread.
/// - to avoid std::terminate(), when stack unwinding is currently in progress
/// in this thread.
///
/// NOTE: that since C++11 destructor marked with noexcept by default, and
/// this means that any throw from destructor (that is not marked with
Expand Down
2 changes: 1 addition & 1 deletion src/Common/ZooKeeper/IKeeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class Exception : public DB::Exception
class IKeeper
{
public:
virtual ~IKeeper() {}
virtual ~IKeeper() = default;

/// If expired, you can only destroy the object. All other methods will throw exception.
virtual bool isExpired() const = 0;
Expand Down
12 changes: 4 additions & 8 deletions src/Compression/CompressedWriteBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <Compression/CompressionFactory.h>

#include <Common/MemorySanitizer.h>
#include <Common/MemoryTracker.h>


namespace DB
Expand Down Expand Up @@ -49,14 +50,9 @@ CompressedWriteBuffer::CompressedWriteBuffer(

CompressedWriteBuffer::~CompressedWriteBuffer()
{
try
{
next();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;
next();
}

}
2 changes: 1 addition & 1 deletion src/DataStreams/IBlockOutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class IBlockOutputStream : private boost::noncopyable
*/
virtual std::string getContentType() const { return "text/plain; charset=UTF-8"; }

virtual ~IBlockOutputStream() {}
virtual ~IBlockOutputStream() = default;

/** Don't let to alter table while instance of stream is alive.
*/
Expand Down
24 changes: 9 additions & 15 deletions src/IO/AsynchronousWriteBuffer.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#pragma once

#include <math.h>

#include <vector>

#include <Common/ThreadPool.h>
#include <Common/MemoryTracker.h>
#include <IO/WriteBuffer.h>


Expand Down Expand Up @@ -53,18 +51,14 @@ class AsynchronousWriteBuffer : public WriteBuffer

~AsynchronousWriteBuffer() override
{
try
{
if (started)
pool.wait();

swapBuffers();
out.next();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;

if (started)
pool.wait();

swapBuffers();
out.next();
}

/// That is executed in a separate thread
Expand Down
13 changes: 5 additions & 8 deletions src/IO/BrotliWriteBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# include <IO/BrotliWriteBuffer.h>
# include <brotli/encode.h>

#include <Common/MemoryTracker.h>

namespace DB
{

Expand Down Expand Up @@ -47,14 +49,9 @@ BrotliWriteBuffer::BrotliWriteBuffer(std::unique_ptr<WriteBuffer> out_, int comp

BrotliWriteBuffer::~BrotliWriteBuffer()
{
try
{
finish();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;
finish();
}

void BrotliWriteBuffer::nextImpl()
Expand Down
13 changes: 4 additions & 9 deletions src/IO/HexWriteBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <common/types.h>
#include <Common/hex.h>
#include <Common/Exception.h>
#include <Common/MemoryTracker.h>
#include <IO/HexWriteBuffer.h>


Expand All @@ -22,14 +22,9 @@ void HexWriteBuffer::nextImpl()

HexWriteBuffer::~HexWriteBuffer()
{
try
{
nextImpl();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;
nextImpl();
}

}
2 changes: 1 addition & 1 deletion src/IO/IReadableWriteBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct IReadableWriteBuffer
return getReadBufferImpl();
}

virtual ~IReadableWriteBuffer() {}
virtual ~IReadableWriteBuffer() = default;

protected:

Expand Down
14 changes: 5 additions & 9 deletions src/IO/LZMADeflatingWriteBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <IO/LZMADeflatingWriteBuffer.h>
#include <Common/MemoryTracker.h>

#if !defined(ARCADIA_BUILD)

Expand Down Expand Up @@ -48,16 +49,11 @@ LZMADeflatingWriteBuffer::LZMADeflatingWriteBuffer(

LZMADeflatingWriteBuffer::~LZMADeflatingWriteBuffer()
{
try
{
finish();
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;

lzma_end(&lstr);
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
finish();
lzma_end(&lstr);
}

void LZMADeflatingWriteBuffer::nextImpl()
Expand Down
13 changes: 5 additions & 8 deletions src/IO/WriteBufferFromFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <errno.h>

#include <Common/ProfileEvents.h>
#include <Common/MemoryTracker.h>

#include <IO/WriteBufferFromFile.h>
#include <IO/WriteHelpers.h>
Expand Down Expand Up @@ -77,14 +78,10 @@ WriteBufferFromFile::~WriteBufferFromFile()
if (fd < 0)
return;

try
{
next();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;

next();

::close(fd);
}
Expand Down
17 changes: 8 additions & 9 deletions src/IO/WriteBufferFromFileDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <Common/ProfileEvents.h>
#include <Common/CurrentMetrics.h>
#include <Common/Stopwatch.h>
#include <Common/MemoryTracker.h>

#include <IO/WriteBufferFromFileDescriptor.h>
#include <IO/WriteHelpers.h>
Expand Down Expand Up @@ -90,17 +91,15 @@ WriteBufferFromFileDescriptor::WriteBufferFromFileDescriptor(

WriteBufferFromFileDescriptor::~WriteBufferFromFileDescriptor()
{
try
if (fd < 0)
{
if (fd >= 0)
next();
else
assert(!offset() && "attempt to write after close");
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
assert(!offset() && "attempt to write after close");
return;
}

/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;
next();
}


Expand Down
12 changes: 4 additions & 8 deletions src/IO/WriteBufferFromHTTPServerResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <Common/Exception.h>
#include <Common/NetException.h>
#include <Common/Stopwatch.h>
#include <Common/MemoryTracker.h>

#if !defined(ARCADIA_BUILD)
# include <Common/config.h>
Expand Down Expand Up @@ -206,14 +207,9 @@ void WriteBufferFromHTTPServerResponse::finalize()

WriteBufferFromHTTPServerResponse::~WriteBufferFromHTTPServerResponse()
{
try
{
finalize();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;
finalize();
}

}
13 changes: 4 additions & 9 deletions src/IO/WriteBufferFromOStream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <IO/WriteBufferFromOStream.h>
#include <Common/Exception.h>
#include <Common/MemoryTracker.h>


namespace DB
Expand Down Expand Up @@ -42,14 +42,9 @@ WriteBufferFromOStream::WriteBufferFromOStream(

WriteBufferFromOStream::~WriteBufferFromOStream()
{
try
{
next();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;
next();
}

}
12 changes: 4 additions & 8 deletions src/IO/WriteBufferFromPocoSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <Common/Exception.h>
#include <Common/NetException.h>
#include <Common/Stopwatch.h>
#include <Common/MemoryTracker.h>


namespace ProfileEvents
Expand Down Expand Up @@ -70,14 +71,9 @@ WriteBufferFromPocoSocket::WriteBufferFromPocoSocket(Poco::Net::Socket & socket_

WriteBufferFromPocoSocket::~WriteBufferFromPocoSocket()
{
try
{
next();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;
next();
}

}
12 changes: 4 additions & 8 deletions src/IO/WriteBufferFromS3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# include <IO/WriteBufferFromS3.h>
# include <IO/WriteHelpers.h>
# include <Common/MemoryTracker.h>

# include <aws/s3/S3Client.h>
# include <aws/s3/model/CreateMultipartUploadRequest.h>
Expand Down Expand Up @@ -78,6 +79,8 @@ void WriteBufferFromS3::nextImpl()

void WriteBufferFromS3::finalize()
{
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;
finalizeImpl();
}

Expand All @@ -104,14 +107,7 @@ void WriteBufferFromS3::finalizeImpl()

WriteBufferFromS3::~WriteBufferFromS3()
{
try
{
finalizeImpl();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
finalizeImpl();
}

void WriteBufferFromS3::createMultipartUpload()
Expand Down
12 changes: 4 additions & 8 deletions src/IO/WriteBufferFromVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <vector>

#include <IO/WriteBuffer.h>
#include <Common/MemoryTracker.h>


namespace DB
Expand Down Expand Up @@ -93,14 +94,9 @@ class WriteBufferFromVector : public WriteBuffer

~WriteBufferFromVector() override
{
try
{
finalize();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
/// FIXME move final flush into the caller
MemoryTracker::LockExceptionInThread lock;
finalize();
}
};

Expand Down
Loading