Skip to content

Relation search refresh cleanup exceeds asyncpg parameter limit (prod) #1390

Description

@phernandez

Production evidence

Logfire issue #2589 recorded a pgq.job.resolve_relations failure in production on 2026-08-30 at 11:32:55 UTC. Trace: 01a05271a7f19527aad3e12f3621cd1a.

RelationRepository.clear_pending_search_refreshes() generated one DELETE ... id IN (...) statement for 44,926 refresh marker IDs. Including project_id, the statement exceeded asyncpg's hard limit of 32,767 query arguments and failed before retiring any completed refresh work.

The sibling complete_search_refresh_for_generation() method has the same unbounded IN expansion.

Required fix

  • Bound both refresh-marker delete paths into multiple statements within the caller-owned transaction.
  • Preserve project scoping and generation fencing.
  • Add a regression test that proves the statement bound is load-bearing.

Verification

  • Focused SQLite and PostgreSQL repository tests.
  • Core static/type checks and full required PR CI.
  • After release into Cloud, verify the production resolver completes without recurrence and then resolve Logfire #2589.

Activity

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

    bugSomething isn't workingcloudBasic Memory CloudproductionObserved in production

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions