Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
5c21ad07
Commit
5c21ad07
authored
Apr 05, 2017
by
Andres Freund
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review for recent slot.c changes.
parent
df1a699e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
26 deletions
+22
-26
src/backend/replication/slot.c
src/backend/replication/slot.c
+22
-26
No files found.
src/backend/replication/slot.c
View file @
5c21ad07
...
...
@@ -410,7 +410,7 @@ ReplicationSlotRelease(void)
* Cleanup all temporary slots created in current session.
*/
void
ReplicationSlotCleanup
()
ReplicationSlotCleanup
(
void
)
{
int
i
;
...
...
@@ -802,12 +802,12 @@ ReplicationSlotsCountDBSlots(Oid dboid, int *nslots, int *nactive)
* pg_database oid for the database to prevent creation of new slots on the db
* or replay from existing slots.
*
* This routine isn't as efficient as it could be - but we don't drop databases
* often, especially databases with lots of slots.
*
* Another session that concurrently acquires an existing slot on the target DB
* (most likely to drop it) may cause this function to ERROR. If that happens
* it may have dropped some but not all slots.
*
* This routine isn't as efficient as it could be - but we don't drop
* databases often, especially databases with lots of slots.
*/
void
ReplicationSlotsDropDBSlots
(
Oid
dboid
)
...
...
@@ -822,7 +822,7 @@ restart:
for
(
i
=
0
;
i
<
max_replication_slots
;
i
++
)
{
ReplicationSlot
*
s
;
NameData
slotname
;
char
*
slotname
;
int
active_pid
;
s
=
&
ReplicationSlotCtl
->
replication_slots
[
i
];
...
...
@@ -839,10 +839,10 @@ restart:
if
(
s
->
data
.
database
!=
dboid
)
continue
;
/*
Claim the slot, as if ReplicationSlotAcquire()ing.
*/
/*
acquire slot, so ReplicationSlotDropAcquired can be reused
*/
SpinLockAcquire
(
&
s
->
mutex
);
strncpy
(
NameStr
(
slotname
),
NameStr
(
s
->
data
.
name
),
NAMEDATALEN
);
NameStr
(
slotname
)[
NAMEDATALEN
-
1
]
=
'\0'
;
/* can't change while ReplicationSlotControlLock is held */
slotname
=
NameStr
(
s
->
data
.
name
)
;
active_pid
=
s
->
active_pid
;
if
(
active_pid
==
0
)
{
...
...
@@ -852,36 +852,32 @@ restart:
SpinLockRelease
(
&
s
->
mutex
);
/*
* We might fail here if the slot was active. Even though we hold an
* exclusive lock on the database object a logical slot for that DB can
* still be active if it's being dropped by a backend connected to
* another DB or is otherwise acquired.
* Even though we hold an exclusive lock on the database object a
* logical slot for that DB can still be active, e.g. if it's
* concurrently being dropped by a backend connected to another DB.
*
* It's an unlikely race that'll only arise from concurrent user action,
* so we'll just bail out.
* That's fairly unlikely in practice, so we'll just bail out.
*/
if
(
active_pid
)
elog
(
ERROR
,
"replication slot %s is in use by pid %d"
,
NameStr
(
slotname
),
active_pid
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OBJECT_IN_USE
),
errmsg
(
"replication slot
\"
%s
\"
is active for PID %d"
,
slotname
,
active_pid
)));
/*
* To avoid
largely duplicating ReplicationSlotDropAcquired() or
*
complicating it with already_locked flags for ProcArrayLock
,
*
ReplicationSlotControlLock and ReplicationSlotAllocationLock, w
e
*
just release our ReplicationSlotControlLock to drop the slot
.
* To avoid
duplicating ReplicationSlotDropAcquired() and to avoid
*
holding ReplicationSlotControlLock over filesystem operations
,
*
release ReplicationSlotControlLock and us
e
*
ReplicationSlotDropAcquired
.
*
*
For safety we'll restart our scan from the beginning each
* time we release the lock.
*
As that means the set of slots could change, restart scan from the
*
beginning each
time we release the lock.
*/
LWLockRelease
(
ReplicationSlotControlLock
);
ReplicationSlotDropAcquired
();
goto
restart
;
}
LWLockRelease
(
ReplicationSlotControlLock
);
/* recompute limits once after all slots are dropped */
ReplicationSlotsComputeRequiredXmin
(
false
);
ReplicationSlotsComputeRequiredLSN
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment