No rows are written, though. Still, this may be problematic when this insert fails due to the `too many parts` error, which leads to the parent insert also failing. I haven't reproduced this failure exactly (complicated to do on localhost), but seen it happen for a ClickHouse user in Yandex.

Apparently this only happens with `insert_distributed_sync = 1`.

Cluster config:
```
        <weighted>
            <shard>
                <weight>100</weight>
                <replica>
                    <host>127.0.0.2</host>
                    <port>9000</port>
                </replica>
            </shard>
            <shard>
                <weight>0</weight>
                <replica>
                    <host>127.0.0.3</host>
                    <port>9000</port>
                </replica>
            </shard>
            <shard>
                <weight>100</weight>
                <replica>
                    <host>127.0.0.4</host>
                    <port>9000</port>
                </replica>
            </shard>
        </weighted>
```

Queries:

```
create table t_local (a int) engine MergeTree order by (a);

create table t_dist (a int) engine Distributed(weighted, 'default', 't_local', cityHash64(a));

set insert_distributed_sync = 1;

select written_rows, query_id from system.query_log where initial_query_id = '4c93852e-bdcb-436a-9ad3-4953ccedfcdc' and type != 1;
```

In the query log we see that the query is sent to all three shards, including the one with zero weight, but no rows are sent there.
```
SELECT 
    written_rows,
    query_id
FROM system.query_log
WHERE (initial_query_id = '4c93852e-bdcb-436a-9ad3-4953ccedfcdc') AND (type != 1)

┌─written_rows─┬─query_id─────────────────────────────┐
│            0 │ 177294a7-5612-45ef-bb57-2b36b73d709f │
│       499720 │ 02d724ae-5840-4805-9e5f-747a85332545 │
│       500280 │ a4692444-5409-4aec-a821-d9095e912ca1 │
│      1000000 │ 4c93852e-bdcb-436a-9ad3-4953ccedfcdc │
└──────────────┴──────────────────────────────────────┘
```

For more fun, try the `Log` engine for `t_local` -- the insert deadlocks: https://github.com/ClickHouse/ClickHouse/issues/14570
DistributedBlockOutputStream::runWritingJob(DistributedBlockOutputStream::JobReplica & job, const Block & current_block, size_t num_shards)
{
    auto thread_group = CurrentThread::getGroup();
    return [this, thread_group, &job, &current_block, num_shards]()
    {
        if (thread_group)
            CurrentThread::attachToIfDetached(thread_group);
        setThreadName("DistrOutStrProc");
        ++job.blocks_started;
        SCOPE_EXIT({
            ++finished_jobs_count;
            UInt64 elapsed_time_for_block_ms = watch_current_block.elapsedMilliseconds();
            job.elapsed_time_ms += elapsed_time_for_block_ms;
            job.max_elapsed_time_for_block_ms = std::max(job.max_elapsed_time_for_block_ms, elapsed_time_for_block_ms);
        });
        const auto & shard_info = cluster->getShardsInfo()[job.shard_index];
        auto & shard_job = per_shard_jobs[job.shard_index];
        const auto & addresses = cluster->getShardsAddresses();
        
        if (num_shards > 1)
        {
            auto & shard_permutation = shard_job.shard_current_block_permutation;
            size_t num_shard_rows = shard_permutation.size();
            for (size_t j = 0; j < current_block.columns(); ++j)
            {
                const auto & src_column = current_block.getByPosition(j).column;
                auto & dst_column = job.current_shard_block.getByPosition(j).column;