pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Pad XLogReaderState's main_data buffer more aggressively.
Date: Sun, 26 Nov 2017 20:17:42 +0000
Message-ID: <E1eJ3N0-00021I-7e@gemulon.postgresql.org> (raw)

Pad XLogReaderState's main_data buffer more aggressively.

Originally, we palloc'd this buffer just barely big enough to hold the
largest xlog record seen so far.  It turns out that that can result in
valgrind complaints, because some compilers will emit code that assumes
it can safely fetch padding bytes at the end of a struct, and those
padding bytes were unallocated so far as aset.c was concerned.  We can
fix that by MAXALIGN'ing the palloc request size, ensuring that it is big
enough to include any possible padding that might've been omitted from
the on-disk record.

An additional objection to the original coding is that it could result in
many repeated palloc cycles, in the worst case where we see a series of
gradually larger xlog records.  We can ameliorate that cheaply by
imposing a minimum buffer size that's large enough for most xlog records.
BLCKSZ/2 was chosen after a bit of discussion.

In passing, remove an obsolete comment in struct xl_heap_new_cid that the
combocid field is free due to alignment considerations.  Perhaps that was
true at some point, but it's not now.

Back-patch to 9.5 where this code came in.

Discussion: https://postgr.es/m/E1eHa4J-0006hI-Q8@gemulon.postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8735978e7aebfbc499843630131c18d1f7346c79

Modified Files
--------------
src/backend/access/transam/xlogreader.c | 17 ++++++++++++++++-
src/include/access/heapam_xlog.h        |  8 +-------
2 files changed, 17 insertions(+), 8 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1eJ3N0-00021I-7e@gemulon.postgresql.org>
Permalink:  ../E1eJ3N0-00021I-7e@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1eJ3N0-00021I-7e@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Pad XLogReaderState's main_data buffer more aggressively.
  In-Reply-To: <E1eJ3N0-00021I-7e@gemulon.postgresql.org>
  References: <E1eJ3N0-00021I-7e@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