Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit caa3c42

Browse filesBrowse 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
Copy full SHA for caa3c42

File tree

Expand file treeCollapse file tree

1 file changed

+4
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-6
lines changed
Open diff view settings
Collapse file

‎src/backend/replication/walsender.c‎

Copy file name to clipboardExpand all lines: src/backend/replication/walsender.c
+4-6Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.