Skip to content

Tenant Context Leaks After DB Connection Exhaustion (Laravel Octane + Multitenancy) #597

@MiguelGonc

Description

@MiguelGonc

Context:

I'm using Laravel + Octane + Spatie Multitenancy with a session-based tenant switcher in middleware. The middleware calls Tenant::makeCurrent() using a tenant ID stored in the session.

The Issue:
When the app exhausts PostgreSQL connections (e.g., due to many slow queries or transaction failures), the app/octane crashs and users sometimes begin to see data from another tenant/user after the database becomes available again.

This appears to be a tenant context leak — tenant state is being shared between requests.

I don't know if this is a multi-tenancy or octane related issue.

This is not a bug easy to catch localy.

Does anyone can help me?

Thank You

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