pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Subject: Re: Subscription test 013_partition.pl fails under CLOBBER_CACHE_ALWAYS
Date: Tue, 15 Sep 2020 15:46:18 -0400
Message-ID: <1353598.1600199178@sss.pgh.pa.us> (raw)
In-Reply-To: <1032727.1600096803@sss.pgh.pa.us>
References: <1032727.1600096803@sss.pgh.pa.us>

I wrote:
> [ $subject ]

I found some time to trace this down, and what it turns out to be is
that apply_handle_truncate() is making use of a LogicalRepRelMapEntry's
localreloid field without any consideration for the possibility that
that's been set to zero as a result of a cache flush.  The visible
symptom of "cache lookup failed for relation 0" comes from trying
to invoke find_all_inheritors with a zero OID.

Now, study of apply_handle_truncate doesn't immediately reveal where
a cache flush could have occurred, but I realized that it's actually
possible that the LogicalRepRelMapEntry is *already* marked invalid
when logicalrep_rel_open() returns!  That's because for some reason
it does GetSubscriptionRelState last, after it's already marked the
entry valid, and that function does plenty o' catalog accesses.

It's not really clear to me why setting localreloid to zero is a sane
way to represent "this entry needs to be revalidated".  I think a
separate flag would be more appropriate.  Once we have lock on the
target relation, it seems to me that no interesting changes should
be possible as long as we have lock; so there's no very good reason
to destroy useful state to remind ourselves that we should recheck
it next time.

			regards, tom lane





view thread (9+ messages)  latest in thread

Message-ID: <1353598.1600199178@sss.pgh.pa.us>
Permalink:  ../1353598.1600199178@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1353598.1600199178@sss.pgh.pa.us

 · 

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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: Subscription test 013_partition.pl fails under CLOBBER_CACHE_ALWAYS
  In-Reply-To: <1353598.1600199178@sss.pgh.pa.us>
  References: <1032727.1600096803@sss.pgh.pa.us> <1353598.1600199178@sss.pgh.pa.us>

* 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