prisma: SQL Server: `prisma generate` fails with error "memory allocation of [86GB] failed"
Bug description
We just upgraded from Prisma 2.30.2 to 3.6.0.
Running prisma generate fails with this error message (after a very long time, 30mins plus!):
$ npx prisma generate
Prisma schema loaded from prisma\schema.prisma
memory allocation of 42949672960 bytes failed
The same problem occurs with Prisma 3.0.2
How to reproduce
I created a small repo with our schema that reproduces the issue: https://github.com/peteralbert/prisma-generate-issue
Expected behavior
Command should generate Prisma client without request 86GB of RAM
Prisma information
Environment & setup
- OS: Windows Server 2019 Standard
- Database: SQL Server
- Node.js version: v14.15.1
Prisma Version
prisma : 3.6.0
@prisma/client : 3.6.0
Current platform : windows
Query Engine (Node-API) : libquery-engine dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at ..\..\node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine : migration-engine-cli dc520b92b1ebb2d28dc3161f9f82e875bd35d727
(at ..\..\node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at ..\..\node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at ..\..\node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : dc520b92b1ebb2d28dc3161f9f82e875bd35d727
Studio : 0.440.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (8 by maintainers)
Thanks for reporting. I can reproduce this.
awesome! will verify after xmas break
I have a fix PR. There were two problems. Both are fixed now (and will be released in a future Prisma release).
Happy holidays!
Thanks. We got it. I’m also close on solving the issue.
@pimeys
db pullshows similar behavior - it is now running since >5mins and grabbing more and more memory:I’ll see if I can share the DB schema so you can reproduce locally…
Hey @peteralbert. It’s not in cycle detection, but in the cascading paths validation we have an endless cycle. I’m currently making a minimal reproduction, but meanwhile could you
db pullwith the latest prisma version and see if it modifies the data model to a state that doesn’t cycle anymore? Your old data model didn’t have actions written down, and I highly doubt you have cycles or multiple cascading paths between relations in your SQL Server database, so the generated new data model withdb pullshould not trigger a loop.This needs a fast fix, so I’m looking into doing it today.
https://github.com/prisma/prisma-engines/blob/master/libs/datamodel/core/src/transform/ast_to_dml/validation_pipeline/validations/relations.rs#L280-L470