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

Commit8d140c5

Browse files
Improve the naming in wal_sync_method code.
* sync_method is renamed to wal_sync_method.* sync_method_options[] is renamed to wal_sync_method_options[].* assign_xlog_sync_method() is renamed to assign_wal_sync_method().* The names of the available synchronization methods are now prefixed with "WAL_SYNC_METHOD_" and have been moved into a WalSyncMethod enum.* PLATFORM_DEFAULT_SYNC_METHOD is renamed to PLATFORM_DEFAULT_WAL_SYNC_METHOD, and DEFAULT_SYNC_METHOD is renamed to DEFAULT_WAL_SYNC_METHOD.These more descriptive names help distinguish the code forwal_sync_method from the code for DataDirSyncMethod (e.g., therecovery_init_sync_method configuration parameter and the--sync-method option provided by several frontend utilities). Thischange also prevents name collisions between the aforementionedsets of code. Since this only improves the naming of internalidentifiers, there should be no behavior change.Author: Maxim OrlovDiscussion:https://postgr.es/m/CACG%3DezbL1gwE7_K7sr9uqaCGkWhmvRTcTEnm3%2BX1xsRNwbXULQ%40mail.gmail.com
1 parentc5a032e commit8d140c5

File tree

9 files changed

+52
-48
lines changed

9 files changed

+52
-48
lines changed

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ bool *wal_consistency_checking = NULL;
130130
boolwal_init_zero= true;
131131
boolwal_recycle= true;
132132
boollog_checkpoints= true;
133-
intsync_method=DEFAULT_SYNC_METHOD;
133+
intwal_sync_method=DEFAULT_WAL_SYNC_METHOD;
134134
intwal_level=WAL_LEVEL_REPLICA;
135135
intCommitDelay=0;/* precommit delay in microseconds */
136136
intCommitSiblings=5;/* # concurrent xacts needed to sleep */
@@ -171,17 +171,17 @@ static bool check_wal_consistency_checking_deferred = false;
171171
/*
172172
* GUC support
173173
*/
174-
conststructconfig_enum_entrysync_method_options[]= {
175-
{"fsync",SYNC_METHOD_FSYNC, false},
174+
conststructconfig_enum_entrywal_sync_method_options[]= {
175+
{"fsync",WAL_SYNC_METHOD_FSYNC, false},
176176
#ifdefHAVE_FSYNC_WRITETHROUGH
177-
{"fsync_writethrough",SYNC_METHOD_FSYNC_WRITETHROUGH, false},
177+
{"fsync_writethrough",WAL_SYNC_METHOD_FSYNC_WRITETHROUGH, false},
178178
#endif
179-
{"fdatasync",SYNC_METHOD_FDATASYNC, false},
179+
{"fdatasync",WAL_SYNC_METHOD_FDATASYNC, false},
180180
#ifdefO_SYNC
181-
{"open_sync",SYNC_METHOD_OPEN, false},
181+
{"open_sync",WAL_SYNC_METHOD_OPEN, false},
182182
#endif
183183
#ifdefO_DSYNC
184-
{"open_datasync",SYNC_METHOD_OPEN_DSYNC, false},
184+
{"open_datasync",WAL_SYNC_METHOD_OPEN_DSYNC, false},
185185
#endif
186186
{NULL,0, false}
187187
};
@@ -2343,8 +2343,8 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible)
23432343
* have no open file or the wrong one. However, we do not need to
23442344
* fsync more than one file.
23452345
*/
2346-
if (sync_method!=SYNC_METHOD_OPEN&&
2347-
sync_method!=SYNC_METHOD_OPEN_DSYNC)
2346+
if (wal_sync_method!=WAL_SYNC_METHOD_OPEN&&
2347+
wal_sync_method!=WAL_SYNC_METHOD_OPEN_DSYNC)
23482348
{
23492349
if (openLogFile >=0&&
23502350
!XLByteInPrevSeg(LogwrtResult.Write,openLogSegNo,
@@ -2974,7 +2974,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli,
29742974
*/
29752975
*added= false;
29762976
fd=BasicOpenFile(path,O_RDWR |PG_BINARY |O_CLOEXEC |
2977-
get_sync_bit(sync_method));
2977+
get_sync_bit(wal_sync_method));
29782978
if (fd<0)
29792979
{
29802980
if (errno!=ENOENT)
@@ -3139,7 +3139,7 @@ XLogFileInit(XLogSegNo logsegno, TimeLineID logtli)
31393139

31403140
/* Now open original target segment (might not be file I just made) */
31413141
fd=BasicOpenFile(path,O_RDWR |PG_BINARY |O_CLOEXEC |
3142-
get_sync_bit(sync_method));
3142+
get_sync_bit(wal_sync_method));
31433143
if (fd<0)
31443144
ereport(ERROR,
31453145
(errcode_for_file_access(),
@@ -3371,7 +3371,7 @@ XLogFileOpen(XLogSegNo segno, TimeLineID tli)
33713371
XLogFilePath(path,tli,segno,wal_segment_size);
33723372

33733373
fd=BasicOpenFile(path,O_RDWR |PG_BINARY |O_CLOEXEC |
3374-
get_sync_bit(sync_method));
3374+
get_sync_bit(wal_sync_method));
33753375
if (fd<0)
33763376
ereport(PANIC,
33773377
(errcode_for_file_access(),
@@ -8137,16 +8137,16 @@ get_sync_bit(int method)
81378137
* not included in the enum option array, and therefore will never
81388138
* be seen here.
81398139
*/
8140-
caseSYNC_METHOD_FSYNC:
8141-
caseSYNC_METHOD_FSYNC_WRITETHROUGH:
8142-
caseSYNC_METHOD_FDATASYNC:
8140+
caseWAL_SYNC_METHOD_FSYNC:
8141+
caseWAL_SYNC_METHOD_FSYNC_WRITETHROUGH:
8142+
caseWAL_SYNC_METHOD_FDATASYNC:
81438143
returno_direct_flag;
81448144
#ifdefO_SYNC
8145-
caseSYNC_METHOD_OPEN:
8145+
caseWAL_SYNC_METHOD_OPEN:
81468146
returnO_SYNC |o_direct_flag;
81478147
#endif
81488148
#ifdefO_DSYNC
8149-
caseSYNC_METHOD_OPEN_DSYNC:
8149+
caseWAL_SYNC_METHOD_OPEN_DSYNC:
81508150
returnO_DSYNC |o_direct_flag;
81518151
#endif
81528152
default:
@@ -8160,9 +8160,9 @@ get_sync_bit(int method)
81608160
* GUC support
81618161
*/
81628162
void
8163-
assign_xlog_sync_method(intnew_sync_method,void*extra)
8163+
assign_wal_sync_method(intnew_wal_sync_method,void*extra)
81648164
{
8165-
if (sync_method!=new_sync_method)
8165+
if (wal_sync_method!=new_wal_sync_method)
81668166
{
81678167
/*
81688168
* To ensure that no blocks escape unsynced, force an fsync on the
@@ -8188,7 +8188,7 @@ assign_xlog_sync_method(int new_sync_method, void *extra)
81888188
}
81898189

81908190
pgstat_report_wait_end();
8191-
if (get_sync_bit(sync_method)!=get_sync_bit(new_sync_method))
8191+
if (get_sync_bit(wal_sync_method)!=get_sync_bit(new_wal_sync_method))
81928192
XLogFileClose();
81938193
}
81948194
}
@@ -8214,8 +8214,8 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli)
82148214
* file.
82158215
*/
82168216
if (!enableFsync||
8217-
sync_method==SYNC_METHOD_OPEN||
8218-
sync_method==SYNC_METHOD_OPEN_DSYNC)
8217+
wal_sync_method==WAL_SYNC_METHOD_OPEN||
8218+
wal_sync_method==WAL_SYNC_METHOD_OPEN_DSYNC)
82198219
return;
82208220

82218221
/* Measure I/O timing to sync the WAL file */
@@ -8225,29 +8225,29 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli)
82258225
INSTR_TIME_SET_ZERO(start);
82268226

82278227
pgstat_report_wait_start(WAIT_EVENT_WAL_SYNC);
8228-
switch (sync_method)
8228+
switch (wal_sync_method)
82298229
{
8230-
caseSYNC_METHOD_FSYNC:
8230+
caseWAL_SYNC_METHOD_FSYNC:
82318231
if (pg_fsync_no_writethrough(fd)!=0)
82328232
msg=_("could not fsync file \"%s\": %m");
82338233
break;
82348234
#ifdefHAVE_FSYNC_WRITETHROUGH
8235-
caseSYNC_METHOD_FSYNC_WRITETHROUGH:
8235+
caseWAL_SYNC_METHOD_FSYNC_WRITETHROUGH:
82368236
if (pg_fsync_writethrough(fd)!=0)
82378237
msg=_("could not fsync write-through file \"%s\": %m");
82388238
break;
82398239
#endif
8240-
caseSYNC_METHOD_FDATASYNC:
8240+
caseWAL_SYNC_METHOD_FDATASYNC:
82418241
if (pg_fdatasync(fd)!=0)
82428242
msg=_("could not fdatasync file \"%s\": %m");
82438243
break;
8244-
caseSYNC_METHOD_OPEN:
8245-
caseSYNC_METHOD_OPEN_DSYNC:
8244+
caseWAL_SYNC_METHOD_OPEN:
8245+
caseWAL_SYNC_METHOD_OPEN_DSYNC:
82468246
/* not reachable */
82478247
Assert(false);
82488248
break;
82498249
default:
8250-
elog(PANIC,"unrecognized wal_sync_method: %d",sync_method);
8250+
elog(PANIC,"unrecognized wal_sync_method: %d",wal_sync_method);
82518251
break;
82528252
}
82538253

‎src/backend/storage/file/fd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,9 @@ pg_fsync(int fd)
398398
errno=0;
399399
#endif
400400

401-
/* #if is to skip thesync_method test if there's no need for it */
401+
/* #if is to skip thewal_sync_method test if there's no need for it */
402402
#if defined(HAVE_FSYNC_WRITETHROUGH)
403-
if (sync_method==SYNC_METHOD_FSYNC_WRITETHROUGH)
403+
if (wal_sync_method==WAL_SYNC_METHOD_FSYNC_WRITETHROUGH)
404404
returnpg_fsync_writethrough(fd);
405405
else
406406
#endif

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ static const struct config_enum_entry wal_compression_options[] = {
485485
externconststructconfig_enum_entrywal_level_options[];
486486
externconststructconfig_enum_entryarchive_mode_options[];
487487
externconststructconfig_enum_entryrecovery_target_action_options[];
488-
externconststructconfig_enum_entrysync_method_options[];
488+
externconststructconfig_enum_entrywal_sync_method_options[];
489489
externconststructconfig_enum_entrydynamic_shared_memory_options[];
490490

491491
/*
@@ -4843,9 +4843,9 @@ struct config_enum ConfigureNamesEnum[] =
48434843
gettext_noop("Selects the method used for forcing WAL updates to disk."),
48444844
NULL
48454845
},
4846-
&sync_method,
4847-
DEFAULT_SYNC_METHOD,sync_method_options,
4848-
NULL,assign_xlog_sync_method,NULL
4846+
&wal_sync_method,
4847+
DEFAULT_WAL_SYNC_METHOD,wal_sync_method_options,
4848+
NULL,assign_wal_sync_method,NULL
48494849
},
48504850

48514851
{

‎src/include/access/xlog.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919

2020

2121
/* Sync methods */
22-
#defineSYNC_METHOD_FSYNC0
23-
#defineSYNC_METHOD_FDATASYNC1
24-
#defineSYNC_METHOD_OPEN2/* for O_SYNC */
25-
#defineSYNC_METHOD_FSYNC_WRITETHROUGH3
26-
#defineSYNC_METHOD_OPEN_DSYNC4/* for O_DSYNC */
27-
externPGDLLIMPORTintsync_method;
22+
typedefenumWalSyncMethod
23+
{
24+
WAL_SYNC_METHOD_FSYNC=0,
25+
WAL_SYNC_METHOD_FDATASYNC,
26+
WAL_SYNC_METHOD_OPEN,/* for O_SYNC */
27+
WAL_SYNC_METHOD_FSYNC_WRITETHROUGH,
28+
WAL_SYNC_METHOD_OPEN_DSYNC/* for O_DSYNC */
29+
}WalSyncMethod;
30+
externPGDLLIMPORTintwal_sync_method;
2831

2932
externPGDLLIMPORTXLogRecPtrProcLastRecPtr;
3033
externPGDLLIMPORTXLogRecPtrXactLastRecEnd;

‎src/include/access/xlogdefs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ typedef uint16 RepOriginId;
7171
*
7272
* Note that we define our own O_DSYNC on Windows, but not O_SYNC.
7373
*/
74-
#if defined(PLATFORM_DEFAULT_SYNC_METHOD)
75-
#defineDEFAULT_SYNC_METHODPLATFORM_DEFAULT_SYNC_METHOD
74+
#if defined(PLATFORM_DEFAULT_WAL_SYNC_METHOD)
75+
#defineDEFAULT_WAL_SYNC_METHODPLATFORM_DEFAULT_WAL_SYNC_METHOD
7676
#elif defined(O_DSYNC)&& (!defined(O_SYNC)||O_DSYNC!=O_SYNC)
77-
#defineDEFAULT_SYNC_METHODSYNC_METHOD_OPEN_DSYNC
77+
#defineDEFAULT_WAL_SYNC_METHODWAL_SYNC_METHOD_OPEN_DSYNC
7878
#else
79-
#defineDEFAULT_SYNC_METHODSYNC_METHOD_FDATASYNC
79+
#defineDEFAULT_WAL_SYNC_METHODWAL_SYNC_METHOD_FDATASYNC
8080
#endif
8181

8282
#endif/* XLOG_DEFS_H */

‎src/include/port/freebsd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
* would prefer open_datasync on FreeBSD 13+, but that is not a good choice on
66
* many systems.
77
*/
8-
#definePLATFORM_DEFAULT_SYNC_METHODSYNC_METHOD_FDATASYNC
8+
#definePLATFORM_DEFAULT_WAL_SYNC_METHODWAL_SYNC_METHOD_FDATASYNC

‎src/include/port/linux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
* perform better and (b) causes outright failures on ext4 data=journal
2020
* filesystems, because those don't support O_DIRECT.
2121
*/
22-
#definePLATFORM_DEFAULT_SYNC_METHODSYNC_METHOD_FDATASYNC
22+
#definePLATFORM_DEFAULT_WAL_SYNC_METHODWAL_SYNC_METHOD_FDATASYNC

‎src/include/utils/guc_hooks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,6 @@ extern bool check_wal_consistency_checking(char **newval, void **extra,
159159
GucSourcesource);
160160
externvoidassign_wal_consistency_checking(constchar*newval,void*extra);
161161
externboolcheck_wal_segment_size(int*newval,void**extra,GucSourcesource);
162-
externvoidassign_xlog_sync_method(intnew_sync_method,void*extra);
162+
externvoidassign_wal_sync_method(intnew_wal_sync_method,void*extra);
163163

164164
#endif/* GUC_HOOKS_H */

‎src/tools/pgindent/typedefs.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,6 +3016,7 @@ WalSnd
30163016
WalSndCtlData
30173017
WalSndSendDataCallback
30183018
WalSndState
3019+
WalSyncMethod
30193020
WalTimeSample
30203021
WalUsage
30213022
WalWriteMethod

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp