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

Commit9a32150

Browse files
Make min_wal_size/max_wal_size use MB internally
Previously they were defined using multiples of XLogSegSize.Remove GUC_UNIT_XSEGS. Introduce GUC_UNIT_MBExtracted from patch series on XLogSegSize infrastructure.Beena Emerson
1 parentcd740c0 commit9a32150

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ extern uint32 bootstrap_data_checksum_version;
8686

8787

8888
/* User-settable parameters */
89-
intmax_wal_size=64;/* 1 GB */
90-
intmin_wal_size=5;/* 80 MB */
89+
intmax_wal_size_mb=1024;/* 1 GB */
90+
intmin_wal_size_mb=80;/* 80 MB */
9191
intwal_keep_segments=0;
9292
intXLOGbuffers=-1;
9393
intXLogArchiveTimeout=0;
@@ -738,6 +738,10 @@ static ControlFileData *ControlFile = NULL;
738738
#defineUsableBytesInPage (XLOG_BLCKSZ - SizeOfXLogShortPHD)
739739
#defineUsableBytesInSegment ((XLOG_SEG_SIZE / XLOG_BLCKSZ) * UsableBytesInPage - (SizeOfXLogLongPHD - SizeOfXLogShortPHD))
740740

741+
/* Convert min_wal_size_mb and max wal_size_mb to equivalent segment count */
742+
#defineConvertToXSegs(x)\
743+
(x / (XLOG_SEG_SIZE / (1024 * 1024)))
744+
741745
/*
742746
* Private, possibly out-of-date copy of shared LogwrtResult.
743747
* See discussion above.
@@ -2200,7 +2204,7 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic)
22002204
}
22012205

22022206
/*
2203-
* Calculate CheckPointSegments based onmax_wal_size and
2207+
* Calculate CheckPointSegments based onmax_wal_size_mb and
22042208
* checkpoint_completion_target.
22052209
*/
22062210
staticvoid
@@ -2210,14 +2214,14 @@ CalculateCheckpointSegments(void)
22102214

22112215
/*-------
22122216
* Calculate the distance at which to trigger a checkpoint, to avoid
2213-
* exceedingmax_wal_size. This is based on two assumptions:
2217+
* exceedingmax_wal_size_mb. This is based on two assumptions:
22142218
*
22152219
* a) we keep WAL for two checkpoint cycles, back to the "prev" checkpoint.
22162220
* b) during checkpoint, we consume checkpoint_completion_target *
22172221
* number of segments consumed between checkpoints.
22182222
*-------
22192223
*/
2220-
target= (double)max_wal_size / (2.0+CheckPointCompletionTarget);
2224+
target= (double)ConvertToXSegs(max_wal_size_mb) / (2.0+CheckPointCompletionTarget);
22212225

22222226
/* round down */
22232227
CheckPointSegments= (int)target;
@@ -2229,7 +2233,7 @@ CalculateCheckpointSegments(void)
22292233
void
22302234
assign_max_wal_size(intnewval,void*extra)
22312235
{
2232-
max_wal_size=newval;
2236+
max_wal_size_mb=newval;
22332237
CalculateCheckpointSegments();
22342238
}
22352239

@@ -2253,12 +2257,12 @@ XLOGfileslop(XLogRecPtr PriorRedoPtr)
22532257
XLogSegNorecycleSegNo;
22542258

22552259
/*
2256-
* Calculate the segment numbers thatmin_wal_size andmax_wal_size
2260+
* Calculate the segment numbers thatmin_wal_size_mb andmax_wal_size_mb
22572261
* correspond to. Always recycle enough segments to meet the minimum, and
22582262
* remove enough segments to stay below the maximum.
22592263
*/
2260-
minSegNo=PriorRedoPtr /XLOG_SEG_SIZE+min_wal_size-1;
2261-
maxSegNo=PriorRedoPtr /XLOG_SEG_SIZE+max_wal_size-1;
2264+
minSegNo=PriorRedoPtr /XLOG_SEG_SIZE+ConvertToXSegs(min_wal_size_mb)-1;
2265+
maxSegNo=PriorRedoPtr /XLOG_SEG_SIZE+ConvertToXSegs(max_wal_size_mb)-1;
22622266

22632267
/*
22642268
* Between those limits, recycle enough segments to get us through to the

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,11 @@ static const unit_conversion memory_unit_conversion_table[] =
729729
{"MB",GUC_UNIT_KB,1024},
730730
{"kB",GUC_UNIT_KB,1},
731731

732+
{"TB",GUC_UNIT_MB,1024*1024},
733+
{"GB",GUC_UNIT_MB,1024},
734+
{"MB",GUC_UNIT_MB,1},
735+
{"kB",GUC_UNIT_MB,-1024},
736+
732737
{"TB",GUC_UNIT_BLOCKS, (1024*1024*1024) / (BLCKSZ /1024)},
733738
{"GB",GUC_UNIT_BLOCKS, (1024*1024) / (BLCKSZ /1024)},
734739
{"MB",GUC_UNIT_BLOCKS,1024 / (BLCKSZ /1024)},
@@ -739,11 +744,6 @@ static const unit_conversion memory_unit_conversion_table[] =
739744
{"MB",GUC_UNIT_XBLOCKS,1024 / (XLOG_BLCKSZ /1024)},
740745
{"kB",GUC_UNIT_XBLOCKS,-(XLOG_BLCKSZ /1024)},
741746

742-
{"TB",GUC_UNIT_XSEGS, (1024*1024*1024) / (XLOG_SEG_SIZE /1024)},
743-
{"GB",GUC_UNIT_XSEGS, (1024*1024) / (XLOG_SEG_SIZE /1024)},
744-
{"MB",GUC_UNIT_XSEGS,-(XLOG_SEG_SIZE / (1024*1024))},
745-
{"kB",GUC_UNIT_XSEGS,-(XLOG_SEG_SIZE /1024)},
746-
747747
{""}/* end of table marker */
748748
};
749749

@@ -2236,21 +2236,21 @@ static struct config_int ConfigureNamesInt[] =
22362236
{"min_wal_size",PGC_SIGHUP,WAL_CHECKPOINTS,
22372237
gettext_noop("Sets the minimum size to shrink the WAL to."),
22382238
NULL,
2239-
GUC_UNIT_XSEGS
2239+
GUC_UNIT_MB
22402240
},
2241-
&min_wal_size,
2242-
5,2,INT_MAX,
2241+
&min_wal_size_mb,
2242+
5* (XLOG_SEG_SIZE/ (1024*1024)),2,MAX_KILOBYTES,
22432243
NULL,NULL,NULL
22442244
},
22452245

22462246
{
22472247
{"max_wal_size",PGC_SIGHUP,WAL_CHECKPOINTS,
22482248
gettext_noop("Sets the WAL size that triggers a checkpoint."),
22492249
NULL,
2250-
GUC_UNIT_XSEGS
2250+
GUC_UNIT_MB
22512251
},
2252-
&max_wal_size,
2253-
64,2,INT_MAX,
2252+
&max_wal_size_mb,
2253+
64* (XLOG_SEG_SIZE/ (1024*1024)),2,MAX_KILOBYTES,
22542254
NULL,assign_max_wal_size,NULL
22552255
},
22562256

@@ -8085,6 +8085,9 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
80858085
caseGUC_UNIT_KB:
80868086
values[2]="kB";
80878087
break;
8088+
caseGUC_UNIT_MB:
8089+
values[2]="MB";
8090+
break;
80888091
caseGUC_UNIT_BLOCKS:
80898092
snprintf(buffer,sizeof(buffer),"%dkB",BLCKSZ /1024);
80908093
values[2]=pstrdup(buffer);
@@ -8093,11 +8096,6 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
80938096
snprintf(buffer,sizeof(buffer),"%dkB",XLOG_BLCKSZ /1024);
80948097
values[2]=pstrdup(buffer);
80958098
break;
8096-
caseGUC_UNIT_XSEGS:
8097-
snprintf(buffer,sizeof(buffer),"%dMB",
8098-
XLOG_SEG_SIZE / (1024*1024));
8099-
values[2]=pstrdup(buffer);
8100-
break;
81018099
caseGUC_UNIT_MS:
81028100
values[2]="ms";
81038101
break;

‎src/include/access/xlog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ extern PGDLLIMPORT XLogRecPtr XactLastCommitEnd;
9494
externboolreachedConsistency;
9595

9696
/* these variables are GUC parameters related to XLOG */
97-
externintmin_wal_size;
98-
externintmax_wal_size;
97+
externintmin_wal_size_mb;
98+
externintmax_wal_size_mb;
9999
externintwal_keep_segments;
100100
externintXLOGbuffers;
101101
externintXLogArchiveTimeout;

‎src/include/utils/guc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ typedef enum
218218
#defineGUC_UNIT_KB0x1000/* value is in kilobytes */
219219
#defineGUC_UNIT_BLOCKS0x2000/* value is in blocks */
220220
#defineGUC_UNIT_XBLOCKS0x3000/* value is in xlog blocks */
221-
#defineGUC_UNIT_XSEGS0x4000/* value is inxlog segments */
221+
#defineGUC_UNIT_MB0x4000/* value is inmegabytes */
222222
#defineGUC_UNIT_MEMORY0xF000/* mask for size-related units */
223223

224224
#defineGUC_UNIT_MS 0x10000/* value is in milliseconds */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp