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

Commitef20c69

Browse files
committed
Back-patch change to not keep WAL segments just for UNDO information.
1 parent92e0535 commitef20c69

File tree

1 file changed

+38
-5
lines changed
  • src/backend/access/transam

1 file changed

+38
-5
lines changed

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

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.65 2001/04/05 16:55:21 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.65.2.1 2001/06/06 17:18:56 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1068,9 +1068,15 @@ XLogWrite(XLogwrtRqst WriteRqst)
10681068

10691069
/* OK to write the page */
10701070
from=XLogCtl->pages+Write->curridx*BLCKSZ;
1071+
errno=0;
10711072
if (write(openLogFile,from,BLCKSZ)!=BLCKSZ)
1073+
{
1074+
/* if write didn't set errno, assume problem is no disk space */
1075+
if (errno==0)
1076+
errno=ENOSPC;
10721077
elog(STOP,"write(logfile %u seg %u off %u) failed: %m",
10731078
openLogId,openLogSeg,openLogOff);
1079+
}
10741080
openLogOff+=BLCKSZ;
10751081

10761082
/*
@@ -1323,6 +1329,7 @@ XLogFileInit(uint32 log, uint32 seg,
13231329
MemSet(zbuffer,0,sizeof(zbuffer));
13241330
for (nbytes=0;nbytes<XLogSegSize;nbytes+=sizeof(zbuffer))
13251331
{
1332+
errno=0;
13261333
if ((int)write(fd,zbuffer,sizeof(zbuffer))!= (int)sizeof(zbuffer))
13271334
{
13281335
intsave_errno=errno;
@@ -1332,7 +1339,8 @@ XLogFileInit(uint32 log, uint32 seg,
13321339
* space
13331340
*/
13341341
unlink(tmppath);
1335-
errno=save_errno;
1342+
/* if write didn't set errno, assume problem is no disk space */
1343+
errno=save_errno ?save_errno :ENOSPC;
13361344

13371345
elog(STOP,"ZeroFill(%s) failed: %m",tmppath);
13381346
}
@@ -1987,8 +1995,14 @@ WriteControlFile(void)
19871995
elog(STOP,"WriteControlFile failed to create control file (%s): %m",
19881996
ControlFilePath);
19891997

1998+
errno=0;
19901999
if (write(fd,buffer,BLCKSZ)!=BLCKSZ)
2000+
{
2001+
/* if write didn't set errno, assume problem is no disk space */
2002+
if (errno==0)
2003+
errno=ENOSPC;
19912004
elog(STOP,"WriteControlFile failed to write control file: %m");
2005+
}
19922006

19932007
if (pg_fsync(fd)!=0)
19942008
elog(STOP,"WriteControlFile failed to fsync control file: %m");
@@ -2085,8 +2099,14 @@ UpdateControlFile(void)
20852099
if (fd<0)
20862100
elog(STOP,"open(\"%s\") failed: %m",ControlFilePath);
20872101

2102+
errno=0;
20882103
if (write(fd,ControlFile,sizeof(ControlFileData))!=sizeof(ControlFileData))
2104+
{
2105+
/* if write didn't set errno, assume problem is no disk space */
2106+
if (errno==0)
2107+
errno=ENOSPC;
20892108
elog(STOP,"write(cntlfile) failed: %m");
2109+
}
20902110

20912111
if (pg_fsync(fd)!=0)
20922112
elog(STOP,"fsync(cntlfile) failed: %m");
@@ -2224,8 +2244,14 @@ BootStrapXLOG(void)
22242244
use_existent= false;
22252245
openLogFile=XLogFileInit(0,0,&use_existent, false);
22262246

2247+
errno=0;
22272248
if (write(openLogFile,buffer,BLCKSZ)!=BLCKSZ)
2249+
{
2250+
/* if write didn't set errno, assume problem is no disk space */
2251+
if (errno==0)
2252+
errno=ENOSPC;
22282253
elog(STOP,"BootStrapXLOG failed to write logfile: %m");
2254+
}
22292255

22302256
if (pg_fsync(openLogFile)!=0)
22312257
elog(STOP,"BootStrapXLOG failed to fsync logfile: %m");
@@ -2816,15 +2842,22 @@ CreateCheckPoint(bool shutdown)
28162842
elog(STOP,"XLog concurrent activity while data base is shutting down");
28172843

28182844
/*
2819-
* Remember location of prior checkpoint's earliest info. Oldest item
2820-
* is redo or undo, whichever is older; but watch out for case that
2821-
* undo = 0.
2845+
* Select point at which we can truncate the log, which we base on the
2846+
* prior checkpoint's earliest info.
2847+
*
2848+
* With UNDO support: oldest item is redo or undo, whichever is older;
2849+
* but watch out for case that undo = 0.
2850+
*
2851+
* Without UNDO support: just use the redo pointer. This allows xlog
2852+
* space to be freed much faster when there are long-running transactions.
28222853
*/
2854+
#ifdefNOT_USED
28232855
if (ControlFile->checkPointCopy.undo.xrecoff!=0&&
28242856
XLByteLT(ControlFile->checkPointCopy.undo,
28252857
ControlFile->checkPointCopy.redo))
28262858
XLByteToSeg(ControlFile->checkPointCopy.undo,_logId,_logSeg);
28272859
else
2860+
#endif
28282861
XLByteToSeg(ControlFile->checkPointCopy.redo,_logId,_logSeg);
28292862

28302863
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp