pgsql: Don't report stats in LogicalRepApplyLoop() when in xact.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't report stats in LogicalRepApplyLoop() when in xact.
Date: 2022-05-13 02:00:01
Message-ID: E1npKb3-000QsQ-K7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't report stats in LogicalRepApplyLoop() when in xact.

pgstat_report_stat() is only supposed to be called outside of transactions. In
5891c7a8ed8 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(at)xs4all(dot)nl>
Discussion: https://postgr.es/m/b3463b8c-2328-dcac-0136-af95715493c1@xs4all.nl

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0cf16cb8ca4853b084c40eca310c4c9c3ebf7e2a

Modified Files
--------------
src/backend/replication/logical/worker.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2022-05-13 05:18:23 pgsql: Indent C code in flex and bison files
Previous Message Michael Paquier 2022-05-13 00:41:58 pgsql: Remove PGDLLIMPORT marker from __pg_log_level