Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Postgres RDS pg_stat_statements not loaded

I configured my RDS Postgres 9.6.1 instance so, that the pg_stat_activity is loaded via 'shared_preload_libraries' parameter

shared_preload_libraries=pg_stat_statements,pg_hint_plan

The I rebooted my instance and then check if the pg_stat_statements can be loaded. But I get the error:

[55000] ERROR: pg_stat_statements must be loaded via shared_preload_libraries

The command

SHOW shared_preload_libraries;

does not show the pg_stat_statements library.

And therefore the error above still remains.

Does somebody else has got the same issue ?

Thanks, Detlef

like image 783
Detlef Brendle Avatar asked May 11 '17 22:05

Detlef Brendle


2 Answers

Ran into the same problem today.

Turns out I simply had to reboot the database (via CLI or web interface).

As mentioned on the AWS docs:

When you change a static parameter and save the DB parameter group, the parameter change takes effect after you manually reboot the DB instance.

like image 110
Timothee A Avatar answered Sep 27 '22 17:09

Timothee A


UPDATE

I tried myself. Added to Parameters->shared_preload_libraries values:pg_stat_statements,pg_hint_plan. Clicked "save changes", agreed on "Apply Immediately". Indeed no effect. When I check DB Parameter Group - it shows modified group, but pg_stat_statements unusable. So I think bad on JS and try aws cli:

aws rds describe-db-instances --db-instance-identifier p5

it reveals that group was not indeed changed!:

"OptionGroupMemberships": [
    {
      "Status": "in-sync",
      "OptionGroupName": "default:postgres-9-5"
    }
  ],

So I did:

aws rds modify-db-instance --db-parameter-group-name with-contrib --apply-immediately --db-instance-identifier p5
aws rds reboot-db-instance --db-instance-identifier p5
aws rds describe-db-instances --db-instance-identifier p5

And It was changed. So I try to:

mon=> create extension pg_stat_statements ;
CREATE EXTENSION
mon=> select count(*) from pg_stat_statements;
 count
-------
    26
(1 row)

Voila. Not sure if it was Chrome (Version 57.0.2987.133 (64-bit)) feature or JS failure, or me not getting intuitive clicking steps, but I failed to apply changes as well. Please try with aws cli to see if you success there.

PREVIOUS String requires quotes I think.:

String: In general, enclose the value in single quotes, doubling any single quotes within the value. Quotes can usually be omitted if the value is a simple number or identifier, however.

So maybe setting shared_preload_libraries this way will help:

shared_preload_libraries = 'pg_stat_statements,pg_hint_plan'

https://www.postgresql.org/docs/current/static/runtime-config-client.html:

shared_preload_libraries (string)

This variable specifies one or more shared libraries to be preloaded at server start. This parameter can only be set at server start. If a specified library is not found, the server will fail to start.

like image 33
Vao Tsun Avatar answered Sep 27 '22 16:09

Vao Tsun