(you don't have to strictly follow this form)

**Describe the bug**
The following query leads to OOM if server was built with thread sanitizer.

```sql
SELECT range(65535) FROM system.one ARRAY JOIN range(65536) AS number

{
        emergency_stop = true;
        {
            std::unique_lock<std::mutex> lock(mutex);
            collector_condvar.notify_all();
            writer_condvar.notify_all();
        }
        if (collector_thread.joinable())
            collector_thread.join();
        try
        {
            pool.wait();
        }
        catch (...)
        {
            tryLogCurrentException(__PRETTY_FUNCTION__);
        }
    }
    void ParallelFormattingOutputFormat::collectorThreadFunction()