pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve error message for snapshot import in snapmgr.c, take two
Date: Tue, 19 Sep 2023 01:24:38 +0000
Message-ID: <E1qiPTh-004fFq-Qm@gemulon.postgresql.org> (raw)

Improve error message for snapshot import in snapmgr.c, take two

When a snapshot file fails to be read in ImportSnapshot(), it would
issue an ERROR as "invalid snapshot identifier" when opening a stream
for it in read-only mode.  The error handling is improved to be more
talkative in failure cases:
- If a snapshot identifier uses incorrect characters, complain with the
same error as before this commit.
- If the snapshot file cannot be found in pg_snapshots/, complain with a
"snapshot \"foo\" does not exist" instead.  This maps to the case where
AllocateFile() fails on ENOENT.  Based on a suggestion from Andres
Freund.
- If AllocateFile() throws something else than ENOENT as errno, report
it with more details in %m instead, as these failures are never
expected.

b29504eeb489 was the first improvement take.  The older error message
exists since bb446b689b66 that introduced snapshot imports.  Two test
cases are added to cover the cases of an identifier with an incorrect
format and of a missing snapshot.

Author: Bharath Rupireddy
Reviewed-by: Andres Freund, Daniel Gustafsson, Michael Paquier
Discussion: https://postgr.es/m/CALj2ACWmr=3KdxDkm8h7Zn1XxBoF6hdzq8WQyMn2y1OL5RYFrg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/78a33bba4c634afc3c67dddeb359b5ce872a0b04

Modified Files
--------------
src/backend/utils/time/snapmgr.c           | 18 +++++++++++++++---
src/test/regress/expected/transactions.out | 11 +++++++++++
src/test/regress/sql/transactions.sql      |  9 +++++++++
3 files changed, 35 insertions(+), 3 deletions(-)



Message-ID: <E1qiPTh-004fFq-Qm@gemulon.postgresql.org>
Permalink:  ../E1qiPTh-004fFq-Qm@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qiPTh-004fFq-Qm@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Improve error message for snapshot import in snapmgr.c, take two
  In-Reply-To: <E1qiPTh-004fFq-Qm@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox