| Lists: | pgsql-hackers |
|---|
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-24 19:02:33 |
| Message-ID: | lzzgmgm6e5.fsf@veeddrois.attlocal.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
Greetings,
This patch adds the ability to specify a RelFileNode and optional BlockNum to limit output of
pg_waldump records to only those which match the given criteria. This should be more performant
than `pg_waldump | grep` as well as more reliable given specific variations in output style
depending on how the blocks are specified.
This currently affects only the main fork, but we could presumably add the option to filter by fork
as well, if that is considered useful.
Best,
David
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Add-relation-block-filtering-to-pg_waldump.patch | text/x-patch | 7.0 KB |
| From: | Peter Geoghegan <pg(at)bowt(dot)ie> |
|---|---|
| To: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-24 19:26:09 |
| Message-ID: | CAH2-WzkgeNGgpbJYQbJm68chEmdb6DDkoRBBbTgOYvUqW_ypig@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Thu, Feb 24, 2022 at 11:06 AM David Christensen
<david(dot)christensen(at)crunchydata(dot)com> wrote:
> This patch adds the ability to specify a RelFileNode and optional BlockNum to limit output of
> pg_waldump records to only those which match the given criteria. This should be more performant
> than `pg_waldump | grep` as well as more reliable given specific variations in output style
> depending on how the blocks are specified.
Sounds useful to me.
--
Peter Geoghegan
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-24 19:28:30 |
| Message-ID: | CAOxo6XJRiR-CqP2cZksO_LxZ=cMwmWs6s6QTn+7kjC7E1=D3RA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
Added to commitfest as:
| From: | Japin Li <japinli(at)hotmail(dot)com> |
|---|---|
| To: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | pgsql-hackers(at)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-25 06:32:22 |
| Message-ID: | MEYP282MB1669791B8B59D6CF2C785BDAB63E9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, 25 Feb 2022 at 03:02, David Christensen <david(dot)christensen(at)crunchydata(dot)com> wrote:
> Greetings,
>
> This patch adds the ability to specify a RelFileNode and optional BlockNum to limit output of
> pg_waldump records to only those which match the given criteria. This should be more performant
> than `pg_waldump | grep` as well as more reliable given specific variations in output style
> depending on how the blocks are specified.
>
> This currently affects only the main fork, but we could presumably add the option to filter by fork
> as well, if that is considered useful.
>
Cool. I think we can report an error instead of reading wal files,
if the tablespace, database, or relation is invalid. Does there any
WAL record that has invalid tablespace, database, or relation OID?
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | Japin Li <japinli(at)hotmail(dot)com> |
| Cc: | pgsql-hackers(at)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-25 12:48:55 |
| Message-ID: | E0653476-25FB-42E3-9F41-47651AEB4323@crunchydata.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
> Cool. I think we can report an error instead of reading wal files,
> if the tablespace, database, or relation is invalid. Does there any
> WAL record that has invalid tablespace, database, or relation OID?
The only sort of validity check we could do here is range checking for the underlying data types (which we certainly could/should add if it’s known to never be valid for the underlying types); non-existence of objects is a no-go, since that depends purely on the WAL range you are looking at and you’d have to, you know, scan it to see if it existed before marking as invalid. :)
Thanks,
David
| From: | Japin Li <japinli(at)hotmail(dot)com> |
|---|---|
| To: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | pgsql-hackers(at)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-25 13:08:20 |
| Message-ID: | ME3P282MB16670C9B30D1F1B799E534D8B63E9@ME3P282MB1667.AUSP282.PROD.OUTLOOK.COM |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, 25 Feb 2022 at 20:48, David Christensen <david(dot)christensen(at)crunchydata(dot)com> wrote:
>> Cool. I think we can report an error instead of reading wal files,
>> if the tablespace, database, or relation is invalid. Does there any
>> WAL record that has invalid tablespace, database, or relation OID?
>
> The only sort of validity check we could do here is range checking for the underlying data types
> (which we certainly could/should add if it’s known to never be valid for the underlying types);
The invalid OID I said here is such as negative number and zero, for those
parameters, we do not need to read the WAL files, since it always invalid.
> non-existence of objects is a no-go, since that depends purely on the WAL range you are
> looking at and you’d have to, you know, scan it to see if it existed before marking as invalid. :)
>
Agreed.
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
| From: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
|---|---|
| To: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-25 13:33:38 |
| Message-ID: | CALj2ACXjZRWXvUhvUh7xJeRJd7i40KXdS7p6eHHq+q4+xUNf9w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, Feb 25, 2022 at 12:36 AM David Christensen
<david(dot)christensen(at)crunchydata(dot)com> wrote:
>
> Greetings,
>
> This patch adds the ability to specify a RelFileNode and optional BlockNum to limit output of
> pg_waldump records to only those which match the given criteria. This should be more performant
> than `pg_waldump | grep` as well as more reliable given specific variations in output style
> depending on how the blocks are specified.
>
> This currently affects only the main fork, but we could presumably add the option to filter by fork
> as well, if that is considered useful.
Thanks for the patch. This is not adding something that users can't do
right now, but definitely improves the usability of the pg_waldump as
it avoids external filterings. Also, it can give the stats/info at
table and block level. So, +1 from my side.
I have some comments on the patch:
1) Let's use capitalized "OID" as is the case elsewhere in the documentation.
+ specified via tablespace oid, database oid, and relfilenode separated
2) Good idea to specify an example:
+ by slashes.
Something like, "by slashes, for instance, XXXX/XXXX/XXXX
3) Crossing 80 char limit
+/*
+ * Boolean to return whether the given WAL record matches a specific
relation and optional block
+ */
+static bool
+XLogRecordMatchesRelationBlock(XLogReaderState *record, RelFileNode
matchRnode, BlockNumber matchBlock
)
+ pg_log_error("could not parse block number \"%s\"", optarg);
+ pg_log_error("could not parse relation from \"%s\" (expecting
\"spc/dat/rel\")", optarg);
4) How about (expecting \"tablespace OID/database OID/relation OID\")?
Let's be clear.
+ pg_log_error("could not parse relation from \"%s\" (expecting
\"spc/dat/rel\")", optarg);
5) I would also see a need for "filter by FPW" i.e. list all WAL
records with "FPW".
6) How about "--block option requires --relation option" or some other
better phrasing?
+ pg_log_error("cannot filter by --block without also filtering --relation");
7) Extra new line between } and return false;
+ return true;
+ }
+ return false;
+}
8) Can we have this for-loop local variables instead of function level
variables?
+ RelFileNode rnode;
+ ForkNumber forknum;
+ BlockNumber blk;
Regards,
Bharath Rupireddy.
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-25 15:33:59 |
| Message-ID: | CAOxo6XK5gKr6aLjNo8yL1uEWN5j1T-o34LtXFr4niVmawjWALA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, Feb 25, 2022 at 7:33 AM Bharath Rupireddy <
bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> Thanks for the patch. This is not adding something that users can't do
> right now, but definitely improves the usability of the pg_waldump as
> it avoids external filterings. Also, it can give the stats/info at
> table and block level. So, +1 from my side.
>
Thanks for the feedback; I will be incorporating most of this into a new
version, with a couple of responses below.
> 3) Crossing 80 char limit
>
This is neither here nor there, but have we as a project considered
increasing that to something more modern? I know a lot of current projects
consider 132 to be a more reasonable limit. (Will reduce it down to that
for now, but consider this a vote towards increasing that limit.)
> 5) I would also see a need for "filter by FPW" i.e. list all WAL
> records with "FPW".
>
Yes, that wouldn't be too hard to add to this, can add to the next
version. We probably ought to also add the fork number as specifiable as
well. Other thoughts on could be some wildcard value in the relation part,
so `1234/23456/*` could filter WAL to a specific database only, say, or
some other multiple specifier, like `--block=1234,123456,121234`. (I
honestly consider this to be more advanced than we'd need to support in
this patch, but if probably wouldn't be too hard to add to it.)
Thanks,
David
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | Japin Li <japinli(at)hotmail(dot)com> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-25 15:35:03 |
| Message-ID: | CAOxo6XL+BRZhswS2XoOgiQQC1B-Acr0vC8GZC-4uNjWonfhK_g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, Feb 25, 2022 at 7:08 AM Japin Li <japinli(at)hotmail(dot)com> wrote:
>
> On Fri, 25 Feb 2022 at 20:48, David Christensen <
> david(dot)christensen(at)crunchydata(dot)com> wrote:
> >> Cool. I think we can report an error instead of reading wal files,
> >> if the tablespace, database, or relation is invalid. Does there any
> >> WAL record that has invalid tablespace, database, or relation OID?
> >
> > The only sort of validity check we could do here is range checking for
> the underlying data types
> > (which we certainly could/should add if it’s known to never be valid for
> the underlying types);
>
> The invalid OID I said here is such as negative number and zero, for those
> parameters, we do not need to read the WAL files, since it always invalid.
>
Agreed. Can add some additional range validation to the parsed values.
David
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-25 18:56:16 |
| Message-ID: | lzwnhiai4i.fsf@veeddrois.attlocal.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> writes:
> On Fri, Feb 25, 2022 at 12:36 AM David Christensen
> <david(dot)christensen(at)crunchydata(dot)com> wrote:
>>
>> Greetings,
>>
>> This patch adds the ability to specify a RelFileNode and optional BlockNum to limit output of
>> pg_waldump records to only those which match the given criteria. This should be more performant
>> than `pg_waldump | grep` as well as more reliable given specific variations in output style
>> depending on how the blocks are specified.
>>
>> This currently affects only the main fork, but we could presumably add the option to filter by fork
>> as well, if that is considered useful.
>
> Thanks for the patch. This is not adding something that users can't do
> right now, but definitely improves the usability of the pg_waldump as
> it avoids external filterings. Also, it can give the stats/info at
> table and block level. So, +1 from my side.
Attached is V2 with additional feedback from this email, as well as the specification of the
ForkNumber and FPW as specifiable options.
Best,
David
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Add-additional-filtering-options-to-pg_waldump.patch | text/x-patch | 10.6 KB |
| From: | Cary Huang <cary(dot)huang(at)highgo(dot)ca> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Cc: | David Christensen <david(at)pgguru(dot)net> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-02-28 22:56:31 |
| Message-ID: | 164608899175.882.1340055378279112856.pgcf@coridan.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passed
Hi
I am glad to find this patch here because it helps with my current development work, which involves a lot of debugging with the WAL records and this patch definitely make this much easier rather than using grep externally.
I have tried all of the new options added by the patch and every combination seems to result correctly.
The only comment I would have is in the documentation, where I would replace:
"Display only records touching the given block" with "Display only records associated with the given block"
"Display only records touching the given relation" with " Display only records associated with the given relation"
just to make it sound more formal. :)
best
Cary Huang
------------------
HighGo Software Canada
www.highgo.ca
| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-21 03:36:40 |
| Message-ID: | CA+hUKGL6Oh86gBFT0fwLz7=fOpFWm4-fu6Xo9X9VcOKuJ6t9ow@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Sat, Feb 26, 2022 at 7:58 AM David Christensen
<david(dot)christensen(at)crunchydata(dot)com> wrote:
> Attached is V2 with additional feedback from this email, as well as the specification of the
> ForkNumber and FPW as specifiable options.
Trivial fixup needed after commit 3f1ce973.
| Attachment | Content-Type | Size |
|---|---|---|
| v3-0001-Add-additional-filtering-options-to-pg_waldump.patch | text/x-patch | 10.6 KB |
| v3-0002-fixup-Add-additional-filtering-options-to-pg_wald.patch | text/x-patch | 1.1 KB |
| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-21 04:55:42 |
| Message-ID: | CA+hUKG+i5mp1cxQ0B_04Pq6BJB_k=KfL0b2fdAQtKrGapapmbg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Mon, Mar 21, 2022 at 4:36 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Sat, Feb 26, 2022 at 7:58 AM David Christensen
> <david(dot)christensen(at)crunchydata(dot)com> wrote:
> > Attached is V2 with additional feedback from this email, as well as the specification of the
> > ForkNumber and FPW as specifiable options.
>
> Trivial fixup needed after commit 3f1ce973.
[04:30:50.630] pg_waldump.c:963:26: error: format ‘%u’ expects
argument of type ‘unsigned int *’, but argument 3 has type ‘ForkNumber
*’ [-Werror=format=]
[04:30:50.630] 963 | if (sscanf(optarg, "%u",
&config.filter_by_relation_forknum) != 1 ||
[04:30:50.630] | ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[04:30:50.630] | | |
[04:30:50.630] | | ForkNumber *
[04:30:50.630] | unsigned int *
And now that this gets to the CompilerWarnings CI task, it looks like
GCC doesn't like an enum as a scanf %u destination (I didn't see that
warning locally when I compiled the above fixup because clearly Clang
is cool with it...). Probably needs a temporary unsigned int to
sscanf into first.
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-21 16:10:23 |
| Message-ID: | CAOxo6XLnSfH2a7ZhXBeE4znKj0OzH5aX+8EiNssK1FKk8ffmDw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Sun, Mar 20, 2022 at 11:56 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
wrote:
> On Mon, Mar 21, 2022 at 4:36 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
> wrote:
> > On Sat, Feb 26, 2022 at 7:58 AM David Christensen
> > <david(dot)christensen(at)crunchydata(dot)com> wrote:
> > > Attached is V2 with additional feedback from this email, as well as
> the specification of the
> > > ForkNumber and FPW as specifiable options.
> >
> > Trivial fixup needed after commit 3f1ce973.
>
> [04:30:50.630] pg_waldump.c:963:26: error: format ‘%u’ expects
> argument of type ‘unsigned int *’, but argument 3 has type ‘ForkNumber
> *’ [-Werror=format=]
> [04:30:50.630] 963 | if (sscanf(optarg, "%u",
> &config.filter_by_relation_forknum) != 1 ||
> [04:30:50.630] | ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [04:30:50.630] | | |
> [04:30:50.630] | | ForkNumber *
> [04:30:50.630] | unsigned int *
>
> And now that this gets to the CompilerWarnings CI task, it looks like
> GCC doesn't like an enum as a scanf %u destination (I didn't see that
> warning locally when I compiled the above fixup because clearly Clang
> is cool with it...). Probably needs a temporary unsigned int to
> sscanf into first.
>
Do you need me to fix this, or are you incorporating that into a V4 of this
patch? (Similar to your fixup prior in this thread?)
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-21 17:14:19 |
| Message-ID: | CAOxo6XLhdMW-xYP47Kfyr-EztP2Hbt6WLf5F6_wiV25w52yphw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
Updated to include the V3 fixes as well as the unsigned int/enum fix.
>
| Attachment | Content-Type | Size |
|---|---|---|
| v4-0001-Add-additional-filtering-options-to-pg_waldump.patch | application/octet-stream | 10.6 KB |
| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-21 21:38:32 |
| Message-ID: | CA+hUKGJht74h1rurzdE6R9vhMickFuvNG8M5OJgoGz8wYtFHeA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Tue, Mar 22, 2022 at 6:14 AM David Christensen
<david(dot)christensen(at)crunchydata(dot)com> wrote:
> Updated to include the V3 fixes as well as the unsigned int/enum fix.
Hi David,
I ran this though pg_indent and adjusted some remaining
non-project-style whitespace, and took it for a spin. Very minor
comments:
pg_waldump: error: could not parse valid relation from ""/ (expecting
"tablespace OID/database OID/relation filenode")
-> There was a stray "/" in that message, which I've removed in the attached.
pg_waldump: error: could not parse valid relation from "1664/0/1262"
(expecting "tablespace OID/database OID/relation filenode")
-> Why not? Shared relations like pg_database have invalid database
OID, so I think it should be legal to write --relation=1664/0/1262. I
took out that restriction.
+ if (sscanf(optarg, "%u",
&forknum) != 1 ||
+ forknum >= MAX_FORKNUM)
+ {
+ pg_log_error("could
not parse valid fork number (0..%d) \"%s\"",
+
MAX_FORKNUM - 1, optarg);
+ goto bad_argument;
+ }
I guess you did this because init fork references aren't really
expected in the WAL, but I think it's more consistent to allow up to
MAX_FORKNUM, not least because your documentation mentions 3 as a
valid value. So I adjust this to allow MAX_FORKNUM. Make sense?
Here are some more details I noticed, as a likely future user of this
very handy feature, which I haven't changed, because they seem more
debatable and you might disagree...
1. I think it'd be less surprising if the default value for --fork
wasn't 0... why not show all forks?
2. I think it'd be less surprising if --fork without --relation
either raised an error (like --block without --relation), or were
allowed, with the meaning "show me this fork of all relations".
3. It seems funny to have no short switch for --fork when everything
else has one... what about -F?
| Attachment | Content-Type | Size |
|---|---|---|
| v5-0001-Add-additional-filtering-options-to-pg_waldump.patch | text/x-patch | 10.9 KB |
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-21 23:01:02 |
| Message-ID: | CAOxo6X+6OXWprxDMdz0+PC_YkU9_E2fyOOqKfR3XwcD0j2_Z5Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Mon, Mar 21, 2022 at 4:39 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
[snip]
I guess you did this because init fork references aren't really
> expected in the WAL, but I think it's more consistent to allow up to
> MAX_FORKNUM, not least because your documentation mentions 3 as a
> valid value. So I adjust this to allow MAX_FORKNUM. Make sense?
>
Makes sense, but I think I'd actually thought it was +1 of the max forks,
so you give me more credit than I deserve in this case... :-)
> Here are some more details I noticed, as a likely future user of this
> very handy feature, which I haven't changed, because they seem more
> debatable and you might disagree...
>
> 1. I think it'd be less surprising if the default value for --fork
> wasn't 0... why not show all forks?
>
Agreed; made it default to all, with the ability to filter down if desired.
> 2. I think it'd be less surprising if --fork without --relation
> either raised an error (like --block without --relation), or were
> allowed, with the meaning "show me this fork of all relations".
>
Agreed; reworked to support the use case of only showing target forks.
> 3. It seems funny to have no short switch for --fork when everything
> else has one... what about -F?
>
Good idea; I'd hadn't seen capitals in the getopt list so didn't consider
them, but I like this.
Enclosed is v6, incorporating these fixes and docs tweaks.
Best,
David
| Attachment | Content-Type | Size |
|---|---|---|
| v6-0001-Add-additional-filtering-options-to-pg_waldump.patch | application/octet-stream | 11.1 KB |
| From: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-23 20:53:21 |
| Message-ID: | bd843dc2-12be-8b4b-c260-3d3b85b52a2b@enterprisedb.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On 21.03.22 05:55, Thomas Munro wrote:
> [04:30:50.630] pg_waldump.c:963:26: error: format ‘%u’ expects
> argument of type ‘unsigned int *’, but argument 3 has type ‘ForkNumber
> *’ [-Werror=format=]
> [04:30:50.630] 963 | if (sscanf(optarg, "%u",
> &config.filter_by_relation_forknum) != 1 ||
> [04:30:50.630] | ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [04:30:50.630] | | |
> [04:30:50.630] | | ForkNumber *
> [04:30:50.630] | unsigned int *
>
> And now that this gets to the CompilerWarnings CI task, it looks like
> GCC doesn't like an enum as a scanf %u destination (I didn't see that
> warning locally when I compiled the above fixup because clearly Clang
> is cool with it...). Probably needs a temporary unsigned int to
> sscanf into first.
That's because ForkNum is a signed type. You will probably succeed if
you use "%d" instead.
| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
| Cc: | David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-23 22:54:15 |
| Message-ID: | CA+hUKGLGS8mJuTxNPVMqEg2Whr6Gg3OSMuWaZYhws1HmQHLQ-A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Thu, Mar 24, 2022 at 9:53 AM Peter Eisentraut
<peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
> On 21.03.22 05:55, Thomas Munro wrote:
> > [04:30:50.630] pg_waldump.c:963:26: error: format ‘%u’ expects
> > argument of type ‘unsigned int *’, but argument 3 has type ‘ForkNumber
> > *’ [-Werror=format=]
> > [04:30:50.630] 963 | if (sscanf(optarg, "%u",
> > &config.filter_by_relation_forknum) != 1 ||
> > [04:30:50.630] | ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > [04:30:50.630] | | |
> > [04:30:50.630] | | ForkNumber *
> > [04:30:50.630] | unsigned int *
> >
> > And now that this gets to the CompilerWarnings CI task, it looks like
> > GCC doesn't like an enum as a scanf %u destination (I didn't see that
> > warning locally when I compiled the above fixup because clearly Clang
> > is cool with it...). Probably needs a temporary unsigned int to
> > sscanf into first.
>
> That's because ForkNum is a signed type. You will probably succeed if
> you use "%d" instead.
Erm, is that really OK? C says "Each enumerated type shall be
compatible with char, a signed integer type, or an
unsigned integer type. The choice of type is implementation-defined,
but shall be capable of representing the values of all the members of
the enumeration." It could even legally vary from enum to enum,
though in practice most compilers probably just use ints all the time
unless you use weird pragma pack incantation. Therefore I think you
need an intermediate variable with the size and signedness matching the
format string, if you're going to scanf directly into it, which
David's V6 did.
| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-24 01:06:36 |
| Message-ID: | 20220324010636.goeqehteid6tffgj@alap3.anarazel.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On 2022-03-24 11:54:15 +1300, Thomas Munro wrote:
> Erm, is that really OK? C says "Each enumerated type shall be
> compatible with char, a signed integer type, or an
> unsigned integer type. The choice of type is implementation-defined,
> but shall be capable of representing the values of all the members of
> the enumeration." It could even legally vary from enum to enum,
> though in practice most compilers probably just use ints all the time
> unless you use weird pragma pack incantation. Therefore I think you
> need an intermediate variable with the size and signedness matching the
> format string, if you're going to scanf directly into it, which
> David's V6 did.
/me yearns for the perfectly reasonable C++ 11 feature of defining the base
type for enums (enum name : basetype { }). One of those features C should have
adopted long ago. Not that we could use it yet, given we insist that C
standards have reached at least european drinking age before relying on them.
| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-24 08:50:34 |
| Message-ID: | CA+hUKGKKATUJw3zY-KJ4U90Zr4n5i8LG-kARO9JSqyngqfamnA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Tue, Mar 22, 2022 at 12:01 PM David Christensen
<david(dot)christensen(at)crunchydata(dot)com> wrote:
> Enclosed is v6, incorporating these fixes and docs tweaks.
Thanks!
I made a couple of minor changes in the docs, to wit: fixed
copy/paste-o "-F block" -> "-F fork", fork names didn't have initial
caps elsewhere, tablespace is better represented by
<replaceable>tblspc</replaceable> than <replaceable>tbl</replaceable>,
some minor wording changes to avoid constructions with "filter" where
it seemed to me a little ambiguous whether that means something is
included or excluded, and some other wording changes for consistency
with nearby paragraphs.
And... pushed.
| From: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-24 10:57:56 |
| Message-ID: | d51b7a33-9662-0af5-5061-114defb1d5fb@enterprisedb.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On 23.03.22 23:54, Thomas Munro wrote:
>> That's because ForkNum is a signed type. You will probably succeed if
>> you use "%d" instead.
>
> Erm, is that really OK? C says "Each enumerated type shall be
> compatible with char, a signed integer type, or an
> unsigned integer type. The choice of type is implementation-defined,
> but shall be capable of representing the values of all the members of
> the enumeration." It could even legally vary from enum to enum,
> though in practice most compilers probably just use ints all the time
> unless you use weird pragma pack incantation. Therefore I think you
> need an intermediate variable with the size and signedness matching the
> format string, if you're going to scanf directly into it, which
> David's V6 did.
An intermediate variable is probably the best way to avoid thinking
about this much more. ;-) But note that the committed patch uses a %u
format whereas the ForkNum enum is signed.
Btw., why the sscanf() instead of just strtol/stroul?
| From: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-24 11:01:47 |
| Message-ID: | 3a4c2e93-7976-2320-fc0a-32097fe148a7@enterprisedb.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On 24.03.22 11:57, Peter Eisentraut wrote:
> On 23.03.22 23:54, Thomas Munro wrote:
>>> That's because ForkNum is a signed type. You will probably succeed if
>>> you use "%d" instead.
>>
>> Erm, is that really OK? C says "Each enumerated type shall be
>> compatible with char, a signed integer type, or an
>> unsigned integer type. The choice of type is implementation-defined,
>> but shall be capable of representing the values of all the members of
>> the enumeration." It could even legally vary from enum to enum,
>> though in practice most compilers probably just use ints all the time
>> unless you use weird pragma pack incantation. Therefore I think you
>> need an intermediate variable with the size and signedness matching the
>> format string, if you're going to scanf directly into it, which
>> David's V6 did.
>
> An intermediate variable is probably the best way to avoid thinking
> about this much more. ;-) But note that the committed patch uses a %u
> format whereas the ForkNum enum is signed.
>
> Btw., why the sscanf() instead of just strtol/stroul?
Or even: Why are we exposing fork *numbers* in the user interface?
Even low-level tools such as pageinspect use fork *names* in their
interface.
| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
| Cc: | David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-24 11:26:43 |
| Message-ID: | CA+hUKG+h-1qbQS0w0ARR73gw+Mv1fcxVZaFMycQS3JGc8iZiZA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, Mar 25, 2022 at 12:01 AM Peter Eisentraut
<peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
> Or even: Why are we exposing fork *numbers* in the user interface?
> Even low-level tools such as pageinspect use fork *names* in their
> interface.
I wondered about that but thought it seemed OK for such a low level
tool. It's a fair point though, especially if other low level tools
are doing that. Here's a patch to change it.
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Use-fork-names-not-numbers-in-pg_waldump-option.patch | text/x-patch | 3.2 KB |
| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
| Cc: | David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-24 11:42:50 |
| Message-ID: | CA+hUKGL+0PrQmEnnHidi1Vc-5f8Bqo4bpHAbuBk778c1k8Aiow@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, Mar 25, 2022 at 12:26 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Fri, Mar 25, 2022 at 12:01 AM Peter Eisentraut
> <peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
> > Or even: Why are we exposing fork *numbers* in the user interface?
> > Even low-level tools such as pageinspect use fork *names* in their
> > interface.
>
> I wondered about that but thought it seemed OK for such a low level
> tool. It's a fair point though, especially if other low level tools
> are doing that. Here's a patch to change it.
Oh, and there's already a name lookup function to use for this.
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Use-fork-names-not-numbers-in-pg_waldump-option.patch | text/x-patch | 3.1 KB |
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-24 12:43:02 |
| Message-ID: | CA702020-B3F9-4597-86F7-EFB1CB7D6E42@crunchydata.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
> On Mar 24, 2022, at 6:43 AM, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>
> On Fri, Mar 25, 2022 at 12:26 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>>> On Fri, Mar 25, 2022 at 12:01 AM Peter Eisentraut
>>> <peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
>>> Or even: Why are we exposing fork *numbers* in the user interface?
>>> Even low-level tools such as pageinspect use fork *names* in their
>>> interface.
>>
>> I wondered about that but thought it seemed OK for such a low level
>> tool. It's a fair point though, especially if other low level tools
>> are doing that. Here's a patch to change it.
>
> Oh, and there's already a name lookup function to use for this.
+1 on the semantic names.
David
| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
| Cc: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-24 21:11:32 |
| Message-ID: | CA+hUKGJL3LztRrLa=ba87_08cKnfoSJ3U1f=E+9o+wG7hwwDhg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, Mar 25, 2022 at 1:43 AM David Christensen
<david(dot)christensen(at)crunchydata(dot)com> wrote:
> > On Mar 24, 2022, at 6:43 AM, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> > On Fri, Mar 25, 2022 at 12:26 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> >>> On Fri, Mar 25, 2022 at 12:01 AM Peter Eisentraut
> >>> <peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
> >>> Or even: Why are we exposing fork *numbers* in the user interface?
> >>> Even low-level tools such as pageinspect use fork *names* in their
> >>> interface.
> >>
> >> I wondered about that but thought it seemed OK for such a low level
> >> tool. It's a fair point though, especially if other low level tools
> >> are doing that. Here's a patch to change it.
> >
> > Oh, and there's already a name lookup function to use for this.
>
> +1 on the semantic names.
Cool.
I had another thought while changing that (and also re-alphabetising):
Why don't we switch to -B for --block and -R for --relation? I
gather you used -k and -l because -b and -r were already taken, but
since we already started using upper case for -F, it seems consistent
this way. Or were they chosen for consistency with something else?
It's also slightly more helpful to a user if the help says
--relation=T/D/R instead of N/N/N (TS/DB/REL would be nicer but
doesn't fit in the space).
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Improve-command-line-switches-in-pg_waldump-option.patch | text/x-patch | 7.3 KB |
| From: | David Christensen <david(dot)christensen(at)crunchydata(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-24 22:40:30 |
| Message-ID: | F336AACF-7AF8-44E8-827D-CBDCB862AE8E@crunchydata.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
> On Mar 24, 2022, at 4:12 PM, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>
> On Fri, Mar 25, 2022 at 1:43 AM David Christensen
> <david(dot)christensen(at)crunchydata(dot)com> wrote:
>>>> On Mar 24, 2022, at 6:43 AM, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>>> On Fri, Mar 25, 2022 at 12:26 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>>>>> On Fri, Mar 25, 2022 at 12:01 AM Peter Eisentraut
>>>>> <peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
>>>>> Or even: Why are we exposing fork *numbers* in the user interface?
>>>>> Even low-level tools such as pageinspect use fork *names* in their
>>>>> interface.
>>>>
>>>> I wondered about that but thought it seemed OK for such a low level
>>>> tool. It's a fair point though, especially if other low level tools
>>>> are doing that. Here's a patch to change it.
>>>
>>> Oh, and there's already a name lookup function to use for this.
>>
>> +1 on the semantic names.
>
> Cool.
>
> I had another thought while changing that (and also re-alphabetising):
> Why don't we switch to -B for --block and -R for --relation? I
> gather you used -k and -l because -b and -r were already taken, but
> since we already started using upper case for -F, it seems consistent
> this way. Or were they chosen for consistency with something else?
Works here; was just trying to get semi-memorable ones from the available lowercase ones, but I like your idea here, and it kind of puts them in the same mental space for remembering.
> It's also slightly more helpful to a user if the help says
> --relation=T/D/R instead of N/N/N (TS/DB/REL would be nicer but
> doesn't fit in the space).
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Improve-command-line-switches-in-pg_waldump-option.patch | application/octet-stream | 7.3 KB |
| From: | Japin Li <japinli(at)hotmail(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-25 00:43:30 |
| Message-ID: | MEYP282MB166915697F54EB47877F6DB6B61A9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, 25 Mar 2022 at 05:11, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> Cool.
>
> I had another thought while changing that (and also re-alphabetising):
> Why don't we switch to -B for --block and -R for --relation? I
> gather you used -k and -l because -b and -r were already taken, but
> since we already started using upper case for -F, it seems consistent
> this way. Or were they chosen for consistency with something else?
>
> It's also slightly more helpful to a user if the help says
> --relation=T/D/R instead of N/N/N (TS/DB/REL would be nicer but
> doesn't fit in the space).
Thanks for updating the patch!
+ printf(_(" -x, --xid=XID only show records with transaction ID XID\n"));
I think the description of transaction ID is enough, IIUC, XID is use in core,
which means transaction ID.
See: src/bin/pg_resetwal/pg_resetwal.c
1239 printf(_(" -V, --version output version information, then exit\n"));
1240 printf(_(" -x, --next-transaction-id=XID set next transaction ID\n"));
+ if (sscanf(optarg, "%u/%u/%u",
+ &config.filter_by_relation.spcNode,
+ &config.filter_by_relation.dbNode,
+ &config.filter_by_relation.relNode) != 3 ||
+ !OidIsValid(config.filter_by_relation.spcNode) ||
+ !OidIsValid(config.filter_by_relation.relNode))
It seems we should also check the dbNode.
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | Japin Li <japinli(at)hotmail(dot)com> |
| Cc: | David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-25 00:55:04 |
| Message-ID: | CA+hUKGL0Uh7vVNCLCV4K=ZCG7nVXa1SHmqqJin9WFgRGxqNZcw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, Mar 25, 2022 at 1:43 PM Japin Li <japinli(at)hotmail(dot)com> wrote:
> + printf(_(" -x, --xid=XID only show records with transaction ID XID\n"));
>
> I think the description of transaction ID is enough, IIUC, XID is use in core,
> which means transaction ID.
The mention of "XID" corresponds to XID on the left, like a sort of
variable. That text is not changed by this patch.
> See: src/bin/pg_resetwal/pg_resetwal.c
>
> 1239 printf(_(" -V, --version output version information, then exit\n"));
> 1240 printf(_(" -x, --next-transaction-id=XID set next transaction ID\n"));
Hmm, yeah that is inconsistent, but it seems like it is pg_resetwal.c
that is not following the notational convention there. Other things
in pg_resetwal's --help use that 'variable' style.
> + if (sscanf(optarg, "%u/%u/%u",
> + &config.filter_by_relation.spcNode,
> + &config.filter_by_relation.dbNode,
> + &config.filter_by_relation.relNode) != 3 ||
> + !OidIsValid(config.filter_by_relation.spcNode) ||
> + !OidIsValid(config.filter_by_relation.relNode))
>
> It seems we should also check the dbNode.
This was discussed earlier: it's OK for the dbNode to be invalid (0),
because that's how shared relations like pg_database are referenced.
Like this:
$ pg_waldump pgdata/pg_wal/000000010000000000000001 --relation
1664/0/1262 --fork vm --limit 1
rmgr: Heap2 len (rec/tot): 64/ 8256, tx: 0, lsn:
0/01491F20, prev 0/01491EC0, desc: VISIBLE cutoff xid 1 flags 0x03,
blkref #0: rel 1664/0/1262 fork vm blk 0 FPW, blkref #1: rel
1664/0/1262 blk 0
Thanks for looking! I've now pushed the improvements discussed so far.
| From: | Japin Li <japinli(at)hotmail(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] add relation and block-level filtering to pg_waldump |
| Date: | 2022-03-25 01:32:49 |
| Message-ID: | MEYP282MB16698466E671832348807445B61A9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Fri, 25 Mar 2022 at 08:55, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Fri, Mar 25, 2022 at 1:43 PM Japin Li <japinli(at)hotmail(dot)com> wrote:
>> + printf(_(" -x, --xid=XID only show records with transaction ID XID\n"));
>>
>> I think the description of transaction ID is enough, IIUC, XID is use in core,
>> which means transaction ID.
>
> The mention of "XID" corresponds to XID on the left, like a sort of
> variable. That text is not changed by this patch.
>
>> See: src/bin/pg_resetwal/pg_resetwal.c
>>
>> 1239 printf(_(" -V, --version output version information, then exit\n"));
>> 1240 printf(_(" -x, --next-transaction-id=XID set next transaction ID\n"));
>
> Hmm, yeah that is inconsistent, but it seems like it is pg_resetwal.c
> that is not following the notational convention there. Other things
> in pg_resetwal's --help use that 'variable' style.
>
Thanks for your explanation!
>> + if (sscanf(optarg, "%u/%u/%u",
>> + &config.filter_by_relation.spcNode,
>> + &config.filter_by_relation.dbNode,
>> + &config.filter_by_relation.relNode) != 3 ||
>> + !OidIsValid(config.filter_by_relation.spcNode) ||
>> + !OidIsValid(config.filter_by_relation.relNode))
>>
>> It seems we should also check the dbNode.
>
> This was discussed earlier: it's OK for the dbNode to be invalid (0),
> because that's how shared relations like pg_database are referenced.
> Like this:
>
> $ pg_waldump pgdata/pg_wal/000000010000000000000001 --relation
> 1664/0/1262 --fork vm --limit 1
> rmgr: Heap2 len (rec/tot): 64/ 8256, tx: 0, lsn:
> 0/01491F20, prev 0/01491EC0, desc: VISIBLE cutoff xid 1 flags 0x03,
> blkref #0: rel 1664/0/1262 fork vm blk 0 FPW, blkref #1: rel
> 1664/0/1262 blk 0
>
Oh, my bad, I missed the discussion email. Sorry for the noise.
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.