-
Notifications
You must be signed in to change notification settings - Fork 325
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
Deployment fails on 2nd deployment due to Prisma migration error #598
Comments
I just tried the whole flow you described myself, and everything worked fine for me until I made a code change and attempted to deploy that. Here were my steps. I simply followed the prompts (answering "yes" to everything) when running
Then I added the That deploy worked out fine:
You'll notice logs from litefs because there's a bit of downtime between deploys (this is not a problem once you add another instance). Then I made a code change and tried deploying again and that failed: https://github.com/kentcdodds/epic-stack-issue-598/actions/runs/7560580501 With these logs:
I'm not certain what caused the migration to fail, but this is definitely a problem. I'll try to find time to investigate further, but any help is appreciated! |
It should be noted that the Epic Stack template project is working fine, so there's probably something funny going on with a new project. |
Same issue with me! I found this article here and was about to try: @kentcdodds If I fork the Epic Stack template and create my project from there, is it supposed to work? |
Forking it shouldn't make any difference with the migration. Also, I'm not sure this is related because we didn't make any changes to the migration. |
What I find is interesting is that the error says:
But if you look at the previous logs it says that migration was successful. This seems like a prisma issue to me. But I'm not sure what's going on.
|
Perhaps is a bug in the latest prisma. So I've updated all deps and we'll see if the Epic Stack deploy fails: 97d789f |
That deploy worked ok. So it's unlikely to be a Prisma regression. But there's definitely something going wrong here. I'm afraid I don't have the resources to look into this right now so any help from anyone else is welcome. |
I did a bit of digging. Looking at the sqlite database generated on fly.io, the In a succesful dev migration copy of the database, these are the Still not sure why this happening. Especially with Prisma claiming successful migration on the initial push. Even more odd, it seems that none of the tables actually exist in the fly.io db until after something in the app uses them. |
Alright. This is a wild one folks. I suspect there is an odd interaction somewhere between Prisma migrations, SQLite and LiteFS at this point. I realized that the database I was exporting and grabbing would slowly have more of the initial schema in it as I added more notes and played around in the app. After a fresh app, once I got the txnid of LiteFS up to I ran the deploy same base deploy again with no migration and it worked just fine this time. I am able to consistently reproduce this. Deploy fresh app, create a bunch of actions on the database, second deploy now works. Someone that knows more about LiteFS and/or Prisma may have more of an idea why this happens. |
Same issue here. Following. I've created yesterday a fresh new app (and one today with the latest version) and the issue is still there. There is a perfectly working first deploy and then (in my case adding a secret to fly) the deployment process just stop. I copy and paste the error I can see from the console (hope it helps)
Also, I may ask. Is there any way to bootstrap an old version of the EpicStack (if you think this can solve the current issue, as I'm starting from scratch right now)? |
I just removed LiteFS from the equation: kentcdodds/epic-stack-issue-598@ce2e508 (https://github.com/kentcdodds/epic-stack-issue-598/actions/runs/7572607626/job/20622905749) That made a successful deploy:
So I did another deploy to make sure a follow-up deploy works and it did: https://github.com/kentcdodds/epic-stack-issue-598/actions/runs/7572672223/job/20623113200
So I'm pretty confident this is a LiteFS issue. |
Ok, @benbjohnson investigated and open an issue on LiteFS: superfly/litefs#425 A fix is to just do migrations before setting up WAL. d194759 I haven't confirmed this solves the problem myself, so if someone else would like to do that, I would appreciate it! |
@kentcdodds later in the day I'll make a test with the @latest and let you know. In the meantime, trying to apply your patch didn't work as expected
I'm gonna investigate also on this later on. |
Temporary solved issue on .sh extension making a
Still, having some troubles finding the DB.
In a couple of hours I'll continue the debug with @latest |
Hey guys, for some reason this issue is closed, are we sure its liteFS? im also having these errors in the past few days (tried to open several projects), trying to figure out whats wrong, will follow this topic as well 🙏 |
@kentcdodds the fix to do migrations before setting up WAL worked. |
Applied the fix and it worked for me as well. I was able to submit several commits with successful deployments. And then I tried to modify the prisma schema and generate a new migration file. I end up getting the same error as before, failed migration. P3009
|
For those following this is now fixed on v.0.5.11 with the pr superfly/litefs#426 |
Can someone confirm this actually fixes the issue of using WAL mode? I was under the impression that this doesn't fix WAL mode and instead just improves the error message, but I could be reading this wrong... |
@kentcdodds The change prevents WAL mode writes from being used with exclusive locking mode which will show as an error in the LiteFS logs. I posted an issue against the |
Good issue to up-vote everyone! Thanks Ben! |
Can I still make comments on a Closed issue? I have tried to move Here is the error that I see...
|
Based on the error it looks like it's completely unrelated to anything in the Epic Stack. My guess is it's something wrong with this package that I'm guessing you added: https://www.npmjs.com/package/prisma-erd-generator You'll have to try and understand the requirements for that package and make sure you update your dockerfile to satisfy those system requirements. Or just remove the package because it looks like it's only necessary for development. |
Thanks so much, @kentcdodds! And thanks for the quick response! |
I just created a brand new Epic Stack to show someone how it worked. Ran through the setup following the docs and choosing the defaults. Deployed to Fly.io, which worked, and then setup a GitHub repo per the Deployment doc. Pushed the code and get a Prisma migration error.
Verified this by starting a new Epic Stack and doing it again, ensuring no code changes get made and following the instructions in the documentation. It also fails on the 1st push to GitHub (and the 2nd deployment to fly)
Is there potentially some secret that's not getting set in Fly for the database location?
The text was updated successfully, but these errors were encountered: