https://clickhouse-test-reports.s3.yandex.net/0/a70249f8f70aae1c00b6324afe1509ccef8be617/stress_test_(debug).html#fail1

```
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:32.738573 [ 2935 ] {d791e065-406e-49b7-86d4-587eb3f502c6} <Fatal> : Logical error: 'Block structure mismatch in Buffer stream: different number of columns:
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:32.779010 [ 20850 ] {} <Fatal> BaseDaemon: ########################################
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:32.792655 [ 20850 ] {} <Fatal> BaseDaemon: (version 21.11.1.8368 (official build), build id: 2C27DF78605FD3C86BCD90A72BF6E51B0666EB10) (from thread 2935) (query_id: d791e065-406e-49b7-86d4-587eb3f502c6) Received signal Aborted (6)
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:32.846872 [ 20850 ] {} <Fatal> BaseDaemon: 
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:32.857580 [ 20850 ] {} <Fatal> BaseDaemon: Stack trace: 0x7f9d0682e18b 0x7f9d0680d859 0x14e26bf8 0x14e26d02 0x20b58cd1 0x20b5743c 0x20b57327 0x2222d4c2 0x22233843 0x22233485 0x22d51415 0x22cc9783 0x22cc971d 0x22cc96dd 0x22cc96b5 0x22cc967d 0x14e73246 0x14e72335 0x22cc8e6e 0x22cc8b4e 0x229927b9 0x2299271f 0x229926bd 0x2299267d 0x22992655 0x2299261d 0x14e73246 0x14e72335 0x229910c5 0x22990298 0x229b7fba 0x228cc2fb 0x228c628b 0x228d3a85 0x26d438f9 0x26d44108 0x26e92034 0x26e8eb1a 0x26e8d8fc 0x7f9d069f4609 0x7f9d0690a293
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:32.892884 [ 20850 ] {} <Fatal> BaseDaemon: 4. raise @ 0x4618b in /usr/lib/x86_64-linux-gnu/libc-2.31.so
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:32.896289 [ 20850 ] {} <Fatal> BaseDaemon: 5. abort @ 0x25859 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:33.239118 [ 20850 ] {} <Fatal> BaseDaemon: 6. ./obj-x86_64-linux-gnu/../src/Common/Exception.cpp:53: DB::handle_error_code(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool, std::__1::vector<void*, std::__1::allocator<void*> > const&) @ 0x14e26bf8 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:33.398452 [ 20850 ] {} <Fatal> BaseDaemon: 7. ./obj-x86_64-linux-gnu/../src/Common/Exception.cpp:60: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x14e26d02 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:34.219076 [ 20850 ] {} <Fatal> BaseDaemon: 8. ./obj-x86_64-linux-gnu/../src/Core/Block.cpp:32: void DB::onError<void>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x20b58cd1 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:34.708525 [ 20850 ] {} <Fatal> BaseDaemon: 9. ./obj-x86_64-linux-gnu/../src/Core/Block.cpp:86: void DB::checkBlockStructure<void>(DB::Block const&, DB::Block const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) @ 0x20b5743c in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:35.269648 [ 20850 ] {} <Fatal> BaseDaemon: 10. ./obj-x86_64-linux-gnu/../src/Core/Block.cpp:595: DB::assertBlocksHaveEqualStructure(DB::Block const&, DB::Block const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0x20b57327 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:37.547788 [ 20850 ] {} <Fatal> BaseDaemon: 11. ./obj-x86_64-linux-gnu/../src/Storages/StorageBuffer.cpp:447: DB::appendBlock(DB::Block const&, DB::Block&) @ 0x2222d4c2 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:39.047825 [ 20850 ] {} <Fatal> BaseDaemon: 12. ./obj-x86_64-linux-gnu/../src/Storages/StorageBuffer.cpp:634: DB::BufferSink::insertIntoBuffer(DB::Block const&, DB::StorageBuffer::Buffer&) @ 0x22233843 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:39.947747 [ 20850 ] {} <Fatal> BaseDaemon: 13. ./obj-x86_64-linux-gnu/../src/Storages/StorageBuffer.cpp:595: DB::BufferSink::consume(DB::Chunk) @ 0x22233485 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:40.411917 [ 20850 ] {} <Fatal> BaseDaemon: 14. ./obj-x86_64-linux-gnu/../src/Processors/Sinks/SinkToStorage.cpp:18: DB::SinkToStorage::transform(DB::Chunk&) @ 0x22d51415 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:40.958675 [ 20850 ] {} <Fatal> BaseDaemon: 15. ./obj-x86_64-linux-gnu/../src/Processors/Transforms/ExceptionKeepingTransform.cpp:135: DB::ExceptionKeepingTransform::work()::$_1::operator()() const @ 0x22cc9783 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:41.364164 [ 20850 ] {} <Fatal> BaseDaemon: 16. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3676: decltype(std::__1::forward<DB::ExceptionKeepingTransform::work()::$_1&>(fp)()) std::__1::__invoke<DB::ExceptionKeepingTransform::work()::$_1&>(DB::ExceptionKeepingTransform::work()::$_1&) @ 0x22cc971d in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:41.849624 [ 20850 ] {} <Fatal> BaseDaemon: 17. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/__functional_base:349: void std::__1::__invoke_void_return_wrapper<void>::__call<DB::ExceptionKeepingTransform::work()::$_1&>(DB::ExceptionKeepingTransform::work()::$_1&) @ 0x22cc96dd in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:42.163365 [ 20850 ] {} <Fatal> BaseDaemon: 18. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1608: std::__1::__function::__default_alloc_func<DB::ExceptionKeepingTransform::work()::$_1, void ()>::operator()() @ 0x22cc96b5 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:42.569818 [ 20850 ] {} <Fatal> BaseDaemon: 19. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2089: void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<DB::ExceptionKeepingTransform::work()::$_1, void ()> >(std::__1::__function::__policy_storage const*) @ 0x22cc967d in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:42.671945 [ 20850 ] {} <Fatal> BaseDaemon: 20. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2221: std::__1::__function::__policy_func<void ()>::operator()() const @ 0x14e73246 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:42.948646 [ 20850 ] {} <Fatal> BaseDaemon: 21. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2560: std::__1::function<void ()>::operator()() const @ 0x14e72335 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:43.282898 [ 20850 ] {} <Fatal> BaseDaemon: 22. ./obj-x86_64-linux-gnu/../src/Processors/Transforms/ExceptionKeepingTransform.cpp:102: DB::runStep(std::__1::function<void ()>, DB::ThreadStatus*, std::__1::atomic<unsigned long>*) @ 0x22cc8e6e in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:43.752741 [ 20850 ] {} <Fatal> BaseDaemon: 23. ./obj-x86_64-linux-gnu/../src/Processors/Transforms/ExceptionKeepingTransform.cpp:135: DB::ExceptionKeepingTransform::work() @ 0x22cc8b4e in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:44.690876 [ 20850 ] {} <Fatal> BaseDaemon: 24. ./obj-x86_64-linux-gnu/../src/Processors/Executors/PipelineExecutor.cpp:88: DB::executeJob(DB::IProcessor*) @ 0x229927b9 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:45.532301 [ 20850 ] {} <Fatal> BaseDaemon: 25. ./obj-x86_64-linux-gnu/../src/Processors/Executors/PipelineExecutor.cpp:105: DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0::operator()() const @ 0x2299271f in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:48.400022 [ 20850 ] {} <Fatal> BaseDaemon: 26. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3676: decltype(std::__1::forward<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&>(fp)()) std::__1::__invoke<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&>(DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&) @ 0x229926bd in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:49.354879 [ 20850 ] {} <Fatal> BaseDaemon: 27. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/__functional_base:349: void std::__1::__invoke_void_return_wrapper<void>::__call<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&>(DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&) @ 0x2299267d in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:50.302500 [ 20850 ] {} <Fatal> BaseDaemon: 28. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1608: std::__1::__function::__default_alloc_func<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0, void ()>::operator()() @ 0x22992655 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:51.052476 [ 20850 ] {} <Fatal> BaseDaemon: 29. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2089: void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0, void ()> >(std::__1::__function::__policy_storage const*) @ 0x2299261d in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:51.332390 [ 20850 ] {} <Fatal> BaseDaemon: 30. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2221: std::__1::__function::__policy_func<void ()>::operator()() const @ 0x14e73246 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:52.076876 [ 20850 ] {} <Fatal> BaseDaemon: 31. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2560: std::__1::function<void ()>::operator()() const @ 0x14e72335 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.10.11 01:44:55.401575 [ 498 ] {} <Fatal> Application: Child process was terminated by signal 6.
```

cc: @KochetovNicolai 
{
    extern const Event StorageBufferFlush;
    extern const Event StorageBufferErrorOnFlush;
    extern const Event StorageBufferPassedAllMinThresholds;
    extern const Event StorageBufferPassedTimeMaxThreshold;
    extern const Event StorageBufferPassedRowsMaxThreshold;
    extern const Event StorageBufferPassedBytesMaxThreshold;
    extern const Event StorageBufferPassedTimeFlushThreshold;
    extern const Event StorageBufferPassedRowsFlushThreshold;
    extern const Event StorageBufferPassedBytesFlushThreshold;
    extern const Event StorageBufferLayerLockReadersWaitMilliseconds;
    extern const Event StorageBufferLayerLockWritersWaitMilliseconds;
}
namespace CurrentMetrics
{
    extern const Metric StorageBufferRows;
    extern const Metric StorageBufferBytes;
}
namespace DB
{
namespace ErrorCodes
{
    extern const int BAD_ARGUMENTS;
    extern const int NOT_IMPLEMENTED;
    extern const int LOGICAL_ERROR;
    extern const int INFINITE_LOOP;
    extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
    extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;
}
std::unique_lock<std::mutex> StorageBuffer::Buffer::lockForReading() const