**Describe what's wrong**
Query in clickhouse-client may fail with options `--send_logs_level=trace --server_logs_file=-` (`--server_logs_file=-` means write server logs to stdout).

**How to reproduce**

```
while true; do clickhouse-client -q "select 1" --send_logs_level=trace --server_logs_file=- >log; done
Code: 75. DB::ErrnoException: Cannot write to file (fd = 1), errno: 14, strerror: Bad address: (in query: select 1). (CANNOT_WRITE_TO_FILE_DESCRIPTOR)

Code: 75. DB::ErrnoException: Cannot write to file (fd = 1), errno: 14, strerror: Bad address: (in query: select 1). (CANNOT_WRITE_TO_FILE_DESCRIPTOR)

Code: 75. DB::ErrnoException: Cannot write to file (fd = 1), errno: 14, strerror: Bad address: (in query: select 1). (CANNOT_WRITE_TO_FILE_DESCRIPTOR)
```

Some queries will fail periodically.


if (event_name == user_time_name)
                thread_times[host_name][thread_id].user_ms = value;
            else if (event_name == system_time_name)
                thread_times[host_name][thread_id].system_ms = value;
            else if (event_name == MemoryTracker::USAGE_EVENT_NAME)
                thread_times[host_name][thread_id].memory_usage = value;
        }
        progress_indication.updateThreadEventData(thread_times);
        if (need_render_progress)
            progress_indication.writeProgress();
        if (profile_events.print)
        {
            if (profile_events.watch.elapsedMilliseconds() >= profile_events.delay_ms)
            {
                initLogsOutputStream();
                progress_indication.clearProgressOutput();
                logs_out_stream->writeProfileEvents(block);
                logs_out_stream->flush();
                profile_events.last_block = {};
            }
            else
            {
                incrementProfileEventsBlock(profile_events.last_block, block);
            }
        }
        profile_events.watch.restart();
    }
}
/// Flush all buffers.
void ClientBase::resetOutput()