Merge pull request #22208 from azat/s3-writer

This commit is contained in:
Vladimir 2021-04-26 10:31:45 +03:00 committed by GitHub
commit 3c48b88929
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 18 deletions

View File

@ -112,18 +112,6 @@ void WriteBufferFromS3::finalizeImpl()
finalized = true;
}
WriteBufferFromS3::~WriteBufferFromS3()
{
try
{
finalizeImpl();
}
catch (...)
{
tryLogCurrentException(log);
}
}
void WriteBufferFromS3::createMultipartUpload()
{
Aws::S3::Model::CreateMultipartUploadRequest req;

View File

@ -64,8 +64,6 @@ public:
/// Receives response from the server after sending all data.
void finalize() override;
~WriteBufferFromS3() override;
private:
bool finalized = false;

View File

@ -570,7 +570,16 @@ void TCPHandler::processInsertQuery(const Settings & connection_settings)
/// Send block to the client - table structure.
sendData(state.io.out->getHeader());
readData(connection_settings);
try
{
readData(connection_settings);
}
catch (...)
{
/// To avoid flushing from the destructor, that may lead to uncaught exception.
state.io.out->writeSuffix();
throw;
}
state.io.out->writeSuffix();
}

View File

@ -296,9 +296,18 @@ public:
void writeSuffix() override
{
writer->writeSuffix();
writer->flush();
write_buf->finalize();
try
{
writer->writeSuffix();
writer->flush();
write_buf->finalize();
}
catch (...)
{
/// Stop ParallelFormattingOutputFormat correctly.
writer.reset();
throw;
}
}
private:

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,7 @@
drop table if exists data_01832;
-- Memory writes from the writeSuffix() and if it will be called twice two rows
-- will be written (since it does not reset the block).
create table data_01832 (key Int) Engine=Memory;
insert into data_01832 values (1);
select * from data_01832;