Skip to content

Commit f333f69

Browse files
committed
Bring some sanity to the trace_recovery_messages code and docs.
Per gripe from Fujii Masao, though this is not exactly his proposed patch. Categorize as DEVELOPER_OPTIONS and set context PGC_SIGHUP, as per Fujii, but set the default to LOG because higher values aren't really sensible (see the code for trace_recovery()). Fix the documentation to agree with the code and to try to explain what the variable actually does. Get rid of no-op calls trace_recovery(LOG), which accomplish nothing except to demonstrate that this option confuses even its author.
1 parent 4a1989f commit f333f69

File tree

4 files changed

+48
-38
lines changed

4 files changed

+48
-38
lines changed

doc/src/sgml/config.sgml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.294.2.4 2010/08/17 04:37:15 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.294.2.5 2010/08/19 22:55:09 tgl Exp $ -->
22

33
<chapter Id="runtime-config">
44
<title>Server Configuration</title>
@@ -5689,6 +5689,31 @@ plruby.use_strict = true # generates error: unknown class name
56895689
</listitem>
56905690
</varlistentry>
56915691

5692+
<varlistentry id="guc-trace-recovery-messages" xreflabel="trace_recovery_messages">
5693+
<term><varname>trace_recovery_messages</varname> (<type>enum</type>)</term>
5694+
<indexterm>
5695+
<primary><varname>trace_recovery_messages</> configuration parameter</primary>
5696+
</indexterm>
5697+
<listitem>
5698+
<para>
5699+
Enables logging of recovery-related debugging output that otherwise
5700+
would not be logged. This parameter allows the user to override the
5701+
normal setting of <xref linkend="guc-log-min-messages">, but only for
5702+
specific messages. This is intended for use in debugging Hot Standby.
5703+
Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
5704+
<literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>, and
5705+
<literal>LOG</>. The default, <literal>LOG</>, does not affect
5706+
logging decisions at all. The other values cause recovery-related
5707+
debug messages of that priority or higher to be logged as though they
5708+
had <literal>LOG</> priority; for common settings of
5709+
<varname>log_min_messages</> this results in unconditionally sending
5710+
them to the server log.
5711+
This parameter can only be set in the <filename>postgresql.conf</>
5712+
file or on the server command line.
5713+
</para>
5714+
</listitem>
5715+
</varlistentry>
5716+
56925717
<varlistentry id="guc-trace-sort" xreflabel="trace_sort">
56935718
<term><varname>trace_sort</varname> (<type>boolean</type>)</term>
56945719
<indexterm>
@@ -5871,32 +5896,6 @@ LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
58715896
</listitem>
58725897
</varlistentry>
58735898

5874-
<varlistentry id="guc-trace-recovery-messages" xreflabel="trace_recovery_messages">
5875-
<term><varname>trace_recovery_messages</varname> (<type>enum</type>)</term>
5876-
<indexterm>
5877-
<primary><varname>trace_recovery_messages</> configuration parameter</primary>
5878-
</indexterm>
5879-
<listitem>
5880-
<para>
5881-
Controls which message levels are written to the server log
5882-
for system modules needed for recovery processing. This allows
5883-
the user to override the normal setting of log_min_messages,
5884-
but only for specific messages. This is intended for use in
5885-
debugging Hot Standby.
5886-
Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
5887-
<literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>,
5888-
<literal>INFO</>, <literal>NOTICE</>, <literal>WARNING</>,
5889-
<literal>ERROR</>, <literal>LOG</>, <literal>FATAL</>, and
5890-
<literal>PANIC</>. Each level includes all the levels that
5891-
follow it. The later the level, the fewer messages are sent
5892-
to the log. The default is <literal>WARNING</>. Note that
5893-
<literal>LOG</> has a different rank here than in
5894-
<varname>client_min_messages</>.
5895-
Parameter should be set in <filename>postgresql.conf</filename> only.
5896-
</para>
5897-
</listitem>
5898-
</varlistentry>
5899-
59005899
<varlistentry id="guc-zero-damaged-pages" xreflabel="zero_damaged_pages">
59015900
<term><varname>zero_damaged_pages</varname> (<type>boolean</type>)</term>
59025901
<indexterm>

src/backend/storage/ipc/standby.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.27.2.1 2010/08/12 23:25:45 rhaas Exp $
14+
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.27.2.2 2010/08/19 22:55:10 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -591,7 +591,7 @@ StandbyReleaseLocks(TransactionId xid)
591591
lock->xid, lock->dbOid, lock->relOid);
592592
SET_LOCKTAG_RELATION(locktag, lock->dbOid, lock->relOid);
593593
if (!LockRelease(&locktag, AccessExclusiveLock, true))
594-
elog(trace_recovery(LOG),
594+
elog(LOG,
595595
"RecoveryLockList contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
596596
lock->xid, lock->dbOid, lock->relOid);
597597

@@ -655,7 +655,7 @@ StandbyReleaseLocksMany(TransactionId removeXid, bool keepPreparedXacts)
655655
lock->xid, lock->dbOid, lock->relOid);
656656
SET_LOCKTAG_RELATION(locktag, lock->dbOid, lock->relOid);
657657
if (!LockRelease(&locktag, AccessExclusiveLock, true))
658-
elog(trace_recovery(LOG),
658+
elog(LOG,
659659
"RecoveryLockList contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
660660
lock->xid, lock->dbOid, lock->relOid);
661661
RecoveryLockList = list_delete_cell(RecoveryLockList, cell, prev);

src/backend/utils/error/elog.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
*
4444
* IDENTIFICATION
45-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.224.2.1 2010/07/18 23:43:37 tgl Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.224.2.2 2010/08/19 22:55:10 tgl Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -2798,12 +2798,19 @@ is_log_level_output(int elevel, int log_min_level)
27982798
}
27992799

28002800
/*
2801-
* If trace_recovery_messages is set to make this visible, then show as LOG,
2802-
* else display as whatever level is set. It may still be shown, but only
2803-
* if log_min_messages is set lower than trace_recovery_messages.
2801+
* Adjust the level of a recovery-related message per trace_recovery_messages.
2802+
*
2803+
* The argument is the default log level of the message, eg, DEBUG2. (This
2804+
* should only be applied to DEBUGn log messages, otherwise it's a no-op.)
2805+
* If the level is >= trace_recovery_messages, we return LOG, causing the
2806+
* message to be logged unconditionally (for most settings of
2807+
* log_min_messages). Otherwise, we return the argument unchanged.
2808+
* The message will then be shown based on the setting of log_min_messages.
28042809
*
28052810
* Intention is to keep this for at least the whole of the 9.0 production
28062811
* release, so we can more easily diagnose production problems in the field.
2812+
* It should go away eventually, though, because it's an ugly and
2813+
* hard-to-explain kluge.
28072814
*/
28082815
int
28092816
trace_recovery(int trace_level)

src/backend/utils/misc/guc.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.561 2010/07/06 22:55:26 rhaas Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.561.2.1 2010/08/19 22:55:10 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -2785,13 +2785,17 @@ static struct config_enum ConfigureNamesEnum[] =
27852785
},
27862786

27872787
{
2788-
{"trace_recovery_messages", PGC_SUSET, LOGGING_WHEN,
2789-
gettext_noop("Sets the message levels that are logged during recovery."),
2788+
{"trace_recovery_messages", PGC_SIGHUP, DEVELOPER_OPTIONS,
2789+
gettext_noop("Enables logging of recovery-related debugging information."),
27902790
gettext_noop("Each level includes all the levels that follow it. The later"
27912791
" the level, the fewer messages are sent.")
27922792
},
27932793
&trace_recovery_messages,
2794-
DEBUG1, server_message_level_options, NULL, NULL
2794+
/*
2795+
* client_message_level_options allows too many values, really,
2796+
* but it's not worth having a separate options array for this.
2797+
*/
2798+
LOG, client_message_level_options, NULL, NULL
27952799
},
27962800

27972801
{

0 commit comments

Comments
 (0)