Re: BUG #17973: Reinit of pgstats entry for dropped DB can break autovacuum daemon - Mailing list pgsql-bugs

From Andres Freund
Subject Re: BUG #17973: Reinit of pgstats entry for dropped DB can break autovacuum daemon
Date
Msg-id 20230619174523.2cplxli2hgm25url@awork3.anarazel.de
Whole thread Raw
In response to Re: BUG #17973: Reinit of pgstats entry for dropped DB can break autovacuum daemon  (Michael Paquier <michael@paquier.xyz>)
Responses Re: BUG #17973: Reinit of pgstats entry for dropped DB can break autovacuum daemon  (Michael Paquier <michael@paquier.xyz>)
List 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



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #17982: Inconsistent results of SELECT with CTE caused by subquery comparison
Next
From: Zu-Ming Jiang
Date:
Subject: Re: BUG #17982: Inconsistent results of SELECT with CTE caused by subquery comparison