**How to reproduce**
https://clickhouse-test-reports.s3.yandex.net/0/78c56b891383288cf3a893139e796fc87476412e/stress_test_(debug).html

**Error message and/or stacktrace**
```
2021.03.19 18:11:31.553554 [ 276 ] {} <Fatal> BaseDaemon: (version 21.4.1.6293 (official build), build id: 859E400E1C65C4702FE491420741DD8B58190002) (from thread 17469) Terminate called for uncaught exception:
2021.03.19 18:11:31.698961 [ 80145 ] {} <Fatal> BaseDaemon: ########################################
2021.03.19 18:11:31.699903 [ 80145 ] {} <Fatal> BaseDaemon: (version 21.4.1.6293 (official build), build id: 859E400E1C65C4702FE491420741DD8B58190002) (from thread 17469) (no query) Received signal Aborted (6)
2021.03.19 18:11:31.712523 [ 80145 ] {} <Fatal> BaseDaemon: 
2021.03.19 18:11:31.712778 [ 80145 ] {} <Fatal> BaseDaemon: Stack trace: 0x7f2b3b19e18b 0x7f2b3b17d859 0x11bf0c24 0x21e9b462 0x21e9b3a2 0x119440cf 0x1be77038 0x1bddd7c9 0x1bddd79d 0x1bddd76d 0x1bddd525 0x119490ed 0x1194908f 0x1bdd75fc 0x1bdf6bd5 0x1bdf653f 0x1be6d689 0x1f908b4c 0x1f909350 0x1fa45af3 0x1fa4297d 0x1fa41808 0x7f2b3b353609 0x7f2b3b27a293
2021.03.19 18:11:31.713591 [ 80145 ] {} <Fatal> BaseDaemon: 4. gsignal @ 0x4618b in /usr/lib/x86_64-linux-gnu/libc-2.31.so
2021.03.19 18:11:31.713825 [ 80145 ] {} <Fatal> BaseDaemon: 5. abort @ 0x25859 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
2021.03.19 18:11:32.396951 [ 80145 ] {} <Fatal> BaseDaemon: 6. ./obj-x86_64-linux-gnu/../base/daemon/BaseDaemon.cpp:435: terminate_handler() @ 0x11bf0c24 in /usr/bin/clickhouse
2021.03.19 18:11:32.511904 [ 80145 ] {} <Fatal> BaseDaemon: 7. ./obj-x86_64-linux-gnu/../contrib/libcxxabi/src/cxa_handlers.cpp:59: std::__terminate(void (*)()) @ 0x21e9b462 in /usr/bin/clickhouse
2021.03.19 18:11:32.614075 [ 80145 ] {} <Fatal> BaseDaemon: 8. ./obj-x86_64-linux-gnu/../contrib/libcxxabi/src/cxa_handlers.cpp:89: std::terminate() @ 0x21e9b3a2 in /usr/bin/clickhouse
2021.03.19 18:11:43.686790 [ 80145 ] {} <Fatal> BaseDaemon: 9. ? @ 0x119440cf in /usr/bin/clickhouse
2021.03.19 18:11:43.831215 [ 80145 ] {} <Fatal> BaseDaemon: 10. ./obj-x86_64-linux-gnu/../src/Server/HTTP/WriteBufferFromHTTPServerResponse.cpp:201: ? @ 0x1be77038 in /usr/bin/clickhouse
2021.03.19 18:11:44.743193 [ 80145 ] {} <Fatal> BaseDaemon: 11. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:892: std::__1::allocator<DB::WriteBufferFromHTTPServerResponse>::destroy(DB::WriteBufferFromHTTPServerResponse*) @ 0x1bddd7c9 in /usr/bin/clickhouse
2021.03.19 18:11:45.283905 [ 80145 ] {} <Fatal> BaseDaemon: 12. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:541: void std::__1::allocator_traits<std::__1::allocator<DB::WriteBufferFromHTTPServerResponse> >::__destroy<DB::WriteBufferFromHTTPServerResponse>(std::__1::integral_constant<bool, true>, std::__1::allocator<DB::WriteBufferFromHTTPServerResponse>&, DB::WriteBufferFromHTTPServerResponse*) @ 0x1bddd79d in /usr/bin/clickhouse
2021.03.19 18:11:45.805233 [ 80145 ] {} <Fatal> BaseDaemon: 13. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:487: void std::__1::allocator_traits<std::__1::allocator<DB::WriteBufferFromHTTPServerResponse> >::destroy<DB::WriteBufferFromHTTPServerResponse>(std::__1::allocator<DB::WriteBufferFromHTTPServerResponse>&, DB::WriteBufferFromHTTPServerResponse*) @ 0x1bddd76d in /usr/bin/clickhouse
2021.03.19 18:11:46.351371 [ 80145 ] {} <Fatal> BaseDaemon: 14. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2611: std::__1::__shared_ptr_emplace<DB::WriteBufferFromHTTPServerResponse, std::__1::allocator<DB::WriteBufferFromHTTPServerResponse> >::__on_zero_shared() @ 0x1bddd525 in /usr/bin/clickhouse
2021.03.19 18:11:46.579263 [ 80145 ] {} <Fatal> BaseDaemon: 15. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2476: std::__1::__shared_count::__release_shared() @ 0x119490ed in /usr/bin/clickhouse
2021.03.19 18:11:46.790912 [ 80145 ] {} <Fatal> BaseDaemon: 16. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2517: std::__1::__shared_weak_count::__release_shared() @ 0x1194908f in /usr/bin/clickhouse
2021.03.19 18:11:47.277990 [ 80145 ] {} <Fatal> BaseDaemon: 17. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3213: std::__1::shared_ptr<DB::WriteBufferFromHTTPServerResponse>::~shared_ptr() @ 0x1bdd75fc in /usr/bin/clickhouse
2021.03.19 18:11:47.649213 [ 80145 ] {} <Fatal> BaseDaemon: 18. ./obj-x86_64-linux-gnu/../src/Server/InterserverIOHTTPHandler.h:34: DB::InterserverIOHTTPHandler::Output::~Output() @ 0x1bdf6bd5 in /usr/bin/clickhouse
2021.03.19 18:11:47.921556 [ 80145 ] {} <Fatal> BaseDaemon: 19. ./obj-x86_64-linux-gnu/../src/Server/InterserverIOHTTPHandler.cpp:154: DB::InterserverIOHTTPHandler::handleRequest(DB::HTTPServerRequest&, DB::HTTPServerResponse&) @ 0x1bdf653f in /usr/bin/clickhouse
2021.03.19 18:11:48.167299 [ 80145 ] {} <Fatal> BaseDaemon: 20. ./obj-x86_64-linux-gnu/../src/Server/HTTP/HTTPServerConnection.cpp:48: DB::HTTPServerConnection::run() @ 0x1be6d689 in /usr/bin/clickhouse
2021.03.19 18:11:48.262424 [ 80145 ] {} <Fatal> BaseDaemon: 21. ./obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerConnection.cpp:43: Poco::Net::TCPServerConnection::start() @ 0x1f908b4c in /usr/bin/clickhouse
2021.03.19 18:11:48.416253 [ 80145 ] {} <Fatal> BaseDaemon: 22. ./obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerDispatcher.cpp:113: Poco::Net::TCPServerDispatcher::run() @ 0x1f909350 in /usr/bin/clickhouse
2021.03.19 18:11:48.586800 [ 80145 ] {} <Fatal> BaseDaemon: 23. ./obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/ThreadPool.cpp:199: Poco::PooledThread::run() @ 0x1fa45af3 in /usr/bin/clickhouse
2021.03.19 18:11:48.737683 [ 80145 ] {} <Fatal> BaseDaemon: 24. ./obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread.cpp:56: Poco::(anonymous namespace)::RunnableHolder::run() @ 0x1fa4297d in /usr/bin/clickhouse
2021.03.19 18:11:49.178522 [ 80145 ] {} <Fatal> BaseDaemon: 25. ./obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread_POSIX.cpp:345: Poco::ThreadImpl::runnableEntry(void*) @ 0x1fa41808 in /usr/bin/clickhouse
2021.03.19 18:11:49.178785 [ 80145 ] {} <Fatal> BaseDaemon: 26. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
2021.03.19 18:11:49.178975 [ 80145 ] {} <Fatal> BaseDaemon: 27. __clone @ 0x122293 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
2021.03.19 18:11:50.333544 [ 80145 ] {} <Fatal> BaseDaemon: Checksum of the binary: 90D89256F0C44AD22CDAF28455F993EC, integrity check passed.
2021.03.19 18:11:54.457906 [ 274 ] {} <Fatal> Application: Child process was terminated by signal 6.
```

std::shared_ptr<Aws::S3::S3Client> client_ptr_,
    const String & bucket_,
    const String & key_,
    size_t minimum_upload_part_size_,
    size_t max_single_part_upload_size_,
    std::optional<std::map<String, String>> object_metadata_,
    size_t buffer_size_)
    : BufferWithOwnMemory<WriteBuffer>(buffer_size_, nullptr, 0)
    , bucket(bucket_)
    , key(key_)
    , object_metadata(std::move(object_metadata_))
    , client_ptr(std::move(client_ptr_))
    , minimum_upload_part_size(minimum_upload_part_size_)
    , max_single_part_upload_size(max_single_part_upload_size_)
{
    allocateBuffer();
}
void WriteBufferFromS3::nextImpl()