Skip to content

DATABASE_DIRECT_URL is documented and deployed but never read by any code #165

Description

@Hazzng

Summary

DATABASE_DIRECT_URL is documented in CLAUDE.md and injected by our deployment (aca.yaml:38-39, from the database-direct-url secret), but no code reads it:

$ grep -rn "DATABASE_DIRECT_URL" src/ scripts/
(no matches)

runMigrations resolves its connection through loadTenantConfig() (src/api/server.ts), which reads only TENANT_DATABASES / DATABASE_URL (src/api/tenants.ts:32-41).

Impact

The deployment declares an intent — "run DDL off the pooler" — that the application silently ignores. Migrations connect through whatever DATABASE_URL points at. Combined with the session-scoped advisory lock (see the migrations issue), multi-replica boot has no working mutual exclusion, and nobody reading aca.yaml would know.

A secret is also being provisioned and mounted for no purpose.

Decision needed

We have settled on always connecting through the pooler (Azure Postgres built-in PgBouncer; no direct connection). Given that, the two options are not equal:

  • Preferred — remove it. Delete the CLAUDE.md row and the aca.yaml env + secret, and make migrations pooler-safe instead (single transaction + pg_advisory_xact_lock). This matches how we actually deploy and removes a misleading knob.
  • Alternative — implement it. Have runMigrations prefer DATABASE_DIRECT_URL when set. Only worth doing if we ever want a non-pooled path for DDL; it does not fix the advisory-lock bug on its own.

Either way the doc, the deployment, and the code should stop disagreeing.

Provenance

Found during pre-merge load testing of #162. Not introduced by that PR.

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 workingseverity:mediumMedium severity

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions