Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2986aa6

Browse files
committed
Add checkpoint_warning to warn of excessive checkpoints caused by too
few WAL files.
1 parent 3779f7f commit 2986aa6

File tree

6 files changed

+52
-5
lines changed

6 files changed

+52
-5
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.154 2002/11/15 01:57:25 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.155 2002/11/15 02:44:50 momjian Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -2081,6 +2081,18 @@ dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
20812081
</listitem>
20822082
</varlistentry>
20832083

2084+
<variablelist>
2085+
<varlistentry>
2086+
<term><varname>CHECKPOINT_WARNING</varname> (<type>integer</type>)</term>
2087+
<listitem>
2088+
<para>
2089+
Send a message to the server logs if checkpoints caused by the
2090+
filling of checkpoint segment files happens more frequently than
2091+
this number of seconds. Zero turns off the warning.
2092+
</para>
2093+
</listitem>
2094+
</varlistentry>
2095+
20842096
<varlistentry>
20852097
<term><varname>COMMIT_DELAY</varname> (<type>integer</type>)</term>
20862098
<listitem>

doc/src/sgml/wal.sgml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/wal.sgml,v 1.21 2002/11/02 22:23:01 tgl Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/wal.sgml,v 1.22 2002/11/15 02:44:54 momjian Exp $ -->
22

33
<chapter id="wal">
44
<title>Write-Ahead Logging (<acronym>WAL</acronym>)</title>
@@ -300,6 +300,16 @@
300300
correspondingly increase shared memory usage.
301301
</para>
302302

303+
<para>
304+
Checkpoints are fairly expensive because they force all dirty kernel
305+
buffers to disk using the operating system <literal>sync()</> call.
306+
Busy servers may fill checkpoint segment files too quickly,
307+
causing excessive checkpointing. If such forced checkpoints happen
308+
more frequently than <varname>CHECKPOINT_WARNING</varname> seconds,
309+
a message, will be output to the server logs recommending increasing
310+
<varname>CHECKPOINT_SEGMENTS</varname>.
311+
</para>
312+
303313
<para>
304314
The <varname>COMMIT_DELAY</varname> parameter defines for how many
305315
microseconds the backend will sleep after writing a commit

src/backend/postmaster/postmaster.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.296 2002/11/15 01:57:26 momjian Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.297 2002/11/15 02:44:55 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -198,6 +198,8 @@ bool SilentMode = false; /* silent mode (-S) */
198198
int PreAuthDelay = 0;
199199
int AuthenticationTimeout = 60;
200200
int CheckPointTimeout = 300;
201+
int CheckPointWarning = 30;
202+
time_t LastSignalledCheckpoint = 0;
201203

202204
bool log_hostname; /* for ps display */
203205
bool LogSourcePort;
@@ -2329,6 +2331,22 @@ sigusr1_handler(SIGNAL_ARGS)
23292331

23302332
if (CheckPostmasterSignal(PMSIGNAL_DO_CHECKPOINT))
23312333
{
2334+
if (CheckPointWarning != 0)
2335+
{
2336+
/*
2337+
* This only times checkpoints forced by running out of
2338+
* segment files. Other checkpoints could reduce
2339+
* the frequency of forced checkpoints.
2340+
*/
2341+
time_t now = time(NULL);
2342+
2343+
if (now - LastSignalledCheckpoint < CheckPointWarning)
2344+
elog(LOG, "Checkpoint segments are being created too frequently (%d secs)\n
2345+
Consider increasing CHECKPOINT_SEGMENTS",
2346+
now - LastSignalledCheckpoint);
2347+
LastSignalledCheckpoint = now;
2348+
}
2349+
23322350
/*
23332351
* Request to schedule a checkpoint
23342352
*

src/backend/utils/misc/guc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* command, configuration file, and command line options.
66
* See src/backend/utils/misc/README for more information.
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.105 2002/11/15 01:57:27 momjian Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.106 2002/11/15 02:44:57 momjian Exp $
99
*
1010
* Copyright 2000 by PostgreSQL Global Development Group
1111
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -660,6 +660,11 @@ static struct config_int
660660
300, 30, 3600, NULL, NULL
661661
},
662662

663+
{
664+
{"checkpoint_warning", PGC_SIGHUP}, &CheckPointWarning,
665+
30, 0, INT_MAX, NULL, NULL
666+
},
667+
663668
{
664669
{"wal_buffers", PGC_POSTMASTER}, &XLOGbuffers,
665670
8, 4, INT_MAX, NULL, NULL

src/backend/utils/misc/postgresql.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#
6666
#checkpoint_segments = 3 # in logfile segments, min 1, 16MB each
6767
#checkpoint_timeout = 300 # range 30-3600, in seconds
68+
#checkpoint_warning = 30 # 0 is off, in seconds
6869
#
6970
#commit_delay = 0 # range 0-100000, in microseconds
7071
#commit_siblings = 5 # range 1-1000

src/include/access/xlog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: xlog.h,v 1.39 2002/09/26 22:58:34 tgl Exp $
9+
* $Id: xlog.h,v 1.40 2002/11/15 02:44:57 momjian Exp $
1010
*/
1111
#ifndef XLOG_H
1212
#define XLOG_H
@@ -184,6 +184,7 @@ extern XLogRecPtr ProcLastRecEnd;
184184

185185
/* these variables are GUC parameters related to XLOG */
186186
extern int CheckPointSegments;
187+
extern int CheckPointWarning;
187188
extern int XLOGbuffers;
188189
extern int XLOG_DEBUG;
189190
extern char *XLOG_sync_method;

0 commit comments

Comments
 (0)