**How to reproduce**
```
for i in {1..1000}; do echo 'Hello, world!' | clickhouse-local --query "SELECT * FROM table" --structure 's String' | wc -c; done
```

This script hangs.
{
    Stopwatch watch;
    CurrentMetrics::Increment metric_increment{pool.tasks_metric};
    std::lock_guard lock_exec(exec_mutex);
    {
        std::lock_guard lock_schedule(schedule_mutex);
        if (deactivated)
            return;
        scheduled = false;
        executing = true;
    }
    function();
    UInt64 milliseconds = watch.elapsedMilliseconds();
    
    static const int32_t slow_execution_threshold_ms = 200;
    if (milliseconds >= slow_execution_threshold_ms)
        LOG_TRACE(&Poco::Logger::get(log_name), "Execution took {} ms.", milliseconds);
    {
        std::lock_guard lock_schedule(schedule_mutex);
        executing = false;
        
        
        
        if (scheduled)
            pool.queue.enqueueNotification(new TaskNotification(shared_from_this()));
    }
}
void BackgroundSchedulePoolTaskInfo::scheduleImpl(std::lock_guard<std::mutex> & schedule_mutex_lock)