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

Commitbc028be

Browse files
author
Neil Conway
committed
Make the 'wal_debug' GUC variable a boolean (rather than an integer), and
hide it behind #ifdef WAL_DEBUG blocks.
1 parentb0c4a50 commitbc028be

File tree

7 files changed

+63
-36
lines changed

7 files changed

+63
-36
lines changed

‎doc/src/sgml/ref/show.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/show.sgml,v 1.34 2003/11/29 19:51:39 pgsql Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/show.sgml,v 1.35 2004/01/06 17:26:23 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -172,7 +172,7 @@ SHOW ALL;
172172
.
173173
.
174174
.
175-
wal_debug |0
175+
wal_debug |off
176176
wal_sync_method | fdatasync
177177
(94 rows)
178178
</programlisting>

‎doc/src/sgml/runtime.sgml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.228 2004/01/05 20:37:51 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.229 2004/01/06 17:26:22 neilc Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -2667,10 +2667,13 @@ dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
26672667
</varlistentry>
26682668

26692669
<varlistentry>
2670-
<term><varname>wal_debug</varname> (<type>integer</type>)</term>
2670+
<term><varname>wal_debug</varname> (<type>boolean</type>)</term>
26712671
<listitem>
26722672
<para>
2673-
If nonzero, turn on WAL-related debugging output.
2673+
If true, emit WAL-related debugging output. This option is
2674+
only available if the <symbol>WAL_DEBUG</symbol> macro was
2675+
defined when <productname>PostgreSQL</productname> was
2676+
compiled.
26742677
</para>
26752678
</listitem>
26762679
</varlistentry>

‎doc/src/sgml/wal.sgml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/wal.sgml,v 1.26 2003/11/29 19:51:38 pgsql Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/wal.sgml,v 1.27 2004/01/06 17:26:23 neilc Exp $ -->
22

33
<chapter id="wal">
44
<title>Write-Ahead Logging (<acronym>WAL</acronym>)</title>
@@ -19,10 +19,10 @@
1919
transaction processing. Briefly, <acronym>WAL</acronym>'s central
2020
concept is that changes to data files (where tables and indexes
2121
reside) must be written only after those changes have been logged,
22-
that is, when log records have been flushed to permanent
23-
storage. If we follow this procedure, we do not need to flush
24-
data pages to disk on every transaction commit, because we know
25-
that in the event of a crash we will be able to recover the
22+
that is, when log recordsdescribing the changeshave been flushed
23+
to permanentstorage. If we follow this procedure, we do not need
24+
to flushdata pages to disk on every transaction commit, because we
25+
knowthat in the event of a crash we will be able to recover the
2626
database using the log: any changes that have not been applied to
2727
the data pages will first be redone from the log records (this is
2828
roll-forward recovery, also known as REDO) and then changes made by
@@ -187,7 +187,7 @@
187187
<para>
188188
There will be at least one 16 MB segment file, and will normally
189189
not be more than 2 * <varname>checkpoint_segments</varname> + 1
190-
files. You can use this to estimate space requirements for WAL.
190+
files. You can use this to estimate space requirements for<acronym>WAL</acronym>.
191191
Ordinarily, when old log segment files are no longer needed, they
192192
are recycled (renamed to become the next segments in the numbered
193193
sequence). If, due to a short-term peak of log output rate, there
@@ -254,19 +254,18 @@
254254
<para>
255255
The <varname>wal_sync_method</varname> parameter determines how
256256
<productname>PostgreSQL</productname> will ask the kernel to force
257-
WAL updates out to disk.
257+
<acronym>WAL</acronym> updates out to disk.
258258
All the options should be the same as far as reliability goes,
259259
but it's quite platform-specific which one will be the fastest.
260260
Note that this parameter is irrelevant if <varname>fsync</varname>
261261
has been turned off.
262262
</para>
263263

264264
<para>
265-
Setting the <varname>wal_debug</varname>parameter to any nonzero
266-
valuewill result in each <function>LogInsert</function> and
265+
Enabling the <varname>wal_debug</varname>configuration parameter
266+
will result in each <function>LogInsert</function> and
267267
<function>LogFlush</function> <acronym>WAL</acronym> call being
268-
logged to the server log. At present, it makes no difference what
269-
the nonzero value is. This option may be replaced by a more
268+
logged to the server log. This option may be replaced by a more
270269
general mechanism in the future.
271270
</para>
272271
</sect1>

‎src/backend/access/transam/xlog.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.129 2003/12/20 17:31:20 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.130 2004/01/06 17:26:23 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -86,12 +86,15 @@
8686
/* User-settable parameters */
8787
intCheckPointSegments=3;
8888
intXLOGbuffers=8;
89-
intXLOG_DEBUG=0;
9089
char*XLOG_sync_method=NULL;
9190
constcharXLOG_sync_method_default[]=DEFAULT_SYNC_METHOD_STR;
9291
charXLOG_archive_dir[MAXPGPATH];/* null string means
9392
* delete 'em */
9493

94+
#ifdefWAL_DEBUG
95+
boolXLOG_DEBUG= false;
96+
#endif
97+
9598
/*
9699
* XLOGfileslop is used in the code as the allowed "fuzz" in the number of
97100
* preallocated XLOG segments --- we try to have at least XLOGfiles advance
@@ -766,6 +769,7 @@ begin:;
766769
MyProc->logRec=RecPtr;
767770
}
768771

772+
#ifdefWAL_DEBUG
769773
if (XLOG_DEBUG)
770774
{
771775
charbuf[8192];
@@ -779,6 +783,7 @@ begin:;
779783
}
780784
elog(LOG,"%s",buf);
781785
}
786+
#endif
782787

783788
/* Record begin of record in appropriate places */
784789
if (!no_tran)
@@ -1074,8 +1079,10 @@ XLogWrite(XLogwrtRqst WriteRqst)
10741079
openLogSeg >= (RedoRecPtr.xrecoff /XLogSegSize)+
10751080
(uint32)CheckPointSegments))
10761081
{
1082+
#ifdefWAL_DEBUG
10771083
if (XLOG_DEBUG)
10781084
elog(LOG,"time for a checkpoint, signaling postmaster");
1085+
#endif
10791086
SendPostmasterSignal(PMSIGNAL_DO_CHECKPOINT);
10801087
}
10811088
}
@@ -1214,11 +1221,13 @@ XLogFlush(XLogRecPtr record)
12141221
if (XLByteLE(record,LogwrtResult.Flush))
12151222
return;
12161223

1224+
#ifdefWAL_DEBUG
12171225
if (XLOG_DEBUG)
12181226
elog(LOG,"xlog flush request %X/%X; write %X/%X; flush %X/%X",
12191227
record.xlogid,record.xrecoff,
12201228
LogwrtResult.Write.xlogid,LogwrtResult.Write.xrecoff,
12211229
LogwrtResult.Flush.xlogid,LogwrtResult.Flush.xrecoff);
1230+
#endif
12221231

12231232
START_CRIT_SECTION();
12241233

@@ -2613,8 +2622,10 @@ StartupXLOG(void)
26132622

26142623
/* This is just to allow attaching to startup process with a debugger */
26152624
#ifdefXLOG_REPLAY_DELAY
2625+
#ifdefWAL_DEBUG
26162626
if (XLOG_DEBUG&&ControlFile->state!=DB_SHUTDOWNED)
26172627
sleep(60);
2628+
#endif
26182629
#endif
26192630

26202631
/*
@@ -2742,6 +2753,8 @@ StartupXLOG(void)
27422753
ShmemVariableCache->nextXid=record->xl_xid;
27432754
TransactionIdAdvance(ShmemVariableCache->nextXid);
27442755
}
2756+
2757+
#ifdefWAL_DEBUG
27452758
if (XLOG_DEBUG)
27462759
{
27472760
charbuf[8192];
@@ -2755,6 +2768,7 @@ StartupXLOG(void)
27552768
record->xl_info,XLogRecGetData(record));
27562769
elog(LOG,"%s",buf);
27572770
}
2771+
#endif
27582772

27592773
if (record->xl_info&XLR_BKP_BLOCK_MASK)
27602774
RestoreBkpBlocks(record,EndRecPtr);

‎src/backend/utils/misc/guc.c

Lines changed: 18 additions & 15 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.175 2003/12/03 18:52:00 joe Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.176 2004/01/06 17:26:23 neilc Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -336,17 +336,18 @@ const char *const config_type_names[] =
336336
* TO ADD AN OPTION:
337337
*
338338
* 1. Declare a global variable of type bool, int, double, or char*
339-
* and make use of it.
339+
*and make use of it.
340340
*
341341
* 2. Decide at what times it's safe to set the option. See guc.h for
342-
* details.
342+
*details.
343343
*
344344
* 3. Decide on a name, a default value, upper and lower bounds (if
345-
* applicable), etc.
345+
*applicable), etc.
346346
*
347347
* 4. Add a record below.
348348
*
349-
* 5. Add it to src/backend/utils/misc/postgresql.conf.sample.
349+
* 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if
350+
* appropriate
350351
*
351352
* 6. Add it to src/bin/psql/tab-complete.c, if it's a USERSET option.
352353
*
@@ -862,6 +863,18 @@ static struct config_bool ConfigureNamesBool[] =
862863
#endif
863864
},
864865

866+
#ifdefWAL_DEBUG
867+
{
868+
{"wal_debug",PGC_SUSET,DEVELOPER_OPTIONS,
869+
gettext_noop("Emit WAL-related debugging output."),
870+
NULL,
871+
GUC_NOT_IN_SAMPLE
872+
},
873+
&XLOG_DEBUG,
874+
false,NULL,NULL
875+
},
876+
#endif
877+
865878
/* End-of-list marker */
866879
{
867880
{NULL,0,0,NULL,NULL},NULL, false,NULL,NULL
@@ -1171,16 +1184,6 @@ static struct config_int ConfigureNamesInt[] =
11711184
8,4,INT_MAX,NULL,NULL
11721185
},
11731186

1174-
{
1175-
{"wal_debug",PGC_SUSET,DEVELOPER_OPTIONS,
1176-
gettext_noop("If nonzero, WAL-related debugging output is logged."),
1177-
NULL,
1178-
GUC_NOT_IN_SAMPLE
1179-
},
1180-
&XLOG_DEBUG,
1181-
0,0,16,NULL,NULL
1182-
},
1183-
11841187
{
11851188
{"commit_delay",PGC_USERSET,WAL_CHECKPOINTS,
11861189
gettext_noop("Sets the delay in microseconds between transaction commit and "

‎src/include/access/xlog.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.46 2003/12/12 18:45:10 petere Exp $
9+
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.47 2004/01/06 17:26:23 neilc Exp $
1010
*/
1111
#ifndefXLOG_H
1212
#defineXLOG_H
@@ -189,10 +189,12 @@ extern XLogRecPtr ProcLastRecEnd;
189189
externintCheckPointSegments;
190190
externintCheckPointWarning;
191191
externintXLOGbuffers;
192-
externintXLOG_DEBUG;
193192
externchar*XLOG_sync_method;
194193
externconstcharXLOG_sync_method_default[];
195194

195+
#ifdefWAL_DEBUG
196+
externboolXLOG_DEBUG;
197+
#endif
196198

197199
externXLogRecPtrXLogInsert(RmgrIdrmid,uint8info,XLogRecData*rdata);
198200
externvoidXLogFlush(XLogRecPtrRecPtr);

‎src/include/pg_config_manual.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* for developers.If you edit any of these, be sure to do a *full*
77
* rebuild (and an initdb if noted).
88
*
9-
* $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.8 2003/11/29 22:40:53 pgsql Exp $
9+
* $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.9 2004/01/06 17:26:23 neilc Exp $
1010
*------------------------------------------------------------------------
1111
*/
1212

@@ -224,6 +224,12 @@
224224
*/
225225
/* #define LOCK_DEBUG */
226226

227+
/*
228+
* Enable debugging print statements for WAL-related operations; see
229+
* also the wal_debug GUC var.
230+
*/
231+
/* #define WAL_DEBUG */
232+
227233
/*
228234
* Other debug #defines (documentation, anyone?)
229235
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp