summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2016-09-08 23:51:09 +0000
committerAndres Freund2016-09-08 23:52:13 +0000
commit08fdfe7a8a2f7516172a0d89b678a1b6c21c5afb (patch)
treece9fdb8977d40f67a097b7611b3322889be5a70f
parent0499bd26915f2b4119560142855db3df59d1b8a4 (diff)
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 1a5c450f3024ac5, 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: <[email protected]> Backpatch: all supported releases
-rw-r--r--src/backend/storage/smgr/md.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index f9658b37447..5436241677e 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -868,6 +868,7 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks)
v = v->mdfd_chain;
Assert(ov != reln->md_fd[forknum]); /* we never drop the 1st
* segment */
+ FileClose(ov->mdfd_vfd);
pfree(ov);
}
else if (priorblocks + ((BlockNumber) RELSEG_SIZE) > nblocks)