mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
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.
This commit is contained in:
20
src/backend/utils/cache/inval.c
vendored
20
src/backend/utils/cache/inval.c
vendored
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user