Skip to content

Index OAuth access tokens by session before registry growth #594

Open

Description

@imshashank

Session deletion cascades through oauth_access_token.session_id, which currently has no referencing-column index. PostgreSQL preserves foreign-key correctness without the index, but deletion may scan the child table as it grows: https://www.postgresql.org/docs/17/ddl-constraints.html#DDL-CONSTRAINTS-FK.

A verified read-only production aggregate at 2026-11-17 00:08:41 UTC found 216 access-token rows, zero non-null session_id rows and 11 unexpired access tokens. No token values, session identifiers or customer rows were retrieved. This is a nonblocking performance follow-up to #590, not evidence of the production connection-timeout cause.

Add the matching Drizzle index and a genuinely generated append-only migration after the current planned migration sequence. Preserve released 0037/0038 and all existing SQL, snapshots and journal prefixes. Validate fresh and upgraded schemas with canonical db:release and drift checks, confirm the index definition, and exercise session deletion with populated session-bound credentials. Keep production DDL bounded with a lock timeout; never apply an out-of-band index that disagrees with the declared schema.

Activity

  1. ayam04 commented on Nov 25, 2026

    @ayam04
    Contributor

    Taking this one. Adding oauth_access_token_session_idx on session_id (the FK column that currently has no index) and a generated append-only migration (0042) after the current sequence, preserving 0037/0038 and all prior SQL/snapshots/journal entries. Validation (db:release + drift + session-deletion) will be CI-driven since the local Postgres harness isn't available here; the schema change is a single index and the migration is drizzle-kit generated, so the declared schema and the migration agree by construction.

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