Re: Review: Patch to compute Max LSN of Data Pages

From: Hari Babu <haribabu(dot)kommi(at)huawei(dot)com>
To: "'Robert Haas'" <robertmhaas(at)gmail(dot)com>
Cc: "'Josh Berkus'" <josh(at)agliodbs(dot)com>, "'Amit kapila'" <amit(dot)kapila(at)huawei(dot)com>, "'Andres Freund'" <andres(at)2ndquadrant(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: Patch to compute Max LSN of Data Pages
Date: 2013-07-05 13:17:55
Message-ID: 009701ce7982$104379d0$30ca6d70$@kommi@huawei.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thursday, July 04, 2013 11:19 PM Robert Haas wrote:

>+ fprintf(stderr, _("%s: .. file \"%s\" for seeking: %s\n"),
>+ progname, filename, strerror(errno));

>Weird error message style - what's with the ".."?

>+ fprintf(stderr, _("%s: .. file \"%s\" length is more than
segment
>size: %d.\n"),
>+ progname, filename, RELSEG_SIZE);

>Again.

Corrected.

>+ fprintf(stderr, _("%s: could not seek to next page
\"%s\": %s\n"),
>+ progname, filename,
strerror(errno));

>I think this should be written as: could not seek to offset NUMBER in
>file "PATH"

>+ fprintf(stderr, _("%s: could not read file \"%s\":
%s\n"),
>+ progname, filename,
strerror(errno));

>And this one as: could not read file "PATH" at offset NUMBER

>+ printf("File:%s Maximum LSN found is: %X/%X \nWAL segment
file
>name (fileid,seg): %X/%X\n",

>I think that we don't need to display the WAL segment file name for
>the per-file progress updates. Instead, let's show the block number
>where that LSN was found, like this:

>Highest LSN for file "%s" is %X/%X in block %u.

>The overall output can stay as you have it.

Changed as per your suggestion.

>+ if (0 != result)

>Coding style.

>+ static int
>+ FindMaxLSNinFile(char *filename, XLogRecPtr *maxlsn)

>It seems that this function, and a few others, use -1 for a failure
>return, 0 for success, and all others undefined. Although this is a
>defensible choice, I think it would be more PG-like to make the return
>value bool and use true for success and false for failure.

>+ if (S_ISREG(statbuf.st_mode))
>+ (void) FindMaxLSNinFile(pathbuf, maxlsn);
>+ else
>+ (void) FindMaxLSNinDir(pathbuf, maxlsn);

>I don't see why we're throwing away the return value here. I would
>expect the function to have a "bool result = true" at the top and sent
>result = false if one of these functions returns false. At the end,
>it returns result.

Fixed.

>+ This utility can only be run by the user who installed the server,
because
>+ it requires read/write access to the data directory.

>False.

Removed.

>+ LsnSearchPath = argv[optind];
>+
>+ if (LsnSearchPath == NULL)
>+ LsnSearchPath = getenv("PGDATA");

>I think you should write the code so that the tool loops over its
>input arguments; if none, it processes $PGDATA. (Don't forget to
>update the syntax synopsis and documentation to match.)

Added the functionality of multiple file or directories parsing and printing
Max LSN for each input argument.

>I think the documentation should say something about the intended uses
>of this tool, including cautions against using it for things to which
>it is not well-suited. I guess the threshold question for this patch
>is whether those uses are enough to justify including the tool in the
>core distribution.

Added some use cases and notes regarding the tool. Please suggest if any
More information needs to be documented.

Thanks for the review, please find the updated patch attached in the mail.

Regards,
Hari babu.

Attachment Content-Type Size
pg_computemaxlsn_v8.patch application/octet-stream 16.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jon Nelson 2013-07-05 13:21:01 Re: fallocate / posix_fallocate for new WAL file creation (etc...)
Previous Message Magnus Hagander 2013-07-05 13:13:15 Re: Review: Display number of changed rows since last analyze