R
Railway•10mo ago
tebzito176

Postgres Migration Crashes Servers after deleting plugin

I just did the automatic migration process, after it finished I just deleted the migration plugin before linking service variables into the servers, than my server crashed, only to find out that my old variables were removed during migration. I tried adding the new variables with the new private network postgres server, but still crashes the other servers. Please can anyone help?
84 Replies
Percy
Percy•10mo ago
Project ID: 370f4ec5-bf5b-4bd2-a750-7a7d09608f92
tebzito176
tebzito176•10mo ago
370f4ec5-bf5b-4bd2-a750-7a7d09608f92
Brody
Brody•10mo ago
did you delete the legacy database?
tebzito176
tebzito176•10mo ago
Yes, before linking new service variables to my servers
Brody
Brody•10mo ago
have you used reference variables? like this DATABASE_URL=${{Postgres.DATABASE_URL}}
tebzito176
tebzito176•10mo ago
No, like this as the automatic migration did: postgresql://postgres:[email protected]:53906/railway Am I suppose to replace them to the one your suggesting? And should I keep the server private?
Brody
Brody•10mo ago
you justed shared your database credentials in a public server
tebzito176
tebzito176•10mo ago
Lol I changed them before sending Those aren't real
Brody
Brody•10mo ago
okay good, you would not have been the first to send actually credentials but yes, please use the syntax I have shown
tebzito176
tebzito176•10mo ago
And the DATABASE_PRIVATE_URL? Should I keep the db server private as was done by the automatic migration process?
Brody
Brody•10mo ago
the migration does not make database private, all database are publicly available by default first I would try with DATABASE_URL before you try the private url
tebzito176
tebzito176•10mo ago
Its like this on my side: ${{Postgres.DATABASE_URL}}. Is this fine?
Brody
Brody•10mo ago
yes that looks like a valid reference variable to me
tebzito176
tebzito176•10mo ago
Everything was running fine after the migration until I deleted the legacy plugin
Brody
Brody•10mo ago
maybe you are hardcoding the variables somewhere, get all the database related variables using references before we proceed with the debugging efforts
tebzito176
tebzito176•10mo ago
When I checked the variables, they were empty after deleting the legacy plugin
Brody
Brody•10mo ago
let me know when this is completed please though it is 4:30 am for me, so not sure how long I'll be around for
tebzito176
tebzito176•10mo ago
Should I also add DATABASE_PRIVATE_URL?
Brody
Brody•10mo ago
no, let's stick to using DATABASE_URL for now please and you really only need to add the variables that you are using in your code
tebzito176
tebzito176•10mo ago
My database can't be fetched by railway server when I make the new postgres server public. I wants me to run this command to fix: PGPASSWORD=accC41cA1eWXg7j8g3sGTABA6BDe psql -h muthu.proxy.rlwy.net -U postgres -p 55606 -d railway
Brody
Brody•10mo ago
show me a screenshot of the proxy config for the database
tebzito176
tebzito176•10mo ago
No description
Brody
Brody•10mo ago
in the settings, show me the proxy config please
tebzito176
tebzito176•10mo ago
I'm not sure which one in Settings
No description
Brody
Brody•10mo ago
can you connect to the database from your desktop with software like dbgate?
tebzito176
tebzito176•10mo ago
Can I use pgadmin?
Brody
Brody•10mo ago
of course
tebzito176
tebzito176•10mo ago
So I could see the db in railway postgres UI when the server is private, but not when its public
Brody
Brody•10mo ago
have you ever touched that proxy config?
tebzito176
tebzito176•10mo ago
Naa But it changed after migration
Brody
Brody•10mo ago
have you ever touched any variables on the postgres service service itself?
tebzito176
tebzito176•10mo ago
No, just the ones in my kuber server
Brody
Brody•10mo ago
are there any concerning logs in the postgres service?
tebzito176
tebzito176•10mo ago
No description
tebzito176
tebzito176•10mo ago
When I made the server public
Brody
Brody•10mo ago
nothing here looks bad at all, you said you can't connect to the database from pgadmin?
tebzito176
tebzito176•10mo ago
No. How do I connect into railway login via commandline? what do I do after railway login? I'm in on pgadmin Please let me know when your back @Brody Hey
Duchess
Duchess•10mo ago
Thread has been flagged to Railway team by @Brody.
tebzito176
tebzito176•10mo ago
Hey there @Duchess Have you read the thread yet? @Duchess Please help?
Finn
Finn•10mo ago
Duchess is not a human skull1 . Brody flagged this thread, so I think a team member might help at some point
tebzito176
tebzito176•10mo ago
Ok I'll try it @Finn - uses centos Can I ask, after the automatic postgres migration, am I suppose to live the server in private mode? Leave Or am I suppose to make it public?
Finn
Finn•10mo ago
i have no idea sorry. i did my migration ages ago and iirc it was just a button click for me
tebzito176
tebzito176•10mo ago
Lol ok cool How do I get railway support, I'm seriously struggling?
angelo
angelo•10mo ago
Hey @tebzito176 - I am said Railway support, how do ya do Quick question, is this for a company, whats your downtime nessesity like?
thomas
thomas•10mo ago
This is likely related to the #🚨|incidents we called. The most recent updates will always be on our status page. After a fix we are back. Can you confirm @tebzito176 ?
tebzito176
tebzito176•10mo ago
It is for a company, but its not used too much yet It was working fine until I deleted the legacy plugin. Is there something I'm not getting? @thomas It's not seeing my database. Maybe my variables aren't looking at the database properly I migrated automatically with the railway migration feature. I made the postgres server public. Should it be private with DATABASE_PRIVATE_URL?
tebzito176
tebzito176•10mo ago
No description
tebzito176
tebzito176•10mo ago
Are these right?
tebzito176
tebzito176•10mo ago
I redeployed the postgres server. Not sure if it deployed properly because of the red?
No description
Brody
Brody•10mo ago
red is fine, postgres chooses to log to stderr for some reason that I forget this is your backend right?
tebzito176
tebzito176•10mo ago
yes
Brody
Brody•10mo ago
what environment variables do you use in code to connect to the database?
tebzito176
tebzito176•10mo ago
Let me check It works when I call the database locally
Brody
Brody•10mo ago
where you able to find this information for me
tebzito176
tebzito176•10mo ago
password, server, port, database server name and database name
Brody
Brody•10mo ago
please provide a proper list of the environment variables you use in your code
tebzito176
tebzito176•10mo ago
You mean besides railway?
Brody
Brody•10mo ago
I get the feeling that you've put the database credentials directly into your code?
tebzito176
tebzito176•10mo ago
I don't push those to the servers
Brody
Brody•10mo ago
show me the code that connects to the database please
tebzito176
tebzito176•10mo ago
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext> { private const string AspNetCoreEnvironment = "ASPNETCORE_ENVIRONMENT"; public ApplicationDbContext CreateDbContext(string[] args) { var connectionString = string.Empty; var s = Environment.GetEnvironmentVariable(AspNetCoreEnvironment); if (s == "Development") { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .Build(); connectionString = configuration.GetConnectionString("DefaultConnection"); } var builder = new DbContextOptionsBuilder<ApplicationDbContext>(); var databaseUrl = Environment.GetEnvironmentVariable("DATABASE_URL"); builder.UseNpgsql(string.IsNullOrEmpty(databaseUrl) ? connectionString : databaseUrl); return new ApplicationDbContext(builder.Options); } //build the connection string from the environment. i.e. Heroku private static string BuildConnectionString(string databaseUrl) { var databaseUri = new Uri(databaseUrl); var userInfo = databaseUri.UserInfo.Split(':'); var builder = new NpgsqlConnectionStringBuilder { Host = databaseUri.Host, Port = databaseUri.Port, Username = userInfo[0], Password = userInfo[1], Database = databaseUri.LocalPath.TrimStart('/'), SslMode = SslMode.Require, TrustServerCertificate = true }; return builder.ToString(); } }
Brody
Brody•10mo ago
okay looks good, I think
tebzito176
tebzito176•10mo ago
This works when I run it locally with the new postgres server
Brody
Brody•10mo ago
is that DATABASE_URL variable referencing the DATABASE_URL variable of the new postgres database? please read this before you answer https://docs.railway.app/guides/variables#referencing-another-services-variable
tebzito176
tebzito176•10mo ago
Yes
Brody
Brody•10mo ago
can you send me the reference you've used? aka the raw value of that variable
tebzito176
tebzito176•10mo ago
Meaning my credentials?
Brody
Brody•10mo ago
no, I don't want to see your credentials, does the raw value of your DATABASE_URL variable look like the example in that docs section?
tebzito176
tebzito176•10mo ago
This one: ${{Postgres.DATABASE_URL}}
Brody
Brody•10mo ago
is that the value of your DATABASE_URL variable?
tebzito176
tebzito176•10mo ago
No description
Brody
Brody•10mo ago
perfect now show me the error your code produces
tebzito176
tebzito176•10mo ago
No description
Brody
Brody•10mo ago
show me the proxy config for the postgres service please
tebzito176
tebzito176•10mo ago
No description
Brody
Brody•10mo ago
but your code is trying to connect to something at 7899 you are stil hardcoding your variables somewhere, do you have a .env file in your repo or something??
tebzito176
tebzito176•10mo ago
There's no 7899 in the code
No description
Brody
Brody•10mo ago
it's somewhere because your code is trying to connect to it you see that log right?
tebzito176
tebzito176•10mo ago
Damn found the issue. These were still referencing the old server
tebzito176
tebzito176•10mo ago
No description
Brody
Brody•10mo ago
knew it, please use reference variables going forward so you never have this problem again
tebzito176
tebzito176•10mo ago
Noted. Thanks alot
Brody
Brody•10mo ago
no problem
Want results from more Discord servers?
Add your server