Assorted corrections to the patch to add WAL receiver replies.
Per reports from Fujii Masao.
This commit is contained in:
parent
6a77e9385e
commit
883a9659fa
|
@ -1984,29 +1984,6 @@ SET ENABLE_SEQSCAN TO OFF;
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry id="guc-wal-receiver-status-interval" xreflabel="wal_receiver_status_interval">
|
|
||||||
<term><varname>wal_receiver_status_interval</varname> (<type>integer</type>)</term>
|
|
||||||
<indexterm>
|
|
||||||
<primary><varname>wal_receiver_status_interval</> configuration parameter</primary>
|
|
||||||
</indexterm>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Specifies the minimum frequency, in seconds, for the WAL receiver
|
|
||||||
process on the standby to send information about replication progress
|
|
||||||
to the primary, where they can be seen using the
|
|
||||||
<literal>pg_stat_replication</literal> view. The standby will report
|
|
||||||
the last transaction log position it has written, the last position it
|
|
||||||
has flushed to disk, and the last position it has applied. Updates are
|
|
||||||
sent each time the write or flush positions changed, or at least as
|
|
||||||
often as specified by this parameter. Thus, the apply position may
|
|
||||||
lag slightly behind the true position. Setting this parameter to zero
|
|
||||||
disables status updates completely. This parameter can only be set in
|
|
||||||
the <filename>postgresql.conf</> file or on the server command line.
|
|
||||||
The default value is 10 seconds.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry id="guc-vacuum-defer-cleanup-age" xreflabel="vacuum_defer_cleanup_age">
|
<varlistentry id="guc-vacuum-defer-cleanup-age" xreflabel="vacuum_defer_cleanup_age">
|
||||||
<term><varname>vacuum_defer_cleanup_age</varname> (<type>integer</type>)</term>
|
<term><varname>vacuum_defer_cleanup_age</varname> (<type>integer</type>)</term>
|
||||||
<indexterm>
|
<indexterm>
|
||||||
|
@ -2121,6 +2098,29 @@ SET ENABLE_SEQSCAN TO OFF;
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry id="guc-wal-receiver-status-interval" xreflabel="wal_receiver_status_interval">
|
||||||
|
<term><varname>wal_receiver_status_interval</varname> (<type>integer</type>)</term>
|
||||||
|
<indexterm>
|
||||||
|
<primary><varname>wal_receiver_status_interval</> configuration parameter</primary>
|
||||||
|
</indexterm>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Specifies the minimum frequency, in seconds, for the WAL receiver
|
||||||
|
process on the standby to send information about replication progress
|
||||||
|
to the primary, where they can be seen using the
|
||||||
|
<literal>pg_stat_replication</literal> view. The standby will report
|
||||||
|
the last transaction log position it has written, the last position it
|
||||||
|
has flushed to disk, and the last position it has applied. Updates are
|
||||||
|
sent each time the write or flush positions changed, or at least as
|
||||||
|
often as specified by this parameter. Thus, the apply position may
|
||||||
|
lag slightly behind the true position. Setting this parameter to zero
|
||||||
|
disables status updates completely. This parameter can only be set in
|
||||||
|
the <filename>postgresql.conf</> file or on the server command line.
|
||||||
|
The default value is 10 seconds.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</sect2>
|
</sect2>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
|
@ -89,6 +89,11 @@ static uint32 sendOff = 0;
|
||||||
*/
|
*/
|
||||||
static XLogRecPtr sentPtr = {0, 0};
|
static XLogRecPtr sentPtr = {0, 0};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Buffer for processing reply messages.
|
||||||
|
*/
|
||||||
|
static StringInfoData reply_message;
|
||||||
|
|
||||||
/* Flags set by signal handlers for later service in main loop */
|
/* Flags set by signal handlers for later service in main loop */
|
||||||
static volatile sig_atomic_t got_SIGHUP = false;
|
static volatile sig_atomic_t got_SIGHUP = false;
|
||||||
volatile sig_atomic_t walsender_shutdown_requested = false;
|
volatile sig_atomic_t walsender_shutdown_requested = false;
|
||||||
|
@ -469,7 +474,7 @@ ProcessRepliesIfAny(void)
|
||||||
switch (firstchar)
|
switch (firstchar)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* 'd' means a standby reply wrapped in a COPY BOTH packet.
|
* 'd' means a standby reply wrapped in a CopyData packet.
|
||||||
*/
|
*/
|
||||||
case 'd':
|
case 'd':
|
||||||
ProcessStandbyReplyMessage();
|
ProcessStandbyReplyMessage();
|
||||||
|
@ -495,16 +500,15 @@ ProcessRepliesIfAny(void)
|
||||||
static void
|
static void
|
||||||
ProcessStandbyReplyMessage(void)
|
ProcessStandbyReplyMessage(void)
|
||||||
{
|
{
|
||||||
static StringInfoData input_message;
|
|
||||||
StandbyReplyMessage reply;
|
StandbyReplyMessage reply;
|
||||||
char msgtype;
|
char msgtype;
|
||||||
|
|
||||||
initStringInfo(&input_message);
|
resetStringInfo(&reply_message);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the message contents.
|
* Read the message contents.
|
||||||
*/
|
*/
|
||||||
if (pq_getmessage(&input_message, 0))
|
if (pq_getmessage(&reply_message, 0))
|
||||||
{
|
{
|
||||||
ereport(COMMERROR,
|
ereport(COMMERROR,
|
||||||
(errcode(ERRCODE_PROTOCOL_VIOLATION),
|
(errcode(ERRCODE_PROTOCOL_VIOLATION),
|
||||||
|
@ -516,13 +520,16 @@ ProcessStandbyReplyMessage(void)
|
||||||
* Check message type from the first byte. At the moment, there is only
|
* Check message type from the first byte. At the moment, there is only
|
||||||
* one type.
|
* one type.
|
||||||
*/
|
*/
|
||||||
msgtype = pq_getmsgbyte(&input_message);
|
msgtype = pq_getmsgbyte(&reply_message);
|
||||||
if (msgtype != 'r')
|
if (msgtype != 'r')
|
||||||
|
{
|
||||||
ereport(COMMERROR,
|
ereport(COMMERROR,
|
||||||
(errcode(ERRCODE_PROTOCOL_VIOLATION),
|
(errcode(ERRCODE_PROTOCOL_VIOLATION),
|
||||||
errmsg("unexpected message type %c", msgtype)));
|
errmsg("unexpected message type %c", msgtype)));
|
||||||
|
proc_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
pq_copymsgbytes(&input_message, (char *) &reply, sizeof(StandbyReplyMessage));
|
pq_copymsgbytes(&reply_message, (char *) &reply, sizeof(StandbyReplyMessage));
|
||||||
|
|
||||||
elog(DEBUG2, "write %X/%X flush %X/%X apply %X/%X ",
|
elog(DEBUG2, "write %X/%X flush %X/%X apply %X/%X ",
|
||||||
reply.write.xlogid, reply.write.xrecoff,
|
reply.write.xlogid, reply.write.xrecoff,
|
||||||
|
@ -559,6 +566,12 @@ WalSndLoop(void)
|
||||||
*/
|
*/
|
||||||
output_message = palloc(1 + sizeof(WalDataMessageHeader) + MAX_SEND_SIZE);
|
output_message = palloc(1 + sizeof(WalDataMessageHeader) + MAX_SEND_SIZE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate buffer that will be used for processing reply messages. As
|
||||||
|
* above, do this just once to reduce palloc overhead.
|
||||||
|
*/
|
||||||
|
initStringInfo(&reply_message);
|
||||||
|
|
||||||
/* Loop forever, unless we get an error */
|
/* Loop forever, unless we get an error */
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue