Re: BUG #16961: Could not access status of transaction

Daniil Davydov <3danissimo@gmail.com>

From: Daniil Davydov <3danissimo@gmail.com>
To: Alexandra Wang <alexandra.wang.oss@gmail.com>
Cc: noah@leadboat.com, Tom Lane <tgl@sss.pgh.pa.us>, Stepan Yankevych <Stepan_Yankevych@epam.com>, Stepan Yankevych <stepya@ukr.net>, "sergii.zhuravlev@smartnet.ua" <sergii.zhuravlev@smartnet.ua>, "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>, Shruthi Gowda <gowdashru@gmail.com>, Matheus Alcantara <matheusssilv97@gmail.com>
Date: 2025-08-06T03:30:39Z
Lists: pgsql-bugs
Hi,

On Wed, Aug 6, 2025 at 6:30 AM Alexandra Wang
<alexandra.wang.oss@gmail.com> wrote:
>
> Thank you for sharing your interim solution! Inspired by your solution, I found
> that there is an existing built-in function "pg_notification_queue_usage()"[1]
>
>> pg_notification_queue_usage () → double precision
>> Returns the fraction (0–1) of the asynchronous notification queue's maximum
>> size that is currently occupied by notifications that are waiting to be
>> processed. See LISTEN and NOTIFY for more information.
>
>
> This function calls asyncQueueAdvanceTail(). I think it's a similar workaround
> to your patch, but without code change.
>
> What do you think?
>

Yep, it can be used as a workaround. But obviously the user doesn't know when
this function should be called - it will become clear only when an error occurs,
that is, post factum. Thus, I think that it is better to add such a
functionality
to the autovacuum. This simple code will ensure that there are no
errors in most cases.

--
Best regards,
Daniil Davydov