Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing "wal_level" on PostgreSQL 13 (via client session) is not being respected

On a running PostgreSQL 13 instance, I tried modifying it's wal_level system setting as follows, but it's not being respected:

postgres@localhost:postgres> SHOW wal_level
+-------------+
| wal_level   |
|-------------|
| replica     |
+-------------+
SHOW
Time: 0.021s

postgres@localhost:postgres> ALTER SYSTEM SET wal_level = logical;
ALTER SYSTEM
Time: 0.007s

postgres@localhost:postgres> SHOW wal_level
+-------------+
| wal_level   |
|-------------|
| replica     |
+-------------+
SHOW
Time: 0.021s

postgres@localhost:postgres>

Unfortunately, this is set in the DockerHub image by the Postgres people, so it's not trivial to just modify a configuration file and restart. Indeed workarounds can be done, but I'm hoping the community can suggest a way to do it live from a Postgres client session.

EDIT (additional for comment below):

postgres@localhost:postgres> select * from pg_settings where name ='wal_level';
--+-----------------------------------+------------+-------------+--------------+--------------+-------------------+
  | enumvals                          | boot_val   | reset_val   | sourcefile   | sourceline   | pending_restart   |
--+-----------------------------------+------------+-------------+--------------+--------------+-------------------|
  | ['minimal', 'replica', 'logical'] | replica    | replica     | <null>       | <null>       | False             |
--+-----------------------------------+------------+-------------+--------------+--------------+-------------------+

like image 608
NYCeyes Avatar asked Dec 05 '25 10:12

NYCeyes


2 Answers

You do not need to change docker image/container if you use Postgresql 14.

Just run

ALTER SYSTEM SET wal_level = logical;

and restart the container.

See https://www.postgresql.org/docs/current/sql-altersystem.html

ALTER SYSTEM writes the given parameter setting to the postgresql.auto.conf file, which is read in addition to postgresql.conf.

like image 111
ysa Avatar answered Dec 08 '25 01:12

ysa


As you will see in the documentation, wal_level cannot be changed without restarting the PostgreSQL server. There is no alternative.

like image 45
Laurenz Albe Avatar answered Dec 08 '25 01:12

Laurenz Albe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!