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

Commit8217370

Browse files
committed
Make XLogFileCopy() look the same as in 9.4.
XLogFileCopy() was changed heavily in commitde76884. However it waspartially reverted in commit7abc685 and most of those changes toXLogFileCopy() were no longer needed. Then commit7cbee7c removedthose unnecessary code, but XLogFileCopy() looked different in masterand 9.4 though the contents are almost the same.This patch makes XLogFileCopy() look the same in master and back-branches,which makes back-patching easier, per discussion on pgsql-hackers.Back-patch to 9.5.Discussion: 55760844.7090703@iki.fiMichael Paquier
1 parent7f32dbc commit8217370

File tree

1 file changed

+32
-28
lines changed
  • src/backend/access/transam

1 file changed

+32
-28
lines changed

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

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ static bool XLogCheckpointNeeded(XLogSegNo new_segno);
808808
staticvoidXLogWrite(XLogwrtRqstWriteRqst,boolflexible);
809809
staticboolInstallXLogFileSegment(XLogSegNo*segno,char*tmppath,
810810
boolfind_free,XLogSegNomax_segno,
811-
booluse_lock,intelevel);
811+
booluse_lock);
812812
staticintXLogFileRead(XLogSegNosegno,intemode,TimeLineIDtli,
813813
intsource,boolnotexistOk);
814814
staticintXLogFileReadAnyTLI(XLogSegNosegno,intemode,intsource);
@@ -3013,7 +3013,7 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
30133013
max_segno=logsegno+CheckPointSegments;
30143014
if (!InstallXLogFileSegment(&installed_segno,tmppath,
30153015
*use_existent,max_segno,
3016-
use_lock,LOG))
3016+
use_lock))
30173017
{
30183018
/*
30193019
* No need for any more future segments, or InstallXLogFileSegment()
@@ -3040,20 +3040,25 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
30403040
}
30413041

30423042
/*
3043-
*Copy aWAL segment filein pg_xlog directory.
3043+
*Create anew XLOG filesegment by copying a pre-existing one.
30443044
*
3045-
* srcfnamesource filename
3046-
* uptohow much of the source file to copy? (the rest is filled with
3047-
*zeros)
3048-
* segnoidentify segment to install.
3045+
* destsegno: identify segment to be created.
30493046
*
3050-
* The file is first copied with a temporary filename, and then installed as
3051-
* a newly-created segment.
3047+
* srcTLI, srclog, srcseg: identify segment to be copied (could be from
3048+
*a different timeline)
3049+
*
3050+
* upto: how much of the source file to copy (the rest is filled with
3051+
*zeros)
3052+
*
3053+
* Currently this is only used during recovery, and so there are no locking
3054+
* considerations. But we should be just as tense as XLogFileInit to avoid
3055+
* emplacing a bogus file.
30523056
*/
30533057
staticvoid
3054-
XLogFileCopy(char*srcfname,intupto,XLogSegNosegno)
3058+
XLogFileCopy(XLogSegNodestsegno,TimeLineIDsrcTLI,XLogSegNosrcsegno,
3059+
intupto)
30553060
{
3056-
charsrcpath[MAXPGPATH];
3061+
charpath[MAXPGPATH];
30573062
chartmppath[MAXPGPATH];
30583063
charbuffer[XLOG_BLCKSZ];
30593064
intsrcfd;
@@ -3063,12 +3068,12 @@ XLogFileCopy(char *srcfname, int upto, XLogSegNo segno)
30633068
/*
30643069
* Open the source file
30653070
*/
3066-
snprintf(srcpath,MAXPGPATH,XLOGDIR"/%s",srcfname);
3067-
srcfd=OpenTransientFile(srcpath,O_RDONLY |PG_BINARY,0);
3071+
XLogFilePath(path,srcTLI,srcsegno);
3072+
srcfd=OpenTransientFile(path,O_RDONLY |PG_BINARY,0);
30683073
if (srcfd<0)
30693074
ereport(ERROR,
30703075
(errcode_for_file_access(),
3071-
errmsg("could not open file \"%s\": %m",srcpath)));
3076+
errmsg("could not open file \"%s\": %m",path)));
30723077

30733078
/*
30743079
* Copy into a temp file name.
@@ -3112,11 +3117,11 @@ XLogFileCopy(char *srcfname, int upto, XLogSegNo segno)
31123117
ereport(ERROR,
31133118
(errcode_for_file_access(),
31143119
errmsg("could not read file \"%s\": %m",
3115-
srcpath)));
3120+
path)));
31163121
else
31173122
ereport(ERROR,
31183123
(errmsg("not enough data in file \"%s\"",
3119-
srcpath)));
3124+
path)));
31203125
}
31213126
}
31223127
errno=0;
@@ -3149,9 +3154,11 @@ XLogFileCopy(char *srcfname, int upto, XLogSegNo segno)
31493154

31503155
CloseTransientFile(srcfd);
31513156

3152-
/* install the new file */
3153-
(void)InstallXLogFileSegment(&segno,tmppath, false,
3154-
0, false,ERROR);
3157+
/*
3158+
* Now move the segment into place with its final name.
3159+
*/
3160+
if (!InstallXLogFileSegment(&destsegno,tmppath, false,0, false))
3161+
elog(ERROR,"InstallXLogFileSegment should not have failed");
31553162
}
31563163

31573164
/*
@@ -3178,16 +3185,14 @@ XLogFileCopy(char *srcfname, int upto, XLogSegNo segno)
31783185
* place. This should be TRUE except during bootstrap log creation. The
31793186
* caller must *not* hold the lock at call.
31803187
*
3181-
* elevel: log level used by this routine.
3182-
*
31833188
* Returns TRUE if the file was installed successfully. FALSE indicates that
31843189
* max_segno limit was exceeded, or an error occurred while renaming the
31853190
* file into place.
31863191
*/
31873192
staticbool
31883193
InstallXLogFileSegment(XLogSegNo*segno,char*tmppath,
31893194
boolfind_free,XLogSegNomax_segno,
3190-
booluse_lock,intelevel)
3195+
booluse_lock)
31913196
{
31923197
charpath[MAXPGPATH];
31933198
structstatstat_buf;
@@ -3232,7 +3237,7 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
32323237
{
32333238
if (use_lock)
32343239
LWLockRelease(ControlFileLock);
3235-
ereport(elevel,
3240+
ereport(LOG,
32363241
(errcode_for_file_access(),
32373242
errmsg("could not link file \"%s\" to \"%s\" (initialization of log file): %m",
32383243
tmppath,path)));
@@ -3244,7 +3249,7 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
32443249
{
32453250
if (use_lock)
32463251
LWLockRelease(ControlFileLock);
3247-
ereport(elevel,
3252+
ereport(LOG,
32483253
(errcode_for_file_access(),
32493254
errmsg("could not rename file \"%s\" to \"%s\" (initialization of log file): %m",
32503255
tmppath,path)));
@@ -3733,7 +3738,7 @@ RemoveXlogFile(const char *segname, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
37333738
if (endlogSegNo <=recycleSegNo&&
37343739
lstat(path,&statbuf)==0&&S_ISREG(statbuf.st_mode)&&
37353740
InstallXLogFileSegment(&endlogSegNo,path,
3736-
true,recycleSegNo, true,LOG))
3741+
true,recycleSegNo, true))
37373742
{
37383743
ereport(DEBUG2,
37393744
(errmsg("recycled transaction log file \"%s\"",
@@ -5212,16 +5217,15 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
52125217
*/
52135218
if (endLogSegNo==startLogSegNo)
52145219
{
5215-
XLogFileName(xlogfname,endTLI,endLogSegNo);
5216-
52175220
/*
52185221
* Make a copy of the file on the new timeline.
52195222
*
52205223
* Writing WAL isn't allowed yet, so there are no locking
52215224
* considerations. But we should be just as tense as XLogFileInit to
52225225
* avoid emplacing a bogus file.
52235226
*/
5224-
XLogFileCopy(xlogfname,endOfLog %XLOG_SEG_SIZE,endLogSegNo);
5227+
XLogFileCopy(endLogSegNo,endTLI,endLogSegNo,
5228+
endOfLog %XLOG_SEG_SIZE);
52255229
}
52265230
else
52275231
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp