Overflowing stack on cyclic actions #9931
Labels
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
kind/bug
A reported bug.
team/client
Issue for team Client.
tech/engines
Issue for tech Engines.
topic: previewFeatures
Issue touches on an preview feature flag
topic: referentialIntegrity/relationMode
Milestone
Bug description
When handling the referential integrity in the Query Core, a referential action that cascades an action to the children can cause a stack overflow if at some point the reference causes a circle.
This issue can be solved in two places:
How to reproduce
Simple example is a self relation:
Here deleting an
A
will try to delete anA
that deletes anA
and the loop continues until we hit a stack overflow.There are more examples in our SQL Server test suite for data model validator, that might or might not have the same issue. The first part of the issue is to find out what works and what not with Prisma: https://github.com/prisma/prisma-engines/blob/master/libs/datamodel/core/tests/attributes/relations/referential_actions/cycle_detection.rs
Expected behavior
Either throw a validation error in the data model parser, or handle the cycles without overflowing the stack in the Query Core. It is to be decided which path we take before working on the issue.
Prisma information
All versions which can emulate Cascade, SetNull or SetDefault are suspects.
Environment & setup
Prisma Version
Originally reported here #9380 (comment) by @tastnt with this text:
The text was updated successfully, but these errors were encountered: