/* * Initialize CommitTs at system startup (postmaster start or standalone * backend) */ void CommitTsShmemInit(void) { bool found; CommitTsCtl->PagePrecedes = CommitTsPagePrecedes; SimpleLruInit(CommitTsCtl, "commit_timestamp", CommitTsShmemBuffers(), 0, CommitTsControlLock, "pg_commit_ts", LWTRANCHE_COMMITTS_BUFFERS); commitTsShared = ShmemInitStruct("CommitTs shared", sizeof(CommitTimestampShared), &found); if (!IsUnderPostmaster) { Assert(!found); commitTsShared->xidLastCommit = InvalidTransactionId; TIMESTAMP_NOBEGIN(commitTsShared->dataLastCommit.time); commitTsShared->dataLastCommit.nodeid = InvalidRepOriginId; commitTsShared->commitTsActive = false; } else Assert(found); }
/* * Compute number of LWLocks to allocate in the main array. */ static int NumLWLocks(void) { int numLocks; /* * Possibly this logic should be spread out among the affected modules, * the same way that shmem space estimation is done. But for now, there * are few enough users of LWLocks that we can get away with just keeping * the knowledge here. */ /* Predefined LWLocks */ numLocks = NUM_FIXED_LWLOCKS; /* bufmgr.c needs two for each shared buffer */ numLocks += 2 * NBuffers; /* proc.c needs one for each backend or auxiliary process */ numLocks += MaxBackends + NUM_AUXILIARY_PROCS; /* clog.c needs one per CLOG buffer */ numLocks += CLOGShmemBuffers(); /* commit_ts.c needs one per CommitTs buffer */ numLocks += CommitTsShmemBuffers(); /* subtrans.c needs one per SubTrans buffer */ numLocks += NUM_SUBTRANS_BUFFERS; /* multixact.c needs two SLRU areas */ numLocks += NUM_MXACTOFFSET_BUFFERS + NUM_MXACTMEMBER_BUFFERS; /* async.c needs one per Async buffer */ numLocks += NUM_ASYNC_BUFFERS; /* predicate.c needs one per old serializable xid buffer */ numLocks += NUM_OLDSERXID_BUFFERS; /* slot.c needs one for each slot */ numLocks += max_replication_slots; /* * Add any requested by loadable modules; for backwards-compatibility * reasons, allocate at least NUM_USER_DEFINED_LWLOCKS of them even if * there are no explicit requests. */ lock_addin_request_allowed = false; numLocks += Max(lock_addin_request, NUM_USER_DEFINED_LWLOCKS); return numLocks; }
/* * Shared memory sizing for CommitTs */ Size CommitTsShmemSize(void) { return SimpleLruShmemSize(CommitTsShmemBuffers(), 0) + sizeof(CommitTimestampShared); }