summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-09-06 20:00:15 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-09-06 20:00:15 +0000
commit60c3ccffbe9c8abf6ea88f193e1f76288dc60540 (patch)
tree12a5fcb62d019ee3dc54540f25a8d108b6cf2d5f
parent958e45a84b02691017deaade46854bf90083d0a4 (diff)
Comment out FileUnlink of excess segments during mdtruncate().
This is unsafe in 6.5 because other backends may be able to access the file before noticing the shared cache inval message that tells 'em to re-open the file. We have fixed this for 6.6 but the changes seem too risky to back-patch for 6.5.2. Also, back-patch Tatsuo's change to prevent creation of files during mdopen().
-rw-r--r--src/backend/storage/smgr/md.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index ce3d4c512a4..f696d9c6cae 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.46.2.1 1999/09/02 04:07:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.46.2.2 1999/09/06 20:00:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -284,13 +284,23 @@ mdopen(Relation reln)
fd = FileNameOpenFile(path, O_RDWR | O_BINARY, 0600);
#endif
- /* this should only happen during bootstrap processing */
if (fd < 0)
+ {
+ /* in bootstrap mode, accept mdopen as substitute for mdcreate */
+ if (IsBootstrapProcessingMode())
+ {
#ifndef __CYGWIN32__
- fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL, 0600);
+ fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL, 0600);
#else
- fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600);
+ fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600);
#endif
+ }
+ if (fd < 0)
+ {
+ elog(ERROR, "mdopen: couldn't open %s: %m", path);
+ return -1;
+ }
+ }
vfd = _fdvec_alloc();
if (vfd < 0)
@@ -755,7 +765,16 @@ mdtruncate(Relation reln, int nblocks)
* a big file...
*/
FileTruncate(v->mdfd_vfd, 0);
+ /* In 6.5, it is not safe to unlink apparently-unused segments,
+ * because another backend could store tuples in one of those
+ * segments before it notices the shared-cache-invalidation
+ * message that would warn it to re-open the file. So, don't
+ * unlink 'em, just truncate 'em. This is fixed properly for 6.6
+ * but back-patching the changes was judged too risky.
+ */
+#if 0
FileUnlink(v->mdfd_vfd);
+#endif
v = v->mdfd_chain;
Assert(ov != &Md_fdvec[fd]); /* we never drop the 1st segment */
pfree(ov);