pgsql-server: Restructure subtransaction handling to reduce resource - Mailing list pgsql-committers

From tgl@svr1.postgresql.org (Tom Lane)
Subject pgsql-server: Restructure subtransaction handling to reduce resource
Date
Msg-id 20040916165845.889AD329D9D@svr1.postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
Restructure subtransaction handling to reduce resource consumption,
as per recent discussions.  Invent SubTransactionIds that are managed like
CommandIds (ie, counter is reset at start of each top transaction), and
use these instead of TransactionIds to keep track of subtransaction status
in those modules that need it.  This means that a subtransaction does not
need an XID unless it actually inserts/modifies rows in the database.
Accordingly, don't assign it an XID nor take a lock on the XID until it
tries to do that.  This saves a lot of overhead for subtransactions that
are only used for error recovery (eg plpgsql exceptions).  Also, arrange
to release a subtransaction's XID lock as soon as the subtransaction
exits, in both the commit and abort cases.  This avoids holding many
unique locks after a long series of subtransactions.  The price is some
additional overhead in XactLockTableWait, but that seems acceptable.
Finally, restructure the state machine in xact.c to have a more orthogonal
set of states for subtransactions.

Modified Files:
--------------
    pgsql-server/src/backend/access/heap:
        heapam.c (r1.174 -> r1.175)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/access/heap/heapam.c.diff?r1=1.174&r2=1.175)
    pgsql-server/src/backend/access/transam:
        README (r1.1 -> r1.2)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/access/transam/README.diff?r1=1.1&r2=1.2)
        xact.c (r1.188 -> r1.189)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/access/transam/xact.c.diff?r1=1.188&r2=1.189)
        xlog.c (r1.169 -> r1.170)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/access/transam/xlog.c.diff?r1=1.169&r2=1.170)
    pgsql-server/src/backend/catalog:
        namespace.c (r1.70 -> r1.71)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/catalog/namespace.c.diff?r1=1.70&r2=1.71)
    pgsql-server/src/backend/commands:
        portalcmds.c (r1.35 -> r1.36)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/portalcmds.c.diff?r1=1.35&r2=1.36)
        sequence.c (r1.116 -> r1.117)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/sequence.c.diff?r1=1.116&r2=1.117)
        tablecmds.c (r1.131 -> r1.132)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/tablecmds.c.diff?r1=1.131&r2=1.132)
        user.c (r1.144 -> r1.145)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/user.c.diff?r1=1.144&r2=1.145)
    pgsql-server/src/backend/executor:
        spi.c (r1.127 -> r1.128)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/executor/spi.c.diff?r1=1.127&r2=1.128)
    pgsql-server/src/backend/libpq:
        be-fsstubs.c (r1.75 -> r1.76)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/libpq/be-fsstubs.c.diff?r1=1.75&r2=1.76)
    pgsql-server/src/backend/storage/buffer:
        freelist.c (r1.47 -> r1.48)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/storage/buffer/freelist.c.diff?r1=1.47&r2=1.48)
    pgsql-server/src/backend/storage/file:
        fd.c (r1.112 -> r1.113)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/storage/file/fd.c.diff?r1=1.112&r2=1.113)
    pgsql-server/src/backend/storage/large_object:
        inv_api.c (r1.106 -> r1.107)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/storage/large_object/inv_api.c.diff?r1=1.106&r2=1.107)
    pgsql-server/src/backend/storage/lmgr:
        lmgr.c (r1.69 -> r1.70)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/storage/lmgr/lmgr.c.diff?r1=1.69&r2=1.70)
    pgsql-server/src/backend/utils/adt:
        xid.c (r1.5 -> r1.6)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/adt/xid.c.diff?r1=1.5&r2=1.6)
    pgsql-server/src/backend/utils/cache:
        relcache.c (r1.210 -> r1.211)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/cache/relcache.c.diff?r1=1.210&r2=1.211)
    pgsql-server/src/backend/utils/mmgr:
        portalmem.c (r1.71 -> r1.72)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/mmgr/portalmem.c.diff?r1=1.71&r2=1.72)
    pgsql-server/src/include/access:
        xact.h (r1.72 -> r1.73)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/access/xact.h.diff?r1=1.72&r2=1.73)
    pgsql-server/src/include:
        c.h (r1.171 -> r1.172)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/c.h.diff?r1=1.171&r2=1.172)
    pgsql-server/src/include/catalog:
        namespace.h (r1.33 -> r1.34)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/catalog/namespace.h.diff?r1=1.33&r2=1.34)
    pgsql-server/src/include/commands:
        tablecmds.h (r1.19 -> r1.20)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/commands/tablecmds.h.diff?r1=1.19&r2=1.20)
        user.h (r1.24 -> r1.25)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/commands/user.h.diff?r1=1.24&r2=1.25)
    pgsql-server/src/include/executor:
        spi.h (r1.48 -> r1.49)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/executor/spi.h.diff?r1=1.48&r2=1.49)
        spi_priv.h (r1.20 -> r1.21)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/executor/spi_priv.h.diff?r1=1.20&r2=1.21)
    pgsql-server/src/include/libpq:
        be-fsstubs.h (r1.21 -> r1.22)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/libpq/be-fsstubs.h.diff?r1=1.21&r2=1.22)
    pgsql-server/src/include/storage:
        fd.h (r1.48 -> r1.49)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/storage/fd.h.diff?r1=1.48&r2=1.49)
        large_object.h (r1.29 -> r1.30)

(http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/storage/large_object.h.diff?r1=1.29&r2=1.30)
        lmgr.h (r1.43 -> r1.44)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/storage/lmgr.h.diff?r1=1.43&r2=1.44)
    pgsql-server/src/include/utils:
        portal.h (r1.52 -> r1.53)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/utils/portal.h.diff?r1=1.52&r2=1.53)
        rel.h (r1.79 -> r1.80)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/utils/rel.h.diff?r1=1.79&r2=1.80)
        relcache.h (r1.45 -> r1.46)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/include/utils/relcache.h.diff?r1=1.45&r2=1.46)
    pgsql-server/src/pl/plpgsql/src:
        pl_exec.c (r1.119 -> r1.120)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/plpgsql/src/pl_exec.c.diff?r1=1.119&r2=1.120)
        plpgsql.h (r1.55 -> r1.56)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/pl/plpgsql/src/plpgsql.h.diff?r1=1.55&r2=1.56)

pgsql-committers by date:

Previous
From: neilc@svr1.postgresql.org (Neil Conway)
Date:
Subject: pgsql-server: Minor doc tweak: mention that function names can be
Next
From: tgl@svr1.postgresql.org (Tom Lane)
Date:
Subject: pgsql-server: RecentXmin is too recent to use as the cutoff point for