Commit 7191ce8b authored by Robert Haas's avatar Robert Haas

Make all built-in lwlock tranche IDs fixed.

This makes the values more stable, which seems like a good thing for
anybody who needs to look at at them.

Alexander Korotkov and Amit Kapila
parent 1d0c3b3f
...@@ -457,7 +457,7 @@ CLOGShmemInit(void) ...@@ -457,7 +457,7 @@ CLOGShmemInit(void)
{ {
ClogCtl->PagePrecedes = CLOGPagePrecedes; ClogCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(ClogCtl, "clog", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE, SimpleLruInit(ClogCtl, "clog", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
CLogControlLock, "pg_clog"); CLogControlLock, "pg_clog", LWTRANCHE_CLOG_BUFFERS);
} }
/* /*
......
...@@ -485,7 +485,8 @@ CommitTsShmemInit(void) ...@@ -485,7 +485,8 @@ CommitTsShmemInit(void)
CommitTsCtl->PagePrecedes = CommitTsPagePrecedes; CommitTsCtl->PagePrecedes = CommitTsPagePrecedes;
SimpleLruInit(CommitTsCtl, "commit_timestamp", CommitTsShmemBuffers(), 0, SimpleLruInit(CommitTsCtl, "commit_timestamp", CommitTsShmemBuffers(), 0,
CommitTsControlLock, "pg_commit_ts"); CommitTsControlLock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFERS);
commitTsShared = ShmemInitStruct("CommitTs shared", commitTsShared = ShmemInitStruct("CommitTs shared",
sizeof(CommitTimestampShared), sizeof(CommitTimestampShared),
......
...@@ -1831,10 +1831,12 @@ MultiXactShmemInit(void) ...@@ -1831,10 +1831,12 @@ MultiXactShmemInit(void)
SimpleLruInit(MultiXactOffsetCtl, SimpleLruInit(MultiXactOffsetCtl,
"multixact_offset", NUM_MXACTOFFSET_BUFFERS, 0, "multixact_offset", NUM_MXACTOFFSET_BUFFERS, 0,
MultiXactOffsetControlLock, "pg_multixact/offsets"); MultiXactOffsetControlLock, "pg_multixact/offsets",
LWTRANCHE_MXACTOFFSET_BUFFERS);
SimpleLruInit(MultiXactMemberCtl, SimpleLruInit(MultiXactMemberCtl,
"multixact_member", NUM_MXACTMEMBER_BUFFERS, 0, "multixact_member", NUM_MXACTMEMBER_BUFFERS, 0,
MultiXactMemberControlLock, "pg_multixact/members"); MultiXactMemberControlLock, "pg_multixact/members",
LWTRANCHE_MXACTMEMBER_BUFFERS);
/* Initialize our shared state struct */ /* Initialize our shared state struct */
MultiXactState = ShmemInitStruct("Shared MultiXact State", MultiXactState = ShmemInitStruct("Shared MultiXact State",
......
...@@ -162,7 +162,7 @@ SimpleLruShmemSize(int nslots, int nlsns) ...@@ -162,7 +162,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns, SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir) LWLock *ctllock, const char *subdir, int tranche_id)
{ {
SlruShared shared; SlruShared shared;
bool found; bool found;
...@@ -215,7 +215,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns, ...@@ -215,7 +215,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
Assert(strlen(name) + 1 < SLRU_MAX_NAME_LENGTH); Assert(strlen(name) + 1 < SLRU_MAX_NAME_LENGTH);
strlcpy(shared->lwlock_tranche_name, name, SLRU_MAX_NAME_LENGTH); strlcpy(shared->lwlock_tranche_name, name, SLRU_MAX_NAME_LENGTH);
shared->lwlock_tranche_id = LWLockNewTrancheId(); shared->lwlock_tranche_id = tranche_id;
shared->lwlock_tranche.name = shared->lwlock_tranche_name; shared->lwlock_tranche.name = shared->lwlock_tranche_name;
shared->lwlock_tranche.array_base = shared->buffer_locks; shared->lwlock_tranche.array_base = shared->buffer_locks;
shared->lwlock_tranche.array_stride = sizeof(LWLockPadded); shared->lwlock_tranche.array_stride = sizeof(LWLockPadded);
......
...@@ -179,7 +179,8 @@ SUBTRANSShmemInit(void) ...@@ -179,7 +179,8 @@ SUBTRANSShmemInit(void)
{ {
SubTransCtl->PagePrecedes = SubTransPagePrecedes; SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "subtrans", NUM_SUBTRANS_BUFFERS, 0, SimpleLruInit(SubTransCtl, "subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransControlLock, "pg_subtrans"); SubtransControlLock, "pg_subtrans",
LWTRANCHE_SUBTRANS_BUFFERS);
/* Override default assumption that writes should be fsync'd */ /* Override default assumption that writes should be fsync'd */
SubTransCtl->do_fsync = false; SubTransCtl->do_fsync = false;
} }
......
...@@ -480,7 +480,7 @@ AsyncShmemInit(void) ...@@ -480,7 +480,7 @@ AsyncShmemInit(void)
*/ */
AsyncCtl->PagePrecedes = asyncQueuePagePrecedes; AsyncCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(AsyncCtl, "async", NUM_ASYNC_BUFFERS, 0, SimpleLruInit(AsyncCtl, "async", NUM_ASYNC_BUFFERS, 0,
AsyncCtlLock, "pg_notify"); AsyncCtlLock, "pg_notify", LWTRANCHE_ASYNC_BUFFERS);
/* Override default assumption that writes should be fsync'd */ /* Override default assumption that writes should be fsync'd */
AsyncCtl->do_fsync = false; AsyncCtl->do_fsync = false;
......
...@@ -473,7 +473,7 @@ ReplicationOriginShmemInit(void) ...@@ -473,7 +473,7 @@ ReplicationOriginShmemInit(void)
{ {
int i; int i;
replication_states_ctl->tranche_id = LWLockNewTrancheId(); replication_states_ctl->tranche_id = LWTRANCHE_REPLICATION_ORIGIN;
replication_states_ctl->tranche.name = "ReplicationOrigins"; replication_states_ctl->tranche.name = "ReplicationOrigins";
replication_states_ctl->tranche.array_base = replication_states_ctl->tranche.array_base =
&replication_states[0].lock; &replication_states[0].lock;
......
...@@ -795,7 +795,8 @@ OldSerXidInit(void) ...@@ -795,7 +795,8 @@ OldSerXidInit(void)
*/ */
OldSerXidSlruCtl->PagePrecedes = OldSerXidPagePrecedesLogically; OldSerXidSlruCtl->PagePrecedes = OldSerXidPagePrecedesLogically;
SimpleLruInit(OldSerXidSlruCtl, "oldserxid", SimpleLruInit(OldSerXidSlruCtl, "oldserxid",
NUM_OLDSERXID_BUFFERS, 0, OldSerXidLock, "pg_serial"); NUM_OLDSERXID_BUFFERS, 0, OldSerXidLock, "pg_serial",
LWTRANCHE_OLDSERXID_BUFFERS);
/* Override default assumption that writes should be fsync'd */ /* Override default assumption that writes should be fsync'd */
OldSerXidSlruCtl->do_fsync = false; OldSerXidSlruCtl->do_fsync = false;
......
...@@ -144,7 +144,7 @@ typedef SlruCtlData *SlruCtl; ...@@ -144,7 +144,7 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns); extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns, extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir); LWLock *ctllock, const char *subdir, int tranche_id);
extern int SimpleLruZeroPage(SlruCtl ctl, int pageno); extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok, extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
TransactionId xid); TransactionId xid);
......
...@@ -210,9 +210,17 @@ extern void LWLockInitialize(LWLock *lock, int tranche_id); ...@@ -210,9 +210,17 @@ extern void LWLockInitialize(LWLock *lock, int tranche_id);
typedef enum BuiltinTrancheIds typedef enum BuiltinTrancheIds
{ {
LWTRANCHE_MAIN, LWTRANCHE_MAIN,
LWTRANCHE_CLOG_BUFFERS,
LWTRANCHE_COMMITTS_BUFFERS,
LWTRANCHE_SUBTRANS_BUFFERS,
LWTRANCHE_MXACTOFFSET_BUFFERS,
LWTRANCHE_MXACTMEMBER_BUFFERS,
LWTRANCHE_ASYNC_BUFFERS,
LWTRANCHE_OLDSERXID_BUFFERS,
LWTRANCHE_WAL_INSERT, LWTRANCHE_WAL_INSERT,
LWTRANCHE_BUFFER_CONTENT, LWTRANCHE_BUFFER_CONTENT,
LWTRANCHE_BUFFER_IO_IN_PROGRESS, LWTRANCHE_BUFFER_IO_IN_PROGRESS,
LWTRANCHE_REPLICATION_ORIGIN,
LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS, LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS,
LWTRANCHE_PROC, LWTRANCHE_PROC,
LWTRANCHE_FIRST_USER_DEFINED LWTRANCHE_FIRST_USER_DEFINED
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment