Re: Unnecessary static variable?

From: Antonin Houska <ah(at)cybertec(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Unnecessary static variable?
Date: 2018-01-18 16:06:52
Message-ID: 32666.1516291612@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Antonin Houska <ah(at)cybertec(dot)at> writes:
> > Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> At one time, I think, readLen told how much data in readBuf was
> >> actually valid. It seems not to be used for that anymore, but
> >> I don't much like the idea that readBuf is only partially filled
> >> but there is *no* persistent state indicating how much is valid.
> >> The existing coding guarantees that the answer is "XLOG_BLCKSZ",
> >> so that's fine, but this change would remove the guarantee.
> Oh, I withdraw that complaint --- readBuf isn't a persistent data
> structure anymore, so there's no need for readLen to be persistent
> either.

Well, there's yet a problem. Your concern about invalid data in readBuf
reminded me of a problem that I reported a few years ago [1]. The problem is
hidden as long as all XLOG reader callbacks fetch the whole page.

However if readLen is used as an argument of read() in XLogPageRead() *and* if
some other conditions that also hide the issue are removed (see [2]), the
problem reported in [1] appears to be a live bug.



Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2018-01-18 16:07:20 Re: Faster inserts with mostly-monotonically increasing values
Previous Message Alvaro Herrera 2018-01-18 15:56:25 Re: [HACKERS] Proposal: Local indexes for partitioned table