Re: BUG #15888: Bogus "idle in transaction" state for logical decoding client after creating a slot

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: marko(at)joh(dot)to, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15888: Bogus "idle in transaction" state for logical decoding client after creating a slot
Date: 2019-07-04 04:35:12
Message-ID: 20190704043512.GK3084@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Jul 03, 2019 at 08:03:24AM +0000, PG Bug reporting form wrote:
> Run:
>
> pg_recvlogical -S foo -f /dev/null -d dbname --create-slot --start
>
> and pg_stat_activity will show something like this until that session
> disconnects:
>
> which is quite obviously bogus.

I think that's the transaction which is started when exporting the
snapshot at logical slot creation. Or in short:
#2 0x000055b5f8e5720f in StartTransactionCommand () at xact.c:2699
#3 0x000055b5f90fab4e in SnapBuildExportSnapshot
(builder=0x55b5fa3427b0) at snapbuild.c:575
#4 0x000055b5f90fe5df in CreateReplicationSlot (cmd=0x55b5fa2914e8)
at walsender.c:843

SnapBuildExportSnapshot() needs to keep a transaction context opened
to keep the wanted xmin around. In PG >= 10, this problem gets
"solved" by using NOEXPORT_SNAPSHOT in the CREATE_REPLICATION_SLOT
command. One idea would be to enforce a commit in this case from
CreateReplicationSlot/streamutil.c? We know that pg_recvlogical is
not going to use this snapshot anyway...
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2019-07-04 07:35:39 BUG #15893: pg_dump is not working like as postgres version 10
Previous Message Manuel Rigger 2019-07-03 23:06:08 Re: GROUP BY and inheritance issue