Skip to content

extract: hung Ollama request stalls the whole run indefinitely despite --api-timeout #1686

Closed

Description

@Kyzcreig

Summary

During a long graphify extract semantic pass against a local Ollama backend, the run froze indefinitely (observed 20+ minutes, would not self-recover) after the Ollama server stopped responding. --api-timeout 180 was set but did not abort the stuck request. This appears to be a missing/ineffective client-side read timeout on the Ollama path, so a wedged server hangs the whole extract with no error and no adaptive-retry.

Observed behavior

  • Semantic extraction progressed normally (e.g. chunk 40/86 done), then froze — log stopped, no new chunks.
  • graphify process at 0% CPU (blocked on a socket read, not working).
  • Ollama had the model loaded but was idle (~0.2% CPU).
  • A fresh, independent curl http://localhost:11434/api/generate -d '{"model":"...","prompt":"ok","stream":false}' also hung >15s — confirming the Ollama server itself had wedged, not graphify.
  • The stuck extract never errored or retried; it sat on the dead read until killed. Bouncing ollama + re-running was the only recovery.

Notably this occurred with --api-timeout 180 set, so whatever timeout is applied to the OpenAI-compatible client (_resolve_api_timeout() in llm.py) did not fire on this Ollama request. Possible causes I can't fully confirm from the outside: the timeout not covering a streaming read, or a per-chunk "hollow response" (I saw output_tokens≈35 truncation warnings just before the freeze) resetting the read clock so a slow trickle never trips the total timeout.

Impact

A single wedged local-LLM request silently stalls an entire multi-hour extract with no error, no progress, and no recovery — easy to mistake for "still working" since the process is alive.

Suggestions

  1. Ensure --api-timeout applies as a hard wall-clock read timeout to Ollama requests (including streaming reads), so a hung server aborts the request and lets adaptive-retry fire instead of blocking forever.
  2. Consider a heartbeat/stall detector: if no chunk completes within N× the per-chunk expected time, fail the chunk (retryable) rather than block.
  3. Surface a clear "backend appears unresponsive (no bytes in Ns)" error instead of a silent hang.

Environment

  • graphifyy 0.9.5, --backend ollama, --max-concurrency 1, models qwen3-coder-next (extract) / qwen3.5:122b (label), macOS, local Ollama.

I can't hand you a deterministic repro (it depends on the Ollama server wedging under sustained load), but the 0%-CPU-graphify + idle-Ollama + independently-hung-curl signature was reproducible across three separate stalls in one session.

Activity

  1. safishamsi commented on Jul 6, 2026

    @safishamsi
    Member

    Fixed on v8 (21b851b), shipping in the next release.

    A stalled Ollama request wedged for timeout * (max_retries + 1), so with the default 6 retries one long stall became a ~21-minute block. _call_openai_compat now defaults the Ollama backend to zero client-side retries (a local model that stalls will not un-stall on retry); set GRAPHIFY_MAX_RETRIES to opt back in. Other backends are unchanged.

    Honest caveat: this bounds the wait to a single --api-timeout window, but the underlying stall is driven by the model server and is non-deterministic, so it is not eliminated at the source. If you can still reproduce an indefinite hang within one timeout window, please reopen with the model and --api-timeout value. Thanks for the report.

  2. added a commit that references this issue on Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions