pg_recvlogical use of SIGHUP

Started by Dave Cramerover 7 years ago4 messages
#1Dave Cramer
davecramer@gmail.com

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

#2Andres Freund
andres@anarazel.de
In reply to: Dave Cramer (#1)
Re: pg_recvlogical use of SIGHUP

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

#3Dave Cramer
davecramer@gmail.com
In reply to: Andres Freund (#2)
Re: pg_recvlogical use of SIGHUP

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

#4Dave Cramer
davecramer@gmail.com
In reply to: Dave Cramer (#3)
1 attachment(s)
Re: pg_recvlogical use of SIGHUP

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>