May 21st, 2015 by depesz | Tags: , , , , , , , | Comments Off on Waiting for 9.5 – Add pg_settings.pending_restart column
Did it help? If yes - maybe you can help me?

On 15th of May, Peter Eisentraut committed patch:

Add pg_settings.pending_restart column
 
with input from David G. Johnston, Robert Haas, Michael Paquier

This is, for me, great. It might not sound like much, but it is actually something that I'm very excited about.

Basically – let's assume you change system settings. Either by modifying postgresql.conf, or by doing ALTER SYSTEM.

Some of the settings will work after SELECT pg_reload_conf() (or pg_ctl reload), but some require restart.

When dealing with servers, it is relatively common (for me) to request change of multiple parameters. And then it gets tedious – checking which parameters require reload, and which restart.

Now, we have it solved.

In normal state, the pending_restart column is always false:

$ select pending_restart, count(*) from pg_settings group by 1;
 pending_restart | count
-----------------+-------
 f               |   248
(1 row)

Changing something that requires just reload, doesn't change it:

$ alter system set log_min_duration_statement = 10;
ALTER SYSTEM
 
$ select pending_restart, count(*) from pg_settings group by 1;
 pending_restart | count
-----------------+-------
 f               |   248
(1 row)

But if I'd change something more “critical":

$ alter system set wal_log_hints = true;
ALTER SYSTEM
 
$ select pending_restart, count(*) from pg_settings group by 1;
 pending_restart | count 
-----------------+-------
 f               |   248
(1 row)
 
$ select pg_reload_conf();
 pg_reload_conf 
----------------
 t
(1 row)
 
$ select pending_restart, count(*) from pg_settings group by 1;
 pending_restart | count 
-----------------+-------
 f               |   247
 t               |     1
(2 rows)
 
$ select * from pg_settings where pending_restart;
-[ RECORD 1 ]---+--------------------------------------------------------------------------------------------------------
name            | wal_log_hints
setting         | off
unit            | [null]
category        | Write-Ahead Log / Settings
short_desc      | Writes full pages to WAL when first modified after a checkpoint, even for a non-critical modifications.
extra_desc      | [null]
context         | postmaster
vartype         | bool
source          | default
min_val         | [null]
max_val         | [null]
enumvals        | [null]
boot_val        | off
reset_val       | off
sourcefile      | [null]
sourceline      | [null]
pending_restart | t

Great. Not only I know that I have to restart, but I know exactly why. It probably would be a bit better if I saw “pending_restart" set before pg_reload_conf(), but still, it's just a minor thing. Thanks guys.

Sorry, comments for this post are disabled.