Skip site navigation (1) Skip section navigation (2)

pgsql: Fix up rickety handling of relation-truncation interlocks.

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix up rickety handling of relation-truncation interlocks.
Date: 2010-02-09 21:43:30
Message-ID: (view raw or whole thread)
Lists: pgsql-committers
Log Message:
Fix up rickety handling of relation-truncation interlocks.

Move rd_targblock, rd_fsm_nblocks, and rd_vm_nblocks from relcache to the smgr
relation entries, so that they will get reset to InvalidBlockNumber whenever
an smgr-level flush happens.  Because we now send smgr invalidation messages
immediately (not at end of transaction) when a relation truncation occurs,
this ensures that other backends will reset their values before they next
access the relation.  We no longer need the unreliable assumption that a
VACUUM that's doing a truncation will hold its AccessExclusive lock until
commit --- in fact, we can intentionally release that lock as soon as we've
completed the truncation.  This patch therefore reverts (most of) Alvaro's
patch of 2009-11-10, as well as my marginal hacking on it yesterday.  We can
also get rid of assorted no-longer-needed relcache flushes, which are far more
expensive than an smgr flush because they kill a lot more state.

In passing this patch fixes smgr_redo's failure to perform visibility-map
truncation, and cleans up some rather dubious assumptions in freespace.c and
visibilitymap.c about when rd_fsm_nblocks and rd_vm_nblocks can be out of

Modified Files:
        hio.c (r1.77 -> r1.78)
        visibilitymap.c (r1.7 -> r1.8)
        xlogutils.c (r1.69 -> r1.70)
        storage.c (r1.9 -> r1.10)
        cluster.c (r1.199 -> r1.200)
        sequence.c (r1.164 -> r1.165)
        vacuum.c (r1.406 -> r1.407)
        vacuumlazy.c (r1.130 -> r1.131)
        execMain.c (r1.345 -> r1.346)
        freespace.c (r1.75 -> r1.76)
        smgr.c (r1.119 -> r1.120)
        relcache.c (r1.304 -> r1.305)
        vacuum.h (r1.88 -> r1.89)
        smgr.h (r1.69 -> r1.70)
        rel.h (r1.122 -> r1.123)

pgsql-committers by date

Next:From: Tom LaneDate: 2010-02-10 03:38:35
Subject: pgsql: Improve planner's choices about when to use hashing vs sorting
Previous:From: Heikki LinnakangasDate: 2010-02-09 20:31:35
Subject: pgsql: Fix bug in GIN WAL redo cleanup function: don't free fake

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group