summaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/logical.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-06-04 10:18:02 +0900
committerMichael Paquier <michael@paquier.xyz>2020-06-04 10:18:02 +0900
commit03aa25b6e34b5f5184cfd0df71f1096c66523b72 (patch)
tree7245fd15ad3374aa0bfa5b2e6cef7c3bf8a4b0a6 /src/backend/replication/logical/logical.c
parent3d474a07934c6da9f1adca3fb7010663e6249810 (diff)
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
Diffstat (limited to 'src/backend/replication/logical/logical.c')
-rw-r--r--src/backend/replication/logical/logical.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 218dff0cfec..a0fc480646f 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -974,6 +974,7 @@ LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart
{
slot->candidate_restart_valid = current_lsn;
slot->candidate_restart_lsn = restart_lsn;
+ SpinLockRelease(&slot->mutex);
elog(DEBUG1, "got new restart lsn %X/%X at %X/%X",
(uint32) (restart_lsn >> 32), (uint32) restart_lsn,
@@ -981,18 +982,25 @@ LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart
}
else
{
+ XLogRecPtr candidate_restart_lsn;
+ XLogRecPtr candidate_restart_valid;
+ XLogRecPtr confirmed_flush;
+
+ candidate_restart_lsn = slot->candidate_restart_lsn;
+ candidate_restart_valid = slot->candidate_restart_valid;
+ confirmed_flush = slot->data.confirmed_flush;
+ SpinLockRelease(&slot->mutex);
+
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",
(uint32) (restart_lsn >> 32), (uint32) restart_lsn,
(uint32) (current_lsn >> 32), (uint32) current_lsn,
- (uint32) (slot->candidate_restart_lsn >> 32),
- (uint32) slot->candidate_restart_lsn,
- (uint32) (slot->candidate_restart_valid >> 32),
- (uint32) slot->candidate_restart_valid,
- (uint32) (slot->data.confirmed_flush >> 32),
- (uint32) slot->data.confirmed_flush
- );
+ (uint32) (candidate_restart_lsn >> 32),
+ (uint32) candidate_restart_lsn,
+ (uint32) (candidate_restart_valid >> 32),
+ (uint32) candidate_restart_valid,
+ (uint32) (confirmed_flush >> 32),
+ (uint32) confirmed_flush);
}
- SpinLockRelease(&slot->mutex);
/* candidates are already valid with the current flush position, apply */
if (updated_lsn)