diff --git a/dbms/src/Storages/StorageBuffer.cpp b/dbms/src/Storages/StorageBuffer.cpp index d15f559dc288536d2971121bce774de19bf3f1b1..31d0e96e4907a89852857c3007710e18f3369306 100644 --- a/dbms/src/Storages/StorageBuffer.cpp +++ b/dbms/src/Storages/StorageBuffer.cpp @@ -63,6 +63,16 @@ StorageBuffer::StorageBuffer(const std::string & name_, const ColumnsDescription { } +StorageBuffer::~StorageBuffer() +{ + // Should not happen if shutdown was called + if (flush_thread.joinable()) + { + shutdown_event.set(); + flush_thread.join(); + } +} + /// Reads from one buffer (from one block) under its mutex. class BufferBlockInputStream : public IProfilingBlockInputStream diff --git a/dbms/src/Storages/StorageBuffer.h b/dbms/src/Storages/StorageBuffer.h index 4cf9670a6132d2417bf6af15f4c704279e25c830..587069467ce03bb58461435efd0ec3d06617b5f3 100644 --- a/dbms/src/Storages/StorageBuffer.h +++ b/dbms/src/Storages/StorageBuffer.h @@ -131,6 +131,7 @@ protected: Context & context_, size_t num_shards_, const Thresholds & min_thresholds_, const Thresholds & max_thresholds_, const String & destination_database_, const String & destination_table_, bool allow_materialized_); + ~StorageBuffer(); }; }