From: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Jeff Davis <pgsql(at)j-davis(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Danil Anisimow <anisimow(dot)d(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Yurii Rashkovskii <yrashk(at)omnigres(dot)com> |
Subject: | Re: Comments on Custom RMGRs |
Date: | 2025-10-14 09:11:53 |
Message-ID: | d1e7eb2c-0e37-4bb9-a7bb-bd549f1cf25d@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 27/5/2024 20:20, Michael Paquier wrote:
> Please note that I've been studying ways to have pg_stat_statements
> being plugged in directly with the shared pgstat APIs to get it backed
> by a dshash to give more flexibility and scaling, giving a way for
> extensions to register their own stats kind. In this case, the flush
> of the stats would be controlled with a callback in the stats
> registered by the extensions, conflicting with what's proposed here.
> pg_stat_statements is all about stats, at the end. I don't want this
> argument to act as a barrier if a checkpoint hook is an accepted
> consensus here, but a checkpoint hook used for this code path is not
> the most intuitive solution I can think of in the long-term.Let me continue this thread.
I wait for any kind of checkpoint cut-in machinery for extensions.
Typically, when collecting knowledge about the instance state, we store
it in an extension's owned database table, incurring the costs
associated with transactional mechanics, tuple format overhead, and so
on. Usually, we don't need MVCC or rollback; we have fixed-length data,
and it would be better to store data in hash tables. These hash tables
should survive instances' restarts and crashes - that's the only feature
needed.
The pg_stat_statements dumps its data to a file, but it is not reliable
enough when we need consistent information, such as replication status
or when logging update conflicts (see the Spock extension [1]). When we
learn about query executions, we can't dump the hash table on each
ExecutorEnd due to overhead, but we are okay with adding one more WAL
record containing the hash table entry data - it may be done by the
backend or by a separate background worker.
So, the primary reason for us is to have a moment to store the
extension's state on disk, keeping in mind that we have registered RMGR,
which allows us to restore the full state using this disk file and WAL
records.
For me, the ideal place for such a hook is CheckPointGuts, right between
the CheckPointBuffers call and fsyncs. I think that to demonstrate how
this hook can work, the pg_stat_statements storage may need to be
redesigned slightly.
[1] https://github.com/pgEdge/spock
--
regards, Andrei Lepikhov,
pgEdge
From | Date | Subject | |
---|---|---|---|
Next Message | shveta malik | 2025-10-14 09:23:51 | Re: POC: enable logical decoding when wal_level = 'replica' without a server restart |
Previous Message | torikoshia | 2025-10-14 09:00:45 | Re: Enhancing Memory Context Statistics Reporting |