Skip to content

Commit f8795d2

Browse files
committed
Fix oversight from 9e149c8 with spin-lock handling
Calling an external function while a pin-lock is held is a bad idea as those are designed to be short-lived. The stress of a first commit into a large git history may contribute to that. Reported-by: Andres Freund Discussion: https://postgr.es/m/20180611164952.vmxdpdpirdtkdsz6@alap3.anarazel.de
1 parent 69025c5 commit f8795d2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/backend/replication/slot.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ ReplicationSlotReserveWal(void)
999999
while (true)
10001000
{
10011001
XLogSegNo segno;
1002+
XLogRecPtr restart_lsn;
10021003

10031004
/*
10041005
* For logical slots log a standby snapshot and start logical decoding
@@ -1016,8 +1017,9 @@ ReplicationSlotReserveWal(void)
10161017
XLogRecPtr flushptr;
10171018

10181019
/* start at current insert position */
1020+
restart_lsn = GetXLogInsertRecPtr();
10191021
SpinLockAcquire(&slot->mutex);
1020-
slot->data.restart_lsn = GetXLogInsertRecPtr();
1022+
slot->data.restart_lsn = restart_lsn;
10211023
SpinLockRelease(&slot->mutex);
10221024

10231025
/* make sure we have enough information to start */
@@ -1028,8 +1030,9 @@ ReplicationSlotReserveWal(void)
10281030
}
10291031
else
10301032
{
1033+
restart_lsn = GetRedoRecPtr();
10311034
SpinLockAcquire(&slot->mutex);
1032-
slot->data.restart_lsn = GetRedoRecPtr();
1035+
slot->data.restart_lsn = restart_lsn;
10331036
SpinLockRelease(&slot->mutex);
10341037
}
10351038

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy