diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-08-13 20:10:54 +0000 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-08-13 20:10:54 +0000 |
commit | debcec7dc31a992703911a9953e299c8d730c778 (patch) | |
tree | dad0d10ec39eafe0cc254c17e36eb82ec822cdac /src/backend/utils/cache/inval.c | |
parent | 3f9479ef3fdf49fc22088be5268fa536cf5d4efd (diff) |
Include the backend ID in the relpath of temporary relations.
This allows us to reliably remove all leftover temporary relation
files on cluster startup without reference to system catalogs or WAL;
therefore, we no longer include temporary relations in XLOG_XACT_COMMIT
and XLOG_XACT_ABORT WAL records.
Since these changes require including a backend ID in each
SharedInvalSmgrMsg, the size of the SharedInvalidationMessage.id
field has been reduced from two bytes to one, and the maximum number
of connections has been reduced from INT_MAX / 4 to 2^23-1. It would
be possible to remove these restrictions by increasing the size of
SharedInvalidationMessage by 4 bytes, but right now that doesn't seem
like a good trade-off.
Review by Jaime Casanova and Tom Lane.
Diffstat (limited to 'src/backend/utils/cache/inval.c')
-rw-r--r-- | src/backend/utils/cache/inval.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 7a67f4a85e8..14904839222 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -80,7 +80,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.98 2010/02/26 02:01:11 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.99 2010/08/13 20:10:52 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -319,7 +319,8 @@ AddCatcacheInvalidationMessage(InvalidationListHeader *hdr, { SharedInvalidationMessage msg; - msg.cc.id = (int16) id; + Assert(id < CHAR_MAX); + msg.cc.id = (int8) id; msg.cc.tuplePtr = *tuplePtr; msg.cc.dbId = dbId; msg.cc.hashValue = hashValue; @@ -513,7 +514,10 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg) * We could have smgr entries for relations of other databases, so no * short-circuit test is possible here. */ - smgrclosenode(msg->sm.rnode); + RelFileNodeBackend rnode; + rnode.node = msg->sm.rnode; + rnode.backend = (msg->sm.backend_hi << 16) | (int) msg->sm.backend_lo; + smgrclosenode(rnode); } else if (msg->id == SHAREDINVALRELMAP_ID) { @@ -1163,14 +1167,20 @@ CacheInvalidateRelcacheByRelid(Oid relid) * in commit/abort WAL entries. Instead, calls to CacheInvalidateSmgr() * should happen in low-level smgr.c routines, which are executed while * replaying WAL as well as when creating it. + * + * Note: In order to avoid bloating SharedInvalidationMessage, we store only + * three bytes of the backend ID using what would otherwise be padding space. + * Thus, the maximum possible backend ID is 2^23-1. */ void -CacheInvalidateSmgr(RelFileNode rnode) +CacheInvalidateSmgr(RelFileNodeBackend rnode) { SharedInvalidationMessage msg; msg.sm.id = SHAREDINVALSMGR_ID; - msg.sm.rnode = rnode; + msg.sm.backend_hi = rnode.backend >> 16; + msg.sm.backend_lo = rnode.backend & 0xffff; + msg.sm.rnode = rnode.node; SendSharedInvalidMessages(&msg, 1); } |