pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Luca Ferrari <fluca1978@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: could not read block 0 in file : read only 0 of 8192 bytes when doing nasty on immutable index function
Date: Mon, 9 Jul 2018 11:32:01 -0700
Message-ID: <20180709183201.zn53uwiwqozhettk@alap3.anarazel.de> (raw)
In-Reply-To: <CAH2-Wzn1DDZ6HSDwOpD2b964mqpPDqsE1nAfbHr+TU5cBo219A@mail.gmail.com>
References: <CAKoxK+5fVodiCtMsXKV_1YAKXbzwSfp7DgDqUmcUAzeAhf=HEQ@mail.gmail.com>
	<20180627204439.4b7miflyolm4qtcz@alap3.anarazel.de>
	<CAKoxK+5bCn5d0R5v6j8SQQtUobu9R+m1xTTat8zsD1jH3izeDA@mail.gmail.com>
	<CAKoxK+7gQjxWYZiUm5q9M9dxd1mBgi=1rDwN0UNZbkXvB37Eiw@mail.gmail.com>
	<20180628150209.n2qch5jtn3vt2xaa@alap3.anarazel.de>
	<CAH2-Wzn1DDZ6HSDwOpD2b964mqpPDqsE1nAfbHr+TU5cBo219A@mail.gmail.com>

Hi,

On 2018-07-09 09:59:58 -0700, Peter Geoghegan wrote:
> On Thu, Jun 28, 2018 at 8:02 AM, Andres Freund <andres@anarazel.de> wrote:
> > I believe this happens because there's currently no relcache
> > invalidation registered for the main relation, until *after* the index
> > is built. Normally it'd be the CacheInvalidateRelcacheByTuple(tuple) in
> > index_update_stats(), which is called at the bottom of index_build().
> > But we never get there, because the earlier error.  That's bad, because
> > any relcache entry built *after* the CommandCounterIncrement() in
> > CommandCounterIncrement() will now be outdated.
> >
> > In the olden days we most of the time didn't build a relcache entry
> > until after the index was built - but plan_create_index_workers() now
> > does. I'm suspect there's other ways to trigger that earlier, too.
> 
> Note that there is a kludge within plan_create_index_workers() that
> has us treat the heap relation as an inheritance parent, just to get a
> RelOptInfo for the heap relation without running into similar trouble
> with the index in get_relation_info(). Perhaps there's an argument to
> be made for refactoring plan_create_index_workers() as a fix for this.

Maybe I'm missing something, but what has this got to do with the issue
at hand?


> > Putting in a CacheInvalidateRelcache(heapRelation); before the CCI in
> > index_create() indeed makes the "borked relcache" problem go away.
> >
> >
> > I wonder why we don't just generally trigger invalidations to an
> > indexes' "owning" relation in CacheInvalidateHeapTuple()?
> 
> I don't know, but that seems like a good question.

I assume we'll have to backpatch this issue, so I think it'd probably a
good idea to put a specific CacheInvalidateHeapTuple() in there
explicitly in the back branches, and do the larger fix in 12. ISTM
there's some risks that it'd cause issues.  Will you tackle this?

Greetings,

Andres Freund




view thread (20+ messages)  latest in thread

Message-ID: <20180709183201.zn53uwiwqozhettk@alap3.anarazel.de>
Permalink:  ../20180709183201.zn53uwiwqozhettk@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20180709183201.zn53uwiwqozhettk@alap3.anarazel.de

 · 

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-bugs@postgresql.org
  Cc: andres@anarazel.de, pg@bowt.ie, fluca1978@gmail.com, pgsql-general@postgresql.org
  Subject: Re: could not read block 0 in file : read only 0 of 8192 bytes when doing nasty on immutable index function
  In-Reply-To: <20180709183201.zn53uwiwqozhettk@alap3.anarazel.de>
  References: <CAKoxK+5fVodiCtMsXKV_1YAKXbzwSfp7DgDqUmcUAzeAhf=HEQ@mail.gmail.com> <20180627204439.4b7miflyolm4qtcz@alap3.anarazel.de> <CAKoxK+5bCn5d0R5v6j8SQQtUobu9R+m1xTTat8zsD1jH3izeDA@mail.gmail.com> <CAKoxK+7gQjxWYZiUm5q9M9dxd1mBgi=1rDwN0UNZbkXvB37Eiw@mail.gmail.com> <20180628150209.n2qch5jtn3vt2xaa@alap3.anarazel.de> <CAH2-Wzn1DDZ6HSDwOpD2b964mqpPDqsE1nAfbHr+TU5cBo219A@mail.gmail.com> <20180709183201.zn53uwiwqozhettk@alap3.anarazel.de>

* 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