Re: BUG #17973: Reinit of pgstats entry for dropped DB can break autovacuum daemon

From: Andres Freund <andres(at)anarazel(dot)de>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: will(at)extrahop(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17973: Reinit of pgstats entry for dropped DB can break autovacuum daemon
Date: 2023-06-19 17:45:23
Message-ID: 20230619174523.2cplxli2hgm25url@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On 2023-06-16 10:01:33 +0900, Michael Paquier wrote:
> + /*
> + * If we haven't connected to a database yet, don't attribute time to
> + * "shared state" (InvalidOid is used to track stats for shared relations
> + * etc).
> + */
> + if (!OidIsValid(MyDatabaseId))
> + return;
>
> Hmm. pgstat_report_stat() is called by standby_redo() for a
> XLOG_RUNNING_XACTS record so this would prevent the startup process
> from doing any stats updates for the shared db state, no?

Hm. Effectively the startup process isn't doing that in a useful way
today. Commit/Rollback and session stats don't make sense, and block
read/write time are wrongly attributed.

I think it'd take a fair amount of work to track these stats in a more useful
manner for the startup process, by virtue of it effectively being connected to
multiple databases. We'd need to track
pgStatBlockReadTime/pgStatBlockWriteTime on a per-database level, which
wouldn't be easy to do without increasing overhead.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Zu-Ming Jiang 2023-06-19 18:00:20 Re: BUG #17982: Inconsistent results of SELECT with CTE caused by subquery comparison
Previous Message Tom Lane 2023-06-19 16:08:47 Re: BUG #17982: Inconsistent results of SELECT with CTE caused by subquery comparison