payloadcms / payloadcms/payload

Multi-tenant: tenant deletion fails with DrizzleQueryError — transaction aborted (Postgres)

Open
#14,576 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

stale status: needs-triage
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

Deleting a tenant in the multi-tenant plugin using the Postgres adapter fails. A Drizzle/Postgres error aborts the transaction.

{
  "type": "DrizzleQueryError",
  "message": "Failed query: delete from \"payload_preferences\" where \"payload_preferences\".\"key\" in ($1)\nparams: collection-tenants-3: current transaction is aborted, commands ignored until end of transaction block"
}
Link to the code that reproduces this issue

https://github.com/payloadcms/payload/tree/main/examples/multi-tenant

Reproduction Steps
  1. Clone the multi-tenant example.
  2. Configure the example to use Postgres (set DATABASE_URL to a Postgres DB) so @payloadcms/db-postgres is used.
  3. Start the project and log in to the admin.
  4. Create a tenant.
  5. Attempt to delete the tenant via the admin UI.
  6. Observe the delete fails and the transaction is aborted.
Which area(s) are affected? (Select all that apply)

plugin: multi-tenant, db: postgres

Environment Info
payload: 3.63.0
@payloadcms/plugin-multi-tenant: 3.63.0
@payloadcms/db-postgres: 3.63.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the examples/multi-tenant project, configure DATABASE_URL for Postgres, and reproduce tenant deletion through the admin UI. Then trace the multi-tenant plugin and @payloadcms/db-postgres transaction handling; done means the tenant deletes successfully without an aborted transaction and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgres, typescript
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.