question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query Engine keeps running even after the parent process is killed when using `migrate reset` or `db seed`

See original GitHub issue

Bug description

The issue is in that the query engine processes keep the connection pool open even when the parent Node process crashes/is killed. This means massive memory and connection leaks in production if your application is known to crash and is restored automatically by some other entity. This usually results in too many open connections and your DB rejecting any additional connection requests and

On my MBP query-engine-darwin keeps running long after my NestJS app process is gone. It even happens after running some of the migrations related stuff, e.g. prisma migrate reset --preview-feature.

Caching the Prisma instance resolves this only for use cases described in #1983, e.g. hot reloading in Node apps such as NestJS.

How to reproduce

Run prisma migrate reset --preview-feature multiple times and check the running processes on your system. Make sure to have a seed file that establishes a connection to the database.

Expected behavior

All native processes should end after the parent Node process has quit.

Prisma information

Any schema connecting to the PostgreSQL DB in a container.

Environment & setup

  • OS: macOS
  • Database: PostgreSQL
  • Node.js version: 14.16.1
  • Prisma version: 2.22.1
prisma               : 2.22.1
@prisma/client       : 2.22.1
Current platform     : darwin
Query Engine         : query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 60cc71d884972ab4e897f0277c4b84383dddaf6c
Studio               : 0.379.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
bencuncommented, Aug 4, 2021

@Jolg42 This doesn’t seem to be a seed issue only. Please, pay attention to the original comment: this is also relevant in any other use case, not just the seeding. In our case it was a NestJS app that had a proper $disconnect() call when an app is destroyed. That call did nothing on our end and, therefore, even after our app exits properly we still get a hanging query engine process. Mac only, on Windows there’s no such issue.

2reactions
bencuncommented, May 11, 2021

@janpio Yes, as described this also happens when I kill my app’s Node process with Ctrl+C (it’s a NestJS app) or even force quit it through the Activity Monitor. The Query Engine process keeps running.

Interestingly it doesn’t happen when I run prisma migrate dev but it does when running prisma migrate reset.

I’ll create a seed file that creates a reproducible case for the reset command very soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
Why child process still alive after parent process was killed in ...
No, when you kill a process alone, it will not kill the children. You have to send the signal to the process group...
Read more >
CREAK Data Explorer - UT Computer Science
We are still dealing with major outbreaks of Leprosy. ... There are many different projects currently running under the parent company Alphabet Inc....
Read more >
Known Issues for Oracle SOA Products and Oracle AIA ...
The fault is displayed because the BPEL process service engine is re-executing the scope ... Shut down and restart your database after running...
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
systemPrefs with at least two files" status:RESOLVED resolution:OBSOLETE ... Bug:92113 - "plz add ebuild for Kat - Desktop Search Engine for Linux" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found