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

Commitd77b63b

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
Added GUC variable bgwriter_flush_method controlling the action
done by the background writer between writing dirty blocks andnapping. none (default) no actionsync bgwriter calls smgrsync() causing a sync(2)A global sync() is only good on dedicated database servers, somore flush methods should be added in the future.Jan
1 parent610d33c commitd77b63b

File tree

4 files changed

+68
-5
lines changed

4 files changed

+68
-5
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.152 2004/01/09 21:08:49 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.153 2004/01/24 20:00:45 wieck Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -55,6 +55,7 @@
5555
#include"storage/proc.h"
5656
#include"storage/smgr.h"
5757
#include"utils/relcache.h"
58+
#include"utils/guc.h"
5859

5960
#include"pgstat.h"
6061

@@ -65,9 +66,23 @@
6566
/* GUC variable */
6667
boolzero_damaged_pages= false;
6768

69+
#defineBGWRITER_FLUSH_NONE0
70+
#defineBGWRITER_FLUSH_NONE_STR"none"
71+
#defineBGWRITER_FLUSH_SYNC1
72+
#defineBGWRITER_FLUSH_SYNC_STR"sync"
73+
74+
#defineBGWRITER_FLUSH_DEFAULTBGWRITER_FLUSH_NONE
75+
#defineBGWRITER_FLUSH_DEFAULT_STRBGWRITER_FLUSH_NONE_STR
76+
6877
intBgWriterDelay=200;
6978
intBgWriterPercent=1;
7079
intBgWriterMaxpages=100;
80+
intBgWriterFlushMethod=BGWRITER_FLUSH_NONE;
81+
char*BgWriterFlushMethod_str=NULL;
82+
constcharBgWriterFlushMethod_default[]=BGWRITER_FLUSH_DEFAULT_STR;
83+
84+
constchar*BgWriterAssignSyncMethod(constchar*method,
85+
booldoit,GucSourcesource);
7186

7287
staticvoidWaitIO(BufferDesc*buf);
7388
staticvoidStartBufferIO(BufferDesc*buf,boolforInput);
@@ -1026,6 +1041,19 @@ BufferBackgroundWriter(void)
10261041
if (InterruptPending)
10271042
return;
10281043

1044+
/*
1045+
* Perform the configured buffer flush method
1046+
*/
1047+
switch (BgWriterFlushMethod)
1048+
{
1049+
caseBGWRITER_FLUSH_NONE:
1050+
break;
1051+
1052+
caseBGWRITER_FLUSH_SYNC:
1053+
smgrsync();
1054+
break;
1055+
}
1056+
10291057
/*
10301058
* Nap for the configured time or sleep for 10 seconds if
10311059
* there was nothing to do at all.
@@ -1037,6 +1065,27 @@ BufferBackgroundWriter(void)
10371065
}
10381066
}
10391067

1068+
constchar*
1069+
BgWriterAssignSyncMethod(constchar*method,booldoit,GucSourcesource)
1070+
{
1071+
intnew_flush_method;
1072+
1073+
if (strcasecmp(method,BGWRITER_FLUSH_NONE_STR)==0)
1074+
new_flush_method=BGWRITER_FLUSH_NONE;
1075+
else
1076+
if (strcasecmp(method,BGWRITER_FLUSH_SYNC_STR)==0)
1077+
new_flush_method=BGWRITER_FLUSH_SYNC;
1078+
else
1079+
returnNULL;
1080+
1081+
if (!doit)
1082+
returnmethod;
1083+
1084+
BgWriterFlushMethod=new_flush_method;
1085+
returnmethod;
1086+
}
1087+
1088+
10401089
/*
10411090
* Do whatever is needed to prepare for commit at the bufmgr and smgr levels
10421091
*/

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

Lines changed: 12 additions & 1 deletion
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.179 2004/01/23 23:54:21 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.180 2004/01/24 20:00:45 wieck Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -95,6 +95,8 @@ static const char *assign_msglvl(int *var, const char *newval,
9595
staticconstchar*assign_log_error_verbosity(constchar*newval,booldoit,
9696
GucSourcesource);
9797
staticboolassign_phony_autocommit(boolnewval,booldoit,GucSourcesource);
98+
externconstchar*BgWriterAssignSyncMethod(constchar*method,
99+
booldoit,GucSourcesource);
98100

99101

100102
/*
@@ -1689,6 +1691,15 @@ static struct config_string ConfigureNamesString[] =
16891691
XLOG_sync_method_default,assign_xlog_sync_method,NULL
16901692
},
16911693

1694+
{
1695+
{"bgwriter_flush_method",PGC_SIGHUP,RESOURCES,
1696+
gettext_noop("Selects the method used by the bgwriter for forcing writes out to disk."),
1697+
NULL
1698+
},
1699+
&BgWriterFlushMethod_str,
1700+
BgWriterFlushMethod_default,BgWriterAssignSyncMethod,NULL
1701+
},
1702+
16921703
/* End-of-list marker */
16931704
{
16941705
{NULL,0,0,NULL,NULL},NULL,NULL,NULL,NULL

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@
6161
#debug_shared_buffers = 0# 0-600 seconds
6262

6363
# - Background writer -
64+
#debug_shared_buffers = 0# 0-600 seconds interval (0 = off)
6465
#bgwriter_delay = 200# 10-5000 milliseconds
6566
#bgwriter_percent = 1# 0-100% of dirty buffers
6667
#bgwriter_maxpages = 100# 1-1000 buffers max at once
68+
#bgwriter_flush_method = none # how the bgwriter flushes kernel buffers
69+
# one of: none or sync
6770

6871
# - Free Space Map -
6972

‎src/include/storage/bufmgr.h

Lines changed: 3 additions & 3 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/include/storage/bufmgr.h,v 1.73 2003/12/1400:34:47 neilc Exp $
10+
* $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.74 2004/01/24 20:00:46 wieck Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -31,6 +31,8 @@ extern bool zero_damaged_pages;
3131
externintBgWriterDelay;
3232
externintBgWriterPercent;
3333
externintBgWriterMaxpages;
34+
externchar*BgWriterFlushMethod_str;
35+
externconstcharBgWriterFlushMethod_default[];
3436

3537

3638
/* in buf_init.c */
@@ -180,8 +182,6 @@ extern void AbortBufferIO(void);
180182
externvoidBufmgrCommit(void);
181183
externintBufferSync(intpercent,intmaxpages);
182184
externvoidBufferBackgroundWriter(void);
183-
externconstchar*BgWriterAssignSyncMethod(constchar*method,
184-
booldoid,boolinteractive);
185185

186186
externvoidInitLocalBuffer(void);
187187

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp