Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL FATAL: could not access file "pg_stat_statements": No such file or directory

Our postgres database (version 9.4 instaled on Debian) stopted working (it has been working for several month withouth problem). When I try to connect using psql I get:

psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

When I check status it seems ok:

service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled)
   Active: active (exited) since Mon 2018-11-05 17:04:58 CET; 31s ago
  Process: 1367 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 1367 (code=exited, status=0/SUCCESS)

I tried to restart server

service postgresql restart

and in log file I have got

FATAL:  could not access file "pg_stat_statements": No such file or directory

I have tried to find a solution. Mostly the answers are that there is a problem with pg_stat_statements module. I checked the /etc/postgresql/9.4/main/postgres.conf file but the line was commented:

#shared_preload_libraries = ''          # (change requires restart)

As I know we haven't change any postgres configuration files and we haven't done any upgrade or update recently. Thank you in advance for your help.

like image 213
vitfo Avatar asked Nov 05 '18 16:11

vitfo


3 Answers

I fixed the problem with installing

postgresql11-contrib-11.7-1PGDG.rhel8

pay attention that official (pgdg11 repo) RPM for RHEL8/CentOS/Fedora has version (i.e. 11) in packet name:

postgresql11-contrib

P.S Yum also installed dependencies: perl-Carp-1.42-396.el8.noarch perl-Exporter-5.72-396.el8.noarch perl-libs-4:5.26.3-416.el8

like image 199
IZharsky Avatar answered Nov 16 '22 06:11

IZharsky


I had ever met with the same problem. But later found the cause is that I was running the psql command "alter system set shared_preload_libraries='pg_stat_statements';", which overwrite the PostgreSQL.auto.conf under the $PGDATA path. And, as a consequence, when restarting the postgesql instance again by issuing the "service postgresql start", the postmaster process will read the parameter "shared_preload_libraries" from the conf file "postgreSQL.auto.conf" under $PGDATA instead of from /etc/postgresql/10/main/postgres.conf. where the parameter = ''. So, please comment out the parameter shared_preload_libraries='pg_stat_statements' in postgresql.auto.conf if you want to solve the issue. Thanks.

like image 4
Tony Avatar answered Nov 16 '22 06:11

Tony


At the end I have installed pg_stat_statements and then I was able to start postgresql.

Added to postgres.conf:

shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all
pg_stat_statements.max = 10000
track_activity_query_size = 2048

Installed package postgresql-contrib-9.4:

apt-get install postgresql-contrib-9.4

Restarted postgresql service:

service postgresql restart
like image 3
vitfo Avatar answered Nov 16 '22 08:11

vitfo