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: Remove XLogFileNameP() from the tree
Date: Tue, 03 Dec 2019 06:08:16 +0000
Message-ID: <E1ic1M8-00031b-PE@gemulon.postgresql.org> (raw)

Remove XLogFileNameP() from the tree

XLogFileNameP() is a wrapper routine able to build a palloc'd string for
a WAL segment name, which is used for error string generation.  There
were several code paths where it gets called in a critical section,
where memory allocation is not allowed.  This results in triggering
an assertion failure instead of generating the wanted error message.

Another, more annoying, problem is that if the allocation to generate
the WAL segment name fails on OOM, then the failure would be escalated
to a PANIC.

This removes the routine and all its callers are replaced with a logic
using a fixed-size buffer.  This way, all the existing mistakes are
fixed and future ones are prevented.

Author: Masahiko Sawada
Reviewed-by: Michael Paquier, Álvaro Herrera
Discussion: https://postgr.es/m/CA+fd4k5gC9H4uoWMLg9K_QfNrnkkdEw+-AFveob9YX7z8JnKTA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9989d37d1c8dff12f20a1de8e1f470093136c893

Modified Files
--------------
src/backend/access/transam/xlog.c      | 88 ++++++++++++++++++++++------------
src/backend/access/transam/xlogutils.c |  6 ++-
src/backend/replication/walreceiver.c  | 30 ++++++++----
src/backend/replication/walsender.c    |  9 +++-
src/include/access/xlog.h              |  1 -
src/include/access/xlog_internal.h     |  4 ++
6 files changed, 95 insertions(+), 43 deletions(-)



Message-ID: <E1ic1M8-00031b-PE@gemulon.postgresql.org>
Permalink:  ../E1ic1M8-00031b-PE@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ic1M8-00031b-PE@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Remove XLogFileNameP() from the tree
  In-Reply-To: <E1ic1M8-00031b-PE@gemulon.postgresql.org>
  References: <E1ic1M8-00031b-PE@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