Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bfc8068

Browse files
committed
Fix some documentation in pg_rewind
Since 11, it is possible to use a non-superuser role when using an online source cluster with pg_rewind as long as the role has proper permissions to execute on the source all the functions used by pg_rewind, and the documentation stated that a superuser is necessary. Let's add at the same time all the details needed to create such a role. A second confusion which comes a lot from users is that it is necessary to issue a checkpoint on a freshly-promoted standby so as its control file has up-to-date timeline information which is used by pg_rewind to validate the operation. Let's document that properly. This is back-patched down to 9.5 where pg_rewind has been introduced. Author: Michael Paquier Reviewed-by: Magnus Hagander Discussion: https://postgr.es/m/CABUevEz5bpvbwVsYCaSMV80CBZ5-82nkMzbb+Bu=h1m=rLdn=g@mail.gmail.com Backpatch-through: 9.5
1 parent 57a7a3a commit bfc8068

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

doc/src/sgml/ref/pg_rewind.sgml

+30-4
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ PostgreSQL documentation
155155
<listitem>
156156
<para>
157157
Specifies a libpq connection string to connect to the source
158-
<productname>PostgreSQL</productname> server to synchronize the target with.
159-
The connection must be a normal (non-replication) connection
160-
with superuser access. This option requires the source
161-
server to be running and not in recovery mode.
158+
<productname>PostgreSQL</productname> server to synchronize the target
159+
with. The connection must be a normal (non-replication) connection
160+
with a role having sufficient permissions to execute the functions
161+
used by <application>pg_rewind</application> on the source server
162+
(see Notes section for details) or a superuser role. This option
163+
requires the source server to be running and not in recovery mode.
162164
</para>
163165
</listitem>
164166
</varlistentry>
@@ -246,6 +248,30 @@ PostgreSQL documentation
246248
<refsect1>
247249
<title>Notes</title>
248250

251+
<para>
252+
When executing <application>pg_rewind</application> using an online
253+
cluster as source, a role having sufficient permissions to execute the
254+
functions used by <application>pg_rewind</application> on the source
255+
cluster can be used instead of a superuser. Here is how to create such
256+
a role, named <literal>rewind_user</literal> here:
257+
<programlisting>
258+
CREATE USER rewind_user LOGIN;
259+
GRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;
260+
GRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;
261+
GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;
262+
GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;
263+
</programlisting>
264+
</para>
265+
266+
<para>
267+
When executing <application>pg_rewind</application> using an online
268+
cluster as source which has been recently promoted, it is necessary
269+
to execute a <command>CHECKPOINT</command> after promotion so as its
270+
control file reflects up-to-date timeline information, which is used by
271+
<application>pg_rewind</application> to check if the target cluster
272+
can be rewound using the designated source cluster.
273+
</para>
274+
249275
<refsect2>
250276
<title>How it works</title>
251277

0 commit comments

Comments
 (0)