Skip to content

firestore times out when using default DNS resolver #783

Open
@sergiocampama

Description

@sergiocampama
import asyncio
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore_async
import sys

async def main():
  user_id = sys.argv[1]

  cred = credentials.Certificate("credentials.json")
  firebase_admin.initialize_app(cred)

  db = firestore_async.client()

  user_ref = db.collection("users").document(user_id)
  user = await user_ref.get()
  print(user)

if __name__ == "__main__":
  asyncio.run(main())

This code, using a firebase service account credential, and a database with a users table, will hang for 60 seconds and will fail with a DNS error, this one:

D0408 14:38:20.114377000 7971737600 grpc_ares_wrapper.cc:723]          (c-ares resolver) request:0x60000318e4e0 on_hostbyname_done_locked: C-ares status is not ARES_SUCCESS qtype=AAAA name=firestore.googleapis.com is_balancer=0: DNS query cancelled
D0408 14:38:20.114381000 7971737600 grpc_ares_wrapper.cc:723]          (c-ares resolver) request:0x60000318e4e0 on_hostbyname_done_locked: C-ares status is not ARES_SUCCESS qtype=A name=firestore.googleapis.com is_balancer=0: DNS query cancelled
...
D0408 14:38:20.114467000 7971737600 dns_resolver_ares.cc:328]          (c-ares resolver) resolver:0x600003f8d4a0 dns resolution failed: UNKNOWN:C-ares status is not ARES_SUCCESS qtype=A name=firestore.googleapis.com is_balancer=0: DNS query cancelled {created_time:"2024-04-08T14:38:20.114389-04:00", children:[UNKNOWN:C-ares status is not ARES_SUCCESS qtype=AAAA name=firestore.googleapis.com is_balancer=0: DNS query cancelled {created_time:"2024-04-08T14:38:20.114379-04:00"}]}

This is with firebase-admin 6.5.0 and python 3.12.2

Workaround

Call the python script with this environment variable:

GRPC_DNS_RESOLVER=native

works around the issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions