Skip to content

Commit c1669fd

Browse files
committed
Fix instance of elog() called while holding a spinlock
This broke the project rule to not call any complex code while a spinlock is held. Issue introduced by b89e151. Discussion: https://postgr.es/m/20200602.161518.1399689010416646074.horikyota.ntt@gmail.com Backpatch-through: 9.5
1 parent f88bd31 commit c1669fd

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/backend/replication/logical/logical.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -972,25 +972,33 @@ LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart
972972
{
973973
slot->candidate_restart_valid = current_lsn;
974974
slot->candidate_restart_lsn = restart_lsn;
975+
SpinLockRelease(&slot->mutex);
975976

976977
elog(DEBUG1, "got new restart lsn %X/%X at %X/%X",
977978
(uint32) (restart_lsn >> 32), (uint32) restart_lsn,
978979
(uint32) (current_lsn >> 32), (uint32) current_lsn);
979980
}
980981
else
981982
{
983+
XLogRecPtr candidate_restart_lsn;
984+
XLogRecPtr candidate_restart_valid;
985+
XLogRecPtr confirmed_flush;
986+
987+
candidate_restart_lsn = slot->candidate_restart_lsn;
988+
candidate_restart_valid = slot->candidate_restart_valid;
989+
confirmed_flush = slot->data.confirmed_flush;
990+
SpinLockRelease(&slot->mutex);
991+
982992
elog(DEBUG1, "failed to increase restart lsn: proposed %X/%X, after %X/%X, current candidate %X/%X, current after %X/%X, flushed up to %X/%X",
983993
(uint32) (restart_lsn >> 32), (uint32) restart_lsn,
984994
(uint32) (current_lsn >> 32), (uint32) current_lsn,
985-
(uint32) (slot->candidate_restart_lsn >> 32),
986-
(uint32) slot->candidate_restart_lsn,
987-
(uint32) (slot->candidate_restart_valid >> 32),
988-
(uint32) slot->candidate_restart_valid,
989-
(uint32) (slot->data.confirmed_flush >> 32),
990-
(uint32) slot->data.confirmed_flush
991-
);
995+
(uint32) (candidate_restart_lsn >> 32),
996+
(uint32) candidate_restart_lsn,
997+
(uint32) (candidate_restart_valid >> 32),
998+
(uint32) candidate_restart_valid,
999+
(uint32) (confirmed_flush >> 32),
1000+
(uint32) confirmed_flush);
9921001
}
993-
SpinLockRelease(&slot->mutex);
9941002

9951003
/* candidates are already valid with the current flush position, apply */
9961004
if (updated_lsn)

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