New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: db error: ERROR: canceling statement due to statement timeout #16853
Comments
Which connection string from Supabase are you using in your app? (Should not influence things really, but just to clarify) Generally this sounds more like a problem on the database side on Supabase. Prisma is just reporting what the database told it, and the steps you are following usually are expected to run without any problem. |
having this happen to me. Also with supabase and using their connection string. I've tried to do a migration using SQLite instead and it works |
Prisma has been a pain to work with. Cannot work with elephatant sql and shows this when working with supabase. Too many issues to work around |
I'm having exactly the same issue. |
It looks like we're hitting the default supabase timeout of 2 minutes - from the supabase docs:
I timed how long it took the error message to appear after hitting enter on the migrate command and it took 2:06 |
Thanks for this research @samdigitalpanda, might be we should add this as a known error and give a better error message. It is really unfortunate that Supabase caps the query runtime like that. Are you doing any super heavy things in your migration that are supposed to take 2+ minutes? |
No I don't think so, adding two new tables with a couple of relations to other already existing tables. I did wonder if that could possibly be breaching the run time limit somehow and tried a migration with just adding a single column to a table and it still timed out. |
I found this thread yesterday as I was running into the exact same issue with Supabase. I eventually just ran a |
Ok, so a super simple migration that only adds a single column also times out after 2 minutes? That is weird and maybe worth an investigation with Supabase support. Maybe something is wrong with that database. |
Hmm thanks I will talk to them. I appreciate this is probably not a prisma issue. As someone said above the error message does seem to suggest that the error is coming from the DB provider and not prisma thanks to the 'Error: DB Error' line, so kudos for making that clear in your error messages at least! |
I've since spun up a postgres docker container and run the same migrations which worked, giving further credence to this being a supabase issue rather than prisma. Thanks for your help all. |
If I'm not mistaken db push will work just fine on initial setup right? |
This did work and got my supabase instance in line with my prisma schema. Trying to run prisma migrate dev after this still fails with the same error though |
Hi all, I too was having the same problem following the Mastering Nuxt 3 course. I ran a packet capture to see if there's any resets and who it's coming from. The resets seem to be normal resets (connection closing) but seems the connections closing may have been initiated by the client. I can't decrypt the capture so not sure exactly. However, in doing some more research for this issue, a user named mmoreno, also having the same issue, found this where Prisma is suggesting that you must include a shadowDatabaseUrl for cloud hosted db's. Then running a prisma db push followed by a prisma migrate dev worked for that user. This seemed to work for me. Here's the steps I took:
Before doing this running migrate failed even after running |
pootytang you are the man. Thanks!! |
@pootytang that worked for me too, thanks!! |
Made everything like pootytang described, still fails to migrate UPD made actual shadow database like mentioned in Supabase docs and it worked |
@pootytang Pootytang I did the same thing as you mentioned, and I am also doing the mastering nuxt 3 course, but for some reason, it will drop an error when trying to read the env. file, the only way it works is if I type my env key directly in the schema which is not the ideal way I guess, could it be because I am using windows and not a mac? this is what I get if i use env in schema: `Environment variables loaded from .env Validation Error Count: 1` |
I'm pretty sure something broke on the supabase end here. I was using supabase + prisma without issue but just tried to do a migration and hit the issue here.
I tried adding the SHADOW_DATABASE_URL env var per #16853 (comment) and I no longer get a timeout in Prisma. I can run migrate reset but when I try to create a new migration right after (even an empty one), I get:
EDIT: |
Thanks @gpeal. |
That also worked for me! Thanks! |
You save my day! |
Per the above referenced issue, this is what solved things for me: Specifically, needed to connect to postgres and run |
@pootytang it works, wow! |
After performing a reset, added the shadow database items then was able to perform a "migrate dev" without "db push". Thanks : ) |
Hey everyone, we are investigating this together with Supabase. Here is our public issue for this: supabase/supabase#11691 As long as the problem persists, you can indeed manually |
Problem confirmed by Supabase now: supabase/supabase#11691 (comment) Until this is figured out, please keep using the workaround of using a |
I was working through these Supabase directions over the weekend and got stuck on the whole 'create a ghost database' thing. I couldn't find a spot within the project in the Supabase dashboard to create the ghost or a CLI to create it. I'm sure I'm missing something. Where can you go or what are the steps to create the ghost database? |
The directions are referring to the PostgreSQL CLI |
Hi @trinkel - you should be able to run this command through the dashboard's SQL editor: Alternatively, if you prefer to install a standalone application to manage your database and can't use Postgres.app, pgAdmin is cross-platform and quite full featured. |
You can also create a second project on Supabase and use the database of that project. This will hopefully soon all be not necessary any more when the bug is fixed on Supabase side and all their databases have been updated. Afterwards we will also clean up their documentation on how to use Prisma. |
@matthewatkins @pcnc : Thank you, thank you, thank you. That's exactly what I needed. I knew what to do, but I couldn't find where to do it.
Thanks again for a quick and concise response. |
As per Supabase, this should not be necessary any more as they fixed their PostgreSQL:
Would be great if you could try to remove the |
@janpio: I saw that note and tried a new project last night. I got the same error. I figured it might not be ramped up yet. I'll try it again when I get a chance. Thanks! |
@timrinkel we rolled out the new version today at around 7AM UTC. It is necessary to pause/unpause your current project to be launched with the latest Postgres version. If your project can't be paused, then contacting support to do this on behalf of you is also possible. |
@pcnc: Kinda what I figured: just tried too soon. I'll give it another shot over lunch (day-jobs always getting in the way of progress). Thanks! |
@pcnc, @janpio: So, lunch didn't happen. Sorry. Anyway, I can confirm that after pausing/refreshing my project, I also created a new project and So, I guess Ta-Das are in order. Thanks! |
|
Manual definition of a shadow database should not be necessary for Supabase any more. If it is for you, please open a new issue. Thanks. |
I have used Prisma against Supabase without creating a shadow db a couple of times since this was fixed and it has worked for me. |
@janpio If I do not define a shadow db, I cannot create a migration locally. The schema is migrated correctly on Supabase, but there is no generated db migration file in my local repo. Is that the normal behaviour or does it worth opening a new issue? Cheers! |
Absolutely not expected and worth creating an issue with as much info as possible. That sounds pretty weird. |
Will do. Cheers @janpio |
I am experiencing the same (or similar) error when working with Prisma + Supabase. I have a table with around 7M rows with multiple Decimal fields. I changed one of the field's type to
This is the error I got:
Not sure if the fix on supabase side here is relevant since (if I understand correctly) is applied to |
Bug description
I set up a free tier project on supabase with no changes to the project. I then followed this guide. When I got to the step
prisma migrate dev --name init
, I received this error ...I took a stab at running
prisma migrate reset
to see if that would fix anything and that seemed to run.How to reproduce
Expected behavior
No response
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: