pg_recvlogical use of SIGHUP
There is some undocumented (nothing in the docs) code that allows for
closing reopening the output file for pg_recvlogical.
Since this doesn't change the name of the file in the process I'm wondering
how one might actually use this "feature" ?
I could see it being useful if we were to be able to change the file name
and create a new file based on some form of template ?
Am I missing something ?
Dave Cramer
Hi,
On 2018-07-06 13:49:37 -0400, Dave Cramer wrote:
There is some undocumented (nothing in the docs) code that allows for
closing reopening the output file for pg_recvlogical.Since this doesn't change the name of the file in the process I'm wondering
how one might actually use this "feature" ?
You can rename the file, then sighup, no? Renaming while the file is
open will continue to write into the renamed file, but sighup'ing will
use the original name.
Greetings,
Andres Freund
On 6 July 2018 at 14:11, Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2018-07-06 13:49:37 -0400, Dave Cramer wrote:
There is some undocumented (nothing in the docs) code that allows for
closing reopening the output file for pg_recvlogical.Since this doesn't change the name of the file in the process I'm
wondering
how one might actually use this "feature" ?
You can rename the file, then sighup, no? Renaming while the file is
open will continue to write into the renamed file, but sighup'ing will
use the original name.
That is the missing piece, thanks!
I'll prepare a patch for the docs
Dave Cramer
On 6 July 2018 at 14:11, Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2018-07-06 13:49:37 -0400, Dave Cramer wrote:
There is some undocumented (nothing in the docs) code that allows for
closing reopening the output file for pg_recvlogical.Since this doesn't change the name of the file in the process I'm
wondering
how one might actually use this "feature" ?
You can rename the file, then sighup, no? Renaming while the file is
open will continue to write into the renamed file, but sighup'ing will
use the original name.That is the missing piece, thanks!
I'll prepare a patch for the docs
See attached patch.
Attachments:
pg_recvlogical.patchapplication/octet-stream; name=pg_recvlogical.patchDownload
diff --git a/doc/src/sgml/ref/pg_recvlogical.sgml b/doc/src/sgml/ref/pg_recvlogical.sgml
index 141c5cd..278c991 100644
--- a/doc/src/sgml/ref/pg_recvlogical.sgml
+++ b/doc/src/sgml/ref/pg_recvlogical.sgml
@@ -73,7 +73,7 @@ PostgreSQL documentation
<listitem>
<para>
Drop the replication slot with the name specified
- by <option>--slot</option>, then exit.
+ by <option>--slot</option>, then exit.
</para>
</listitem>
</varlistentry>
@@ -84,7 +84,11 @@ PostgreSQL documentation
<para>
Begin streaming changes from the logical replication slot specified
by <option>--slot</option>, continuing until terminated by a
- signal. If the server side change stream ends with a server shutdown
+ signal. Two signals are handled gracefully: SIGINT will close the
+ connection and exit without an errorcode. SIGHUP will close the
+ existing file and reopen it allowing you to rename the file and
+ potentially store it or process it elsewhere.
+ If the server side change stream ends with a server shutdown
or disconnect, retry in a loop unless
<option>--no-loop</option> is specified.
</para>