(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

{
        setThreadName("Collector");
        try
        {
            while (!emergency_stop)
            {
                const auto current_unit_number = collector_unit_number % processing_units.size();
                auto & unit = processing_units[current_unit_number];
                {
                    std::unique_lock<std::mutex> lock(mutex);
                    collector_condvar.wait(lock,
                        [&]{ return unit.status == READY_TO_READ || emergency_stop; });
                }
                if (emergency_stop)