Skip to content

fix: FK violation publishing self-relation parent & child in one release#26147

Merged
innerdvations merged 2 commits into
strapi:developfrom
garrettheaver:fix/content-releases-self-relation-fk-violation
May 12, 2026
Merged

fix: FK violation publishing self-relation parent & child in one release#26147
innerdvations merged 2 commits into
strapi:developfrom
garrettheaver:fix/content-releases-self-relation-fk-violation

Conversation

@garrettheaver
Copy link
Copy Markdown
Contributor

What does it do?

Replaces Promise.all over a content type's actions in release.publish with sequential for loops, so within content-type publishes serialize on the shared transaction. Also drops the empty try/catch wrapping the cron task in scheduling.ts so task failures propagate to Strapi existing job.on('error') handler instead of being silently swallowed.

Why is it needed?

A Content Release in production failed when publishing two documents of the same content type that referenced each other (parent Page and child Page via a self-referential relation, both in one release):

code:        23503
constraint:  pages_parent_lnk_fk
detail:      Key (page_id)=(255) is not present in table "pages".
table:       pages_parent_lnk
message:     insert into "pages_parent_lnk" ("id", "inv_page_id", "page_id")
             values ($1, $2, $3), ($4, $5, $6), ($7, $8, $9), ($10, $11, $12), ($13, $14, $15)
             - insert or update on table "pages_parent_lnk" violates foreign key constraint "pages_parent_lnk_fk"

The error was only surfaced when a release was triggered manually. Scheduled releases triggered by cron had been hitting the same failure mode (we assume) but the empty try/catch in scheduling.ts's task callback was swallowing the error, so nothing was being logged.

Both publishes shared a transaction via Promise.all. It is most likely that statements interleaved on the connection, so one branch's delete invalidated the other branch's pre-captured join-table snapshot before the second branch tried to re-insert against it. The deleted page_id=255 is the row the other branch had already removed.

User-visible state after the failure: new published rows existed for both documents, but the parent's join rows to all its children were missing, leaving every child orphaned on the published side. The release was recorded as status='failed' and a 500 error returned.

How to test it?

yarn jest packages/core/content-releases. New unit test pins the sequential dispatch.

…violation

1. Concurrent publishes within a content type race on shared join-table state.
2. Errors from scheduled publishes were also silently swallowed leaving
   no trail in the logs.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

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

A member of the Team first needs to authorize it.

@dosubot dosubot Bot added pr: fix This PR is fixing a bug source: core:content-releases Source is the Content Releases feature labels Apr 28, 2026
@innerdvations innerdvations added this to the 5.44.1 milestone Apr 28, 2026
@OcneanuVlad
Copy link
Copy Markdown
Contributor

Internal note: TID 8744

@oiorain oiorain added the community Changes and fixes created by community members label Apr 30, 2026
@innerdvations innerdvations modified the milestones: 5.45.0, 5.45.1 May 5, 2026
@garrettheaver
Copy link
Copy Markdown
Contributor Author

Can I get an update on this please in terms of when it will go into a release? It's an EE feature affecting an EE customer. Thanks!

@OcneanuVlad OcneanuVlad added the flag: EE Issues correlates to internal EE ticket label May 12, 2026
@OcneanuVlad
Copy link
Copy Markdown
Contributor

Can I get an update on this please in terms of when it will go into a release? It's an EE feature affecting an EE customer. Thanks!

Hey Garett, it looks like the fix is currently scheduled to release with 5.46.0 according to the milestones

@garrettheaver
Copy link
Copy Markdown
Contributor Author

Thanks. It had been scheduled for 5.44.1, then it got bumped to 5.45.0, then 5.45.1. Now it's 5.46.0. Given the internal TID / it's on an EE support agreement, can you help prevent it from getting bumped to a later version again?

@innerdvations innerdvations self-assigned this May 12, 2026
@innerdvations innerdvations merged commit 50732df into strapi:develop May 12, 2026
113 of 115 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Changes and fixes created by community members flag: EE Issues correlates to internal EE ticket pr: fix This PR is fixing a bug source: core:content-releases Source is the Content Releases feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants