Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit883a965

Browse files
committed
Assorted corrections to the patch to add WAL receiver replies.
Per reports from Fujii Masao.
1 parent6a77e93 commit883a965

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,29 +1984,6 @@ SET ENABLE_SEQSCAN TO OFF;
19841984
</listitem>
19851985
</varlistentry>
19861986

1987-
<varlistentry id="guc-wal-receiver-status-interval" xreflabel="wal_receiver_status_interval">
1988-
<term><varname>wal_receiver_status_interval</varname> (<type>integer</type>)</term>
1989-
<indexterm>
1990-
<primary><varname>wal_receiver_status_interval</> configuration parameter</primary>
1991-
</indexterm>
1992-
<listitem>
1993-
<para>
1994-
Specifies the minimum frequency, in seconds, for the WAL receiver
1995-
process on the standby to send information about replication progress
1996-
to the primary, where they can be seen using the
1997-
<literal>pg_stat_replication</literal> view. The standby will report
1998-
the last transaction log position it has written, the last position it
1999-
has flushed to disk, and the last position it has applied. Updates are
2000-
sent each time the write or flush positions changed, or at least as
2001-
often as specified by this parameter. Thus, the apply position may
2002-
lag slightly behind the true position. Setting this parameter to zero
2003-
disables status updates completely. This parameter can only be set in
2004-
the <filename>postgresql.conf</> file or on the server command line.
2005-
The default value is 10 seconds.
2006-
</para>
2007-
</listitem>
2008-
</varlistentry>
2009-
20101987
<varlistentry id="guc-vacuum-defer-cleanup-age" xreflabel="vacuum_defer_cleanup_age">
20111988
<term><varname>vacuum_defer_cleanup_age</varname> (<type>integer</type>)</term>
20121989
<indexterm>
@@ -2121,6 +2098,29 @@ SET ENABLE_SEQSCAN TO OFF;
21212098
</listitem>
21222099
</varlistentry>
21232100

2101+
<varlistentry id="guc-wal-receiver-status-interval" xreflabel="wal_receiver_status_interval">
2102+
<term><varname>wal_receiver_status_interval</varname> (<type>integer</type>)</term>
2103+
<indexterm>
2104+
<primary><varname>wal_receiver_status_interval</> configuration parameter</primary>
2105+
</indexterm>
2106+
<listitem>
2107+
<para>
2108+
Specifies the minimum frequency, in seconds, for the WAL receiver
2109+
process on the standby to send information about replication progress
2110+
to the primary, where they can be seen using the
2111+
<literal>pg_stat_replication</literal> view. The standby will report
2112+
the last transaction log position it has written, the last position it
2113+
has flushed to disk, and the last position it has applied. Updates are
2114+
sent each time the write or flush positions changed, or at least as
2115+
often as specified by this parameter. Thus, the apply position may
2116+
lag slightly behind the true position. Setting this parameter to zero
2117+
disables status updates completely. This parameter can only be set in
2118+
the <filename>postgresql.conf</> file or on the server command line.
2119+
The default value is 10 seconds.
2120+
</para>
2121+
</listitem>
2122+
</varlistentry>
2123+
21242124
</variablelist>
21252125
</sect2>
21262126
</sect1>

‎src/backend/replication/walsender.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ static uint32 sendOff = 0;
8989
*/
9090
staticXLogRecPtrsentPtr= {0,0};
9191

92+
/*
93+
* Buffer for processing reply messages.
94+
*/
95+
staticStringInfoDatareply_message;
96+
9297
/* Flags set by signal handlers for later service in main loop */
9398
staticvolatilesig_atomic_tgot_SIGHUP= false;
9499
volatilesig_atomic_twalsender_shutdown_requested= false;
@@ -469,7 +474,7 @@ ProcessRepliesIfAny(void)
469474
switch (firstchar)
470475
{
471476
/*
472-
* 'd' means a standby reply wrapped in aCOPY BOTH packet.
477+
* 'd' means a standby reply wrapped in aCopyData packet.
473478
*/
474479
case'd':
475480
ProcessStandbyReplyMessage();
@@ -495,16 +500,15 @@ ProcessRepliesIfAny(void)
495500
staticvoid
496501
ProcessStandbyReplyMessage(void)
497502
{
498-
staticStringInfoDatainput_message;
499503
StandbyReplyMessagereply;
500504
charmsgtype;
501505

502-
initStringInfo(&input_message);
506+
resetStringInfo(&reply_message);
503507

504508
/*
505509
* Read the message contents.
506510
*/
507-
if (pq_getmessage(&input_message,0))
511+
if (pq_getmessage(&reply_message,0))
508512
{
509513
ereport(COMMERROR,
510514
(errcode(ERRCODE_PROTOCOL_VIOLATION),
@@ -516,13 +520,16 @@ ProcessStandbyReplyMessage(void)
516520
* Check message type from the first byte. At the moment, there is only
517521
* one type.
518522
*/
519-
msgtype=pq_getmsgbyte(&input_message);
523+
msgtype=pq_getmsgbyte(&reply_message);
520524
if (msgtype!='r')
525+
{
521526
ereport(COMMERROR,
522527
(errcode(ERRCODE_PROTOCOL_VIOLATION),
523528
errmsg("unexpected message type %c",msgtype)));
529+
proc_exit(0);
530+
}
524531

525-
pq_copymsgbytes(&input_message, (char*)&reply,sizeof(StandbyReplyMessage));
532+
pq_copymsgbytes(&reply_message, (char*)&reply,sizeof(StandbyReplyMessage));
526533

527534
elog(DEBUG2,"write %X/%X flush %X/%X apply %X/%X ",
528535
reply.write.xlogid,reply.write.xrecoff,
@@ -559,6 +566,12 @@ WalSndLoop(void)
559566
*/
560567
output_message=palloc(1+sizeof(WalDataMessageHeader)+MAX_SEND_SIZE);
561568

569+
/*
570+
* Allocate buffer that will be used for processing reply messages. As
571+
* above, do this just once to reduce palloc overhead.
572+
*/
573+
initStringInfo(&reply_message);
574+
562575
/* Loop forever, unless we get an error */
563576
for (;;)
564577
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp