Skip to content

Commit caa3c42

Browse files
committed
Don't call elog() while holding spinlock.
Previously UpdateSpillStats() called elog(DEBUG2) while holding the spinlock even though the local variables that the elog() accesses don't need to be protected by the lock. Since spinlocks are intended for very short-term locks, they should not be used when calling elog(DEBUG2). So this commit moves that elog() out of spinlock period. Author: Kyotaro Horiguchi Reviewed-by: Amit Kapila and Fujii Masao Discussion: https://postgr.es/m/20200602.161518.1399689010416646074.horikyota.ntt@gmail.com
1 parent e641b2a commit caa3c42

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/backend/replication/walsender.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,17 +3685,15 @@ UpdateSpillStats(LogicalDecodingContext *ctx)
36853685
{
36863686
ReorderBuffer *rb = ctx->reorder;
36873687

3688-
SpinLockAcquire(&MyWalSnd->mutex);
3689-
3690-
MyWalSnd->spillTxns = rb->spillTxns;
3691-
MyWalSnd->spillCount = rb->spillCount;
3692-
MyWalSnd->spillBytes = rb->spillBytes;
3693-
36943688
elog(DEBUG2, "UpdateSpillStats: updating stats %p %lld %lld %lld",
36953689
rb,
36963690
(long long) rb->spillTxns,
36973691
(long long) rb->spillCount,
36983692
(long long) rb->spillBytes);
36993693

3694+
SpinLockAcquire(&MyWalSnd->mutex);
3695+
MyWalSnd->spillTxns = rb->spillTxns;
3696+
MyWalSnd->spillCount = rb->spillCount;
3697+
MyWalSnd->spillBytes = rb->spillBytes;
37003698
SpinLockRelease(&MyWalSnd->mutex);
37013699
}

0 commit comments

Comments
 (0)