Re: Have better wording for snapshot file reading failure
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
To: Yogesh Sharma <yogesh.sharma@catprosystems.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-09-13T10:52:24Z
Lists: pgsql-hackers
On Wed, Sep 13, 2023 at 3:32 PM Yogesh Sharma
<yogesh.sharma@catprosystems.com> wrote:
>
> On 9/13/23 02:10, Bharath Rupireddy wrote:
> > Hi,
> >
> > When a snapshot file reading fails in ImportSnapshot(), it errors out
> > with "invalid snapshot identifier". This message better suits for
> > snapshot identifier parsing errors which is being done just before the
> > file reading. The attached patch adds a generic file reading error
> > message with path to help distinguish if the issue is with snapshot
> > identifier parsing or file reading.
> >
> I suggest error message to include "snapshot" keyword in message, like this:
>
> errmsg("could not open snapshot file \"%s\" for reading: %m",
>
> and also tweak other messages accordingly.
-1. The path includes the pg_snapshots there which is enough to give
the clue, so no need to say "could not open snapshot file". AFAICS,
this is the typical messaging followed across postgres code for
AllocateFile failures.
[1]
/* Define pathname of exported-snapshot files */
#define SNAPSHOT_EXPORT_DIR "pg_snapshots"
/* OK, read the file */
snprintf(path, MAXPGPATH, SNAPSHOT_EXPORT_DIR "/%s", idstr);
f = AllocateFile(path, PG_BINARY_R);
if (!f)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not open file \"%s\" for reading: %m",
path)));
--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Improve error message for snapshot import in snapmgr.c, take two
- 78a33bba4c63 17.0 landed
-
Revert "Improve error message on snapshot import in snapmgr.c"
- bddbbdf99b16 11.22 landed
- 50d44c163352 12.17 landed
- f18efc6f2bc8 13.13 landed
- 1988f8766eeb 14.10 landed
- fe60434af76f 15.5 landed
- 3f94dfc00870 16.1 landed
- be022908cfe2 17.0 landed
-
Improve error message on snapshot import in snapmgr.c
- a4cef3384d6d 11.22 landed
- 33bc7d424695 12.17 landed
- d98cbea20125 13.13 landed
- a7b92d1c6807 14.10 landed
- 19885ab246d8 15.5 landed
- be3dfd3dff03 16.1 landed
- a0d87bcd9b57 17.0 landed