drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]:trx taking too long to return an error on unique index

Open pedro199288 opened this issue 1 year ago • 1 comments

What version of drizzle-orm are you using?

0.26.1

What version of drizzle-kit are you using?

0.18.1

Describe the Bug

I have created this repo to reproduce the bug: https://github.com/pedro199288/drizzle-trx-bug/tree/main

After installing packages and configuring the DB variables and making the migration, just run the index.ts file with node --loader @esbuild-kit/esm-loader ./src/index.ts

the first time the code will work and insert the row as expected, but the second it will fail because unique index rule violation. All good till this point. The thing is that it takes a lot of time (mostly 20 seconds) to return the expected error. This only happens when making an insertion inside a transaction. But not on a regular insertion (you can test it uncommenting the relevant code in src/index.ts file).

I've already talked to planetscale support people and doesn't seem to be related to them, so maybe there is something going wrong on drizzle side? 🤔

thanks in advance for the help!

Expected behavior

The error is returned within a reasonable time frame

Environment & setup

  • install packages
  • set planetscale credentials in src/connection.ts file
  • run migration
  • execute node --loader @esbuild-kit/esm-loader ./src/index.ts

pedro199288 avatar May 29 '23 12:05 pedro199288

After doing more research, It looks like this issue is only happening when using the planetscale driver option (https://orm.drizzle.team/docs/installation-and-db-connection/mysql/planetscale).

When using the mysql2 node option (https://orm.drizzle.team/docs/installation-and-db-connection/mysql/mysql2) it doesn't happen

pedro199288 avatar May 30 '23 08:05 pedro199288

Can we close this as a driver issue? Have you reached out to planescale for support?

Angelelz avatar Dec 18 '23 23:12 Angelelz

yeah sorry, it can be closed! It's definitely a driver issue.

pedro199288 avatar Dec 22 '23 21:12 pedro199288