Skip to content

fix: resolve duplicate extension race condition in seed route#1323

Open
Urbine wants to merge 1 commit into
vercel:mainfrom
Urbine:fix/postgres-23505-extension-conflict
Open

fix: resolve duplicate extension race condition in seed route#1323
Urbine wants to merge 1 commit into
vercel:mainfrom
Urbine:fix/postgres-23505-extension-conflict

Conversation

@Urbine

@Urbine Urbine commented Jun 13, 2026

Copy link
Copy Markdown

Summary

Fixes a PostgreSQL unique_violation error (23505) that could occur during database seeding.

The issue was caused by concurrent execution of CREATE EXTENSION IF NOT EXISTS within a sql.begin transaction block. Multiple parallel transactions could attempt to create the extension simultaneously, resulting in a race condition when writing to pg_catalog.pg_extension.

Changes

  • Moved CREATE EXTENSION IF NOT EXISTS "uuid-ossp" outside of the transaction block so it executes once before seeding begins.
  • Simplified the seeding flow to avoid conflicts between isolated database workers.
  • Eliminated the race condition that could trigger unique_violation (23505) errors during parallel seed execution.

Fixes a PostgreSQL unique_violation error (23505) occurring during database seeding.

The issue was caused by concurrent execution of `CREATE EXTENSION IF NOT EXISTS` across multiple functions inside a `sql.begin` block. This created a race condition where parallel transactions attempted to write to `pg_catalog.pg_extension` at the same time.

Changes:
- Moved extension creation outside and prior to the transaction block.
- Streamlined seeding execution flow to prevent isolated database worker conflicts.

Signed-off-by: Yoham Gabriel B. @Urbine <yohamg@programmer.net>
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

@Urbine is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant