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

Commit7c3fb50

Browse files
author
Amit Kapila
committed
Log messages for replication slot acquisition and release.
This commit log messages (at LOG level when log_replication_commands isset, otherwise at DEBUG1 level) when walsenders acquire and releasereplication slots. These messages help to know the lifetime of areplication slot - one can know how long a streaming standby, logicalsubscriber, or replication slot consumer is down. These messages will beuseful on production servers to debug and analyze inactive replicationslots.Note that these messages are emitted only for walsenders but not forbackends. This is because walsenders are the ones that typically holdreplication slots for longer durations, unlike backends which hold themfor executing replication related functions.Author: Bharath RupireddyReviewed-by: Peter Smith, Amit Kapila, Alvaro HerreraDiscussion:http://postgr.es/m/CALj2ACX17G7F-jeLt+7KhJ6YxVeRwR8Zk0rDh4VnT546o0UpTQ@mail.gmail.com
1 parent07cb297 commit7c3fb50

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7510,11 +7510,12 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
75107510
</term>
75117511
<listitem>
75127512
<para>
7513-
Causes each replication command to be logged in the server log.
7514-
See <xref linkend="protocol-replication"/> for more information about
7515-
replication command. The default value is <literal>off</literal>.
7516-
Only superusers and users with the appropriate <literal>SET</literal>
7517-
privilege can change this setting.
7513+
Causes each replication command and <literal>walsender</literal>
7514+
process's replication slot acquisition/release to be logged in the
7515+
server log. See <xref linkend="protocol-replication"/> for more
7516+
information about replication command. The default value is
7517+
<literal>off</literal>. Only superusers and users with the appropriate
7518+
<literal>SET</literal> privilege can change this setting.
75187519
</para>
75197520
</listitem>
75207521
</varlistentry>

‎src/backend/replication/slot.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,16 @@ ReplicationSlotAcquire(const char *name, bool nowait)
537537
*/
538538
if (SlotIsLogical(s))
539539
pgstat_acquire_replslot(s);
540+
541+
if (am_walsender)
542+
{
543+
ereport(log_replication_commands ?LOG :DEBUG1,
544+
SlotIsLogical(s)
545+
?errmsg("acquired logical replication slot \"%s\"",
546+
NameStr(s->data.name))
547+
:errmsg("acquired physical replication slot \"%s\"",
548+
NameStr(s->data.name)));
549+
}
540550
}
541551

542552
/*
@@ -549,9 +559,17 @@ void
549559
ReplicationSlotRelease(void)
550560
{
551561
ReplicationSlot*slot=MyReplicationSlot;
562+
char*slotname=NULL;/* keep compiler quiet */
563+
boolis_logical= false;/* keep compiler quiet */
552564

553565
Assert(slot!=NULL&&slot->active_pid!=0);
554566

567+
if (am_walsender)
568+
{
569+
slotname=pstrdup(NameStr(slot->data.name));
570+
is_logical=SlotIsLogical(slot);
571+
}
572+
555573
if (slot->data.persistency==RS_EPHEMERAL)
556574
{
557575
/*
@@ -596,6 +614,18 @@ ReplicationSlotRelease(void)
596614
MyProc->statusFlags &= ~PROC_IN_LOGICAL_DECODING;
597615
ProcGlobal->statusFlags[MyProc->pgxactoff]=MyProc->statusFlags;
598616
LWLockRelease(ProcArrayLock);
617+
618+
if (am_walsender)
619+
{
620+
ereport(log_replication_commands ?LOG :DEBUG1,
621+
is_logical
622+
?errmsg("released logical replication slot \"%s\"",
623+
slotname)
624+
:errmsg("released physical replication slot \"%s\"",
625+
slotname));
626+
627+
pfree(slotname);
628+
}
599629
}
600630

601631
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp