**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.
void execute() { task->execute(); }
private:
    BackgroundSchedulePoolTaskInfoPtr task;
};
BackgroundSchedulePoolTaskInfo::BackgroundSchedulePoolTaskInfo(
    BackgroundSchedulePool & pool_, const std::string & log_name_, const BackgroundSchedulePool::TaskFunc & function_)
    : pool(pool_), log_name(log_name_), function(function_)
{
}
bool BackgroundSchedulePoolTaskInfo::schedule()
{
    std::lock_guard lock(schedule_mutex);
    if (deactivated || scheduled)
        return false;
    scheduleImpl(lock);
    return true;
}
bool BackgroundSchedulePoolTaskInfo::scheduleAfter(size_t ms, bool overwrite)
{
    std::lock_guard lock(schedule_mutex);
    if (deactivated || scheduled)
        return false;
    if (delayed && !overwrite)
        return false;
    pool.scheduleDelayedTask(shared_from_this(), ms, lock);
    return true;
}
void BackgroundSchedulePoolTaskInfo::deactivate()