diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-01-29 09:44:29 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-01-29 09:45:38 -0500 |
commit | 2251179e6ad3a865d2f55e1832fab34608fcce43 (patch) | |
tree | b954281d29f2d8b54a41d2080845d03831f15ccb /src/backend | |
parent | b319356f0e94a6482c726cf4af96597c211d8d6e (diff) | |
download | postgresql-2251179e6ad3a865d2f55e1832fab34608fcce43.tar.gz postgresql-2251179e6ad3a865d2f55e1832fab34608fcce43.zip |
Migrate replication slot I/O locks into a separate tranche.
This is following in a long train of similar changes and for the same
reasons - see b319356f0e94a6482c726cf4af96597c211d8d6e and
fe702a7b3f9f2bc5bf6d173166d7d55226af82c8 inter alia.
Author: Amit Kapila
Reviewed-by: Alexander Korotkov, Robert Haas
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/replication/slot.c | 14 | ||||
-rw-r--r-- | src/backend/storage/lmgr/lwlock.c | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c index c12e4128665..251b549768d 100644 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -97,6 +97,7 @@ ReplicationSlot *MyReplicationSlot = NULL; int max_replication_slots = 0; /* the maximum number of replication * slots */ +static LWLockTranche ReplSlotIOLWLockTranche; static void ReplicationSlotDropAcquired(void); /* internal persistency functions */ @@ -137,6 +138,13 @@ ReplicationSlotsShmemInit(void) ShmemInitStruct("ReplicationSlot Ctl", ReplicationSlotsShmemSize(), &found); + ReplSlotIOLWLockTranche.name = "Replication Slot IO Locks"; + ReplSlotIOLWLockTranche.array_base = + ((char *) ReplicationSlotCtl) + offsetof(ReplicationSlotCtlData, replication_slots) +offsetof(ReplicationSlot, io_in_progress_lock); + ReplSlotIOLWLockTranche.array_stride = sizeof(ReplicationSlot); + LWLockRegisterTranche(LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS, + &ReplSlotIOLWLockTranche); + if (!found) { int i; @@ -150,7 +158,7 @@ ReplicationSlotsShmemInit(void) /* everything else is zeroed by the memset above */ SpinLockInit(&slot->mutex); - slot->io_in_progress_lock = LWLockAssign(); + LWLockInitialize(&slot->io_in_progress_lock, LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS); } } } @@ -1008,7 +1016,7 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel) if (!was_dirty) return; - LWLockAcquire(slot->io_in_progress_lock, LW_EXCLUSIVE); + LWLockAcquire(&slot->io_in_progress_lock, LW_EXCLUSIVE); /* silence valgrind :( */ memset(&cp, 0, sizeof(ReplicationSlotOnDisk)); @@ -1101,7 +1109,7 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel) slot->dirty = false; SpinLockRelease(&slot->mutex); - LWLockRelease(slot->io_in_progress_lock); + LWLockRelease(&slot->io_in_progress_lock); } /* diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 5e276a08da3..d087139c286 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -353,9 +353,6 @@ NumLWLocks(void) /* Predefined LWLocks */ numLocks = NUM_FIXED_LWLOCKS; - /* 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 |