DNS lookups survive cancellation

Open
#816 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
18/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python, rust
Domain
networking

Research direction

Start with the attached dns_probe.py and stall_dns.c reproduction to confirm that timed-out DNS lookups keep Tokio blocking threads busy. Then trace where list_async schedules the underlying blocking lookup in the Rust layer to see whether cancellation drops the future without stopping the lookup. The reporter expects the real fix upstream in object_store, so this is investigation-first rather than a contained patch; done means the reproduction no longer exhausts the process-wide blocking pool and unrelated stores stop timing out.

Written by the indexing model from the issue text.

Description

Hi,
when requests timeout, they can leave behind stalled DNS lookups occupying Tokio's blocking threadpool tasks.
I have a long-running polling loop roughly like this in pseudocode

async def poll_source(store):
    while True:
        try:
            ls = await store.list_async(dir, timeout=...).collect_async()
            await process_new_files(ls)
        except TimeoutError:
            log.error(...)
        await asyncio.sleep(10)
await asyncio.gather(*(poll_source(store)) for store in stores))

I noticed that if the process is running long enough, all of the pollers eventually start timeouting forever in my setup, even though the code looks quite safe.
It may be possible that stalled DNS threads are accumulating and eventually exhaust the threadpool.
The threadpool is process-wide, so even requests to unrelated MemoryStore start timing out.

While looking for the cause, it has been revealed to me that there is this reproducible DNS failure mode that fits the observed behavior of my service, though I do not know whether it is responsible for my service failure.

The workaround for me is clear now, just restart the service whenever it happens, but I thought the bug is worth reporting. It seems that a proper fix would need to be upstream in object_store.

AI disclosure: the bug has been found and reproduced by AI
I attach an AI generated write up and reproduction scripts

dns_probe.py
README.md
stall_dns.c

Dominant language
Python
Stars
842
Forks
50
Avg merge
9h
Merged PRs (30d)
13

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developmentseed/obstore

All issues in developmentseed/obstore

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.