pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't report stats in LogicalRepApplyLoop() when in xact.
Date: Fri, 13 May 2022 02:00:01 +0000
Message-ID: <E1npKb3-000QsQ-K7@gemulon.postgresql.org> (raw)

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@xs4all.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(-)



Message-ID: <E1npKb3-000QsQ-K7@gemulon.postgresql.org>
Permalink:  ../E1npKb3-000QsQ-K7@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1npKb3-000QsQ-K7@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de
  Subject: Re: pgsql: Don't report stats in LogicalRepApplyLoop() when in xact.
  In-Reply-To: <E1npKb3-000QsQ-K7@gemulon.postgresql.org>
  References: <E1npKb3-000QsQ-K7@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox