pgsql: When truncating a relation in-place (eg during VACUUM), do not - Mailing list pgsql-committers

From tgl@postgresql.org (Tom Lane)
Subject pgsql: When truncating a relation in-place (eg during VACUUM), do not
Date
Msg-id 20061120010756.C56329FA333@postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
When truncating a relation in-place (eg during VACUUM), do not try to unlink
any no-longer-needed segments; just truncate them to zero bytes and leave
the files in place for possible future re-use.  This avoids problems when
the segments are re-used due to relation growth shortly after truncation.
Before, the bgwriter, and possibly other backends, could still be holding
open file references to the old segment files, and would write dirty blocks
into those files where they'd disappear from the view of other processes.

Back-patch as far as 8.0.  I believe the 7.x branches are not vulnerable,
because they had no bgwriter, and "blind" writes by other backends would
always be done via freshly-opened file references.

Modified Files:
--------------
    pgsql/src/backend/storage/smgr:
        md.c (r1.122 -> r1.123)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/smgr/md.c.diff?r1=1.122&r2=1.123)

pgsql-committers by date:

Previous
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Repair problems with hash indexes that span multiple segments:
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: When truncating a relation in-place (eg during VACUUM), do not