]> granicus.if.org Git - postgresql/commitdiff
Make all built-in lwlock tranche IDs fixed.
authorRobert Haas <rhaas@postgresql.org>
Tue, 2 Feb 2016 11:42:14 +0000 (06:42 -0500)
committerRobert Haas <rhaas@postgresql.org>
Tue, 2 Feb 2016 11:45:55 +0000 (06:45 -0500)
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

src/backend/access/transam/clog.c
src/backend/access/transam/commit_ts.c
src/backend/access/transam/multixact.c
src/backend/access/transam/slru.c
src/backend/access/transam/subtrans.c
src/backend/commands/async.c
src/backend/replication/logical/origin.c
src/backend/storage/lmgr/predicate.c
src/include/access/slru.h
src/include/storage/lwlock.h

index f4aae10d6b7af49228fdf615bf6f04d8cc8e6492..06aff181d8dde0c565822dbaa59f6d0c2ed72f33 100644 (file)
@@ -457,7 +457,7 @@ CLOGShmemInit(void)
 {
        ClogCtl->PagePrecedes = CLOGPagePrecedes;
        SimpleLruInit(ClogCtl, "clog", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
-                                 CLogControlLock, "pg_clog");
+                                 CLogControlLock, "pg_clog", LWTRANCHE_CLOG_BUFFERS);
 }
 
 /*
index 8942a1d2f5b0007f8d1d73bd9837c67da701804f..17134396a4bea1e2a27f2afa76fc5aa20cd9cc0c 100644 (file)
@@ -485,7 +485,8 @@ CommitTsShmemInit(void)
 
        CommitTsCtl->PagePrecedes = CommitTsPagePrecedes;
        SimpleLruInit(CommitTsCtl, "commit_timestamp", CommitTsShmemBuffers(), 0,
-                                 CommitTsControlLock, "pg_commit_ts");
+                                 CommitTsControlLock, "pg_commit_ts",
+                                 LWTRANCHE_COMMITTS_BUFFERS);
 
        commitTsShared = ShmemInitStruct("CommitTs shared",
                                                                         sizeof(CommitTimestampShared),
index 3334e0cdb629679b9ff902287bf2e3532403486a..a677af00496cd80f14194c331394d98b7173b683 100644 (file)
@@ -1831,10 +1831,12 @@ MultiXactShmemInit(void)
 
        SimpleLruInit(MultiXactOffsetCtl,
                                  "multixact_offset", NUM_MXACTOFFSET_BUFFERS, 0,
-                                 MultiXactOffsetControlLock, "pg_multixact/offsets");
+                                 MultiXactOffsetControlLock, "pg_multixact/offsets",
+                                 LWTRANCHE_MXACTOFFSET_BUFFERS);
        SimpleLruInit(MultiXactMemberCtl,
                                  "multixact_member", NUM_MXACTMEMBER_BUFFERS, 0,
-                                 MultiXactMemberControlLock, "pg_multixact/members");
+                                 MultiXactMemberControlLock, "pg_multixact/members",
+                                 LWTRANCHE_MXACTMEMBER_BUFFERS);
 
        /* Initialize our shared state struct */
        MultiXactState = ShmemInitStruct("Shared MultiXact State",
index fb74915ee44c7c5fc1af8109a006913da5ce3a71..36a011cc94e52a634a211d234ed10b48b3c3158e 100644 (file)
@@ -162,7 +162,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
 
 void
 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;
        bool            found;
@@ -215,7 +215,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 
                Assert(strlen(name) + 1 < 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.array_base = shared->buffer_locks;
                shared->lwlock_tranche.array_stride = sizeof(LWLockPadded);
index dd5db7c404db7bf345c17d0a8f6138a0f4b9587f..8170ba3e3e7ccacf72f40a84c38e8a9958159e94 100644 (file)
@@ -179,7 +179,8 @@ SUBTRANSShmemInit(void)
 {
        SubTransCtl->PagePrecedes = SubTransPagePrecedes;
        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 */
        SubTransCtl->do_fsync = false;
 }
index cf17b01547a071dbc6238877e3e6007171da2e28..c39ac3aeef00d506308034c85b43f8223177cdcf 100644 (file)
@@ -480,7 +480,7 @@ AsyncShmemInit(void)
         */
        AsyncCtl->PagePrecedes = asyncQueuePagePrecedes;
        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 */
        AsyncCtl->do_fsync = false;
 
index 757b50eb10b2467b743f0664a9be7a1a8340c562..5af47ec584e1686e9c234fecbaa6ef3d5e9547ea 100644 (file)
@@ -473,7 +473,7 @@ ReplicationOriginShmemInit(void)
        {
                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.array_base =
                        &replication_states[0].lock;
index d9d4e2204a5405f6ff168dddb726da15f9614d86..026d2b9ab7a4d9ae92029a14675e55cc258cba96 100644 (file)
@@ -795,7 +795,8 @@ OldSerXidInit(void)
         */
        OldSerXidSlruCtl->PagePrecedes = OldSerXidPagePrecedesLogically;
        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 */
        OldSerXidSlruCtl->do_fsync = false;
 
index 6c452c8b96770264002526dc9527474fdf25a6a6..5fcebc52fba4a38e694798608cc3f4ccc4964235 100644 (file)
@@ -144,7 +144,7 @@ typedef SlruCtlData *SlruCtl;
 
 extern Size SimpleLruShmemSize(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 SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
                                  TransactionId xid);
index 9e4f512e2c816b27a6aede3828c17f8962fe48f1..613df19ad64ff637246a1a643bc3cba8556b0213 100644 (file)
@@ -210,9 +210,17 @@ extern void LWLockInitialize(LWLock *lock, int tranche_id);
 typedef enum BuiltinTrancheIds
 {
        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_BUFFER_CONTENT,
        LWTRANCHE_BUFFER_IO_IN_PROGRESS,
+       LWTRANCHE_REPLICATION_ORIGIN,
        LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS,
        LWTRANCHE_PROC,
        LWTRANCHE_FIRST_USER_DEFINED