Content-Length: 272721 | pFad | http://github.com/postgrespro/postgres/commit/0cf16cb8ca4853b084c40eca310c4c9c3ebf7e2a

E1 Don't report stats in LogicalRepApplyLoop() when in xact. · postgrespro/postgres@0cf16cb · GitHub
Skip to content

Commit 0cf16cb

Browse files
committed
Don't report stats in LogicalRepApplyLoop() when in xact.
pgstat_report_stat() is only supposed to be called outside of transactions. In 5891c7a I added a pgstat_report_stat() call into LogicalRepApplyLoop()'s timeout branch. While not commonly reached inside a transaction, it is reachable (e.g. due to network bottlenecks or the sender being stalled / slow for some reason). To fix, add a !IsTransactionState() check. No test added because there's no easy way to reproduce this case without patching the code. Reported-By: Erik Rijkers <er@xs4all.nl> Discussion: https://postgr.es/m/b3463b8c-2328-dcac-0136-af95715493c1@xs4all.nl
1 parent 8d33412 commit 0cf16cb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/backend/replication/logical/worker.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,9 +2883,14 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
28832883

28842884
/*
28852885
* Force reporting to ensure long idle periods don't lead to
2886-
* arbitrarily delayed stats.
2886+
* arbitrarily delayed stats. Stats can only be reported outside
2887+
* of (implicit or explicit) transactions. That shouldn't lead to
2888+
* stats being delayed for long, because transactions are either
2889+
* sent as a whole on commit or streamed. Streamed transactions
2890+
* are spilled to disk and applied on commit.
28872891
*/
2888-
pgstat_report_stat(true);
2892+
if (!IsTransactionState())
2893+
pgstat_report_stat(true);
28892894
}
28902895
}
28912896

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/0cf16cb8ca4853b084c40eca310c4c9c3ebf7e2a

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy