Prisma-client-js: invalid `prisma.()` invocation (query engine dying?) on missing foreign key

Created on 25 Jan 2020  Â·  14Comments  Â·  Source: prisma/prisma-client-js

I am able to perform a few queries, then Prisma Client just throws an invalid 'prisma.()' invocation error. It doesn't seem to matter which query I run. After a few queries it starts throwing the error.

running with debug=* reveals that it's getting a ECONNREFUSED error on port 38641 (this port changes each time I restart my server). I assume this is some kind of server that prisma2 starts and communicates with?

Also weird, this was not happening earlier today, and now I can't even run a few queries after restarting my process without this error. (I am developing by running with nodemon, which kills the node process and restarts it when I make a change, so the process has been restarted many time if that matters) I also did upgrade to preview 20.3 earlier today, and didn't see this problem until a few hours after upgrading.

Turns out this is happening when there is a foreign key to a key that doesn't exist. See comment below.

environment:
ubuntu linux
2.0.0-preview020.3
mysql

output running debug=* with one query that results in a few queries that reproduces every time now:

 prisma-client {
  prisma-client   engineConfig: {
  prisma-client     cwd: '/opt/korihor/server/prisma',
  prisma-client     debug: false,
  prisma-client     datamodelPath: '/opt/korihor/server/node_modules/@prisma/client/schema.prisma',
  prisma-client     prismaPath: undefined,
  prisma-client     datasources: [],
  prisma-client     generator: {
  prisma-client       name: 'client',
  prisma-client       provider: 'prisma-client-js',
  prisma-client       output: '/opt/korihor/server/node_modules/@prisma/client',
  prisma-client       binaryTargets: [],
  prisma-client       config: {}
  prisma-client     },
  prisma-client     showColors: true,
  prisma-client     logLevel: undefined,
  prisma-client     logQueries: undefined
  prisma-client   }
  prisma-client } +0ms
  prisma-client disconnection promise doesnt exist +89ms
  engine {
  engine   PRISMA_DML_PATH: '/opt/korihor/server/node_modules/@prisma/client/schema.prisma',
  engine   PORT: '38641',
  engine   RUST_BACKTRACE: '1',
  engine   RUST_LOG: 'info',
  engine   OVERWRITE_DATASOURCES: '[]',
  engine   CLICOLOR_FORCE: '1'
  engine } +0ms
  engine { cwd: '/opt/korihor/server/prisma' } +0ms
  getos { version: 'OpenSSL 1.0.2g  1 Mar 2016\n' } +0ms
  getos { ls: '' } +0ms
  getos { platform: 'linux', libssl: '1.0.x' } +5ms
  plusX Execution permissions of /opt/korihor/server/node_modules/@prisma/client/runtime/query-engine-debian-openssl-1.0.x are fine +0ms
  engine stderr Printing to stderr for debugging
 +31ms
  engine stderr Listening on  +2ms
  engine stderr 127 +1ms
  engine stderr . +0ms
  engine stderr 0 +0ms
  engine stderr . +0ms
  engine stderr 0 +0ms
  engine stderr . +1ms
  engine stderr 1 +0ms
  engine stderr : +0ms
  engine stderr 38641 +0ms
  engine stderr
 +1ms
  engine Ready after try number 0 +44ms
  express:application set "x-powered-by" to true +0ms
  express:application set "etag" to 'weak' +0ms
  express:application set "etag fn" to [Function: generateETag] +0ms
  express:application set "env" to 'development' +1ms
  express:application set "query parser" to 'extended' +0ms
  express:application set "query parser fn" to [Function: parseExtendedQueryString] +0ms
  express:application set "subdomain offset" to 2 +0ms
  express:application set "trust proxy" to false +0ms
  express:application set "trust proxy fn" to [Function: trustNone] +0ms
  express:application booting in development mode +0ms
  express:application set "view" to [Function: View] +0ms
  express:application set "views" to '/opt/korihor/server/views' +1ms
  express:application set "jsonp callback name" to 'callback' +0ms
  express:router use '/' query +21ms
  express:router:layer new '/' +0ms
  express:router use '/' expressInit +1ms
  express:router:layer new '/' +0ms
  express:router use '/' corsMiddleware +0ms
  express:router:layer new '/' +0ms
  express:router:route new '/' +0ms
  express:router:layer new '/' +1ms
  express:router:route post '/' +0ms
  express:router:layer new '/' +0ms
  express:router:route new '/' +0ms
  express:router:layer new '/' +0ms
  express:router:route post '/' +0ms
  express:router:layer new '/' +0ms
  express:router:route new '/' +0ms
  express:router:layer new '/' +0ms
  express:router:route post '/' +0ms
  express:router:layer new '/' +0ms
  express:router:route new '/' +1ms
  express:router:layer new '/' +0ms
  express:router:route get '/' +0ms
  express:router:layer new '/' +0ms
Server is running on localhost:4000
  express:router dispatching POST / +3s
  express:router query  : / +1ms
  express:router expressInit  : / +1ms
  express:router corsMiddleware  : / +0ms
  body-parser:json content-type "application/json" +2ms
  body-parser:json content-encoding "identity" +0ms
  body-parser:json read body +0ms
  body-parser:json parse body +7ms
  body-parser:json parse json +0ms
  prisma-client Request: +3s
  prisma-client query {
  prisma-client   findManychapter(where: {
  prisma-client     chapter_number: 1
  prisma-client     book: {
  prisma-client       book_lds_url: "gen"
  prisma-client     }
  prisma-client   }) {
  prisma-client     chapter_number
  prisma-client     id
  prisma-client   }
  prisma-client } +0ms
  prisma-client disconnection promise doesnt exist +0ms
  agentkeepalive sock[0#localhost:38641:] create, timeout 60000ms +0ms
  agentkeepalive sock[0#localhost:38641:](requests: 1, finished: 1) free +5ms
  prisma-client Response: +8ms
  prisma-client { findManychapter: [ { chapter_number: 1, id: 1 } ] } +0ms
  prisma-client Request: +2ms
  prisma-client query {
  prisma-client   findOnechapter(where: {
  prisma-client     id: 1
  prisma-client   }) {
  prisma-client     annotations {
  prisma-client       id
  prisma-client       text
  prisma-client       verseSpan
  prisma-client       textRange
  prisma-client       status
  prisma-client       createdAt
  prisma-client       updatedAt
  prisma-client     }
  prisma-client   }
  prisma-client } +0ms
  prisma-client disconnection promise doesnt exist +1ms
  prisma-client Request: +0ms
  prisma-client query {
  prisma-client   findOnechapter(where: {
  prisma-client     id: 1
  prisma-client   }) {
  prisma-client     book {
  prisma-client       book_lds_url
  prisma-client       book_long_title
  prisma-client       book_short_title
  prisma-client       book_subtitle
  prisma-client       book_title
  prisma-client       id
  prisma-client     }
  prisma-client   }
  prisma-client } +0ms
  prisma-client disconnection promise doesnt exist +1ms
  prisma-client Request: +1ms
  prisma-client query {
  prisma-client   findOnechapter(where: {
  prisma-client     id: 1
  prisma-client   }) {
  prisma-client     verses {
  prisma-client       id
  prisma-client       scripture_text
  prisma-client       verse_number
  prisma-client     }
  prisma-client   }
  prisma-client } +0ms
  prisma-client disconnection promise doesnt exist +0ms
  agentkeepalive sock[0#localhost:38641:] reset timeout to 60000ms +7ms
  agentkeepalive sock[0#localhost:38641:](requests: 2, finished: 1) reuse on addRequest, timeout 60000ms +1ms
  agentkeepalive sock[1#localhost:38641:] create, timeout 60000ms +3ms
  agentkeepalive sock[2#localhost:38641:] create, timeout 60000ms +0ms
  agentkeepalive sock[0#localhost:38641:](requests: 2, finished: 2) free +1ms
  prisma-client Response: +7ms
  prisma-client { findOnechapter: { annotations: [ [Object] ] } } +0ms
  prisma-client Request: +1ms
  prisma-client query {
  prisma-client   findOneAnnotation(where: {
  prisma-client     id: 16
  prisma-client   }) {
  prisma-client     author {
  prisma-client       id
  prisma-client       name
  prisma-client       email
  prisma-client       password
  prisma-client     }
  prisma-client   }
  prisma-client } +0ms
  prisma-client disconnection promise doesnt exist +1ms
  agentkeepalive sock[0#localhost:38641:] reset timeout to 60000ms +4ms
  agentkeepalive sock[0#localhost:38641:](requests: 3, finished: 2) reuse on addRequest, timeout 60000ms +0ms
  agentkeepalive sock[0#localhost:38641:](requests: 3, finished: 2) close, isError: false +5ms
  agentkeepalive sock[2#localhost:38641:](requests: 1, finished: 0) close, isError: false +0ms
  agentkeepalive sock[1#localhost:38641:](requests: 1, finished: 0) close, isError: false +1ms
  agentkeepalive sock[3#localhost:38641:] create, timeout 60000ms +1s
  agentkeepalive sock[3#localhost:38641:](requests: 1, finished: 0) error: Error: connect ECONNREFUSED 127.0.0.1:38641
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 38641
}, listenerCount: 2 +1ms
  agentkeepalive sock[3#localhost:38641:](requests: 1, finished: 0) close, isError: true +2ms
  agentkeepalive sock[4#localhost:38641:] create, timeout 60000ms +63ms
  agentkeepalive sock[4#localhost:38641:](requests: 1, finished: 0) error: Error: connect ECONNREFUSED 127.0.0.1:38641
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 38641
}, listenerCount: 2 +0ms
  agentkeepalive sock[4#localhost:38641:](requests: 1, finished: 0) close, isError: true +1ms
  agentkeepalive sock[5#localhost:38641:] create, timeout 60000ms +23ms
  agentkeepalive sock[5#localhost:38641:](requests: 1, finished: 0) error: Error: connect ECONNREFUSED 127.0.0.1:38641
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 38641
}, listenerCount: 2 +1ms
  agentkeepalive sock[5#localhost:38641:](requests: 1, finished: 0) close, isError: true +1ms
  agentkeepalive sock[6#localhost:38641:] create, timeout 60000ms +2s
  agentkeepalive sock[6#localhost:38641:](requests: 1, finished: 0) error: Error: connect ECONNREFUSED 127.0.0.1:38641
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 38641
}, listenerCount: 2 +1ms
  engine {
  engine   error: GotError [RequestError]: connect ECONNREFUSED 127.0.0.1:38641
  engine       at ClientRequest.<anonymous> (/opt/korihor/server/node_modules/@prisma/client/runtime/index.js:7144:14)
  engine       at Object.onceWrapper (events.js:313:26)
  engine       at ClientRequest.emit (events.js:228:7)
  engine       at ClientRequest.origin.emit (/opt/korihor/server/node_modules/@prisma/client/runtime/index.js:35400:11)
  engine       at Socket.socketErrorListener (_http_client.js:406:9)
  engine       at Socket.emit (events.js:228:7)
  engine       at emitErrorNT (internal/streams/destroy.js:92:8)
  engine       at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
  engine       at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  engine     name: 'RequestError',
  engine     code: 'ECONNREFUSED',
  engine     host: 'localhost:38641',
  engine     hostname: 'localhost',
  engine     method: 'POST',
  engine     path: '/',
  engine     socketPath: undefined,
  engine     protocol: 'http:',
  engine     url: 'http://localhost:38641/',
  engine     gotOptions: {
  engine       path: '/',
  engine       protocol: 'http:',
  engine       slashes: true,
  engine       auth: null,
  engine       host: 'localhost:38641',
  engine       port: '38641',
  engine       hostname: 'localhost',
  engine       hash: null,
  engine       search: null,
  engine       query: null,
  engine       pathname: '/',
  engine       href: 'http://localhost:38641/',
  engine       retry: [Object],
  engine       headers: [Object],
  engine       hooks: [Object],
  engine       decompress: true,
  engine       throwHttpErrors: true,
  engine       followRedirect: true,
  engine       stream: false,
  engine       form: false,
  engine       json: true,
  engine       cache: false,
  engine       useElectronNet: false,
  engine       body: '{"query":"query {\\n  findOneAnnotation(where: {\\n    id: 16\\n  }) {\\n    author {\\n      id\\n      name\\n      email\\n      password\\n    }\\n  }\\n}","variables":{}}',
  engine       agent: [Agent],
  engine       method: 'POST',
  engine       forceRefresh: true
  engine     }
  engine   }
  engine } +6s
  prisma-client Error: Engine exited {"target":"exit","timestamp":"2020-01-25T01:18:14.001Z","level":"error","fields":{"message":"255"}}
  prisma-client     at /opt/korihor/server/node_modules/@prisma/client/runtime/index.js:3387:27
  prisma-client     at processTicksAndRejections (internal/process/task_queues.js:94:5)
  prisma-client     at async PrismaClientFetcher.request (/opt/korihor/server/node_modules/@prisma/client/index.js:41:28)
  prisma-client     at async Promise.all (index 2)
  prisma-client     at async Promise.all (index 0)
  prisma-client     at async Promise.all (index 2)
  prisma-client     at async Promise.all (index 0)
  prisma-client     at async Promise.all (index 0) +3s
  agentkeepalive sock[6#localhost:38641:](requests: 1, finished: 0) close, isError: true +10ms
  agentkeepalive sock[7#localhost:38641:] create, timeout 60000ms +52ms
  agentkeepalive sock[8#localhost:38641:] create, timeout 60000ms +1ms
  agentkeepalive sock[7#localhost:38641:](requests: 1, finished: 0) error: Error: connect ECONNREFUSED 127.0.0.1:38641
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 38641
}, listenerCount: 2 +0ms
  engine {
  engine   error: GotError [RequestError]: connect ECONNREFUSED 127.0.0.1:38641
  engine       at ClientRequest.<anonymous> (/opt/korihor/server/node_modules/@prisma/client/runtime/index.js:7144:14)
  engine       at Object.onceWrapper (events.js:313:26)
  engine       at ClientRequest.emit (events.js:228:7)
  engine       at ClientRequest.origin.emit (/opt/korihor/server/node_modules/@prisma/client/runtime/index.js:35400:11)
  engine       at Socket.socketErrorListener (_http_client.js:406:9)
  engine       at Socket.emit (events.js:228:7)
  engine       at emitErrorNT (internal/streams/destroy.js:92:8)
  engine       at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
  engine       at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  engine     name: 'RequestError',
  engine     code: 'ECONNREFUSED',
  engine     host: 'localhost:38641',
  engine     hostname: 'localhost',
  engine     method: 'POST',
  engine     path: '/',
  engine     socketPath: undefined,
  engine     protocol: 'http:',
  engine     url: 'http://localhost:38641/',
  engine     gotOptions: {
  engine       path: '/',
  engine       protocol: 'http:',
  engine       slashes: true,
  engine       auth: null,
  engine       host: 'localhost:38641',
  engine       port: '38641',
  engine       hostname: 'localhost',
  engine       hash: null,
  engine       search: null,
  engine       query: null,
  engine       pathname: '/',
  engine       href: 'http://localhost:38641/',
  engine       retry: [Object],
  engine       headers: [Object],
  engine       hooks: [Object],
  engine       decompress: true,
  engine       throwHttpErrors: true,
  engine       followRedirect: true,
  engine       stream: false,
  engine       form: false,
  engine       json: true,
  engine       cache: false,
  engine       useElectronNet: false,
  engine       body: '{"query":"query {\\n  findOnechapter(where: {\\n    id: 1\\n  }) {\\n    book {\\n      book_lds_url\\n      book_long_title\\n      book_short_title\\n      book_subtitle\\n      book_title\\n      id\\n    }\\n  }\\n}","variables":{}}',
  engine       agent: [Agent],
  engine       method: 'POST',
  engine       forceRefresh: true
  engine     }
  engine   }
  engine } +64ms
  prisma-client Error: Engine exited {"target":"exit","timestamp":"2020-01-25T01:18:14.001Z","level":"error","fields":{"message":"255"}}
  prisma-client     at /opt/korihor/server/node_modules/@prisma/client/runtime/index.js:3387:27
  prisma-client     at processTicksAndRejections (internal/process/task_queues.js:94:5)
  prisma-client     at async PrismaClientFetcher.request (/opt/korihor/server/node_modules/@prisma/client/index.js:41:28)
  prisma-client     at async Promise.all (index 3)
  prisma-client     at async Promise.all (index 0)
  prisma-client     at async Promise.all (index 0) +63ms
Error:
Invalid `.author()` invocation in
/opt/korihor/server/src/resolvers/index.js:152:10

  148 return context.prisma.annotations
  149   .findOne({
  150     where: { id: root.id },
  151   })
→ 152   .author()

Engine exited {"target":"exit","timestamp":"2020-01-25T01:18:14.001Z","level":"error","fields":{"message":"255"}}
    at PrismaClientFetcher.request (/opt/korihor/server/node_modules/@prisma/client/index.js:62:23)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
Error:
Invalid `.book()` invocation in
/opt/korihor/server/src/resolvers/index.js:118:10

  114 return context.prisma.chapters
  115   .findOne({
  116     where: { id: root.id },
  117   })
→ 118   .book()

Engine exited {"target":"exit","timestamp":"2020-01-25T01:18:14.001Z","level":"error","fields":{"message":"255"}}
    at PrismaClientFetcher.request (/opt/korihor/server/node_modules/@prisma/client/index.js:62:23)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
  agentkeepalive sock[7#localhost:38641:](requests: 1, finished: 0) close, isError: true +12ms
  agentkeepalive sock[8#localhost:38641:](requests: 1, finished: 0) error: Error: connect ECONNREFUSED 127.0.0.1:38641
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 38641
}, listenerCount: 2 +1ms
  engine {
  engine   error: GotError [RequestError]: connect ECONNREFUSED 127.0.0.1:38641
  engine       at ClientRequest.<anonymous> (/opt/korihor/server/node_modules/@prisma/client/runtime/index.js:7144:14)
  engine       at Object.onceWrapper (events.js:313:26)
  engine       at ClientRequest.emit (events.js:228:7)
  engine       at ClientRequest.origin.emit (/opt/korihor/server/node_modules/@prisma/client/runtime/index.js:35400:11)
  engine       at Socket.socketErrorListener (_http_client.js:406:9)
  engine       at Socket.emit (events.js:228:7)
  engine       at emitErrorNT (internal/streams/destroy.js:92:8)
  engine       at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
  engine       at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  engine     name: 'RequestError',
  engine     code: 'ECONNREFUSED',
  engine     host: 'localhost:38641',
  engine     hostname: 'localhost',
  engine     method: 'POST',
  engine     path: '/',
  engine     socketPath: undefined,
  engine     protocol: 'http:',
  engine     url: 'http://localhost:38641/',
  engine     gotOptions: {
  engine       path: '/',
  engine       protocol: 'http:',
  engine       slashes: true,
  engine       auth: null,
  engine       host: 'localhost:38641',
  engine       port: '38641',
  engine       hostname: 'localhost',
  engine       hash: null,
  engine       search: null,
  engine       query: null,
  engine       pathname: '/',
  engine       href: 'http://localhost:38641/',
  engine       retry: [Object],
  engine       headers: [Object],
  engine       hooks: [Object],
  engine       decompress: true,
  engine       throwHttpErrors: true,
  engine       followRedirect: true,
  engine       stream: false,
  engine       form: false,
  engine       json: true,
  engine       cache: false,
  engine       useElectronNet: false,
  engine       body: '{"query":"query {\\n  findOnechapter(where: {\\n    id: 1\\n  }) {\\n    verses {\\n      id\\n      scripture_text\\n      verse_number\\n    }\\n  }\\n}","variables":{}}',
  engine       agent: [Agent],
  engine       method: 'POST',
  engine       forceRefresh: true
  engine     }
  engine   }
  engine } +12ms
  prisma-client Error: Engine exited {"target":"exit","timestamp":"2020-01-25T01:18:14.001Z","level":"error","fields":{"message":"255"}}
  prisma-client     at /opt/korihor/server/node_modules/@prisma/client/runtime/index.js:3387:27
  prisma-client     at processTicksAndRejections (internal/process/task_queues.js:94:5)
  prisma-client     at async PrismaClientFetcher.request (/opt/korihor/server/node_modules/@prisma/client/index.js:41:28)
  prisma-client     at async Promise.all (index 4) +12ms
  agentkeepalive sock[8#localhost:38641:](requests: 1, finished: 0) close, isError: true +3ms
kinimprovement dx

Most helpful comment

@pantharshit00 I had manipulated data directly with foreign key constraints disabled. So yes, constraints should have prevented this from happening and prisma2 generate did generate the correct restraints. But with projects that use an existing database, it's possible for constraints to not exist if the database wasn't created with constraints.

The issues with prisma as I see them relating to this are:

  1. Queries with a bad key shouldn't crash the query engine
  2. There should be an appropriate, helpful error message if this occurs
  3. Perhaps there should be a mechanism to restart the query engine if it crashes for any reason.

All 14 comments

Ok looking into this further, it looks like the query engine is dying for some reason. When I start my app I see the query engine process node_modules/@prisma/client/runtime/query-engine-debian-openssl-1.0. running. When I get the error, this process is no longer running. I'm not sure if this process has logs, or where to find them.

Ok I was able to figure out why the query engine is dying. I had a foreign key that was missing in the data that I was querying. So if you have a missing foreign key, the query engine crashes completely, and you can't perform any new queries since the query engine process is gone and doesn't get restarted.
By missing foreign key, I mean with a schema with:

model User {
  id          Int          @id @default(autoincrement())
  name        String       @unique
  email       String       @unique
  password    String
  annotations Annotation[]
}
model Annotation {
  id        Int               @id @default(autoincrement())
  text      String
  author    User
  createdAt DateTime          @default(now())
  updatedAt DateTime          @updatedAt
}

Then create an Annotation record with an author key that doesn't have an existing User record with that key in your database, and then query that annotation record.

@JWambaugh Do you imply that you introspected this schema and database doesn't have any constraints in place to ensure this type of inconsistency doesn't occur.

If you can, please share your database schema here.

@pantharshit00 I had manipulated data directly with foreign key constraints disabled. So yes, constraints should have prevented this from happening and prisma2 generate did generate the correct restraints. But with projects that use an existing database, it's possible for constraints to not exist if the database wasn't created with constraints.

The issues with prisma as I see them relating to this are:

  1. Queries with a bad key shouldn't crash the query engine
  2. There should be an appropriate, helpful error message if this occurs
  3. Perhaps there should be a mechanism to restart the query engine if it crashes for any reason.

I created this github repo that reproduces the problem. The schema has no foreign keys in the schema (I know this isn't how you should design a database, but people don't always do what they should)
https://github.com/JWambaugh/prisma2QueryEngineCrash
the createSchema.sql file creates the schema and example data in mysql.

Yeah, you are right about this that people don't always tend to follow the constraint and we should handle this in a way which doesn't crash the query engine process.

In the future when prisma engine is consumed via ffi I see this being minimized but till then I don't think we might fix this pretty soon as other this gets more priority over this.

(Sorry for accidental closure, accidentally hit the wrong button)

I think we indeed should handle this case much better. @JWambaugh's list in https://github.com/prisma/prisma-client-js/issues/435#issuecomment-579440801 seems like a really good starting point for us to look into that.

Thanks for the reproduction repo Jordan, that will make it super easy for us to pick this up and see what we can do. Appreciate it.

I see two next steps we can take here:

  1. Improve handling of crashes
  2. Improve handling of missing/incorrect foreign keys

(1) has already been done in the latest alpha.
(2) is a separate work item.

Internal note: dropping from current sprint

I am working with a fairly large database of 10k Cards, 2k Sets and 165k CardPrints.
I am exposing this dataset to users via Type GraphQL generators.

A user could request something like

{
  cards {
    id
    sets {
      id
      cardPrint {
        id
      }
    }
  }
}

(~10 sets per card, ~50 prints per set = 5 million results)
This results in a long query that crashes the query engine and fails all future request until I manually restart the docker image the API is deployed in.

It would be very helpful if either (a) long running queries didn't crash the entire engine (b) an error was thrown when the crash occurs on long running queries like this OR (c) the query engine restarts when it crashes, preferably all of these.

Is there anything blocking this issue from being resolved?
If I make a PR that provides simple fixes for these will it be looked at and merged in a timely manner?

Update: Looking at my looks it looks like the query may have died due to running out of RAM.
This is from my logs on Digital Ocean and it may not be polling every second so there is a good chance that I actually hit 100% RAM usage. I have 4GB of RAM on this server, by my calculations I would need 9GB for 5 million rows.

Screen Shot 2020-04-29 at 18 41 49

Please open a new issue with this information @wSedlacek if your problem is not the same as the original one ("invalid prisma.() invocation (query engine dying?) on missing foreign key") in this issue.

Please open a new issue with this information @JWambaugh if your problem is not the same as the original one ("invalid prisma.() invocation (query engine dying?) on missing foreign key") in this issue.

@janpio The error of Invalid prisma.() invocation is the same with the Query Engine dying, the cause is just different, rather then missing foreign key mine is caused by running out of RAM. Given this I am not sure if you want another issue made or if you want to just update this issue.
The real problem is simply how Prisma behaves when it crashes, the cause of the crash isn't important for this issue imho.

Please open a new issue @wSedlacek (me mentioning JWambaugh before of course was a mistake)

This is fixed in the latest version. In case you still face any issues, please let us know.

Was this page helpful?
0 / 5 - 0 ratings