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

Commit401de9c

Browse files
committed
Improve the checkpoint signaling mechanism so that the bgwriter can tell
the difference between checkpoints forced due to WAL segment consumptionand checkpoints forced for other reasons (such as CREATE DATABASE). Avoidgenerating 'checkpoints are occurring too frequently' messages when thecheckpoint wasn't caused by WAL segment consumption. Per gripe fromChris K-L.
1 parentb5f7cff commit401de9c

File tree

6 files changed

+45
-29
lines changed

6 files changed

+45
-29
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
2525
* Portions Copyright (c) 1994, Regents of the University of California
2626
*
27-
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.30 2005/06/06 20:22:57 tgl Exp $
27+
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.31 2005/06/30 00:00:50 tgl Exp $
2828
*
2929
*-------------------------------------------------------------------------
3030
*/
@@ -336,7 +336,7 @@ TruncateCLOG(TransactionId oldestXact)
336336
return;/* nothing to remove */
337337

338338
/* Perform a CHECKPOINT */
339-
RequestCheckpoint(true);
339+
RequestCheckpoint(true, false);
340340

341341
/* Now we can remove the old CLOG segment(s) */
342342
SimpleLruTruncate(ClogCtl,cutoffPage);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2005, 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.204 2005/06/29 22:51:53 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.205 2005/06/30 00:00:50 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1337,7 +1337,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
13371337
if (XLOG_DEBUG)
13381338
elog(LOG,"time for a checkpoint, signaling bgwriter");
13391339
#endif
1340-
RequestCheckpoint(false);
1340+
RequestCheckpoint(false, true);
13411341
}
13421342
}
13431343
}
@@ -5496,7 +5496,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
54965496
* will have different checkpoint positions and hence different
54975497
* history file names, even if nothing happened in between.
54985498
*/
5499-
RequestCheckpoint(true);
5499+
RequestCheckpoint(true, false);
55005500

55015501
/*
55025502
* Now we need to fetch the checkpoint record location, and also its

‎src/backend/commands/dbcommands.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.163 2005/06/29 20:34:13 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.164 2005/06/30 00:00:50 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -542,7 +542,7 @@ createdb(const CreatedbStmt *stmt)
542542
* Perhaps if we ever implement CREATE DATABASE in a less cheesy
543543
* way, we can avoid this.
544544
*/
545-
RequestCheckpoint(true);
545+
RequestCheckpoint(true, false);
546546

547547
/*
548548
* Set flag to update flat database file at commit.
@@ -668,7 +668,7 @@ dropdb(const char *dbname)
668668
* open files, which would cause rmdir() to fail.
669669
*/
670670
#ifdefWIN32
671-
RequestCheckpoint(true);
671+
RequestCheckpoint(true, false);
672672
#endif
673673

674674
/*

‎src/backend/postmaster/bgwriter.c

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.16 2005/05/28 17:21:32 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.17 2005/06/30 00:00:51 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -86,8 +86,14 @@
8686
*6. If ckpt_failed is different from the originally saved value,
8787
* assume request failed; otherwise it was definitely successful.
8888
*
89+
* An additional field is ckpt_time_warn; this is also sig_atomic_t for
90+
* simplicity, but is only used as a boolean. If a backend is requesting
91+
* a checkpoint for which a checkpoints-too-close-together warning is
92+
* reasonable, it should set this field TRUE just before sending the signal.
93+
*
8994
* The requests array holds fsync requests sent by backends and not yet
90-
* absorbed by the bgwriter.
95+
* absorbed by the bgwriter. Unlike the checkpoint fields, the requests
96+
* fields are protected by BgWriterCommLock.
9197
*----------
9298
*/
9399
typedefstruct
@@ -105,6 +111,8 @@ typedef struct
105111
sig_atomic_tckpt_done;/* advances when checkpoint done */
106112
sig_atomic_tckpt_failed;/* advances when checkpoint fails */
107113

114+
sig_atomic_tckpt_time_warn;/* warn if too soon since last ckpt? */
115+
108116
intnum_requests;/* current # of requests */
109117
intmax_requests;/* allocated array size */
110118
BgWriterRequestrequests[1];/* VARIABLE LENGTH ARRAY */
@@ -319,20 +327,20 @@ BackgroundWriterMain(void)
319327
*/
320328
if (do_checkpoint)
321329
{
322-
if (CheckPointWarning!=0)
323-
{
324-
/*
325-
*Ideally we should only warn if this checkpoint was
326-
*requested due to running out of segment files, and not
327-
*if it was manually requested. However we can't tell
328-
* the difference with the current signalling mechanism.
329-
*/
330-
if (elapsed_secs<CheckPointWarning)
331-
ereport(LOG,
332-
(errmsg("checkpoints are occurring too frequently (%d seconds apart)",
333-
elapsed_secs),
334-
errhint("Consider increasing the configuration parameter \"checkpoint_segments\".")));
335-
}
330+
/*
331+
* We will warn if (a) too soon since last checkpoint (whatever
332+
* caused it) and (b) somebody has set the ckpt_time_warn flag
333+
*since the last checkpoint start. Note in particular that
334+
*this implementation will not generate warnings caused by
335+
*CheckPointTimeout < CheckPointWarning.
336+
*/
337+
if (BgWriterShmem->ckpt_time_warn&&
338+
elapsed_secs<CheckPointWarning)
339+
ereport(LOG,
340+
(errmsg("checkpoints are occurring too frequently (%d seconds apart)",
341+
elapsed_secs),
342+
errhint("Consider increasing the configuration parameter \"checkpoint_segments\".")));
343+
BgWriterShmem->ckpt_time_warn= false;
336344

337345
/*
338346
* Indicate checkpoint start to any waiting backends.
@@ -497,9 +505,13 @@ BgWriterShmemInit(void)
497505
* If waitforit is true, wait until the checkpoint is completed
498506
* before returning; otherwise, just signal the request and return
499507
* immediately.
508+
*
509+
* If warnontime is true, and it's "too soon" since the last checkpoint,
510+
* the bgwriter will log a warning. This should be true only for checkpoints
511+
* caused due to xlog filling, else the warning will be misleading.
500512
*/
501513
void
502-
RequestCheckpoint(boolwaitforit)
514+
RequestCheckpoint(boolwaitforit,boolwarnontime)
503515
{
504516
/* use volatile pointer to prevent code rearrangement */
505517
volatileBgWriterShmemStruct*bgs=BgWriterShmem;
@@ -523,6 +535,10 @@ RequestCheckpoint(bool waitforit)
523535
return;
524536
}
525537

538+
/* Set warning request flag if appropriate */
539+
if (warnontime)
540+
bgs->ckpt_time_warn= true;
541+
526542
/*
527543
* Send signal to request checkpoint. When waitforit is false, we
528544
* consider failure to send the signal to be nonfatal.

‎src/backend/tcop/utility.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.239 2005/06/28 05:09:00 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.240 2005/06/30 00:00:51 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -989,7 +989,7 @@ ProcessUtility(Node *parsetree,
989989
ereport(ERROR,
990990
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
991991
errmsg("must be superuser to do CHECKPOINT")));
992-
RequestCheckpoint(true);
992+
RequestCheckpoint(true, false);
993993
break;
994994

995995
caseT_ReindexStmt:

‎src/include/postmaster/bgwriter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
*
8-
* $PostgreSQL: pgsql/src/include/postmaster/bgwriter.h,v 1.5 2005/03/04 20:21:06 tgl Exp $
8+
* $PostgreSQL: pgsql/src/include/postmaster/bgwriter.h,v 1.6 2005/06/30 00:00:52 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -23,7 +23,7 @@ extern intCheckPointWarning;
2323

2424
externvoidBackgroundWriterMain(void);
2525

26-
externvoidRequestCheckpoint(boolwaitforit);
26+
externvoidRequestCheckpoint(boolwaitforit,boolwarnontime);
2727

2828
externboolForwardFsyncRequest(RelFileNodernode,BlockNumbersegno);
2929
externvoidAbsorbFsyncRequests(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp