Migrate lock timeout on PlanetScale
See original GitHub issueWhen using Migrate with PlanetScale, sometimes you get an error message like this:
Error querying the database: Server error: `ERROR 70100 (1317): held locks released: vttablet: rpc error: code = Aborted desc = transaction 1621634564893708666: ended at 2021-05-21 23:54:48.118 UTC (exceeded timeout: 20s) (CallerID: unsecure_grpc_client)'
Also see all the related reports here: https://github.com/planetscale/beta/discussions/34
Two possible causes we can think of:
- Wait to long when CLI prompts your for migration name
- Migrations take “to long” to run (Reproducible easily with https://stackoverflow.com/questions/4284524/how-and-when-to-use-sleep-correctly-in-mysql)
We should try to reproduce both so we know if we have something that needs fixing. It might also be worth to investigate if something like this could happen on other database providers as well or if this is PlanetScale/Vitess specific.
(Potential solutions: Only lock after migration name is known, do not lock on PlanetScale at all, etc)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Automatic Rails migrations - PlanetScale
In this tutorial, you're going to learn how Rails migrations work with ... to your production databases without downtime or locking tables.
Read more >Stop worrying about PostgreSQL locks in your Rails migrations
Our best option here is to add a lock timeout, which will abort the migration if the lock is not acquired after a...
Read more >Transactions - Prisma
Optimistic concurrency control (OCC) is a model for handling concurrent operations on a single entity that does not rely on locking. Instead, we ......
Read more >What database are you using and why? - Indie Hackers
I only once so far on my app got a timeout error as the whole DB is locked for writes and I guess...
Read more >OnlineMigrations Alternatives - Ruby Database Tools | LibHunt
Catch unsafe PostgreSQL migrations in development and run them easier in ... def change # Lower PostgreSQL's lock timeout to avoid statement ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure, thanks for the quick reply @janpio
I used
prisma migrate dev
as my primary workflow through the bootstrapping of my app and saw a gradual increase in the time it took.When I reached 64 migrations (most of these were attempts to debug #10758 issues) my migrate flow hit the 20s Planetscale timeout and I got the error above.
This happened even if I pre-typed my migration name as the process started so that it immediately filled and didn’t add any real time to the process.
I’m using
prisma db push
now, which executes in 1.1s.I will create fresh dbs locally and on planetscale and run a single initial migration soon. If this jumps me back into the timeout I’ll report back here.