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

Commit9261557

Browse files
committed
Revert "Use "transient" files for blind writes"
This reverts commit54d9e8c, whichcaused a failure on the buildfarm. Not a good thing to have just beforea beta release.
1 parent54d9e8c commit9261557

File tree

6 files changed

+28
-119
lines changed

6 files changed

+28
-119
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,10 +1834,7 @@ BufferGetTag(Buffer buffer, RelFileNode *rnode, ForkNumber *forknum,
18341834
* written.)
18351835
*
18361836
* If the caller has an smgr reference for the buffer's relation, pass it
1837-
* as the second parameter. If not, pass NULL. In the latter case, the
1838-
* relation will be marked as "transient" so that the corresponding
1839-
* kernel-level file descriptors are closed when the current transaction ends,
1840-
* if any.
1837+
* as the second parameter. If not, pass NULL.
18411838
*/
18421839
staticvoid
18431840
FlushBuffer(volatileBufferDesc*buf,SMgrRelationreln)
@@ -1859,12 +1856,9 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln)
18591856
errcontext.previous=error_context_stack;
18601857
error_context_stack=&errcontext;
18611858

1862-
/* Find smgr relation for buffer, and mark it as transient */
1859+
/* Find smgr relation for buffer */
18631860
if (reln==NULL)
1864-
{
18651861
reln=smgropen(buf->tag.rnode,InvalidBackendId);
1866-
smgrsettransient(reln);
1867-
}
18681862

18691863
TRACE_POSTGRESQL_BUFFER_FLUSH_START(buf->tag.forkNum,
18701864
buf->tag.blockNum,

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

Lines changed: 26 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,12 @@ static intmax_safe_fds = 32;/* default if not changed */
125125
/* these are the assigned bits in fdstate below: */
126126
#defineFD_TEMPORARY(1 << 0)/* T = delete when closed */
127127
#defineFD_XACT_TEMPORARY(1 << 1)/* T = delete at eoXact */
128-
#defineFD_XACT_TRANSIENT(1 << 2)/* T = close (not delete) at aoXact,
129-
* but keep VFD */
130128

131-
/* Flag to tell whether there are files to close/delete at end of transaction */
132-
staticboolhave_pending_fd_cleanup= false;
129+
/*
130+
* Flag to tell whether it's worth scanning VfdCache looking for temp files to
131+
* close
132+
*/
133+
staticboolhave_xact_temporary_files= false;
133134

134135
typedefstructvfd
135136
{
@@ -952,7 +953,7 @@ OpenTemporaryFile(bool interXact)
952953
VfdCache[file].resowner=CurrentResourceOwner;
953954

954955
/* ensure cleanup happens at eoxact */
955-
have_pending_fd_cleanup= true;
956+
have_xact_temporary_files= true;
956957
}
957958

958959
returnfile;
@@ -1025,45 +1026,6 @@ OpenTemporaryFileInTablespace(Oid tblspcOid, bool rejectError)
10251026
returnfile;
10261027
}
10271028

1028-
/*
1029-
* Set the transient flag on a file
1030-
*
1031-
* This flag tells CleanupTempFiles to close the kernel-level file descriptor
1032-
* (but not the VFD itself) at end of transaction.
1033-
*/
1034-
void
1035-
FileSetTransient(Filefile)
1036-
{
1037-
Vfd*vfdP;
1038-
1039-
Assert(FileIsValid(file));
1040-
1041-
vfdP=&VfdCache[file];
1042-
vfdP->fdstate |=FD_XACT_TRANSIENT;
1043-
1044-
have_pending_fd_cleanup= true;
1045-
}
1046-
1047-
/*
1048-
* Close a file at the kernel level, but keep the VFD open
1049-
*/
1050-
staticvoid
1051-
FileKernelClose(Filefile)
1052-
{
1053-
Vfd*vfdP;
1054-
1055-
Assert(FileIsValid(file));
1056-
1057-
vfdP=&VfdCache[file];
1058-
1059-
if (!FileIsNotOpen(file))
1060-
{
1061-
if (close(vfdP->fd))
1062-
elog(ERROR,"could not close file \"%s\": %m",vfdP->fileName);
1063-
vfdP->fd=VFD_CLOSED;
1064-
}
1065-
}
1066-
10671029
/*
10681030
* close a file when done with it
10691031
*/
@@ -1816,9 +1778,8 @@ AtEOSubXact_Files(bool isCommit, SubTransactionId mySubid,
18161778
* particularly care which). All still-open per-transaction temporary file
18171779
* VFDs are closed, which also causes the underlying files to be deleted
18181780
* (although they should've been closed already by the ResourceOwner
1819-
* cleanup). Transient files have their kernel file descriptors closed.
1820-
* Furthermore, all "allocated" stdio files are closed. We also forget any
1821-
* transaction-local temp tablespace list.
1781+
* cleanup). Furthermore, all "allocated" stdio files are closed. We also
1782+
* forget any transaction-local temp tablespace list.
18221783
*/
18231784
void
18241785
AtEOXact_Files(void)
@@ -1841,10 +1802,7 @@ AtProcExit_Files(int code, Datum arg)
18411802
}
18421803

18431804
/*
1844-
* General cleanup routine for fd.c.
1845-
*
1846-
* Temporary files are closed, and their underlying files deleted.
1847-
* Transient files are closed.
1805+
* Close temporary files and delete their underlying files.
18481806
*
18491807
* isProcExit: if true, this is being called as the backend process is
18501808
* exiting. If that's the case, we should remove all temporary files; if
@@ -1861,49 +1819,35 @@ CleanupTempFiles(bool isProcExit)
18611819
* Careful here: at proc_exit we need extra cleanup, not just
18621820
* xact_temporary files.
18631821
*/
1864-
if (isProcExit||have_pending_fd_cleanup)
1822+
if (isProcExit||have_xact_temporary_files)
18651823
{
18661824
Assert(FileIsNotOpen(0));/* Make sure ring not corrupted */
18671825
for (i=1;i<SizeVfdCache;i++)
18681826
{
18691827
unsigned shortfdstate=VfdCache[i].fdstate;
18701828

1871-
if (VfdCache[i].fileName!=NULL)
1829+
if ((fdstate&FD_TEMPORARY)&&VfdCache[i].fileName!=NULL)
18721830
{
1873-
if (fdstate&FD_TEMPORARY)
1874-
{
1875-
/*
1876-
* If we're in the process of exiting a backend process, close
1877-
* all temporary files. Otherwise, only close temporary files
1878-
* local to the current transaction. They should be closed by
1879-
* the ResourceOwner mechanism already, so this is just a
1880-
* debugging cross-check.
1881-
*/
1882-
if (isProcExit)
1883-
FileClose(i);
1884-
elseif (fdstate&FD_XACT_TEMPORARY)
1885-
{
1886-
elog(WARNING,
1887-
"temporary file %s not closed at end-of-transaction",
1888-
VfdCache[i].fileName);
1889-
FileClose(i);
1890-
}
1891-
}
1892-
elseif (fdstate&FD_XACT_TRANSIENT)
1831+
/*
1832+
* If we're in the process of exiting a backend process, close
1833+
* all temporary files. Otherwise, only close temporary files
1834+
* local to the current transaction. They should be closed by
1835+
* the ResourceOwner mechanism already, so this is just a
1836+
* debugging cross-check.
1837+
*/
1838+
if (isProcExit)
1839+
FileClose(i);
1840+
elseif (fdstate&FD_XACT_TEMPORARY)
18931841
{
1894-
/*
1895-
* Close the kernel file descriptor, but also remove the
1896-
* flag from the VFD. This is to ensure that if the VFD is
1897-
* reused in the future for non-transient access, we don't
1898-
* close it inappropriately then.
1899-
*/
1900-
FileKernelClose(i);
1901-
VfdCache[i].fdstate &= ~FD_XACT_TRANSIENT;
1842+
elog(WARNING,
1843+
"temporary file %s not closed at end-of-transaction",
1844+
VfdCache[i].fileName);
1845+
FileClose(i);
19021846
}
19031847
}
19041848
}
19051849

1906-
have_pending_fd_cleanup= false;
1850+
have_xact_temporary_files= false;
19071851
}
19081852

19091853
/* Clean up "allocated" stdio files and dirs. */

‎src/backend/storage/smgr/md.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
288288

289289
pfree(path);
290290

291-
if (reln->smgr_transient)
292-
FileSetTransient(fd);
293-
294291
reln->md_fd[forkNum]=_fdvec_alloc();
295292

296293
reln->md_fd[forkNum]->mdfd_vfd=fd;
@@ -545,9 +542,6 @@ mdopen(SMgrRelation reln, ForkNumber forknum, ExtensionBehavior behavior)
545542

546543
pfree(path);
547544

548-
if (reln->smgr_transient)
549-
FileSetTransient(fd);
550-
551545
reln->md_fd[forknum]=mdfd=_fdvec_alloc();
552546

553547
mdfd->mdfd_vfd=fd;
@@ -1562,9 +1556,6 @@ _mdfd_openseg(SMgrRelation reln, ForkNumber forknum, BlockNumber segno,
15621556
if (fd<0)
15631557
returnNULL;
15641558

1565-
if (reln->smgr_transient)
1566-
FileSetTransient(fd);
1567-
15681559
/* allocate an mdfdvec entry for it */
15691560
v=_fdvec_alloc();
15701561

‎src/backend/storage/smgr/smgr.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -165,33 +165,16 @@ smgropen(RelFileNode rnode, BackendId backend)
165165
reln->smgr_targblock=InvalidBlockNumber;
166166
reln->smgr_fsm_nblocks=InvalidBlockNumber;
167167
reln->smgr_vm_nblocks=InvalidBlockNumber;
168-
reln->smgr_transient= false;
169168
reln->smgr_which=0;/* we only have md.c at present */
170169

171170
/* mark it not open */
172171
for (forknum=0;forknum <=MAX_FORKNUM;forknum++)
173172
reln->md_fd[forknum]=NULL;
174173
}
175-
else
176-
/* if it was transient before, it no longer is */
177-
reln->smgr_transient= false;
178174

179175
returnreln;
180176
}
181177

182-
/*
183-
* smgrsettransient() -- mark an SMgrRelation object as transaction-bound
184-
*
185-
* The main effect of this is that all opened files are marked to be
186-
* kernel-level closed (but not necessarily VFD-closed) when the current
187-
* transaction ends.
188-
*/
189-
void
190-
smgrsettransient(SMgrRelationreln)
191-
{
192-
reln->smgr_transient= true;
193-
}
194-
195178
/*
196179
* smgrsetowner() -- Establish a long-lived reference to an SMgrRelation object
197180
*

‎src/include/storage/fd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ extern intmax_files_per_process;
6161
/* Operations on virtual Files --- equivalent to Unix kernel file ops */
6262
externFilePathNameOpenFile(FileNamefileName,intfileFlags,intfileMode);
6363
externFileOpenTemporaryFile(boolinterXact);
64-
externvoidFileSetTransient(Filefile);
6564
externvoidFileClose(Filefile);
6665
externintFilePrefetch(Filefile,off_toffset,intamount);
6766
externintFileRead(Filefile,char*buffer,intamount);

‎src/include/storage/smgr.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ typedef struct SMgrRelationData
6262
* submodules.Do not touch them from elsewhere.
6363
*/
6464
intsmgr_which;/* storage manager selector */
65-
boolsmgr_transient;/* T if files are to be closed at EOXact */
6665

6766
/* for md.c; NULL for forks that are not open */
6867
struct_MdfdVec*md_fd[MAX_FORKNUM+1];
@@ -75,7 +74,6 @@ typedef SMgrRelationData *SMgrRelation;
7574

7675
externvoidsmgrinit(void);
7776
externSMgrRelationsmgropen(RelFileNodernode,BackendIdbackend);
78-
externvoidsmgrsettransient(SMgrRelationreln);
7977
externboolsmgrexists(SMgrRelationreln,ForkNumberforknum);
8078
externvoidsmgrsetowner(SMgrRelation*owner,SMgrRelationreln);
8179
externvoidsmgrclose(SMgrRelationreln);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp