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
Project ID:
370f4ec5-bf5b-4bd2-a750-7a7d09608f92
370f4ec5-bf5b-4bd2-a750-7a7d09608f92
did you delete the legacy database?
Yes, before linking new service variables to my servers
have you used reference variables? like this
DATABASE_URL=${{Postgres.DATABASE_URL}}
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?
you justed shared your database credentials in a public server
Lol I changed them before sending
Those aren't real
okay good, you would not have been the first to send actually credentials
but yes, please use the syntax I have shown
And the DATABASE_PRIVATE_URL? Should I keep the db server private as was done by the automatic migration process?
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 urlIts like this on my side: ${{Postgres.DATABASE_URL}}. Is this fine?
yes that looks like a valid reference variable to me
Everything was running fine after the migration until I deleted the legacy plugin
maybe you are hardcoding the variables somewhere, get all the database related variables using references before we proceed with the debugging efforts
When I checked the variables, they were empty after deleting the legacy plugin
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
Should I also add DATABASE_PRIVATE_URL?
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 codeMy 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
show me a screenshot of the proxy config for the database
in the settings, show me the proxy config please
I'm not sure which one in Settings
can you connect to the database from your desktop with software like dbgate?
Can I use pgadmin?
of course
So I could see the db in railway postgres UI when the server is private, but not when its public
have you ever touched that proxy config?
Naa
But it changed after migration
have you ever touched any variables on the postgres service service itself?
No, just the ones in my kuber server
are there any concerning logs in the postgres service?
When I made the server public
nothing here looks bad at all, you said you can't connect to the database from pgadmin?
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
Thread has been flagged to Railway team by @Brody.
Hey there
@Duchess Have you read the thread yet?
@Duchess Please help?
Duchess is not a human . Brody flagged this thread, so I think a team member might help at some point
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?
i have no idea sorry. i did my migration ages ago and iirc it was just a button click for me
Lol ok cool
How do I get railway support, I'm seriously struggling?
Hey @tebzito176 - I am said Railway support, how do ya do
Quick question, is this for a company, whats your downtime nessesity like?
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 ?
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?
Are these right?
I redeployed the postgres server. Not sure if it deployed properly because of the red?
red is fine, postgres chooses to log to stderr for some reason that I forget
this is your backend right?
yes
what environment variables do you use in code to connect to the database?
Let me check
It works when I call the database locally
where you able to find this information for me
password, server, port, database
server name and database name
please provide a proper list of the environment variables you use in your code
You mean besides railway?
I get the feeling that you've put the database credentials directly into your code?
I don't push those to the servers
show me the code that connects to the database please
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();
}
}
okay looks good, I think
This works when I run it locally with the new postgres server
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
Yes
can you send me the reference you've used? aka the raw value of that variable
Meaning my credentials?
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?
This one: ${{Postgres.DATABASE_URL}}
is that the value of your DATABASE_URL variable?
perfect
now show me the error your code produces
show me the proxy config for the postgres service please
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??
There's no 7899 in the code
it's somewhere because your code is trying to connect to it
you see that log right?
Damn found the issue. These were still referencing the old server
knew it, please use reference variables going forward so you never have this problem again
Noted. Thanks alot
no problem