![image](https://user-images.githubusercontent.com/45587738/182279814-651a1636-8f30-47f3-bead-273cf65794cd.png)

{
        auto * ptr_records = reinterpret_cast<std::vector<std::string>*>(arg);
        if (status == ARES_SUCCESS && host->h_aliases)
        {
            int i = 0;
            while (auto * ptr_record = host->h_aliases[i])
            {
                ptr_records->emplace_back(ptr_record);
                i++;
            }
        }
    }
    CaresPTRResolver::CaresPTRResolver(CaresPTRResolver::provider_token) : channel(nullptr)
    {
        /*
         * ares_library_init is not thread safe. Currently, the only other usage of c-ares seems to be in grpc.
         * In grpc, ares_library_init seems to be called only in Windows.
         * See https://github.com/grpc/grpc/blob/master/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc#L1187
         * That means it's safe to init it here, but we should be cautious when introducing new code that depends on c-ares and even updates
         * to grpc. As discussed in https://github.com/ClickHouse/ClickHouse/pull/37827#discussion_r919189085, c-ares should be adapted to be atomic
         * */
        if (ares_library_init(ARES_LIB_INIT_ALL) != ARES_SUCCESS || ares_init(&channel) != ARES_SUCCESS)
        {
            throw DB::Exception("Failed to initialize c-ares", DB::ErrorCodes::DNS_ERROR);
        }
    }
    CaresPTRResolver::~CaresPTRResolver()