Re: WAL-logging facility for pgstats kinds

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: WAL-logging facility for pgstats kinds
Date: 2025-01-10 04:46:53
Message-ID: Z4CmPdoUJAiBNpzE@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 31, 2024 at 11:29:26AM +0000, Bertrand Drouvot wrote:
> === 1
>
> + * Copyright (c) 2001-2024, PostgreSQL Global Development Group
>
> As pgstat_kind.h is a new file, s/Copyright (c) 2001-2024/Copyright (c) 2025/
> maybe?

Fixed.

> No more comments, as v2-0002 is "just" moving some stuff from pgstat.h to
> pgstat_kind.h.

Thanks. This split is independent of the main topic of the thread,
and I think that it just makes the declarations cleaner, so I'm
planning to apply this one. I was also planning to write some custom
tool to manipulate the pgstats file. That will help a bit.

For the rest of the patch set, let's see how the discussion moves on..

> Same as === 1 for pgstatdesc.c, pgstat_xlog.c and pgstat_xlog.h.

Fixed.

> +void
> +pgstat_desc(StringInfo buf, XLogReaderState *record)
> +{
>
> Looks like logicalmsg_desc(), fine by me, except:

Yes, there's not much you can do here, except if we invent one day a
way to load external libraries in the frontend.

> s/data payload/stats data/ maybe?
> s/invalid stats data/invalid stats kind/ maybe?

Okay.

> + PgStat_StatInjRecord record_data = {0};
>
> PgStat_StatInjRecord does not contain any padding but as it acts as a template,
> better to use memset() instead? (to cover the cases where the record contains
> padding).

Dammit, forgot about that. Good point about the padding, especially
for the template bits.

> + if (!RecoveryInProgress() && inj_stats_wal_enabled)
>
> s/!RecoveryInProgress()/XLogInsertAllowed()/ maybe?

I'd rather use RecoveryInProgress() here even if XLogInsertAllowed()
is a synonym of that, minus the update of LocalXLogInsertAllowed for
the local process.
--
Michael

Attachment Content-Type Size
v3-0002-Move-information-about-pgstats-kinds-into-its-own.patch text/x-diff 5.7 KB
v3-0003-Add-RMGR-and-WAL-logging-API-for-pgstats.patch text/x-diff 11.1 KB
v3-0004-injection_points-Add-option-and-tests-for-WAL-log.patch text/x-diff 7.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-01-10 04:49:48 Re: An improvement of ProcessTwoPhaseBuffer logic
Previous Message Ashutosh Bapat 2025-01-10 04:37:40 Re: Small refactoring around vacuum_open_relation