patternsqlMinor
PostgreSQL closing connection during requests
Viewed 0 times
postgresqlduringrequestsclosingconnection
Problem
I have a PostgreSQL 10.12 server running on an Ubuntu 18.04 Server. Since today, I am suddenly getting errors when querying data from a Python script running on the same machine, and in some edge cases also in pgAdmin 4.
In about 50% of the cases, my Python script will fail to return any data because the DB server closed the connection. I am using SQLAlchemy and it is giving me the following error:
Interestingly, the same queries (which are simple "SELECT * FROM table" statements) run perfectly fine in pgAdmin. However, when I try to run the following query in pgAdmin, I get the message
This query specifically worked fine a few days ago. I couldn't find any other examples where this happens in pgAdmin, but there is surely something wrong.
What is weird is that the database has been running for over a month without any issues, and this only started today. I did try to restart the service to no avail.
The logs are not making much sense to me, but there are several things wrong.
The last few days, it constantly gave me the following message:
I am certain that I am using the correct password, as it does work 50% of the time of the queries. It is showing this message for the default
In about 50% of the cases, my Python script will fail to return any data because the DB server closed the connection. I am using SQLAlchemy and it is giving me the following error:
psycopg2.errors.AdminShutdown: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.Interestingly, the same queries (which are simple "SELECT * FROM table" statements) run perfectly fine in pgAdmin. However, when I try to run the following query in pgAdmin, I get the message
Connection to the server has been lost.select * from mytable where mycolumn <> ''This query specifically worked fine a few days ago. I couldn't find any other examples where this happens in pgAdmin, but there is surely something wrong.
What is weird is that the database has been running for over a month without any issues, and this only started today. I did try to restart the service to no avail.
The logs are not making much sense to me, but there are several things wrong.
The last few days, it constantly gave me the following message:
2020-04-06 19:43:26.959 CEST [7820] postgres@postgres FATAL: password authentication failed for user "postgres"
2020-04-06 19:43:26.959 CEST [7820] postgres@postgres DETAIL: Password does not match for user "postgres".
Connection matched pg_hba.conf line 102: "host all all all md5"I am certain that I am using the correct password, as it does work 50% of the time of the queries. It is showing this message for the default
postgres database and not my own, but it still confuses me why this happens as I'm using the default postgres user forSolution
2020-04-06 19:43:26.959 CEST [7820] postgres@postgres FATAL: password authentication failed for user "postgres"
2020-04-06 19:43:26.959 CEST [7820] postgres@postgres DETAIL: Password does not match for user "postgres".
Connection matched pg_hba.conf line 102: "host all all all md5"You should add
%h to your log_line_prefix setting, so you can see where these are coming from. Most likely some bad guy on the internet is trying to guess your password. Based on this error, he failed, at least this time.2020-04-07 11:25:18.891 CEST [5497] LOG: server process (PID 20569) was terminated by signal 11: Segmentation fault
2020-04-07 11:25:18.891 CEST [5497] DETAIL: Failed process was running: SELECT * FROM transactionoutputs WHERE fileheader <> ''Is this the type of query you would intentionally be running? If not, then it seems like the bad guy succeeded at least once.
Code Snippets
2020-04-06 19:43:26.959 CEST [7820] postgres@postgres FATAL: password authentication failed for user "postgres"
2020-04-06 19:43:26.959 CEST [7820] postgres@postgres DETAIL: Password does not match for user "postgres".
Connection matched pg_hba.conf line 102: "host all all all md5"2020-04-07 11:25:18.891 CEST [5497] LOG: server process (PID 20569) was terminated by signal 11: Segmentation fault
2020-04-07 11:25:18.891 CEST [5497] DETAIL: Failed process was running: SELECT * FROM transactionoutputs WHERE fileheader <> ''Context
StackExchange Database Administrators Q#264530, answer score: 3
Revisions (0)
No revisions yet.