Skip to content

tei: intermittent 'Bad file descriptor' on embedding requests — stale pooled connections lack health checks #3284

Description

@nicoloboschi

Problem

Intermittent embedding failures surface as:

Failed to generate batch embeddings: TEI embedding request failed: [Errno 9] Bad file descriptor

Observed ~once daily in a production deployment, typically after idle periods or infrastructure disturbances (e.g. shortly after a database failover shuffled worker activity) — consistent with the HTTP client reusing a connection whose socket died underneath it, rather than any TEI-server fault (TEI pods healthy, zero restarts across occurrences).

Task-level retries absorb it today, but each hit fails a consolidation/retain attempt and re-runs the whole operation.

Proposed fix

  • Enable/verify connection health-checking on the TEI HTTP client pool (e.g. httpx/aiohttp keepalive expiry shorter than infra idle timeouts, or retry-once-on-OSError at the request level before failing the batch).
  • A single request-level retry on stale-socket OSErrors is cheap and converts a full task retry into a transparent reconnect.

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