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

Commit f680293

Browse files
committed
Fix mdtruncate() to close fd.c handle of deleted segments.
mdtruncate() forgot to FileClose() a segment's mdfd_vfd, when deleting it. That lead to a fd.c handle to a truncated file being kept open until backend exit. The issue appears to have been introduced way back in 1a5c450, before that the handle was closed inside FileUnlink(). The impact of this bug is limited - only VACUUM and ON COMMIT TRUNCATE for temporary tables, truncate files in place (i.e. TRUNCATE itself is not affected), and the relation has to be bigger than 1GB. The consequences of a leaked fd.c handle aren't severe either. Discussion: <20160908220748.oqh37ukwqqncbl3n@alap3.anarazel.de> Backpatch: all supported releases
1 parent e012e78 commit f680293

File tree

1 file changed

+1
-0
lines changed
  • src/backend/storage/smgr

1 file changed

+1
-0
lines changed

src/backend/storage/smgr/md.c

+1
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks)
976976
v = v->mdfd_chain;
977977
Assert(ov != reln->md_fd[forknum]); /* we never drop the 1st
978978
* segment */
979+
FileClose(ov->mdfd_vfd);
979980
pfree(ov);
980981
}
981982
else if (priorblocks + ((BlockNumber) RELSEG_SIZE) > nblocks)

0 commit comments

Comments
 (0)