mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 11:02:08 +00:00
fix WriteBufferFromFileDecorator cancelation
This commit is contained in:
parent
19bafb5063
commit
90231e302e
@ -20,7 +20,7 @@ WriteBuffer::~WriteBuffer()
|
||||
LoggerPtr log = getLogger("WriteBuffer");
|
||||
LOG_ERROR(
|
||||
log,
|
||||
"WriteBuffer is not finalized when destructor is called. "
|
||||
"WriteBuffer is neither finalized nor canceled when destructor is called. "
|
||||
"No exceptions in flight are detected. "
|
||||
"The file might not be written at all or might be truncated. "
|
||||
"Stack trace: {}",
|
||||
|
@ -59,6 +59,9 @@ public:
|
||||
*/
|
||||
pos = working_buffer.begin();
|
||||
bytes += bytes_in_buffer;
|
||||
|
||||
cancel();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
@ -133,28 +136,21 @@ public:
|
||||
catch (...)
|
||||
{
|
||||
pos = working_buffer.begin();
|
||||
finalized = true;
|
||||
|
||||
cancel();
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void cancel()
|
||||
void cancel() noexcept
|
||||
{
|
||||
if (canceled || finalized)
|
||||
return;
|
||||
|
||||
LockMemoryExceptionInThread lock(VariableContext::Global);
|
||||
try
|
||||
{
|
||||
cancelImpl();
|
||||
canceled = true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
pos = working_buffer.begin();
|
||||
canceled = true;
|
||||
throw;
|
||||
}
|
||||
cancelImpl();
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
/// Wait for data to be reliably written. Mainly, call fsync for fd.
|
||||
@ -172,7 +168,7 @@ protected:
|
||||
next();
|
||||
}
|
||||
|
||||
virtual void cancelImpl()
|
||||
virtual void cancelImpl() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void cancelImpl() override
|
||||
void cancelImpl() noexcept override
|
||||
{
|
||||
out->cancel();
|
||||
}
|
||||
|
@ -28,6 +28,12 @@ void WriteBufferFromFileDecorator::finalizeImpl()
|
||||
}
|
||||
}
|
||||
|
||||
void WriteBufferFromFileDecorator::cancelImpl() noexcept
|
||||
{
|
||||
SwapHelper swap(*this, *impl);
|
||||
impl->cancel();
|
||||
}
|
||||
|
||||
WriteBufferFromFileDecorator::~WriteBufferFromFileDecorator()
|
||||
{
|
||||
/// It is not a mistake that swap is called here
|
||||
|
@ -24,6 +24,8 @@ public:
|
||||
protected:
|
||||
void finalizeImpl() override;
|
||||
|
||||
void cancelImpl() noexcept override;
|
||||
|
||||
std::unique_ptr<WriteBuffer> impl;
|
||||
|
||||
private:
|
||||
|
@ -224,7 +224,7 @@ void WriteBufferFromS3::finalizeImpl()
|
||||
}
|
||||
}
|
||||
|
||||
void WriteBufferFromS3::cancelImpl()
|
||||
void WriteBufferFromS3::cancelImpl() noexcept
|
||||
{
|
||||
tryToAbortMultipartUpload();
|
||||
}
|
||||
@ -251,7 +251,7 @@ String WriteBufferFromS3::getShortLogDetails() const
|
||||
bucket, key, multipart_upload_details);
|
||||
}
|
||||
|
||||
void WriteBufferFromS3::tryToAbortMultipartUpload()
|
||||
void WriteBufferFromS3::tryToAbortMultipartUpload() noexcept
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ private:
|
||||
/// Receives response from the server after sending all data.
|
||||
void finalizeImpl() override;
|
||||
|
||||
void cancelImpl() override;
|
||||
void cancelImpl() noexcept override;
|
||||
|
||||
String getVerboseLogDetails() const;
|
||||
String getShortLogDetails() const;
|
||||
@ -73,7 +73,7 @@ private:
|
||||
void createMultipartUpload();
|
||||
void completeMultipartUpload();
|
||||
void abortMultipartUpload();
|
||||
void tryToAbortMultipartUpload();
|
||||
void tryToAbortMultipartUpload() noexcept;
|
||||
|
||||
S3::PutObjectRequest getPutRequest(PartData & data);
|
||||
void makeSinglepartUpload(PartData && data);
|
||||
|
Loading…
Reference in New Issue
Block a user