mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
Terminate if S3 buffer is not finalized
This commit is contained in:
parent
9be17ef50c
commit
98e3b16560
@ -152,6 +152,13 @@ void WriteBufferFromS3::allocateBuffer()
|
||||
|
||||
WriteBufferFromS3::~WriteBufferFromS3()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if (!is_finalized.load(std::memory_order_relaxed))
|
||||
{
|
||||
LOG_ERROR(log, "WriteBufferFromS3 is not finalized in destructor. It's a bug");
|
||||
std::terminate();
|
||||
}
|
||||
#else
|
||||
try
|
||||
{
|
||||
finalize();
|
||||
@ -160,6 +167,7 @@ WriteBufferFromS3::~WriteBufferFromS3()
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool WriteBufferFromS3::cacheEnabled() const
|
||||
@ -193,6 +201,8 @@ void WriteBufferFromS3::finalizeImpl()
|
||||
|
||||
if (!multipart_upload_id.empty())
|
||||
completeMultipartUpload();
|
||||
|
||||
is_finalized.store(true, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void WriteBufferFromS3::createMultipartUpload()
|
||||
|
@ -47,7 +47,7 @@ class WriteBufferFromFile;
|
||||
class WriteBufferFromS3 final : public BufferWithOwnMemory<WriteBuffer>
|
||||
{
|
||||
public:
|
||||
explicit WriteBufferFromS3(
|
||||
WriteBufferFromS3(
|
||||
std::shared_ptr<Aws::S3::S3Client> client_ptr_,
|
||||
const String & bucket_,
|
||||
const String & key_,
|
||||
@ -105,6 +105,7 @@ private:
|
||||
std::vector<String> part_tags;
|
||||
|
||||
bool is_prefinalized = false;
|
||||
std::atomic<bool> is_finalized = false;
|
||||
|
||||
/// Following fields are for background uploads in thread pool (if specified).
|
||||
/// We use std::function to avoid dependency of Interpreters
|
||||
|
Loading…
Reference in New Issue
Block a user