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

Commit 8a2f5d2

Browse files
committed
Reduce unnecessary PANIC to ERROR, improve a couple of comments.
1 parent e7b498b commit 8a2f5d2

File tree

1 file changed

+11
-15
lines changed
  • src/backend/access/transam

1 file changed

+11
-15
lines changed

src/backend/access/transam/xlog.c

+11-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, 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.309 2008/05/14 14:02:57 mha Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.310 2008/05/16 19:15:05 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -67,6 +67,7 @@ bool XLogArchiveMode = false;
6767
char *XLogArchiveCommand = NULL;
6868
bool fullPageWrites = true;
6969
bool log_checkpoints = false;
70+
int sync_method = DEFAULT_SYNC_METHOD;
7071

7172
#ifdef WAL_DEBUG
7273
bool XLOG_DEBUG = false;
@@ -88,8 +89,6 @@ bool XLOG_DEBUG = false;
8889
/*
8990
* GUC support
9091
*/
91-
int sync_method = DEFAULT_SYNC_METHOD;
92-
9392
const struct config_enum_entry sync_method_options[] = {
9493
{"fsync", SYNC_METHOD_FSYNC},
9594
#ifdef HAVE_FSYNC_WRITETHROUGH
@@ -1613,7 +1612,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible, bool xlog_switch)
16131612
* have no open file or the wrong one. However, we do not need to
16141613
* fsync more than one file.
16151614
*/
1616-
if (sync_method != SYNC_METHOD_OPEN && sync_method != SYNC_METHOD_OPEN_DSYNC)
1615+
if (sync_method != SYNC_METHOD_OPEN &&
1616+
sync_method != SYNC_METHOD_OPEN_DSYNC)
16171617
{
16181618
if (openLogFile >= 0 &&
16191619
!XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg))
@@ -6340,10 +6340,10 @@ get_sync_bit(int method)
63406340
switch (method)
63416341
{
63426342
/*
6343-
* Values for these sync options are defined even if they are not
6344-
* supported on the current platform. They are not included in
6345-
* the enum option array, and therefor will never be set if the
6346-
* platform doesn't support it.
6343+
* enum values for all sync options are defined even if they are not
6344+
* supported on the current platform. But if not, they are not
6345+
* included in the enum option array, and therefore will never be seen
6346+
* here.
63476347
*/
63486348
case SYNC_METHOD_FSYNC:
63496349
case SYNC_METHOD_FSYNC_WRITETHROUGH:
@@ -6358,12 +6358,8 @@ get_sync_bit(int method)
63586358
return OPEN_DATASYNC_FLAG;
63596359
#endif
63606360
default:
6361-
/*
6362-
* This "can never happen", since the available values in
6363-
* new_sync_method are controlled by the available enum
6364-
* options.
6365-
*/
6366-
elog(PANIC, "unrecognized wal_sync_method: %d", method);
6361+
/* can't happen (unless we are out of sync with option array) */
6362+
elog(ERROR, "unrecognized wal_sync_method: %d", method);
63676363
return 0; /* silence warning */
63686364
}
63696365
}
@@ -6392,7 +6388,7 @@ assign_xlog_sync_method(int new_sync_method, bool doit, GucSource source)
63926388
(errcode_for_file_access(),
63936389
errmsg("could not fsync log file %u, segment %u: %m",
63946390
openLogId, openLogSeg)));
6395-
if (get_sync_bit(sync_method) != get_sync_bit(new_sync_method))
6391+
if (get_sync_bit(sync_method) != get_sync_bit(new_sync_method))
63966392
XLogFileClose();
63976393
}
63986394
}

0 commit comments

Comments
 (0)