Merge pull request #36857 from ClickHouse/dont_finalize_s3_buffer

Terminate if S3 buffer is not finalized
This commit is contained in:
alesapin 2022-05-11 00:57:10 +02:00 committed by GitHub
commit 5c725fe77c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -151,6 +151,13 @@ void WriteBufferFromS3::allocateBuffer()
WriteBufferFromS3::~WriteBufferFromS3()
{
#ifndef NDEBUG
if (!is_finalized)
{
LOG_ERROR(log, "WriteBufferFromS3 is not finalized in destructor. It's a bug");
std::terminate();
}
#else
try
{
finalize();
@ -159,6 +166,7 @@ WriteBufferFromS3::~WriteBufferFromS3()
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
#endif
}
bool WriteBufferFromS3::cacheEnabled() const
@ -192,6 +200,8 @@ void WriteBufferFromS3::finalizeImpl()
if (!multipart_upload_id.empty())
completeMultipartUpload();
is_finalized = true;
}
void WriteBufferFromS3::createMultipartUpload()

View File

@ -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;
bool is_finalized = false;
/// Following fields are for background uploads in thread pool (if specified).
/// We use std::function to avoid dependency of Interpreters