Postgres DB stuck in recovery mode - postgresql

I have an application build with RoR and on Postgres db on separate server (VM with Linux red hat).
I am facing an issue with the db, it suddenly is stuck in the recovery mode, and I can’t access it even from the server console.
The only way is to restart the whole server and again it works fine.
Error details:
Exception
PG::ConnectionBad
Error
FATAL: the database system is in recovery mode
Please any advise for this issue?

Related

java.net.UnknownHostException: when trying to connect to heroku postgres through intellij

I have just signed up to a free heroku account hoping to try and see if a web app I am making functions properly, all works fine on my local machine connected locally to my postgres db.
I am trying to connect to the heroku postgres db I set up. I have connected fine through pgadmin and also in the application.yaml file so that when in prod profile, it runs on the heroku postgres database.
But if I try and connect to the DB using the intellij database connection, I keep getting an error,
[08001] The connection attempt failed. java.net.UnknownHostException: ec2-54-73-110-26.eu-west-1.compute.amazonaws.com
I have checked everything several times, and all the fields on the database connection wizard are correct. I have also set ssl to true, sslmode to verify-ca and sslfactory to sslfactory:org.postgresql.ssl.NonValidatingFactory
but I get the above error each time.

After Deploy App is not connecting to postgres anymore

after deploying my changes to heroku my strapi app isn't starting anymore.
[2020-11-10T15:47:29.476Z] debug :no_entry:️ Server wasn't able to start properly.
2020-11-10T15:47:29.479699+00:00 app[web.1]: [2020-11-10T15:47:29.479Z] error error: password authentication failed for user "xxxxxxxxxxxxx"
Checked the ENVs everything looks fine but it is not working.
I saw that postgresql updated my database, since that point it is broken.
heroku-postgresql: Update DATABASE by heroku-postgresql
Today at 4:22 PM · v34
Please help me can´t do anything rn.

pgadmin error while connecting to docker postgres instance: "The server encountered an internal error and was unable to complete your request."

I'm running a postgres image from a docker container. While trying to access it from the pgadmin 4 GUI client, I'm getting the error: "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."
After connecting to the docker instance, the pgadmin GUI displays the default postgres database, but there is a cross on the other databases which I had created from within the container.
After refreshing connection multiple times I get a message along the lines of connection made to database, but it doesn't actually load in the GUI.
How do I connect to those databases?
(I'm running docker in Windows 10 powershell with admin privileges)
Made changes as per the suggestion here.
Restarted pdadmin, and started container in non-admin mode.
Able to retrieve and commit data.

"FATAL: the database system is shutting down" while creating connection to PostgreSQL

I am getting FATAL: the database system is shutting down errors while creating PostgreSQL JDBC connections to a PostgreSQL 9.2 server. The specific exception path I'm getting from JDBC is here:
Caused by: org.postgresql.util.PSQLException: FATAL: the database system is shutting down
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:398)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:173)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:393)
at org.postgresql.Driver.connect(Driver.java:267)
From various log files (from PostgreSQL, from our management layer, from the app using PostgreSQL), I do not see any database shutdown actually happening (other connections are created to PostgreSQL as usual, no shutdown was initiated from our management layer, etc.), however in the PostgreSQL server logs I do see the error message with the same timestamp:
2014-06-16 12:30:00.736 GMT LOG: connection received: host=127.0.0.1 port=38530
2014-06-16 12:30:00.737 GMT FATAL: the database system is shutting down
Researching online, I learned that this error message is used whenever PostgreSQL shuts down connections.
Why would PostgreSQL refuse to give me a new connection? Could this be caused by some sort of resource contention? How can I get more information about the error from PostgreSQL itself?
This issue turned out to be caused by a very bad misuse of PostgreSQL where our server had booted two PostgreSQL instances on the same data directory (it had deleted postmaster.pid and used a new port number, so the normal safeguards against this behavior were bypassed) which explains why the logs did not hold any useful information -- they were being overwritten by the PostgreSQL instance which wasn't refusing connections. The actual issue was caused by a complex interaction between the competing PostgreSQL instances, and I hope nobody else runs into this issue as well!
We encountered this problem when the server was restarted. In this case the reboot did not initiate the connection with PostgreSql. Just check the status: "/etc/init.d/postgresql status" if the return is: "no server running" just start: "/etc/init.d/postgresql start"
Maybe there is not enough space on hard drive.
SOLUTION:
brew remove postgresql
Temporary rename the lock files: mv /tmp/.s.PGSQL.5432.lock /tmp/BK.s.PGSQL.5432.lockand mv /tmp/.s.PGSQL.5432 /tmp/BK.s.PGSQL.5432
brew install postgresql
Enjoy!

Heroku PostgreSQL Connection reset by peer

We are using PostgreSQL Crane plan, and got a lot of log like this
app postgres - - [5-1] ... LOG: could not receive data from client: Connection reset by peer
We are using about 50 dynos.
Is PostgreSQL running out of connections with bunch of dynos?
Can someone help me explain this case?
Thanks
From what I've found the cause for the errors is the client not disconnecting at the end of the session, or a new connection not being created.
New connection solving the problem:
Postgres error on Heroku with Resque
Explicit disconnection solving the problem:
https://github.com/resque/resque/issues/367 (comment #2)
There's a Heroku FAQ entry on this: Understanding Heroku Postgres Log Statements and Common Errors: could not receive data from client: Connection reset by peer.
Although this log is emitted from postgres, the cause for the error has nothing to do with the database itself. Your application happened to crash while connected to postgres, and did not clean up its connection to the database. Postgres noticed that the client (your application) disappeared without ending the connection properly, and logged a message saying so.
If you are not seeing your application’s backtrace, you may need to ensure that you are, in fact, logging to stdout (instead of a file) and that you have stdout sync’d.