Saturday, 26 September 2020

PostgreSQL Startup Failure : FATAL: could not access file "pg_stat_statements"

 I tried to enable the pg_stat_statements and Database was unable to start 


bash-4.1$ pg_ctl -D /var/lib/pgsql/pg10/data -l logfile start

waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.

 


bash-4.1$ tail -40f logfile

2020-09-14 14:03:27.991 IST [12517] FATAL:  could not access file "pg_stat_statements": No such file or directory
2020-09-14 14:03:27.997 IST [12517] LOG:  database system is shut down

2020-09-14 14:04:16.145 IST [12580] FATAL:  could not access file "pg_stat_statements": No such file or directory
2020-09-14 14:04:16.146 IST [12580] LOG:  database system is shut down

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';

This overwrites 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 and proceed with the startup.




No comments:

Post a Comment