Postgres Migration taking a long time, can I still use the database it's migrating from?

Hey, db has been migrating for over an hour and some production services are down. Could use some help here
48 Replies
Percy
Percy6mo ago
Project ID: db735447-598c-455d-b1be-6718e98e1aff
0xdima95
0xdima956mo ago
db735447-598c-455d-b1be-6718e98e1aff
Brody
Brody6mo ago
@fp - database migration stuck
Faraz
Faraz6mo ago
Hmm, I think the migration is complete but the workflow is failing to detect the same. Did you manually make any changes to the migration service or the new DB?
0xdima95
0xdima956mo ago
production is totally busted right now i did not make any manual changes
Faraz
Faraz6mo ago
Okay, so I think the migration went fine and our system failed to detect the same. I've manually canceled the migration.
0xdima95
0xdima956mo ago
but i did deploy a service that runs a prisma migration while it was migrating yeah my bad
Faraz
Faraz6mo ago
Could you verify the data was moved properly and then just port over the variables? I think you should be good.
0xdima95
0xdima956mo ago
it looks like the data is good yes
Faraz
Faraz6mo ago
Basically, any service that uses the legacy db, point it to the new db.
0xdima95
0xdima956mo ago
going to do that right now, will get back to you yup
Faraz
Faraz6mo ago
@Brody feel free to loud tag me as I am stepping away from the desk for dinner.
0xdima95
0xdima956mo ago
updated everything, still cant connect but I can connect locally with the connectionstring so something must be wrong on my setup
Brody
Brody6mo ago
what errors are you getting
0xdima95
0xdima956mo ago
cant reach database server at 'viaduct.proxy.rlwy.net':'23653'
Brody
Brody6mo ago
can you add a 3 second sleep to the beginning of your start commands?
0xdima95
0xdima956mo ago
yeah that didn't change it, it appears to be a problem with the connection string probably something really stupid
Brody
Brody6mo ago
can you show me how youve added the sleep?
0xdima95
0xdima956mo ago
should i be using the private url for postgres? Where should the sleep be? i just put a 3 second sleep befre starting the app. Its an express app
Brody
Brody6mo ago
if you dont want to be charged for egrees, yes can you show me how youve added the sleep?
0xdima95
0xdima956mo ago
like i said, its a 3 second await in the main function, before starting the application
Brody
Brody6mo ago
in the start command please
0xdima95
0xdima956mo ago
on railway?
Brody
Brody6mo ago
whatever is most applicable, that or in the start script of your package.json
0xdima95
0xdima956mo ago
"start": "sleep 3 & prisma migrate deploy && node build/server.js", this doesnt actually sleep for 3 seconds better way to do this?
Brody
Brody6mo ago
why wouldnt that sleep for 3 seconds?
0xdima95
0xdima956mo ago
locally it just rips right through it, i dont know ill try and deploy can I have two different postgres instances in the same project? or do the postgres variable references overlap? a bit confused aboutthat
Brody
Brody6mo ago
absolutely, the references can't overlap because you can't have two services with the same names
0xdima95
0xdima956mo ago
yup i can see that now sleep didnt fix it im certain its an issue with the connection string I don't know how, but it is
Brody
Brody6mo ago
can you connect to the database locally
0xdima95
0xdima956mo ago
yes i know the problem, but i dont know why its happening
Brody
Brody6mo ago
are you sure railway is using the start script with the sleep?
0xdima95
0xdima956mo ago
yes, and now im getting a prisma migration error so it's actually connecting to db hold on doing a migration rollback...
Brody
Brody6mo ago
when does the service run the migration? and are you trying to use the private url now?
0xdima95
0xdima956mo ago
Im using the private url on prod but when i run the migration on the prod db locally, im using the public start script is sleep for 3, migrate, and run
Brody
Brody6mo ago
can you maybe show me why you are sure railway is running a start command with the sleep in it
0xdima95
0xdima956mo ago
I fixed it Whew. Thanks for the help it was 2 issues. Sleep helped it, plus the migration issue i can delete these old legacy dbs right?
Brody
Brody6mo ago
as long as you have confirmed your data is where it should be
0xdima95
0xdima956mo ago
deleting them, prod is stable and online. Thank youa gain
Brody
Brody6mo ago
glad to hear it!
0xdima95
0xdima956mo ago
why does this fix this?
Brody
Brody6mo ago
theres a private network init time
0xdima95
0xdima956mo ago
still getting it but only on one of my services should i try upping the sleep time?
Brody
Brody6mo ago
sure
0xdima95
0xdima956mo ago
sleep 8 & yarn start not doing anything... ill try with a semi colon?
Brody
Brody6mo ago
&&
0xdima95
0xdima956mo ago
whoops