**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.


auto metadata = storage->getInMemoryMetadataPtr();
            QueryPlan plan;
            storage->read(
                    plan,
                    sample.getNames(),
                    storage->getStorageSnapshot(metadata, global_context),
                    query_info,
                    global_context,
                    {},
                    global_context->getSettingsRef().max_block_size,
                    getNumberOfPhysicalCPUCores());
            auto builder = plan.buildQueryPipeline(
                QueryPlanOptimizationSettings::fromContext(global_context),
                BuildQueryPipelineSettings::fromContext(global_context));
            QueryPlanResourceHolder resources;
            auto pipe = QueryPipelineBuilder::getPipe(std::move(*builder), resources);
            sendDataFromPipe(
                std::move(pipe),
                parsed_query,
                have_data_in_stdin
            );
        }
        catch (Exception & e)
        {
            e.addMessage("data for INSERT was parsed from file");
            throw;
        }
        if (have_data_in_stdin)
            sendDataFromStdin(sample, columns_description_for_query, parsed_query);
    }