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.

The `ConnectorError` `cached plan must not change result type` periodically appears (Postgres).

See original GitHub issue

Bug description

I’ve got several test suites for the graphql API (built with ApolloServer & Prisma). The tests basically run some queries against the API endpoint with the apollo client. They are standalone (imitate user queries to the API). API uses a dev database (local Postgres docker container) and a locally running server.

An error occurs periodically, I can run 1 test file a few times and it passes, then this error occurs, after that again the tests pass.

console.error src/tests/utils/ErrorLog.ts:7
    Exception: {
      errors: [
        {
          message: '\n' +
            'Invalid `prisma.company.create()` invocation:\n' +
            '\n' +
            '\n' +
            '  Error occurred during query execution:\n' +
            'ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("0A000"), message: "cached plan must not change result type", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("plancache.c"), line: Some(722), routine: Some("RevalidateCachedQuery") }) }) })',
          locations: [],
          path: [Array]
        }
      ],
      stacktrace: [
        'Error: ',
        'Invalid `prisma.company.create()` invocation:',
        '',
        '',
        '  Error occurred during query execution:',
        'ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("0A000"), message: "cached plan must not change result type", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("plancache.c"), line: Some(722), routine: Some("RevalidateCachedQuery") }) }) })',
        '    at new CombinedError (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/stitching/errors.ts:90:5)',
        '    at Object.checkResultAndHandleErrors (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/stitching/errors.ts:111:11)',
        '    at CheckResultAndHandleErrors.transformResult (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/transforms/CheckResultAndHandleErrors.ts:15:12)',
        '    at /Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/transforms/transforms.ts:37:45',
        '    at Array.reduce (<anonymous>)',
        '    at applyResultTransforms (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/transforms/transforms.ts:35:21)',
        '    at /Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/stitching/delegateToSchema.ts:104:12',
        '    at step (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:32:23)',
        '    at Object.next (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:13:53)',
        '    at fulfilled (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:4:58)'
      ]
    }

OR this error occurs if some tests pass in the suite

console.error src/tests/utils/ErrorLog.ts:7
    Exception: {
      errors: [
        {
          message: '\n' +
            'Invalid `prisma.salesDomain.create()` invocation:\n' +
            '\n' +
            '\n' +
            '  Error occurred during query execution:\n' +
            'ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("0A000"), message: "cached plan must not change result type", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("plancache.c"), line: Some(722), routine: Some("RevalidateCachedQuery") }) }) })',
          locations: [],
          path: [Array]
        }
      ],
      stacktrace: [
        'Error: ',
        'Invalid `prisma.salesDomain.create()` invocation:',
        '',
        '',
        '  Error occurred during query execution:',
        'ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("0A000"), message: "cached plan must not change result type", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("plancache.c"), line: Some(722), routine: Some("RevalidateCachedQuery") }) }) })',
        '    at new CombinedError (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/stitching/errors.ts:90:5)',
        '    at Object.checkResultAndHandleErrors (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/stitching/errors.ts:111:11)',
        '    at CheckResultAndHandleErrors.transformResult (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/transforms/CheckResultAndHandleErrors.ts:15:12)',
        '    at /Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/transforms/transforms.ts:37:45',
        '    at Array.reduce (<anonymous>)',
        '    at applyResultTransforms (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/transforms/transforms.ts:35:21)',
        '    at /Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/src/stitching/delegateToSchema.ts:104:12',
        '    at step (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:32:23)',
        '    at Object.next (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:13:53)',
        '    at fulfilled (/Users/jackiejo/main/smidyo/smidyo-monorepo/quoting-portal/api/node_modules/apollo-server/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:4:58)'
      ]
    }

Also this periodically appears on postgres log in docker

dev-postgres_postgres_1 | 2021-06-15 14:09:35.072 UTC [35] ERROR: cached plan must not change result type

How to reproduce

Please refer to this repository: https://github.com/JackieJoo/prisma-error-sample

Expected behavior

No response

Prisma information

Environment & setup

  • OS: Mac OS
  • Database: PostgreSQL
  • Node.js version: v14.15.1

Prisma Version

2.24.1

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
MarcusHSmithcommented, Oct 17, 2022

Is there any news on this thread?

4reactions
pantharshit00commented, Apr 19, 2022

I can reproduce this after running the reproduction twice.

It doesn’t seem to happen if I add &statement_cache_size=0 to the connection string so looks like a bug in the statement cache implementation. Add this to the connection string as a workaround for now.

You need to enable mode using DEBUG=* to see these error logs. I am marking this as confirmed bug.

Relevant stack traces:

  
 prisma:client:fetcher Error: Error occurred during query execution:
  prisma:client:fetcher ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("0A000"), message: "cached plan must not change result type", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("plancache.c"), line: Some(722), routine: Some("RevalidateCachedQuery") }) }) })
  prisma:client:fetcher     at NodeEngine.graphQLToJSError (C:\Users\harshit\code\reproductions\prisma-error-sample\node_modules\@prisma\client\runtime\index.js:28016:14)
  prisma:client:fetcher     at NodeEngine.request (C:\Users\harshit\code\reproductions\prisma-error-sample\node_modules\@prisma\client\runtime\index.js:27912:24)
  prisma:client:fetcher     at processTicksAndRejections (internal/process/task_queues.js:95:5) +117ms
prisma:client:fetcher Error: An operation failed because it depends on one or more records that were required but not
found. No 'User' record(s) (needed to inline the relation on 'Post' record(s)) was found for a nested connect on one-to-many relation 'PostToUser'.
  prisma:client:fetcher     at NodeEngine.graphQLToJSError (C:\Users\harshit\code\reproductions\prisma-error-sample\node_modules\@prisma\client\runtime\index.js:28014:16)
  prisma:client:fetcher     at NodeEngine.request (C:\Users\harshit\code\reproductions\prisma-error-sample\node_modules\@prisma\client\runtime\index.js:27912:24)
  prisma:client:fetcher     at processTicksAndRejections (internal/process/task_queues.js:95:5)
  prisma:client:fetcher     at cb (C:\Users\harshit\code\reproductions\prisma-error-sample\node_modules\@prisma\client\runtime\index.js:33786:26) +17ms
Read more comments on GitHub >

github_iconTop Results From Across the Web

Postgres: "ERROR: cached plan must not change result type"
I figured out what was causing this error. My application opened a database connection and prepared a SELECT statement for execution.
Read more >
Error: "cached plan must not change result type" - PostgreSQL
Dear Members! At Friday one of our clients got this error: "cached plan must not change result type". He restarted the application and...
Read more >
V3: 'cached plan must not change result type' error by Enum ...
Hi, I'm faced with 'cached plan must not change result type' error on Postgres DB with redwood 3.0.1. It will reproduce when Prisma...
Read more >
ActiveRecord “ERROR: cached plan must not change result ...
Unfortunately this meant that both apps would need to share the original PostgreSQL database for a period of time. Now generally this is ......
Read more >
cached plan must not change result type" when mixing DDL ...
29K subscribers in the PostgreSQL community. The home of the most advanced Open Source database server on the worlds largest and most active ......
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