RE: Resetting spilled txn statistics in pg_stat_replication

From: "Shinoda, Noriyoshi (PN Japan A&PS Delivery)" <noriyoshi(dot)shinoda(at)hpe(dot)com>
To: Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Ajin Cherian <itsajin(at)gmail(dot)com>
Subject: RE: Resetting spilled txn statistics in pg_stat_replication
Date: 2020-10-12 14:45:04
Message-ID: TU4PR8401MB11525308498B3F6213CDF79BEE070@TU4PR8401MB1152.NAMPRD84.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Sawada-san, Thank you your comments.

The attached patch reflects the comment.
I also made a fix for the regression test.

Regards,
Noriyoshi Shinoda

-----Original Message-----
From: Masahiko Sawada [mailto:masahiko(dot)sawada(at)2ndquadrant(dot)com]
Sent: Monday, October 12, 2020 8:12 PM
To: Shinoda, Noriyoshi (PN Japan A&PS Delivery) <noriyoshi(dot)shinoda(at)hpe(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>; Dilip Kumar <dilipbalaut(at)gmail(dot)com>; Magnus Hagander <magnus(at)hagander(dot)net>; Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>; PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>; Ajin Cherian <itsajin(at)gmail(dot)com>
Subject: Re: Resetting spilled txn statistics in pg_stat_replication

On Mon, 12 Oct 2020 at 18:29, Shinoda, Noriyoshi (PN Japan A&PS
Delivery) <noriyoshi(dot)shinoda(at)hpe(dot)com> wrote:
>
> Hi, thank you for the awesome feature.
>

Thank you for reporting!

> As it may have been discussed, I think the 'name' column in pg_stat_replication_slots is more consistent with the column name and data type matched to the pg_replication_slots catalog.
> The attached patch changes the name and data type of the 'name' column to slot_name and 'name' type, respectively.

It seems a good idea to me. In other system views, we use the name data type for object name. When I wrote the first patch, I borrowed the code for pg_stat_slru which uses text data for the name but I think it's an oversight.

> Also, the macro name PG_STAT_GET_..._CLOS has been changed to PG_STAT_GET_..._COLS.

Good catch!

Here is my comments on the patch:

--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -798,7 +798,7 @@ CREATE VIEW pg_stat_replication AS

CREATE VIEW pg_stat_replication_slots AS
SELECT
- s.name,
+ s.name AS slot_name,
s.spill_txns,
s.spill_count,
s.spill_bytes,

I think we should modify 'proargnames' of
pg_stat_get_replication_slots() in pg_proc.dat instead.

---
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -7094,7 +7094,7 @@ pgstat_replslot_index(const char *name, bool create_it)
Assert(nReplSlotStats <= max_replication_slots);
for (i = 0; i < nReplSlotStats; i++)
{
- if (strcmp(replSlotStats[i].slotname, name) == 0)
+ if (strcmp(replSlotStats[i].slotname.data, name) == 0)
return i; /* found */
}

@@ -7107,7 +7107,7 @@ pgstat_replslot_index(const char *name, bool create_it)

/* Register new slot */
memset(&replSlotStats[nReplSlotStats], 0, sizeof(PgStat_ReplSlotStats));
- memcpy(&replSlotStats[nReplSlotStats].slotname, name, NAMEDATALEN);
+ memcpy(&replSlotStats[nReplSlotStats].slotname.data, name,
+ NAMEDATALEN);

return nReplSlotStats++;
}

We can use NameStr() instead.

---
Perhaps we need to update the regression test as well.

Regards,

--
Masahiko Sawada http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
pg_stat_replication_slots_v2.diff application/octet-stream 5.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-10-12 15:13:38 Re: BUG #15858: could not stat file - over 4GB
Previous Message Pavel Stehule 2020-10-12 14:36:00 Re: broken logic of simple_eval_resowner after CALL and COMMIT inside procedure