Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitccdc288

Browse files
robertmhaasAlexander Korotkov
authored and
Alexander Korotkov
committed
Migrate replication slot I/O locks into a separate tranche.
This is following in a long train of similar changes and for the samereasons - seeb319356 andfe702a7 inter alia.Author: Amit KapilaReviewed-by: Alexander Korotkov, Robert Haas
1 parentf63940d commitccdc288

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

‎src/backend/replication/slot.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ ReplicationSlot *MyReplicationSlot = NULL;
9696
intmax_replication_slots=0;/* the maximum number of replication
9797
* slots */
9898

99+
staticLWLockTrancheReplSlotIOLWLockTranche;
99100
staticvoidReplicationSlotDropAcquired(void);
100101

101102
/* internal persistency functions */
@@ -136,6 +137,13 @@ ReplicationSlotsShmemInit(void)
136137
ShmemInitStruct("ReplicationSlot Ctl",ReplicationSlotsShmemSize(),
137138
&found);
138139

140+
ReplSlotIOLWLockTranche.name="Replication Slot IO Locks";
141+
ReplSlotIOLWLockTranche.array_base=
142+
((char*)ReplicationSlotCtl)+ offsetof(ReplicationSlotCtlData,replication_slots)+offsetof(ReplicationSlot,io_in_progress_lock);
143+
ReplSlotIOLWLockTranche.array_stride=sizeof(ReplicationSlot);
144+
LWLockRegisterTranche(LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS,
145+
&ReplSlotIOLWLockTranche);
146+
139147
if (!found)
140148
{
141149
inti;
@@ -149,7 +157,7 @@ ReplicationSlotsShmemInit(void)
149157

150158
/* everything else is zeroed by the memset above */
151159
SpinLockInit(&slot->mutex);
152-
slot->io_in_progress_lock=LWLockAssign();
160+
LWLockInitialize(&slot->io_in_progress_lock,LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS);
153161
}
154162
}
155163
}
@@ -965,7 +973,7 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
965973
if (!was_dirty)
966974
return;
967975

968-
LWLockAcquire(slot->io_in_progress_lock,LW_EXCLUSIVE);
976+
LWLockAcquire(&slot->io_in_progress_lock,LW_EXCLUSIVE);
969977

970978
/* silence valgrind :( */
971979
memset(&cp,0,sizeof(ReplicationSlotOnDisk));
@@ -1062,7 +1070,7 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
10621070
SpinLockRelease(&vslot->mutex);
10631071
}
10641072

1065-
LWLockRelease(slot->io_in_progress_lock);
1073+
LWLockRelease(&slot->io_in_progress_lock);
10661074
}
10671075

10681076
/*

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,6 @@ NumLWLocks(void)
353353
/* Predefined LWLocks */
354354
numLocks=NUM_FIXED_LWLOCKS;
355355

356-
/* slot.c needs one for each slot */
357-
numLocks+=max_replication_slots;
358-
359356
/*
360357
* Add any requested by loadable modules; for backwards-compatibility
361358
* reasons, allocate at least NUM_USER_DEFINED_LWLOCKS of them even if

‎src/include/replication/slot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ typedef struct ReplicationSlot
109109
ReplicationSlotPersistentDatadata;
110110

111111
/* is somebody performing io on this slot? */
112-
LWLock*io_in_progress_lock;
112+
LWLockio_in_progress_lock;
113113

114114
/* all the remaining data is only used for logical slots */
115115

‎src/include/storage/lwlock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ typedef enum BuiltinTrancheIds
209209
LWTRANCHE_WAL_INSERT,
210210
LWTRANCHE_BUFFER_CONTENT,
211211
LWTRANCHE_BUFFER_IO_IN_PROGRESS,
212+
LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS,
212213
LWTRANCHE_PROC,
213214
LWTRANCHE_FIRST_USER_DEFINED
214215
}BuiltinTrancheIds;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp