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.

Sig Bus when using update/upsert with PlanetScale

See original GitHub issue

Bug description

When trying to update a record using either update or upsert the node process crashes with a bus error. Workaround: update the record using prisma.$execRaw

How to reproduce

  1. Create a simple model using PlanetScale as the database
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["referentialIntegrity"]
}

datasource db {
  provider             = "mysql"
  url                  = env("DATABASE_URL")
  shadowDatabaseUrl    = env("SHADOW_DATABASE_URL")
  referentialIntegrity = "prisma"
}

model Counter {
  id                  String          @id @default(cuid())
  createdAt           DateTime        @default(now())
  updatedAt           DateTime        @updatedAt
  amount          Int
}
  1. Insert a record using await prisma.counter.create(...)
  2. Attempt to update the record using await prisma.counter.update({ data: { amount: 100 }})
  3. Watch node crash

Expected behavior

Record should be updated in the database

Prisma information

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["referentialIntegrity"]
}

datasource db {
  provider             = "mysql"
  url                  = env("DATABASE_URL")
  shadowDatabaseUrl    = env("SHADOW_DATABASE_URL")
  referentialIntegrity = "prisma"
}

model Counter {
  id                  String          @id @default(cuid())
  createdAt           DateTime        @default(now())
  updatedAt           DateTime        @updatedAt
  amount          Int
}

Environment & setup

  • OS: MacOs
  • Database: PlanetScale (MySQL)
  • Node.js version: v17.2.0

Prisma Version

prisma                  : 3.6.0
@prisma/client          : 3.6.0
Current platform        : darwin
Query Engine (Node-API) : libquery-engine dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : dc520b92b1ebb2d28dc3161f9f82e875bd35d727
Studio                  : 0.440.0
Preview Features        : referentialIntegrity

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kaylegcommented, Dec 22, 2021

Working perfectly in 3.7.0 for me. Thanks @janpio

2reactions
mxkaskecommented, Dec 6, 2021

We had the same issue with Planetscale.

Downgrading to "prisma": "3.5.0" and "@prisma/client": "3.5.0" did the job.

Not the best answer, but a solution for the short term…

Read more comments on GitHub >

github_iconTop Results From Across the Web

PlanetScale quickstart guide
Name your database using lowercase, alphanumeric characters or ... This quickstart demonstrates how to create and use two relational tables: ...
Read more >
The PlanetScale workflow
Use the PlanetScale workflow for branching databases, non-blocking schema changes and more.
Read more >
Building PlanetScale with PlanetScale
You're probably wondering–if you use MySQL for local development, when do you use PlanetScale? When it comes time to make schema changes, we...
Read more >
MySQL compatibility - PlanetScale
If you're importing an existing database, PlanetScale supports MySQL database versions 5.7 through 8.0 . New PlanetScale databases are ...
Read more >
Bring your data to PlanetScale
We're happy to announce that PlanetScale now supports zero downtime data migrations from your existing MySQL database.
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