Skip to content

API: TransactionsEngine leaks one task and session per asyncio task聽#7130

Description

@mmabrouk

馃 The AI agent says:

What happens: every asyncio task that opens a database session through TransactionsEngine.session() leaves an entry for itself in the task-scoped session registry, and the entry holds both the task and its session. Cleanup closes the session but never removes the entry. We measured it: 50 short tasks left 50 entries behind.

Why it matters: the leak affects the whole API and all workers, not only Channels. Long-running workers accumulate these entries and the memory grows without bound. Codex found it while reviewing #7128 (the channels advisory lock). #7128 works around it by using a pooled connection of its own.

Likely fix: deregister the task's scoped session in session()'s cleanup instead of only closing it. Add a test that runs N tasks and asserts the registry is empty afterwards.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions