R
Railway12mo ago
0xdima95

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
Percy12mo ago
Project ID: db735447-598c-455d-b1be-6718e98e1aff
0xdima95
0xdima95OP12mo ago
db735447-598c-455d-b1be-6718e98e1aff
Brody
Brody12mo ago
@fp - database migration stuck
Faraz
Faraz12mo 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
0xdima95OP12mo ago
production is totally busted right now i did not make any manual changes
Faraz
Faraz12mo ago
Okay, so I think the migration went fine and our system failed to detect the same. I've manually canceled the migration.
0xdima95
0xdima95OP12mo ago
but i did deploy a service that runs a prisma migration while it was migrating yeah my bad
Faraz
Faraz12mo ago
Could you verify the data was moved properly and then just port over the variables? I think you should be good.
0xdima95
0xdima95OP12mo ago
it looks like the data is good yes
Faraz
Faraz12mo ago
Basically, any service that uses the legacy db, point it to the new db.
0xdima95
0xdima95OP12mo ago
going to do that right now, will get back to you yup
Faraz
Faraz12mo ago
@Brody feel free to loud tag me as I am stepping away from the desk for dinner.
0xdima95
0xdima95OP12mo ago
updated everything, still cant connect but I can connect locally with the connectionstring so something must be wrong on my setup
Brody
Brody12mo ago
what errors are you getting
0xdima95
0xdima95OP12mo ago
cant reach database server at 'viaduct.proxy.rlwy.net':'23653'
Brody
Brody12mo ago
can you add a 3 second sleep to the beginning of your start commands?
0xdima95
0xdima95OP12mo ago
yeah that didn't change it, it appears to be a problem with the connection string probably something really stupid
Brody
Brody12mo ago
can you show me how youve added the sleep?
0xdima95
0xdima95OP12mo 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
Brody12mo ago
if you dont want to be charged for egrees, yes can you show me how youve added the sleep?
0xdima95
0xdima95OP12mo ago
like i said, its a 3 second await in the main function, before starting the application
Brody
Brody12mo ago
in the start command please
0xdima95
0xdima95OP12mo ago
on railway?
Brody
Brody12mo ago
whatever is most applicable, that or in the start script of your package.json
0xdima95
0xdima95OP12mo ago
"start": "sleep 3 & prisma migrate deploy && node build/server.js", this doesnt actually sleep for 3 seconds better way to do this?
Brody
Brody12mo ago
why wouldnt that sleep for 3 seconds?
0xdima95
0xdima95OP12mo 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
Brody12mo ago
absolutely, the references can't overlap because you can't have two services with the same names
0xdima95
0xdima95OP12mo 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
Brody12mo ago
can you connect to the database locally
0xdima95
0xdima95OP12mo ago
yes i know the problem, but i dont know why its happening
Brody
Brody12mo ago
are you sure railway is using the start script with the sleep?
0xdima95
0xdima95OP12mo ago
yes, and now im getting a prisma migration error so it's actually connecting to db hold on doing a migration rollback...
Brody
Brody12mo ago
when does the service run the migration? and are you trying to use the private url now?
0xdima95
0xdima95OP12mo 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
Brody12mo ago
can you maybe show me why you are sure railway is running a start command with the sleep in it
0xdima95
0xdima95OP12mo 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
Brody12mo ago
as long as you have confirmed your data is where it should be
0xdima95
0xdima95OP12mo ago
deleting them, prod is stable and online. Thank youa gain
Brody
Brody12mo ago
glad to hear it!
0xdima95
0xdima95OP12mo ago
why does this fix this?
Brody
Brody12mo ago
theres a private network init time
0xdima95
0xdima95OP12mo ago
still getting it but only on one of my services should i try upping the sleep time?
Brody
Brody12mo ago
sure
0xdima95
0xdima95OP12mo ago
sleep 8 & yarn start not doing anything... ill try with a semi colon?
Brody
Brody12mo ago
&&
0xdima95
0xdima95OP12mo ago
whoops
Want results from more Discord servers?
Add your server