write_kafka: check for partition availability before selecting one