fix: resolve duplicate extension race condition in seed route#1323
Open
Urbine wants to merge 1 commit into
Open
fix: resolve duplicate extension race condition in seed route#1323Urbine wants to merge 1 commit into
Urbine wants to merge 1 commit into
Conversation
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>
Contributor
|
@Urbine is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a PostgreSQL
unique_violationerror (23505) that could occur during database seeding.The issue was caused by concurrent execution of
CREATE EXTENSION IF NOT EXISTSwithin asql.begintransaction block. Multiple parallel transactions could attempt to create the extension simultaneously, resulting in a race condition when writing topg_catalog.pg_extension.Changes
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"outside of the transaction block so it executes once before seeding begins.unique_violation (23505)errors during parallel seed execution.